commit 78ae9dcd2e7e5577918860a6c86e306ee7c195f4 Author: XingCheng3 <1773407212@qq.com> Date: Fri May 29 09:34:04 2026 +0800 chore: initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad9c8bb --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +## Visual Studio +.vs/ +[Bb]in/ +[Oo]bj/ +packages/ +*.user +*.suo +*.userosscache +*.sln.docstates +*.userprefs + +## Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Bb]uild/ +bld/ + +## Logs / temp +*.log +*.tmp +*.cache diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cbc14d0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "claudeCodeChat.permissions.yoloMode": false +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction.sln b/Common/09MesDataFunction/MesDataFunction.sln new file mode 100644 index 0000000..5cc56d6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MesDataFunction", "MesDataFunction\MesDataFunction.csproj", "{90E76FB4-646D-45E2-95DB-0B8AB4E465D6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {48DF007D-B08C-43B9-9AC7-78F6B2C23954} + EndGlobalSection +EndGlobal diff --git a/Common/09MesDataFunction/MesDataFunction/01-MesDataFunction.csproj b/Common/09MesDataFunction/MesDataFunction/01-MesDataFunction.csproj new file mode 100644 index 0000000..72b6042 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/01-MesDataFunction.csproj @@ -0,0 +1,151 @@ + + + + + Debug + AnyCPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6} + Library + Properties + MesDataFunction + 09MesDataFunction + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\dll_common\BasicData.dll + + + ..\..\..\dll_common\ConLink.dll + + + ..\..\..\dll_common\ConLink19.dll + + + ..\..\..\dll_common\DataLinkMesWork.dll + + + ..\..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\dll_common\Monitor.MesWork.dll + + + ..\..\..\dll_common\MQTTnet.dll + + + ..\..\..\dll_common\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\dll_common\Newtonsoft.Json.dll + + + ..\..\..\dll_common\NPOI.dll + + + ..\..\..\dll_common\NPOI.OOXML.dll + + + ..\..\..\dll_common\NPOI.OpenXml4Net.dll + + + ..\..\..\dll_common\NPOI.OpenXmlFormats.dll + + + ..\..\..\dll_common\Opc.Ua.Client.dll + + + ..\..\..\dll_common\Opc.Ua.Configuration.dll + + + ..\..\..\dll_common\Opc.Ua.Core.dll + + + ..\..\..\dll_common\OpcUaHelper.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + + + + + + + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + + + + \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/DataAccess.cs b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/DataAccess.cs new file mode 100644 index 0000000..aa173d8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/DataAccess.cs @@ -0,0 +1,746 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataLinkMesWork1 +{ + public class DataAccess + { + // 读配置文件有问题,先直接写死 + public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"]; + public static bool ExecuteNonQuery(string sql, string connectionString, out string errorMessage) + { + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + //ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + + } + public static bool ExecuteDataset(string sql, string connectionString, out DataSet ds, out string errorMessage) + { + errorMessage = ""; + bool result = true; + errorMessage = ""; + ds = new DataSet(); + + /// SQLSERVER + /// SQLiteDB + try + { + //bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + //ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + catch (Exception err) + { + + } + + return result; + + + } + /// + /// 增 删 改 + /// + /// + /// + /// + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlCommand cmd = new SqlCommand(procedureName, conn)) + { + cmd.CommandTimeout = 0; + cmd.CommandType = CommandType.StoredProcedure; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + cmd.Parameters.Add(sqlParameters[i]); + } + } + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + if (conn.State == ConnectionState.Open) + conn.Close(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters,out DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + //ds = new DataSet(); + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataSet ds) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlCommand cmd = new SqlCommand(procedureName, conn)) + { + cmd.CommandTimeout = 0; + cmd.CommandType = CommandType.StoredProcedure; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + cmd.Parameters.Add(sqlParameters[i]); + } + } + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + if (conn.State == ConnectionState.Open) + conn.Close(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataTable dt, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + //ds = new DataSet(); + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteDataset(string sql, out DataSet ds) + { + string errorMessage; + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteDataTable(string sql, out DataTable dt) + { + //public static bool ExecuteDataTable(string sql, string connectionString, out DataTable dt, out string errorMessage) + string errorMessage; + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static DataTable ExecuteSQL(string sql, ref SqlParameter[] sqlParameters) + { + string connectionString = ConnectionString_MES; + string err; + bool result = false; + err = ""; + DataTable dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter(sql, conn)) + { + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + dsCommand.Fill(dt); + } + result = true; + } + catch (Exception e) + { + err = e.ToString(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteSelectMesWork\r\n" + sql + "\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return dt; + } + + public static bool ExecuteSQL(string sql) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用) + /// + /// 存储过程名称 + /// 存储过程参数数组 + /// 增加数据的数据表 + /// + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + // if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.InsertCommand = new SqlCommand(procedureName, conn); + dsCommand.InsertCommand.CommandType = CommandType.StoredProcedure; + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]); + } + if (dt == null) return false; + dt.AcceptChanges(); + for (int i = 0; i < dt.Rows.Count; i++) + { + dt.Rows[i].SetAdded(); + } + dsCommand.Update(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用) + /// + /// + /// + /// + public static bool ExecuteStoredProcedure(string procedureName, out DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// + /// + /// + /// + /// + /// + public static bool ExecuteSQL(string sql, ref SqlParameter[] sqlParameters, DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + + + try + { + // if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.InsertCommand = new SqlCommand(sql, conn); + + for (int i = 0; i < sqlParameters.Length; i++) + { + sqlParameters[i].IsNullable = true; + dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]); + } + if (dt == null) return false; + dt.AcceptChanges(); + for (int i = 0; i < dt.Rows.Count; i++) + { + dt.Rows[i].SetAdded(); + } + dsCommand.Update(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + //ApplicationConfig.ConnectionStringPIS_NEW_Value = "0"; + //TestConnection(); + //errorMessage = e.ToString(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteSQL\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteNonQuery_newID(string sql, out long newID) + { + sql += ";select @@identity"; + string connectionString; + connectionString = ConnectionString_MES; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + conn.Open(); + newID = Convert.ToInt64(cmd.ExecuteScalar()); + } + return true; + } + catch (Exception e) + { + newID = 0; + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\n ExecuteNonQuery_newID\r\n�洢���̣�\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + return false; + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + } + + public static bool ExecuteOutNum(string sql, out int count) + { + string connectionString; + connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + count = 0; + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + count = Convert.ToInt32(cmd.ExecuteScalar().ToString()); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + } + + +} diff --git a/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/JsonHelper.cs b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/JsonHelper.cs new file mode 100644 index 0000000..5ec9f9c --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/JsonHelper.cs @@ -0,0 +1,336 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Data; +using System.Runtime.Serialization.Json; +using System.Web.Script.Serialization; +//using System.Runtime.Serialization.Json; + +//using System.Runtime.Serialization.Json; + +public class JsonHelper +{ + #region 序列化和反序列化 + // 序列化 + public static string JsonSerializer(T t) + { + // 使用 DataContractJsonSerializer 将 T 对象序列化为内存流。 + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T)); + MemoryStream ms = new MemoryStream(); + // 使用 WriteObject 方法将 JSON 数据写入到流中。 + jsonSerializer.WriteObject(ms, t); + // 流转字符串 + string jsonString = Encoding.UTF8.GetString(ms.ToArray()); + ms.Close(); + //替换Json的Date字符串 + string p = @"\\/Date\((\d+)\+\d+\)\\/"; + MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString); + Regex reg = new Regex(p); + jsonString = reg.Replace(jsonString, matchEvaluator); + return jsonString; + } + public static T JsonDeserialize(string jsonString) + { + //将"yyyy-MM-dd HH:mm:ss"格式的字符串转为"\/Date(1294499956278+0800)\/"格式 + string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}"; + MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate); + Regex reg = new Regex(p); + jsonString = reg.Replace(jsonString, matchEvaluator); + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T)); + // 字符串转流 + MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)); + // 通过使用 DataContractJsonSerializer 的 ReadObject 方法,将 JSON 编码数据反序列化为T + T obj = (T)jsonSerializer.ReadObject(ms); + return obj; + } + public static string ConvertJsonDateToDateString(Match match) + { + string result = string.Empty; + DateTime dateTime = new DateTime(1970, 1, 1); + dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value)); + dateTime = dateTime.ToLocalTime(); + result = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); + return result; + } + private static string ConvertDateStringToJsonDate(Match m) + { + string result = string.Empty; + DateTime dt = DateTime.Parse(m.Groups[0].Value); + dt = dt.ToUniversalTime(); + TimeSpan ts = dt - DateTime.Parse("1970-01-01"); + result = string.Format("\\/Date({0}+0800)\\/", ts.TotalMilliseconds); + return result; + } + #endregion + + // 对象转换为Json + public static string ObjectToJson(object obj) + { + JavaScriptSerializer js = new JavaScriptSerializer(); + js.MaxJsonLength = Int32.MaxValue; // 定义JavaScriptSerializer接受字符串的最大长度 hdk 20180524 + try + { + return js.Serialize(obj); + } + catch (Exception exception) + { + + throw new Exception(exception.Message); + } + } + // 数据表转化为集合 + public static List> DataTableToList(DataTable dt) + { + List> list = new List>(); + foreach (DataRow dataRow in dt.Rows) + { + Dictionary dic = new Dictionary(); + + + foreach (DataColumn dc in dt.Columns) + { + if (dataRow[dc.ColumnName].GetType() == typeof(DateTime)) + { + string str = Convert.ToDateTime(dataRow[dc.ColumnName]).ToString("yyyy-MM-dd HH:mm:ss"); + dic.Add(dc.ColumnName, str); + } + else if + (dataRow[dc.ColumnName].GetType() == typeof(byte[])) + { + string str = Convert.ToBase64String((byte[])dataRow[dc.ColumnName]); + dic.Add(dc.ColumnName, str); + } + else + { + dic.Add(dc.ColumnName, dataRow[dc.ColumnName]); + } + + //Type type1 = dt.Rows[0]["产品图片"].GetType(); + //Type type2 = typeof(byte[]); + + } + list.Add(dic); + } + return list; + } + /// + /// 表转换为Json + /// + /// + /// + public static string DataTableToJson(DataTable dt) + { + return ObjectToJson(DataTableToList(dt)); + } + /// + /// 将DataTable中的数据转换成JSON格式 + /// + /// 数据源DataTable + /// 是否输出数据总条数 + /// JSON中显示的数据总条数 + /// + public static string CreateJsonParameters(DataTable dt, bool displayCount, int totalcount) + { + StringBuilder JsonString = new StringBuilder(); + //Exception Handling + + if (dt != null) + { + JsonString.Append("{ "); + JsonString.Append("\"rows\":[ "); + for (int i = 0; i < dt.Rows.Count; i++) + { + JsonString.Append("{ "); + for (int j = 0; j < dt.Columns.Count; j++) + { + if (j < dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower() + ","); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString() + ","); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + } + } + else if (j == dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower()); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString()); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + } + } + } + /*end Of String*/ + if (i == dt.Rows.Count - 1) + { + JsonString.Append("} "); + } + else + { + JsonString.Append("}, "); + } + } + JsonString.Append("]"); + + if (displayCount) + { + JsonString.Append(","); + + JsonString.Append("\"total\":"); + JsonString.Append(totalcount); + } + + JsonString.Append("}"); + return JsonString.ToString().Replace("\n", ""); + } + else + { + return null; + } + } + public static string CreateJsonParameters(DataTable dt) + { + StringBuilder JsonString = new StringBuilder(); + //Exception Handling + + if (dt != null) + { + JsonString.Append("{ "); + JsonString.Append("\"rows\":[ "); + for (int i = 0; i < dt.Rows.Count; i++) + { + JsonString.Append("{ "); + for (int j = 0; j < dt.Columns.Count; j++) + { + if (j < dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower() + ","); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString() + ","); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + } + } + else if (j == dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower()); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString()); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + } + } + } + /*end Of String*/ + if (i == dt.Rows.Count - 1) + { + JsonString.Append("} "); + } + else + { + JsonString.Append("}, "); + } + } + JsonString.Append("]"); + + JsonString.Append("}"); + return JsonString.ToString().Replace("\n", ""); + } + else + { + return null; + } + } + StringBuilder result = new StringBuilder(); + StringBuilder sb = new StringBuilder(); + /// + /// 根据DataTable生成EasyUI Tree Json树结构 + /// + /// 数据源 + /// ID列 + /// Text列 + /// 节点Url + /// 关系字段 + /// 父ID + public string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId) + { + result.Append(sb.ToString()); + sb.Clear(); + if (tabel.Rows.Count > 0) + { + sb.Append("["); + string filer = string.Format("{0}='{1}'", rela, pId); + DataRow[] rows = tabel.Select(filer); + if (rows.Length > 0) + { + foreach (DataRow row in rows) + { + sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\",\"state\":\"open\""); + if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0) + { + sb.Append(",\"children\":"); + GetTreeJsonByTable(tabel, idCol, txtCol, url, rela, row[idCol]); + result.Append(sb.ToString()); + sb.Clear(); + } + result.Append(sb.ToString()); + sb.Clear(); + sb.Append("},"); + } + sb = sb.Remove(sb.Length - 1, 1); + } + sb.Append("]"); + result.Append(sb.ToString()); + sb.Clear(); + } + return result.ToString(); + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_base.cs b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_base.cs new file mode 100644 index 0000000..a9d1eb8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_base.cs @@ -0,0 +1,165 @@ +using System; +namespace MesWebFun_base +{ + public partial class MisWebInterface + { + public static MesWebFun_base _MesWebFun_base = new MesWebFun_base(); + public string WebSocket_Function(string msg) + { + var responseStr = ""; + try + { + //返回的数据msg.data,包含了协议中的4部分9 + var arrays_signal = msg.Split('|'); + var m_Source = arrays_signal[0]; + var m_Command = arrays_signal[1]; + var m_Opname = arrays_signal[2]; + var m_Value = arrays_signal[3]; + // var opName = $("#tbx_opname").val(); + switch (m_Source) + { + case "MES": + + switch (m_Command) + { + //显示托盘信息 √ + case "ShowMoby": + try + { + responseStr = MesWebFun_base.MobySelect(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShowMoby" + "|" + "info"); + } + break; + //显示操作指南√ + case "ProcessList": + try + { + responseStr = MesWebFun_base.ProcessList(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ProcessList" + "|" + "info"); + } + break; + //显示物料√ + case "MaterialList": + try + { + responseStr = MesWebFun_base.MaterialList(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:MaterialList" + "|" + "info"); + } + break; + //显示操作图片√ + case "PicShow": + try + { + responseStr = MesWebFun_base.PictureShow(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:PicShow" + "|" + "info"); + } + break; + //显示拧紧位置√ + case "ShaftPosition": + try + { + responseStr = MesWebFun_base.ShaftPotion_Select(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShaftPosition" + "|" + "info"); + } + break; + //实时显示质量数据√ + case "ShowTimelyQuality": + try + { + responseStr = MesWebFun_base.Quality_Select(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShowTimelyQuality" + "|" + "info"); + } + break; + //手动拧紧实时显示质量数据√ + case "ShowTimelyQuality_Tight": + try + { + responseStr = MesWebFun_base.Quality_Select(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShowTimelyQuality_Tight" + "|" + "info"); + } + break; + + //√ + case "OrderFormList": + try + { + responseStr = MesWebFun_base.OrderFormList(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:OrderFormList" + "|" + "info"); + } + break; + //弹窗消息√ + case "Notice": + try + { + responseStr = MesWebFun_base.ShowWindowNotice(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:Notice" + "|" + "info"); + } + break; + //LED消息提醒√ + case "ScrollNotice": + try + { + responseStr = MesWebFun_base.ShowLEDNotice(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ScrollNotice" + "|" + "info"); + } + break; + //物料检测初始化√ + case "MaterialCheckPosition": + try + { + responseStr = MesWebFun_base.MaterialCheckPosition(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:MaterialCheckPosition" + "|" + "info"); + } + break; + + default: + // Web_Socket_Interface(m_Opname, msg); + break; + } + break; + } + } + catch (Exception exception) + { + var error = exception.ToString(); + //ApplicationLog.WriteLog("信息提示" + "|" + "系统出现错误,接受onmessage:" + "|" + error + "|" + "info"); + responseStr = ""; + } + return responseStr; + } + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_baseFun.cs b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_baseFun.cs new file mode 100644 index 0000000..f9004d2 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_baseFun.cs @@ -0,0 +1,1860 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Text; + +using System.Data; +using MisDataFunDll; +//using SystemFramework; + +namespace MesWebFun_base +{ + public partial class MesWebFun_base + { + ///// + ///// 电子看板_发动机号_合格放行_记录_增加 + ///// + ///// + //private string Insert_ConfirmOk(string opName, string operatorNum, string type) + //{ + // string text = ""; + // try + // { + // // string operatorNum = HttpContext.Current.Request["userName"];//放行者工号 + // // string type = HttpContext.Current.Request["recordType"];//放行类型 + // MES.InsertRecord_ComfirmOkGO(opName, operatorNum, type); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_ConfirmOk"); + // } + // return text; + //} + + + + ///// + ///// 初始化节拍数据 + ///// + ///// + //private string InitOpNameOuputCount(string opnameValue) + //{ + // string text = ""; + // try + // { + // int outputValue = 0; //工位产量 + // int nowOutputValue = 0; //在线产量 + // int opNameBeatValue = 0; //工位节拍 + // int NowOpNameBeatValue = 0; //在线节拍 + // int classNumber = 0;//班次代码 + // MisDataFun.InitOpNameOuputCount(opnameValue, out outputValue, out nowOutputValue, out opNameBeatValue, out NowOpNameBeatValue, out classNumber); + // text = "{\"outputValue\":\"" + outputValue + "\",\"nowOutputValue\":\"" + nowOutputValue + "\",\"opNameBeatValue\":\"" + opNameBeatValue + "\",\"NowOpNameBeatValue\":\"" + NowOpNameBeatValue + "\",\"classNumber\":\"" + classNumber + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:InitOpNameOuputCount"); + // } + // return text; + //} + + ///// + ///// 功能按钮 - 从数据库中初始化在线 / 离线 / 屏蔽的combobox + ///// + ///// + //private string Init_OnlineOutline(string opnameValue) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.Init_OnlineOutline(opnameValue, out dt); + // string value = ""; + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // value = dt.Rows[0]["工位状态"].ToString(); + // } + // } + // text = "{\"value\":\"" + value + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Init_OnlineOutline"); + // } + // return text; + //} + + ///// + ///// 功能按钮---将在线,离线,屏蔽更新到数据库中 + ///// + ///// + //private string Insert_OnlineOutline(string opnameValue, string selectValue) + //{ + // string text = ""; + // try + // { + // //string opnameValue = HttpContext.Current.Request["opnameValue"];//工位号 + // //string selectValue = HttpContext.Current.Request["selectValue"];//选择的值 + // if (selectValue == "") + // { + // selectValue = "0"; + // } + // int selectValueint = Convert.ToInt32(selectValue); + // bool falg = MES.Insert_OnlineOutline(opnameValue, selectValueint); + // if (falg) + // { + // text = "{\"falg\":\"1\"}"; + // } + // else + // { + // text = "{\"falg\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_OnlineOutline"); + // } + // return text; + //} + + ///// + ///// 合格放行 + ///// + ///// + //private string functionButtonConfirmOk(string userName, string passWord) + //{ + // string text = ""; + // try + // { + // string roleFlag = ""; + // string loginFlag = ""; + // System.Data.DataTable dt_User = null; + // //string userName = HttpContext.Current.Request["function_button_confirmOkGo_userName"]; + // //string passWord = HttpContext.Current.Request["function_button_confirmOkGo_passWord"]; + + // BaseDataSystemMES.UserInfo_Login(userName, passWord, out dt_User); + // if (dt_User != null) + // { + // if (dt_User.Rows.Count == 1) + // { + // int roleCodSum = Convert.ToInt32(dt_User.Rows[0][0].ToString()); + // bool IsOK = false; + // RoleDistribution(roleCodSum, out IsOK); + // if (IsOK == true) + // { + // roleFlag = "1"; + // loginFlag = "1"; + // } + // else + // { + // roleFlag = "0"; + // } + // } + // else + // { + // loginFlag = "0"; + // } + // } + // else + // { + // loginFlag = "0"; + // } + // text = "{\"roleFlag\":\"" + roleFlag + "\",\"loginFlag\":\"" + loginFlag + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:functionButtonConfirmOk"); + // } + // return text; + //} + + ///// + ///// 看用户是否有权限访问该页面 + ///// + ///// + ///// + //private void RoleDistribution(int roleCodSum, out bool IsOK) + //{ + // IsOK = false; + // //登录工位MES的权限是256 如果role&256>0则有权限登录MES软件 + // int roleCode = 64; + // //ArrayList aList = new ArrayList(); + // if ((roleCodSum & roleCode) > 0) + // { + // ////加了没用上 + // //aList.Add(roleCode); + + // switch (roleCode) + // { + // case 64: + // { + // //一级用户管理 + // IsOK = true; + // } + // break; + + // default: + // break; + // } + // } + //} + + ///// + ///// 选择订单_增加订单号 + ///// + ///// + //private string InsertOrderNum(string orderlist, string opName) + //{ + // //string orderlist = HttpContext.Current.Request["orderNum"]; + // MES.OrderNum_Add(opName, orderlist); + // return orderlist; + //} + + ///// + ///// 选择订单_增加发动机型号 + ///// + ///// + //private string InsertEngineNum(string opName, string enginetype, string enginetypecode) + //{ + // string orderlist = ""; + // //string enginetype = HttpContext.Current.Request["enginetype"]; + // //string enginetypecode = HttpContext.Current.Request["enginetypecode"]; + // int enginetypeID = Convert.ToInt32(enginetypecode); + // MES.EngineNum_Add(opName, enginetype, enginetypeID); + // return orderlist; + //} + + ///// + ///// 物料拉动_确认接受 + ///// + ///// + //private string AffirmReceive(string opName, string DistributionNums) + //{ + // string text = ""; + // try + // { + // bool falg = false; + // //string DistributionNums = HttpContext.Current.Request["DistributionNums"]; + // string[] array = DistributionNums.Split(','); + // string DistributionNum = ""; + // for (int i = 0; i < array.Length; i++) + // { + // DistributionNum = array[i]; + // falg = MaterialPull.DistributionNum(opName, DistributionNum); + // } + // if (falg) + // { + // text = "{\"falg\":\"1\"}"; + // } + // else + // { + // text = "{\"falg\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // //////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:AffirmReceive"); + // } + // return text; + //} + + ///// + ///// 设备管理_设备保养记录增加 + ///// + ///// + //private string equipmentmanagementSubmit(string opname, string mark) + //{ + // string text = ""; + // try + // { + // bool flag; + // // string mark = HttpContext.Current.Request["mark"]; + // flag = bizFacade.MES_MachineManage.Mes_MachineTakeCare_Insert(opname, mark); + // if (flag) + // { + // text = "{\"flag\":\"1\"}"; + // } + // else + // { + // text = "{\"flag\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:equipmentmanagementSubmit"); + // } + // return text; + //} + + ///// + ///// 获取对应工位的质量数据 + ///// + ///// + //private string QualityDataSelect(string opName, string opname) + //{ + // string qualitydata = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // //string opname = HttpContext.Current.Request["opname"]; + // MES.QualityDataSelect(opName, opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // qualitydata = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:QualityDataSelect"); + // } + // return qualitydata; + //} + + + + ///// 获取设备保养类型 + ///// + ///// + //private string LoadMachineType(string opName) + //{ + // string Maintain = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // MES.LoadMachineType(opName, out dt); + // if (dt.Rows.Count > 0) + // { + // Maintain = JsonHelper.DataTableToJson(dt); + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:LoadMachineType"); + // } + // return Maintain; + //} + + + ///// 获取设备保养内容 + ///// + ///// + //private string ShowMaintainData(string opName, string MachineType) + //{ + // string Maintain = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // //string MachineType = HttpContext.Current.Request["machinetype"]; + // MES.ShowMaintainData(opName, MachineType, out dt); + // if (dt.Rows.Count > 0) + // { + // Maintain = JsonHelper.CreateJsonParameters(dt); + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowMaintainData"); + // } + // return Maintain; + //} + + ///// + ///// 获取设备保养图片 + ///// + ///// + //private string ShowMaintainPic(string opName, string MachineType) + //{ + // string Maintain = ""; + // try + // { + // //string opName = HttpContext.Current.Request["value"]; + // //string MachineType = HttpContext.Current.Request["machinetype"]; + // byte[] imgBytesIn; + // MES.GetMaintainImageFile(opName, MachineType, out imgBytesIn); + // if (imgBytesIn == null) + // { + // return Maintain; + // } + // Maintain = Convert.ToBase64String(imgBytesIn); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowMaintainPic"); + // } + // return Maintain; + //} + + ///// + ///// 物料ando复位 + ///// + ///// + //private string submitAndoMaterialReset(string opname, string andoTypeCode, string andoListCode, string number) + //{ + // string text = ""; + // try + // { + // string number1 = ""; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + + // string[] number_array = number.Split(','); + // string number_value = ""; + // string callInfo = "复位信息"; + + // for (int i = 0; i < number_array.Length - 1; i++) + // { + // number_value = number_array[i].ToString(); + // string[] valuelist = number_value.Split('_'); + // if (valuelist.Length >= 4) + // { + // number1 = valuelist[3]; + // bizFacade.ando_matertial.AndoMaterialReset(opname, number1, andoTypeCode, andoListCode, callInfo); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:submitAndoMaterialReset"); + // } + + // return text; + //} + + ///// + ///// ando界面_质量ando复位 + ///// + ///// + //private string submitAndoQualityReset(string opname, string andoTypeCode, string andoListCode, string number) + //{ + // string text = ""; + // try + // { + // string number1 = ""; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + // string[] valuelist = number.Split('_'); + // if (valuelist.Length >= 4) + // { + // number1 = valuelist[3]; + // } + + // //呼叫内容 + // string callInfo = "复位信息"; + // bool flag = bizFacade.ando_matertial.AndoMaterialReset(opname, number1, andoTypeCode, andoListCode, callInfo); + // if (flag) + // { + // text = "{\"flag\":\"1\"}"; + // } + // else + // { + // text = "{\"flag\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:submitAndoQualityReset"); + // } + // return text; + //} + + ///// + ///// 物料ando_更新ando的具体的tabel + ///// + ///// + //private string updataAndoMaterialTabel(string opname, string andoTypeCode) + //{ + // string text = ""; + // try + // { + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // text = bizFacade.ando_matertial.CreatAndo_Material_table(opname, andoTypeCode); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:updataAndoMaterialTabel"); + // } + // return text; + //} + + ///// + ///// 质量ando_更新ando的具体的tabel + ///// + ///// + //private string updataAndoQualityTabel(string opname, string andoTypeCode) + //{ + // string text = ""; + // try + // { + // // string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // text = bizFacade.ando_quality.CreatAndo_quality_table(opname, andoTypeCode); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:updataAndoQualityTabel"); + // } + // return text; + //} + + ///// + ///// ando界面_提交物料ando信息(插入呼叫信息) + ///// + ///// + //private string submitAndoMaterialCall(string opname, string andoTypeCode, string andoListCode, string number) + //{ + // string text = ""; + // try + // { + // string number1 = ""; + // //System.Data.DataTable tb; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + // string[] number_array = number.Split(','); + // string number_value = ""; + // string callInfo = "0"; + // int callCount = 0; + // string cardNumber = "0"; + // string noNumber = "0"; + + // for (int i = 0; i < number_array.Length - 1; i++) + // { + // number_value = number_array[i].ToString(); + // string[] valuelist = number_value.Split('_'); + // if (valuelist.Length >= 4) + // { + // number1 = valuelist[3]; + // bizFacade.ando_matertial.andoMaterialCall(opname, andoTypeCode, andoListCode, number1, callInfo, callCount, cardNumber, noNumber); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:submitAndoMaterialCall"); + // } + // return text; + //} + + ///// + ///// 安东界面_质量ando_呼叫提交 + ///// + ///// + //private string submitAndoQualityCall() + //{ + // string text = ""; + // //string number1 = ""; + // //string opname = HttpContext.Current.Request["opname"]; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + // //string[] valuelist = number.Split('_'); + // //if (valuelist.Length >= 4) + // //{ + // // number1 = valuelist[3]; + // //} + // //string callInfo = "0"; + // //int callCount = 5; + // //string cardNumber = "0"; + // //string noNumber = "0"; + // //bool flag = bizFacade.ando_matertial.andoMaterialCall(opname, andoTypeCode, andoListCode, number1, callInfo, callCount, cardNumber, noNumber); + // //if (flag) + // //{ + // // text = "{\"flag\":\"1\"}"; + // //} + // //else + // //{ + // // text = "{\"flag\":\"0\"}"; + // //} + // return text; + //} + + ///// + ///// 查询物料ando条数,为了左移动的 + ///// + ///// + //private string InitMaterailAndoCount(string opname, string andoTypeCode) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt_material; + // System.Data.DataTable dt_quality; + // System.Data.DataTable dt_machine; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //查询物料ando具体的button个数 + // bizFacade.ando_matertial.andoListSelect(opname, "1", out dt_material); + // int count_material = 0; + + // //不为空 + // if (dt_material != null) + // { + // if (dt_material.Rows.Count == 0) + // { + // count_material = 0; + // } + // else + // { + // count_material = dt_material.Rows.Count; + // } + // } + // //查询质量ando具体的button个数 + // bizFacade.ando_matertial.andoListSelect(opname, "2", out dt_quality); + // int count_quality = 0; + // if (dt_quality != null) + // { + // if (dt_quality.Rows.Count == 0) + // { + // count_quality = 0; + // } + // else + // { + // count_quality = dt_quality.Rows.Count; + // } + // } + // //查询设备ando具体的button个数 + // bizFacade.ando_matertial.andoListSelect(opname, "3", out dt_machine); + + // int count_machine = 0; + // if (dt_machine != null) + // { + // if (dt_machine.Rows.Count == 0) + // { + // count_machine = 0; + // } + // else + // { + // count_machine = dt_machine.Rows.Count; + // } + // } + // text = "{\"material_count\":\"" + count_material + "\",\"machine_count\":\"" + count_machine + "\",\"quality_count\":\"" + count_quality + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:InitMaterailAndoCount"); + // } + // return text; + //} + + ///// + ///// 初始化ando + ///// + ///// + //private string InitMaterailAndo(string opname) + //{ + // string text = ""; + // try + // { + // text = bizFacade.ando_load.ando_loading(opname); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:InitMaterailAndo"); + // } + // return text; + //} + + ///// + ///// ando_查询具体ando类型明细 + ///// + ///// + //private string InitComboboxAndoDetail() + //{ + // string text = ""; + // //System.Data.DataTable dt = null; + // //string andoType="1"; + // //bizFacade.ando.select_ando_detail(andoType, out dt); + // //text = JsonHelper.DataTableToJson(dt); + // return text; + //} + + ///// + ///// 初始化装配线MES + ///// + ///// + //private string MesloadingSelect(string opname, string languageType, string mainModule) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + + // //string languageType = HttpContext.Current.Request["mainModule"]; + // //string mainModule = HttpContext.Current.Request["MesWebCode"]; + // bizFacade.MES_Loading.MES_Loading_select(languageType, mainModule, opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.DataTableToJson(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MesloadingSelect"); + // } + // return text; + //} + + + + ///// + ///// 查询物料库存信息 + ///// + ///// + //private string MaterialListStock(string OpName) + //{ + // string jsonStr_Materail = ""; + // try + // { + // string orderNum = ""; + // int EngineTypeID = 0; + // string EngineType = ""; + // string EngineID = ""; + // string PartPallet_Code = ""; + // int IsrepairBarcode = 0; + // string repairBarcode = ""; + // string EngineTypeString = ""; + // MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + // DataTable dt_Material; + + // MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out dt_Material); + // if (dt_Material != null) + // { + // if (dt_Material.Rows.Count > 0) + // { + // jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + // } + // return jsonStr_Materail; + //} + + + + + + ///// + ///// 获得工步属性 + ///// + ///// + //private string StepProperty(string opName) + //{ + // string stepProperty = "512"; + // System.Data.DataTable dt = null; + // bizFacade.UserLogin.GetUrl(opName, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // stepProperty = dt.Rows[0]["工步属性"].ToString(); + // } + // } + // return stepProperty; + //} + + + + //private static string CreateJsonParameters(DataTable dt) + //{ + // StringBuilder JsonString = new StringBuilder(); + // //Exception Handling + // if (dt != null) + // { + // JsonString.Append("{ "); + // JsonString.Append("\"total\":"); + // JsonString.Append(dt.Rows.Count); + // JsonString.Append(","); + // JsonString.Append("\"rows\":[ "); + // for (int i = 0; i < dt.Rows.Count; i++) + // { + // JsonString.Append("{ "); + // for (int j = 0; j < dt.Columns.Count; j++) + // { + // if (j < dt.Columns.Count - 1) + // { + // //if (dt.Rows[i][j] == DBNull.Value) continue; + // if (dt.Columns[j].DataType == typeof(bool)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + + // dt.Rows[i][j].ToString().ToLower() + ","); + // } + // else if (dt.Columns[j].DataType == typeof(string)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + // } + // else + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + // } + // } + // else if (j == dt.Columns.Count - 1) + // { + // //if (dt.Rows[i][j] == DBNull.Value) continue; + // if (dt.Columns[j].DataType == typeof(bool)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + + // dt.Rows[i][j].ToString().ToLower()); + // } + // else if (dt.Columns[j].DataType == typeof(string)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + // } + // else + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + // } + // } + // } + // /*end Of String*/ + // if (i == dt.Rows.Count - 1) + // { + // JsonString.Append("} "); + // } + // else + // { + // JsonString.Append("}, "); + // } + // } + // JsonString.Append("]"); + // JsonString.Append("}"); + // return JsonString.ToString().Replace("\n", ""); + // } + // else + // { + // return null; + // } + //} + + ///// + ///// 获得机型 + ///// + ///// + //private string Orderenginetypeselect() + //{ + // string enginetypelist = ""; + // try + // { + // System.Data.DataTable dt = null; + // ShaftPosition.EngineType_Select(out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // enginetypelist = JsonHelper.DataTableToJson(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Orderenginetypeselect"); + // } + // return enginetypelist; + //} + + ///// + ///// 物料拉动_获取单号 + ///// + ///// + //private string MaterialPush_ListNumer(string opName) + //{ + // string listNumber = ""; + // try + // { + // System.Data.DataTable dt = null; + // MaterialPull.MaterialPush_ListNumer_Select(0, "", 1, opName, 0, "", out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // listNumber = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialPush_ListNumer"); + // } + // return listNumber; + //} + + ///// + ///// 物料拉动_根据单号获取详细信息 + ///// + ///// + //private string MaterialPush_Details(string opname, string listNumer) + //{ + // string listDetails = ""; + // try + // { + // System.Data.DataTable dt = null; + // //单号 + // //string listNumer = HttpContext.Current.Request["listNumber"]; + // MaterialPull.MaterialPush_Details_Select(listNumer, opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // listDetails = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialPush_Details"); + // } + // return listDetails; + //} + + ///// + ///// 物料拉动_根据单号获取详细信息 + ///// + ///// + //private string QualityDataButton_bgColor_Select(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // //单号 + // MES.QualityDataButton_bgColor_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count >= 0) + // { + // text = Buttons.Createbuttons(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:QualityDataButton_bgColor_Select"); + // } + // return text; + //} + + + + + + ///// + ///// 获取生产订单 + ///// + ///// + //private string GetOrderForm(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.OpName_MIS_OrderForm_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["订单号"].ToString(); + // return text; + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetOrderForm"); + // } + // return text; + //} + + ///// + ///// 获取发动机型号 + ///// + ///// + //private string GetEngineType(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.OpName_MIS_EngineType_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["产品型号代码"].ToString() + "&" + dt.Rows[0]["发动机型号"].ToString(); + // return text; + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetEngineType"); + // } + // return ("" + "&" + ""); + //} + + ///// + ///// + ///// + ///// + //private string ShowOpNameMessage(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // BaseDataSystemMES.GetOpNameByOpName(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["工序名称"].ToString() + "&" + dt.Rows[0]["操作者工号"].ToString() + "&" + dt.Rows[0]["是否启用物料拉动"].ToString(); + // return text; + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowOpNameMessage"); + // } + // return ("" + "&" + "" + "&" + "0"); + //} + + ///// + ///// 系统初始化时 + ///// + ///// + //private string WebLoginIn(string opname) + //{ + // string text = ""; + // MES.WebLoginIn(opname); + // return text; + //} + + + + ///// + ///// 获取对应工位的物料数据 + ///// + ///// + //private string MaterialDataSelect(string opName, string opname) + //{ + // string qualitydata = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // //string opname = HttpContext.Current.Request["opname"]; + // MES.MaterialDataSelect(opName, opname, out dt); + // if (dt != null) + // { + // //if (dt.Rows.Count > 0) + // { + // qualitydata = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialDataSelect"); + // } + // return qualitydata; + //} + + ///// + ///// 电子看板_装配零件_查询 + ///// + ///// + //private string MaterialSelect(string opName, string enginetypeid, string enginetype) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string enginetypeid = HttpContext.Current.Request["enginetypeid"]; + // //string enginetype = HttpContext.Current.Request["enginetype"]; + // ShaftPosition.Material_Select(opName, enginetypeid, enginetype, out dt); + + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialSelect"); + // } + // return text; + //} + + //public string GetLoginOutUrl() + //{ + // string url = System.Configuration.ConfigurationManager.AppSettings["Linklogin"].ToString(); + // return url; + //} + + ///// + ///// 手动修改批次信息 + ///// + ///// + //private string MaterialManualUpdateBetch(string opName,string arrays, string enginetype) + //{ + // string text = ""; + // try + // { + // //string arrays = HttpContext.Current.Request["arrays"];//组合 + // //string enginetype = HttpContext.Current.Request["enginetype"];//产品型号 + + // //创建datatable + // DataRow row; + // DataTable dt = new DataTable(); + // dt.Columns.AddRange(new DataColumn[] { + // new DataColumn("零件图号"), + // new DataColumn("零件批号"), + // new DataColumn("生产厂家") }); + + // string[] collection = arrays.Split('^');//获取 + // if (collection.Length > 0) + // { + // for (int i = 0; i < collection.Length; i++) + // { + // string a = collection[i]; + // string[] a_array = a.Split('&'); + // if (a_array.Length > 2) + // { + // row = dt.NewRow(); + // string materialid = a_array[0].ToString(); + // string betch = a_array[1].ToString(); + // string factory = a_array[2].ToString(); + // row["零件图号"] = materialid; + // row["零件批号"] = betch; + // row["生产厂家"] = factory; + // dt.Rows.Add(row); + // } + // } + + // //修改到数据库 + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // MES.Material_Betch_Update(opName, enginetype, dt); + // } + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialManualUpdateBetch"); + // } + // return text; + //} + + ///// + ///// 获得返修数量信息 + ///// + ///// + //private string GetRepaireNum(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.OpName_MIS_RepiareNum_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["当前数量"].ToString() + "&" + dt.Rows[0]["设置数量"].ToString(); + // return text; + // } + // else + // { + // return text = "0&0"; + // } + // } + // else + // { + // return text = "0&0"; + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetEngineType"); + // } + // return ("" + "&" + ""); + //} + + ///// + ///// 插入返修数量 + ///// + ///// + //private string Insert_RepiareNum(string opnameValue, string selectValue) + //{ + // string text = ""; + // try + // { + // //string selectValue = HttpContext.Current.Request["CurrentNum"];//选择值 + // if (selectValue == "") + // { + // selectValue = "0"; + // } + // int selectValueint = Convert.ToInt32(selectValue); + // bool falg = MES.Insert_RepiareNum(opnameValue, selectValueint); + // if (falg) + // { + // text = "{\"falg\":\"1\"}"; + // } + // else + // { + // text = "{\"falg\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_RepiareNum"); + // } + // return text; + //} + + ///// + ///// 初始化返修选择tree数据 + ///// + ///// + //private string Init_TreeData(string opnameValue) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt; + // //string opnameValue = HttpContext.Current.Request["Opname"];//工位号 + // MES.Init_TreeData(opnameValue, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Init_TreeData"); + // } + // return text; + //} + + ///// + ///// 返修上线--初始化质量数据 + ///// + ///// + //private string Quality_Select_Repair(string OpName, string EngineID) + //{ + // string text = ""; + // try + // { + // DataTable dt; + // MES.QualitySelect(OpName, EngineID, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select_Repair"); + // } + // return text; + //} + + ///// + ///// 返修上线-将选择的根节点数据更新到数据库中 + ///// + ///// + //private string Insert_selectTreeData(string opName, string engineTypeId, string selectIdsArray) + //{ + // string text = ""; + // try + // { + // //string engineTypeId = HttpContext.Current.Request["engineTypeId"];//产品型号代码 + // //string selectIdsArray = HttpContext.Current.Request["selectId"];//选中的节点数据数据 + // //创建datatable + // DataRow row; + // DataTable dt = new DataTable(); + // dt.Columns.AddRange(new DataColumn[] { + // new DataColumn("工位号"), + // new DataColumn("产品型号代码"), + // new DataColumn("序号") }); + // string[] collection = selectIdsArray.Split(',');//获取 + // if (collection.Length > 0) + // { + // for (int i = 0; i < collection.Length - 1; i++) + // { + // string idValue = collection[i]; + // row = dt.NewRow(); + // string opNameValue = opName; + // int engineTypeIdValue = Convert.ToInt32(engineTypeId); + // int selectId = Convert.ToInt32(idValue); + // row["工位号"] = opNameValue; + // row["产品型号代码"] = engineTypeIdValue; + // row["序号"] = selectId; + // dt.Rows.Add(row); + // } + // //修改到数据库 + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // MES.Insert_selectTreeData(dt); + // } + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_selectTreeData"); + // } + + // return text; + //} + + ///// + ///// 质量报警_根据按钮获取详细信息 20170318 + ///// + ///// + //public static string QualityDataButton_bgColor_alert_Select(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // //单号 + // //string opname = HttpContext.Current.Request["value"]; + // //string lineout_barcode = HttpContext.Current.Request["lineout_barcode"]; + // MES.QualityDataButton_bgColor_alert_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count >= 0) + // { + // text = Buttons.Createbuttons_alert(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:QualityDataButton_bgColor_alert_Select"); + // } + // return text; + //} + + ///// + ///// 获取对应工位的物料数据_根据发动机 20170319 + ///// + ///// + //private string MaterialDataSelect_F_EnergineID(string opname, string energineID) + //{ + // string qualitydata = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string energineID = HttpContext.Current.Request["value"]; + // MES.MaterialDataSelect_F_EnergineID(opname, energineID, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // qualitydata = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialDataSelect"); + // } + // return qualitydata; + //} + + ///// + ///// 获取操作指南的PDF路径 + ///// + ///// + //private string GetPdfSrc(string OpName) + //{ + // string PdfSrc = ""; + // try + // { + // System.Data.DataTable dt = null; + + // string orderNum = ""; + // int EngineTypeID = 0; + // string EngineType = ""; + // string EngineID = ""; + // string PartPallet_Code = ""; + // int IsrepairBarcode = 0; + // string repairBarcode = ""; + // string EngineTypeString = ""; + // MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + // BaseDataSystemMES.GetPdfSrc(OpName, EngineTypeID.ToString(), out PdfSrc); + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetPdfSrc"); + // } + // return PdfSrc; + //} + + + + #region 目前有用的函数 + + /// + /// 查询托盘信息 + /// + /// + public static string MobySelect(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode + "&" + + workCode + "&" + projectName + "&" + splitCode + "&" + unidCode + "&" + engineType + "&" + engineTypeModel + "&" + startTime; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect"); + } + return data; + } + + /// + /// 查询操作图片 + /// + /// + public static string PictureShow(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + byte[] imgBytesIn; + MisDataFun.GetImageFile(OpName, EngineTypeID, out imgBytesIn); + if (imgBytesIn == null) + { + return data; + } + data = Convert.ToBase64String(imgBytesIn); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow"); + } + return data; + } + + /// + /// 查询物料 + /// + /// + public static string MaterialList(string OpName) + { + string jsonStr_Materail = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + DataTable dt_Material; + MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out dt_Material); + if (dt_Material != null) + { + if (dt_Material.Rows.Count > 0) + { + jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + } + return jsonStr_Materail; + } + /// + /// 查询操作指南 + /// + /// + public static string ProcessList(string OpName) + { + string jsonStr_Process = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + + DataTable dt_Proccess; + MisDataFun.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess); + if (dt_Proccess != null) + { + if (dt_Proccess.Rows.Count > 0) + { + jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList"); + } + return jsonStr_Process; + } + /// + /// 创建动态div + /// + /// + public static string ShaftPotion_Select(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + + DataTable dt; + MisDataFun.ShaftPositionSelect(OpName, EngineTypeID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShaftPotion_Select"); + } + return text; + } + /// + /// 实时显示质量数据 + /// + /// + public static string Quality_Select(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + + DataTable dt; + MisDataFun.QualitySelect(OpName, EngineID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.CreateJsonParameters(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select"); + } + return text; + } + /// + /// 订单完工,上线数量大于计划数量,界面提示 + /// + /// + private string OrderFormList_OrderComplete(string opName) + { + string text = ""; + try + { + int isCompleted;//订单数量是否完全上线 + int num_plan;//计划数量 + int num_complete;//上线数量 + MisDataFun.Select_OrderFormList_OrderComplete(opName, out isCompleted, out num_plan, out num_complete); + text = "{\"isCompleted\":\"" + isCompleted + "\",\"num_plan\":\"" + num_plan + "\",\"num_complete\":\"" + num_complete + "\"}"; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:OrderFormList_OrderComplete"); + } + return text; + } + /// + /// 获得订单信息 + /// + /// + public static string OrderFormList(string opName) + { + string orderlist = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.OrderFormList_Select(opName, out dt); + //对其进行判断 + if (dt != null) + { + if (dt.Rows.Count > 0) + { + int planCount;//计划数量 + int finishCount;//完成数量 + int isOverCount;//是否超标,0表示未完成,1表示正好完成,2表示超过预期 + int isSelect;//选择标志 + int isCanSelect;//是否有订单选择权限 + string status;//状态 + for (int i = 0; i < dt.Rows.Count; i++) + { + planCount = 0; + finishCount = 0; + isOverCount = 0; + isSelect = 0; + isCanSelect = 0; + status = ""; + + if (dt.Rows[i]["计划数量"].ToString() != "") + { + planCount = Convert.ToInt32(dt.Rows[i]["计划数量"]); + } + if (dt.Rows[i]["完成数量"].ToString() != "") + { + finishCount = Convert.ToInt32(dt.Rows[i]["完成数量"]); + } + if (dt.Rows[i]["选择标志"].ToString() != "") + { + isSelect = Convert.ToInt32(dt.Rows[i]["选择标志"]); + } + if (dt.Rows[i]["订单选择权限"].ToString() != "") + { + isCanSelect = Convert.ToInt32(dt.Rows[i]["订单选择权限"]); + } + if (isSelect == 1)//表示选择当前订单,显示"√" + { + status = "√"; + } + if (finishCount == planCount)//完成数量>计划数量则表示超标 + { + isOverCount = 1; + } + if (finishCount > planCount)//完成数量>计划数量则表示超标 + { + isOverCount = 2; + } + //重新赋值 + dt.Rows[i]["状态"] = status; + dt.Rows[i]["是否超标"] = isOverCount;//0表示未完成,1表示正好完成,2表示超过预期 + dt.Rows[i]["选择标志"] = isSelect; + dt.Rows[i]["订单选择权限"] = isCanSelect; + } + } + } + + orderlist = JsonHelper.CreateJsonParameters(dt); + //orderlist = CreateJsonParameters(dt); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:OrderFormList"); + } + return orderlist; + } + /// + /// 消息提醒 + /// + /// + public static string ShowWindowNotice(string opname) + { + string text = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.ShowWindowNotice(opname, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowWindowNotice"); + } + return text; + } + /// + /// 消息滚动 + /// + /// + public static string ShowLEDNotice(string opname) + { + string text = ""; + try + { + DataTable dt = null; + MisDataFun.ShowLEDNotice(opname, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowLEDNotice"); + } + return text; + } + /// + /// 物料检测 + /// + /// + public static string MaterialCheckPosition(string OpName) + { + string text = ""; + try + { + DataTable dt; + MisDataFun.MaterialCheckSelect(OpName, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialCheckPosition"); + } + return text; + } + + + + + + + + + + + + + + #endregion + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/MIS.SendMessage.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/MIS.SendMessage.cs new file mode 100644 index 0000000..120fb56 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/MIS.SendMessage.cs @@ -0,0 +1,100 @@ +using System; +using System.Data; +using System.Collections; +//using BasicData; +////using bizFacade; +//using SystemFramework; +using System.Configuration; +//using MesWork; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Receiving; +using MQTTnet; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public partial class MIS_SendMessage + { + /// + /// + /// + public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"]; + /// + /// + /// + static new MesWebFun_base.MisWebInterface misWebInterface = new MesWebFun_base.MisWebInterface(); + /// + /// + /// + static readonly Object locker = new Object(); + /// + /// 发消息给通讯服务器 + /// + /// + public static string asyncSendMessage(string Message) + { + lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + Task.Run(() => Mqtt.Publish(topic, Message)); + + var responseStr = misWebInterface.WebSocket_Function(Message); + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + return responseStr; + } + } + + public static string asyncSendMessageDemo(string Message) + { + lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + + //Mqtt.Publish(topic, Message); + string responseStr = ""; + //var responseStr = misWebInterface.WebSocket_Function(Message); + //if (responseStr.Length > 0) + //{ + + // Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"); + //} + return responseStr; + } + } + + /// + /// 发消息给通讯服务器 + /// + /// + public static string asyncSendMessageQos0(string Message) + { + lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + Mqtt.PublishQos0(topic, Message); + + return ""; + } + } + + + + } +} + diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/Mqtt.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/Mqtt.cs new file mode 100644 index 0000000..e6a69e6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/Mqtt.cs @@ -0,0 +1,281 @@ + +using MQTTnet; +using MQTTnet.Client; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Options; +using MQTTnet.Client.Receiving; +using MQTTnet.Extensions.ManagedClient; +using MQTTnet.Formatter; + +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Mqtt + { + /// + /// + /// + public static IManagedMqttClient mqttClient = null; + public static string MqttUrl = ConfigurationManager.AppSettings["MqttUrl"]; + /// + /// + /// + public static string topic = ""; + + + /// + /// + /// + /// + /// + public static async Task StartAsync() + { + string uri = MqttUrl; + //127.0.0.1:18083,123 + var array = uri.Split(new char[] { ':', ',' }); + string mqttUser = "MisDataFun"; + string mqttPassword = ""; + var options = new MqttClientOptions + { + ClientId = "MisDataFun-200170511", + ProtocolVersion = MqttProtocolVersion.V311, + ChannelOptions = new MqttClientTcpOptions { Server = array[0], Port = Convert.ToInt32(array[1]) }, + CleanSession = false, + SessionExpiryInterval = 300, + KeepAlivePeriod = TimeSpan.FromSeconds(20), + Credentials = new MqttClientCredentials + { + Username = mqttUser, + Password = Encoding.UTF8.GetBytes(mqttPassword) + } + }; + mqttClient = new MqttFactory().CreateManagedMqttClient(); + + //mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected); + //mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected); + //mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived); + await mqttClient.StartAsync(new ManagedMqttClientOptions { ClientOptions = options }); + topic = array[2]; + await mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = topic }); + + } + + + /// + /// + /// + /// + /// + /// + public static async Task Publish(string publish_topic, string publish_msg) + { + if (mqttClient != null) + { + try + { + await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithExactlyOnceQoS().Build()); + + } + catch (Exception err) + { + + } + } + } + /// + /// + /// + /// + /// + /// + public static async Task PublishQos0(string publish_topic, string publish_msg) + { + if (mqttClient != null) + { + await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithAtLeastOnceQoS().Build()); + } + } + /// + /// + /// + /// + public static async Task StopAsync() + { + if (mqttClient != null) + { + await mqttClient.UnsubscribeAsync(new string[] { topic }); + await mqttClient.StopAsync(); + } + } + ///// + ///// + ///// + ///// + //private static void OnSubscriberConnected(MqttClientConnectedEventArgs x) + //{ + // var rec = x.AuthenticateResult.ResultCode.ToString(); + // // label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x) + //{ + // //var rec = x.AuthenticateResult.ResultCode.ToString(); + // //label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x) + //{ + // var rec = x.ApplicationMessage.ConvertPayloadToString(); + // // txt_Rec.Text = txt_Rec.Text + rec + System.Environment.NewLine; + + //} + + + + } + + public class Mqtt2 + { + /// + /// + /// + public IManagedMqttClient mqttClient = null; + public string MqttUrl; + /// + /// + /// + public string topic = ""; + + public Mqtt2() + { + mqttClient = new MqttFactory().CreateManagedMqttClient(); + } + /// + /// + /// + /// + /// + public async Task StartAsync() + { + string uri = MqttUrl; + //127.0.0.1:18083,123 + var array = uri.Split(new char[] { ':', ',' }); + string mqttUser = ""; + string mqttPassword = ""; + var options = new MqttClientOptions + { + ClientId = Guid.NewGuid().ToString(), + ProtocolVersion = MqttProtocolVersion.V311, + ChannelOptions = new MqttClientTcpOptions { Server = array[0], Port = Convert.ToInt32(array[1]) }, + CleanSession = true, + KeepAlivePeriod = TimeSpan.FromSeconds(100), + Credentials = new MqttClientCredentials + { + Username = mqttUser, + Password = Encoding.UTF8.GetBytes(mqttPassword) + } + }; + //mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected); + //mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected); + //mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived); + await mqttClient.StartAsync(new ManagedMqttClientOptions { ClientOptions = options }); + //topic = array[2]; + await mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = topic }); + + } + + + /// + /// + /// + /// + /// + /// + public async Task Publish(string publish_topic, string publish_msg) + { + if (mqttClient != null) + { + try + { + await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithExactlyOnceQoS().Build()); + + } + catch (Exception err) + { + + } + } + } + //static public async Task Publish(IManagedMqttClient mqttClient_1, string publish_topic, string publish_msg) + //{ + // if (mqttClient_1 != null) + // { + // try + // { + // await mqttClient_1.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithExactlyOnceQoS().Build()); + + // } + // catch (Exception err) + // { + + // } + // } + //} + /// + /// + /// + /// + public async Task StopAsync() + { + if (mqttClient != null) + { + await mqttClient.UnsubscribeAsync(new string[] { topic }); + await mqttClient.StopAsync(); + } + } + ///// + ///// + ///// + ///// + //private static void OnSubscriberConnected(MqttClientConnectedEventArgs x) + //{ + // var rec = x.AuthenticateResult.ResultCode.ToString(); + // // label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x) + //{ + // //var rec = x.AuthenticateResult.ResultCode.ToString(); + // //label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x) + //{ + // var rec = x.ApplicationMessage.ConvertPayloadToString(); + // // txt_Rec.Text = txt_Rec.Text + rec + System.Environment.NewLine; + + //} + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessage.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessage.cs new file mode 100644 index 0000000..d5d8ee6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessage.cs @@ -0,0 +1,666 @@ +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + + /// + /// 命令 + ///显示托盘信息√ case "ShowMoby": + ///显示操作指南√ case "ProcessList": + ///显示物料√ case "MaterialList": + ///显示操作图片√ case "PicShow": + ///显示拧紧位置√ case "ShaftPosition": + ///实时显示质量数据√ case "ShowTimelyQuality": + ///手动拧紧实时显示质量数据√case "ShowTimelyQuality_Tight": + ///√ case "OrderFormList": + ///弹窗消息√ case "Notice": + ///LED消息提醒√ case "ScrollNotice": + ///物料检测初始化√ case "MaterialCheckPosition": + ///返修质量数据显示√ case "RepairQuality" + /// + /// + public class SendMessage + { + /// + /// MES/InstantMessaging/BQ + /// + public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"]; + + /// + /// 5 显示订单、机型信息 上线工位 + /// + /// + public static void ShowMoby_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ShowMoby_String_FirstOpName(opName); + string cmd = "ShowMoby"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + /// + /// 5 显示订单、机型信息 非上线工位 + /// + /// + public static void ShowMoby(string opName, int type = 1) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ShowMoby_String(opName, type); + string cmd = "ShowMoby"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + public static void MaterialList_Dif(string opName, string msgText) + { + var topic = $"{MqttTargetTopic}/{opName}"; + string cmd = "MaterialList_Dif"; + if (msgText.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{msgText}")); + } + } + public static void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + MisDataFun.Web_Notice_Insert(opname, notice); + Notice(opname); + } + public static void Notice(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = Notice_String(opName); + string cmd = "Notice"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + /// + /// 1(直接在界面通过选择机型确认工序内容) + /// + /// + public static void ProcessList(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ProcessList_String(opName); + string cmd = "ProcessList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + public static void ProcessList_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ProcessList_String_FirstOpName(opName); + string cmd = "ProcessList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + /// + /// 2显示物料 + /// + /// + public static void MaterialList(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = MaterialList_String(opName); + string cmd = "MaterialList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + + } + public static void MaterialList_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = MaterialList_String_FirstOpName(opName); + string cmd = "MaterialList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + + } + /// + /// 3显示操作指导图片 + /// + /// + public static void PicShow(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = PicShow_String(opName); + string cmd = "PicShow"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + public static void PicShow_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = PicShow_String_FirstOpName(opName); + string cmd = "PicShow"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + + /// + /// 4订单完工模块刷新完成数量 + /// + /// + public static void OrderFormList(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = OrderFormList_String(); + string cmd = "OrderFormList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + + //实时显示质量数据√ + public static void ShowTimelyQuality(string opName) + { + + } + + public static void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + //if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + + MisDataFun.OpNameCount_BQ(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + } + } + } + + public static void SendInfomation(string Command, string Value, string OpName) + { + + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + } + + public static void AsyncSendMessage(string Message) + { + //lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + Task.Run(() => Mqtt.Publish(topic, Message)); + + } + + + } + private static string ProcessList_String(string OpName) + { + string jsonStr_Process = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt_Proccess; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess); + if (dt_Proccess != null) + { + if (dt_Proccess.Rows.Count > 0) + { + jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList"); + } + return jsonStr_Process; + } + private static string ProcessList_String_FirstOpName(string OpName) + { + string jsonStr_Process = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt_Proccess; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess); + if (dt_Proccess != null) + { + if (dt_Proccess.Rows.Count > 0) + { + jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList"); + } + return jsonStr_Process; + } + // + private static string PicShow_String(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + byte[] imgBytesIn; + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.GetImageFile(OpName, EngineTypeID, out imgBytesIn); + if (imgBytesIn == null) + { + return data; + } + data = Convert.ToBase64String(imgBytesIn); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow"); + } + return data; + } + + private static string PicShow_String_FirstOpName(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + byte[] imgBytesIn; + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.GetImageFile(OpName, EngineTypeID, out imgBytesIn); + if (imgBytesIn == null) + { + return data; + } + data = Convert.ToBase64String(imgBytesIn); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow"); + } + return data; + } + /// + /// 上线工位 + /// + /// + /// + private static string ShowMoby_String(string OpName, int type = 1) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + //非上线工位 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode + "&" + EngineTypeString; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect"); + } + return data; + } + private static string ShowMoby_String_FirstOpName(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + //上线工位 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode + "&" + EngineTypeString; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect"); + } + return data; + } + private static string MaterialList_String(string OpName) + { + string jsonStr_Materail = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out DataTable dt_Material); + if (dt_Material != null) + { + if (dt_Material.Rows.Count > 0) + { + jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + } + return jsonStr_Materail; + } + private static string MaterialList_String_FirstOpName(string OpName) + { + string jsonStr_Materail = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out DataTable dt_Material); + if (dt_Material != null) + { + if (dt_Material.Rows.Count > 0) + { + jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + } + return jsonStr_Materail; + } + + private static string ShowTimelyQuality_String(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.QualitySelect(OpName, EngineID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.CreateJsonParameters(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select"); + } + return text; + } + private static string ShowTimelyQuality_String_FirstOpName(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt; + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.QualitySelect(OpName, EngineID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.CreateJsonParameters(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select"); + } + return text; + } + + private static string OrderFormList_String() + { + string enginetypelist = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.EngineType_Select(out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + enginetypelist = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Orderenginetypeselect"); + } + return enginetypelist; + } + + /// + /// 消息提醒 + /// + /// + private static string Notice_String(string opname) + { + string text = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.ShowWindowNotice(opname, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowWindowNotice"); + } + return text; + } + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm, string Value, string OpName) + { + for (int i = 0; i < MessageNumm.Length; i++) + { + Sendmessage(MessageNumm[i], Value[i].ToString(), OpName); + + } + } + + /// + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + static void Sendmessage(char Num, string Value, string OpName) + { + string SendMessage; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '3': + + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '4': + //3显示操作指导图片 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '8': + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'b': + SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'c': + SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + } + } + ///// + ///// 发送信息到MES通讯服务器或者其他的 + ///// + ///// + //static private void AsyncSendMessage1(string Message) + //{ + // MIS_BASE.asyncSendMessage(Message); + //} + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessageFun.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessageFun.cs new file mode 100644 index 0000000..af96e4a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessageFun.cs @@ -0,0 +1,249 @@ +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + /// + /// 命令 + ///显示托盘信息√ case "ShowMoby": + ///显示操作指南√ case "ProcessList": + ///显示物料√ case "MaterialList": + ///显示操作图片√ case "PicShow": + ///显示拧紧位置√ case "ShaftPosition": + ///实时显示质量数据√ case "ShowTimelyQuality": + ///手动拧紧实时显示质量数据√case "ShowTimelyQuality_Tight": + ///√ case "OrderFormList": + ///弹窗消息√ case "Notice": + ///LED消息提醒√ case "ScrollNotice": + ///物料检测初始化√ case "MaterialCheckPosition": + ///返修质量数据显示√ case "RepairQuality" + /// + /// + public class SendMessageFun + { + /// + /// 批量发送WEB消息(Value为BOOL值) + /// 1:显示工序内容 + /// 2:显示物料 + /// 3:显示操作指导图片 + /// 5:显示机型、工件流水号、订单信息 + /// c:显示质量数据 + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + static public void SendMessage(string MessageNumm, string Value, string OpName) + { + for (int i = 0; i < MessageNumm.Length; i++) + { + SendMessageFun.SendMessage(MessageNumm[i], Value[i].ToString(), OpName); + + } + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + static public void SendInfomation(string Command, string Value, string OpName) + { + + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + } + + static public void AsyncSendMessage_Notice(string opname, string notice, string noticeType = "misServer") + { + //通知Web界面 + notice = $"{{\"Notice\":\"{notice}\",\"NoticeType\":\"{noticeType}\"}}"; + + MisDataFun.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice_Info|" + opname + "|" + notice; + MIS_SendMessage.asyncSendMessage(SendMessage); + } + /// + /// + /// + /// + /// + /// barcode mis + static public void AsyncSendMessage_Notice_Error(string opname, string notice, string noticeType) + { + //通知Web界面 + // notice: notice, noticeType: noticeType + + notice = $"{{\"Notice\":\"{notice}\",\"NoticeType\":\"{noticeType}\"}}"; + + MisDataFun.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice_Error|" + opname + "|" + notice; + MIS_SendMessage.asyncSendMessage(SendMessage); + } + /// + /// 选择发送给WEB的消息 + /// 1:显示工序内容 + /// 2:显示物料 + /// 3:显示操作指导图片 + /// 5:显示机型、工件流水号、订单信息 + /// c:显示质量数据 + /// + /// 消息类型 + /// 消息工位 + static void SendMessage(char Num, string Value, string OpName) + { + string SendMessage; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '3': + + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '4': + //3显示操作指导图片 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '8': + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'b': + SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'c': + //SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + SendMessage = "MES|ShowTimelyQuality|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + } + } + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + //void SendInfomation(string Command, string Value, string OpName) + //{ + + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + //} + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + + MisDataFun.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + } + } + } + + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + static public void AsyncSendMessage(string Message) + { + MIS_SendMessage.asyncSendMessage(Message); + } + + ///// + ///// 发送提示消息 + ///// + ///// + //static public void AsyncSendMessage_Notice(string opname, string notice) + //{ + // //通知Web界面 + // BaseDataSystemMES.Web_Notice_Insert(opname, notice); + // string SendMessage = "MES|Notice|" + opname + "|" + "1"; + // MIS_BASE.asyncSendMessage(SendMessage); + //} + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + + + } +} + diff --git a/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.Alarm.cs b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.Alarm.cs new file mode 100644 index 0000000..bd04a2f --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.Alarm.cs @@ -0,0 +1,247 @@ +using DataLinkMesWork1; +using MesServerFunctions; +using MesServerWork; +using MisDataFunDll; +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace MisDataSaveDate +{ + public partial class FuntionMesRead + { + + #region 2023.05.14,新增报警 + + public static Hashtable Base_TagIdList = new Hashtable(); + public static Hashtable Base_ObjList = new Hashtable(); + + + public static void GetAlarmInit() + { + Base_TagIdList.Clear(); + GetTagIdList("", out DataTable dt); + + for (int i = 0; i < dt.Rows.Count; i++) + { + string tagid = dt.Rows[i]["TagID"].ToString(); + + if (tagid[0].ToString() == "9") + { + var opName = dt.Rows[i]["工位号"].ToString(); + var ItemName = dt.Rows[i]["测量项目"].ToString(); // 报警内容 + var ShaftID = dt.Rows[i]["测量位置"].ToString(); // 报警类型 + + string SendMessage = "MES|PlcAlarm|" + opName + "|" + tagid + "&@TagValue&" + ItemName + "&" + ShaftID; + Base_TagIdList.Add(tagid, SendMessage); + + //在存一份报警对象到键值对中 + Base_ObjList.Add(tagid, dt.Rows[i]); + } + } + } + + //public static void Send_AlarmMsg(string tagid, string tagVvalue) + //{ + // var val = Base_TagIdList[tagid]; + // if (val != null) + // { + // //var msg = Base_TagIdList[tagid].ToString(); + // //var sendmsg = msg.Replace("@TagValue", tagVvalue); + // //SendMessageFun.AsyncSendMessage(sendmsg); + // string alarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + // var msg = Base_TagIdList[tagid].ToString(); + // var sendmsg = msg.Replace("@TagValue", tagVvalue) + "&" + alarmTime; + // SendMessageFun.AsyncSendMessage(sendmsg); + // // 去存一份记录到数据库 + // DataRow errObj = (DataRow)Base_ObjList[tagid]; + // MisDataFun.Alarm_Insert2(Convert.ToInt32(errObj["TagID"]), errObj["工位号"].ToString(), errObj["测量项目"].ToString(), Convert.ToInt32(tagVvalue), errObj["测量位置"].ToString()); + // } + //} + public static DataRow Send_AlarmMsg(string tagid, string tagVvalue) + { + var val = Base_TagIdList[tagid]; + DataRow errObj = null; + if (val != null) + { + //var msg = Base_TagIdList[tagid].ToString(); + //var sendmsg = msg.Replace("@TagValue", tagVvalue); + //SendMessageFun.AsyncSendMessage(sendmsg); + + var msg = Base_TagIdList[tagid].ToString(); + var sendmsg = msg.Replace("@TagValue", tagVvalue); + SendMessageFun.AsyncSendMessage(sendmsg); + // 去存一份记录到数据库 + errObj = (DataRow)Base_ObjList[tagid]; + + MisDataFun.Alarm_Insert2(Convert.ToInt32(errObj["TagID"]), errObj["工位号"].ToString(), errObj["测量项目"].ToString(), Convert.ToInt32(tagVvalue), errObj["测量位置"].ToString()); + } + return errObj; + } + + + + static public void GetTagIdList(string opName, out DataTable dt) + { + string procedureName; + procedureName = "MES_基本变量_原始数据_根据工位号查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + + + + + + #endregion + + public static void Alarm_Insert_Init(string Opname) + { + DataTable dt; + MisDataFun.Alarm_Moby_Search(out dt); + if (dt == null) return; + for (int i = 0; i < dt.Rows.Count; i++) + { + string TagId = dt.Rows[i]["TagId"].ToString(); + object tagValueStr = ""; + string tagValue = "0"; + MIS_BASE.Read_TagValueByTagID(TagId, out tagValueStr); + if (tagValueStr != null) + { + switch (tagValueStr.ToString().ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + Send_AlarmMsg(TagId, tagValue); + } + } + } + + public static void Alarm_InitAlarm_Send(string opName, out Hashtable ht) + { + var tagValues = MIS_BASE.ReadPLC_OpName(opName); + //过滤出来质量数据 //获得带合格标志的质量数据 + var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + ht = new Hashtable(); + + foreach (KeyValuePair _cd in keyValues) + { + var tf = _cd.Value; + string TagID = tf.TagID.ToString(); + if (TagID[0].ToString() == "9") + { + string tagValue = tf.TagValue.ToString(); + if (tf.TagValue == null) return; + switch (tagValue.ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + if (tagValue == "1") + { + ht.Add(tf.TagID, tagValue); + } + } + } + } + public static bool Alarm_Insert(string TagID, string tagTypeID, string opName, int TagValue, + DateTime alarmStartTime, DateTime alarmEndTime, int TimeDiff, + string Text1, string Text2, string TagOrderBy) + { + + + string produceName = "测量数据工位报警全部_增加数据"; + SqlParameter[] thisParms = new SqlParameter[10]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@TagID", TagID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagTypeID", tagTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@opName", opName); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", TagValue); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@alarmStartTime", alarmStartTime); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@alarmEndTime", alarmEndTime); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@TimeDiff", TimeDiff); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Text1", Text1); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@Text2", Text2); + thisParms[9] = new System.Data.SqlClient.SqlParameter("@TagOrderBy", TagOrderBy); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + + return true; + } + return false; + } + + /// + /// 报错详细工件记录日志 (有可能报错 所以封装) + /// + /// 1.申请上线 2.传递机型 3.允许保存 4.扫码 + /// + public static void Alarm_SaveFileLog4Error(string errorStep, object e, string FunName, Exception err) + { + try + { + MyLog4Net.MyLogHelper.Error($"{FunName}异常:", $"Message:{err.Message} InnerException: {err.InnerException}"); + string leftErrorStep; + if (errorStep == "PartLoad") + { + leftErrorStep = "申请上线"; + } + else if (errorStep == "EngineGetOver") + { + leftErrorStep = "传递机型"; + } + else if (errorStep == "MesRead") + { + leftErrorStep = "允许保存"; + } + else if (errorStep == "Barcode") + { + leftErrorStep = "扫码"; + } + else + { + leftErrorStep = $"未知类型{errorStep}"; + } + + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + MIS_BASE.GetEngineTypeFromPLC(OpName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code, out string OrderForm); + MyLog4Net.MyLogHelper.Error($"{FunName}{leftErrorStep}操作异常:", $"工位号:{OpName}、总成号:{EngineID}、机型:{EngineType}、机型代码:{EngineTypeID}、订单号:{OrderForm}、托盘号:{PartPallet_Code}"); + + string saveString = $"{FunName}{leftErrorStep}操作异常 Message:{err.Message} InnerException: {err.InnerException}:工位号:{OpName}、总成号:{EngineID}、机型:{EngineType}、机型代码:{EngineTypeID}、订单号:{OrderForm}、托盘号:{PartPallet_Code}"; + var sql = + $"INSERT INTO 合力_系统日志 ([工位号],[日志类型],[日志文本])"+ + $" VALUES('{OpName}', 'system', '{saveString}')"; + DataAccess.ExecuteDataTable(sql, out DataTable dt); + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error($"{FunName}保存错误日志失败:", $"Message:{ex}"); + } + } + + public static void Alarm_SystemError(string FunName, Exception err) + { + MyLog4Net.MyLogHelper.Error($"系统{FunName}方法异常:", $"Message:{err.Message} InnerException:{err.InnerException}"); + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.MesRead.cs b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.MesRead.cs new file mode 100644 index 0000000..3866226 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.MesRead.cs @@ -0,0 +1,635 @@ +using BasicData; +using MesServerFunctions; +using MesServerWork; +using MisDataFunDll; +using Newtonsoft.Json; +using OpcBasic; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using DataLinkMesWork1; + +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskBand; + +namespace MisDataSaveDateMesRead +{ + public partial class Funtion + { + + + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + public static int MesRead(string opName, string tagValue, string tagid, bool isCheck = false) + { + int qualityMask = 0; + + qualityMask = SaveQualityData(opName, Convert.ToInt32(tagValue), tagid, isCheck); + + + //if (tagValue == "0") + //{ + // MIS_BASE.Write_TagTypeID(20, opName, false); + //} + //else + //{ + // qualityMask = SaveQualityData(opName, Convert.ToInt32(tagValue), tagid, isCheck); + // MIS_BASE.Write_TagTypeID(20, opName, true); + //} + return qualityMask; + } + public static string GetRealTimeQualityData(string opName) + { + string message = ""; + DataTable dt1 = new DataTable(); + DataTable dt_WWW; + DataTable dt_WWW_Copy1; + DataTable dt_WWW_Copy2; + Hashtable valueList; + try + { + //读取工位全部数据 + var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + var pp = JsonConvert.SerializeObject(rtList); + var tagValues = JsonConvert.DeserializeObject>(pp); + //过滤出来质量数据 //获得带合格标志的质量数据 + valueList = ReadPLC_OpName_Qd(tagValues); + + //获得带基本信息的质量数据表 + GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue, MIS_BASE.BasicDataTagValueUpDown, out dt_WWW); + + dt_WWW_Copy1 = dt_WWW.Copy().Select("变量排序 = 1").CopyToDataTable(); + DataView dv1 = dt_WWW_Copy1.DefaultView; + dv1.Sort = "列位置 DESC"; + dt_WWW_Copy1 = dv1.ToTable(); + + dt_WWW_Copy2 = dt_WWW.Copy().Select("变量排序 = 2").CopyToDataTable(); + DataView dv2 = dt_WWW_Copy2.DefaultView; + dv2.Sort = "列位置 DESC"; + dt_WWW_Copy2 = dv2.ToTable(); + + dt1.Columns.Add("列位置", System.Type.GetType("System.String")); + dt1.Columns.Add("测量项目1", System.Type.GetType("System.String")); + dt1.Columns.Add("测量项目2", System.Type.GetType("System.String")); + dt1.Columns.Add("合格标志", System.Type.GetType("System.String")); + dt1.Columns.Add("名称", System.Type.GetType("System.String")); + + for (int i = 0; i < dt_WWW_Copy1.Rows.Count; i++) + { + if (Convert.ToInt32(dt_WWW_Copy1.Rows[i]["TagValue"]) > 45) + { + var dr = dt1.NewRow(); + dr["列位置"] = dt_WWW_Copy1.Rows[i]["列位置"].ToString(); + dr["测量项目1"] = dt_WWW_Copy1.Rows[i]["TagValue"].ToString(); + dr["合格标志"] = "1"; + dr["名称"] = dt_WWW_Copy1.Rows[i]["测量项目"].ToString(); + dt1.Rows.Add(dr); + } + } + for (int i = 0; i < dt_WWW_Copy2.Rows.Count; i++) + { + if (Convert.ToInt32(dt_WWW_Copy2.Rows[i]["TagValue"]) > 45) + { + var dr = dt1.NewRow(); + dr["列位置"] = dt_WWW_Copy2.Rows[i]["列位置"].ToString(); + dr["测量项目1"] = dt_WWW_Copy2.Rows[i]["TagValue"].ToString(); + dr["合格标志"] = "1"; + dr["名称"] = dt_WWW_Copy2.Rows[i]["测量项目"].ToString(); + dt1.Rows.Add(dr); + } + } + } + catch (Exception err) + { + } + message = JsonHelper.CreateJsonParameters(dt1); + + return message; + } + /// + /// 返回合格标志 + /// + /// + /// + /// + /// + private static int SaveQualityData(string opName, int tagValue, string tagID, bool isCheck = false) + + { + int id_tagCF; + int qualityMask = 0; + int engineTypeID = 0; + string engineID = ""; + string engineType = ""; + string partPallet = ""; + string orderFormPlc = ""; + DataTable dt_WWW; + Hashtable valueList; + try + { + + //读取工位全部数据 + var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + var pp = JsonConvert.SerializeObject(rtList); + var tagValues = JsonConvert.DeserializeObject>(pp); + //过滤出来质量数据 //获得带合格标志的质量数据 + valueList = ReadPLC_OpName_Qd(tagValues); + + + engineTypeID = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineTypeID))); + engineID = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineID)).ToString(); + engineType = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineType)).ToString(); + orderFormPlc = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.OrderFormPLC)).ToString(); + qualityMask = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.QualityMask))); + + + + //获得带基本信息的质量数据表 + GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue, + MIS_BASE.BasicDataTagValueUpDown, out dt_WWW); + + DateTime lastupdatetime = DateTime.Now; + //保存质量数 + BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF); + BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW, isCheck); + //保存质量数据到 接口表 + MisDataFun.SaveQualityInterfaceData(opName, engineID); + } + catch (Exception err) + { + //MIS_BASE.Write_TagTypeID(20, opName, true); + ////ApplicationLog.WriteLog(err, err.Message); + } + return qualityMask; + } + + public class QualityDataType1 + { + public int tagValueType; + public int tagTypeID; + public string opName; + public string tagID; + public object TagValeNormal; + public object TagValueDown; + public object TagValueUp; + public object Unit; + public object tagValue; + public int tagQuality; + public int tagOrderBy; + public int tagItemOrderBy; + public int tagProperty; + public int isGoodBad; + } + static public void GetQualityDataTable(Hashtable valuList, string opName, DataTable BasicDataTagValue, DataTable BasicDataTagValueUpDown, out DataTable dt) + { + //78 0:屏蔽MES;1:启用MES(必须MIS) + //79 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线;0正常状态,实现正常功能。1离线:2屏蔽。(必须MIS) + //41 机体流向标志(1 BYTE):0普通工位:1:上线(发动机上线);2:下线(发动机下线);(必须PLC) + //51 返修工位,修改后的数据MES将数据写入PLC ,MES通知PLC数据修改完成。(YN) + //8 只要返修,必须由mes发送此信号,plc接收此信号后才能放行 + //(暂时没用)用于有扳手拧紧工位。通知设备螺钉拧紧完成。PC已经将数据保存到数据库中。(B5A) + + QualityDataType1 qualityData; + //是否有数据 + //bool isUsing; + + DataRow dr; + DataRow[] dr_WWW; + //MES_基本数据_测量范围 + DataRow[] dr_WWW_UpDown; + + dt = MisDataFun.BuildDataTables_WWW(); + + //测量位置 + string shaftID; + //测量项目 + string item; + //测量单位 + string unit; + //机体类型 + //原始数据中的机型代码 + int engineTypeID_Source; + //上限值 + string tagValueUp; + //下限值 + string tagValueDown; + //理论值 + string tagValeNormal; + //TagValue + // 合格标志 + //string IsGoodBad; + + foreach (DictionaryEntry valueItem in valuList) //ht为一个Hashtable实例 + { + try + { + qualityData = (QualityDataType1)valueItem.Value; + + + //if ((qualityData.tagProperty != 2) || (qualityData.tagProperty != 6)) + //{ + // continue ; + //} + //if ((qualityData.tagProperty == 2) || (qualityData.tagProperty == 6)) + { + //if (engineTypeID == 0) + //{ + // engineTypeID = 1; + //} + dr_WWW = BasicDataTagValue.Select("TagID = " + qualityData.tagID); + //try + //{ + // dr_WWW_UpDown = BasicDataTagValueUpDown.Select("TagID = " + qualityData.tagID); + //} + //catch { dr_WWW_UpDown = null; } + + + //if (dr_WWW.Length > 0) + //{ + // { + // engineTypeID_Source = Convert.ToInt32(dr_WWW[0]["机体类型"]); + // int temp; + // temp = engineTypeID_Source & engineTypeID; + // if (temp == 0) + // { + // continue; + // } + // if (qualityData.isGoodBad == -1) + // { + // continue; + // } + // } + //} + //else + //{ + // continue; + + //} + + try + { + shaftID = dr_WWW[0]["测量位置"].ToString(); + } + catch + { + shaftID = ""; + } + try + { + item = dr_WWW[0]["测量项目"].ToString(); + } + catch + { + item = ""; + } + try + { + unit = dr_WWW[0]["测量单位"].ToString(); + } + catch + { + unit = ""; + } + try + { + tagValueUp = qualityData.TagValueUp.ToString(); + //if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0) + //{ + // tagValueUp = dr_WWW_UpDown[0]["值上限"].ToString(); + //} + //else + //{ + // tagValueUp = ""; + //} + } + catch + { + tagValueUp = ""; + } + try + { + tagValueDown = ""; + tagValueDown = qualityData.TagValueDown.ToString(); + //if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0) + //{ + // tagValueDown = dr_WWW_UpDown[0]["值下限"].ToString(); + //} + } + catch + { + tagValueDown = ""; + } + try + { + tagValeNormal = ""; + tagValeNormal = qualityData.TagValeNormal.ToString(); + //if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0) + //{ + // tagValeNormal = dr_WWW_UpDown[0]["理论值"].ToString(); + //} + + } + catch + { + tagValeNormal = ""; + } + + dr = dt.NewRow(); + + dr["TagID"] = qualityData.tagID; + dr["测量位置"] = shaftID; + dr["测量项目"] = item; + dr["测量单位"] = unit; + dr["上限值"] = tagValueUp; + dr["下限值"] = tagValueDown; + dr["理论值"] = tagValeNormal; + dr["工位号"] = opName; + dr["列位置"] = qualityData.tagOrderBy; + dr["变量排序"] = qualityData.tagItemOrderBy; + + dr["IsGoodBad"] = qualityData.isGoodBad; + + switch (qualityData.tagTypeID)// + { + //合格标志数组 + case 8203: + dr["TagValue"] = MisDataFun.GetQualityData_GoodBad_String((bool[])qualityData.tagValue); + break; + case 8209: + dr["TagValue"] = ""; + break; + //非标准REAL + case 8210: + dr["TagValue"] = MisDataFun.GetNoNormalReal(qualityData.tagValue); + dt.Rows.Add(dr); + break; + default: + dr["TagValue"] = Convert.ToString(qualityData.tagValue); + dt.Rows.Add(dr); + break; + } + + ////福田对质量数据特殊处理,MA20保留4位小数点,其余保留两位 + //if (opName == "J07MA020") + //{ + // dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.####"); + //} + //else + //{ + // dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.##"); + //} + + //if (opName == "J07MA150") + //{ + // dr["变量排序"] = 1; + // dr["IsGoodBad"] = 1; + //} + + + } + + + + } + catch (Exception err) + { + //ApplicationLog.WriteLog(err, err.Message); + } + } + } + /// + /// 数据表 + /// + /// + private static object GetValueByTagTypeCodeID(ConcurrentDictionary opTagList, int TagTypeCodeID) + { + try + { + return opTagList.Where(x => x.Value.TagTypeCodeID == TagTypeCodeID).ToList()[0].Value.TagValue; + + } + catch (Exception err) { return "-3"; } + } + /// + /// 根据工位名称,读取工位对应的质量数据,带合格标志 + /// + /// + /// + public static Hashtable ReadPLC_OpName_Qd(ConcurrentDictionary tagValues) + { + //lock (l) + { + + //var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + + var keyValues = tagValues.Where(x => x.Value.TagTypeCodeID == 105).OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + + TagFormat tagFormatTemp; + int tagIndex = 1; + int isOK = 0; + string TagValeNormal = ""; + string TagValueDown = ""; + string TagValueUp = ""; + + Hashtable ht = new Hashtable(); + + for (int i = 0; i < keyValues.Count / 8; i++) + { + isOK = Convert.ToInt32(keyValues.ElementAt(i * 8 + 0).Value.TagValue); + TagValeNormal = keyValues.ElementAt(i * 8 + 3).Value.TagValue.ToString(); + TagValueUp = keyValues.ElementAt(i * 8 + 4).Value.TagValue.ToString(); + TagValueDown = keyValues.ElementAt(i * 8 + 5).Value.TagValue.ToString(); + + var TF1 = keyValues.ElementAt(i * 8 + 1).Value; + QualityDataType1 qualityDataType1; + qualityDataType1 = GetQualityDataType(TF1); + qualityDataType1.isGoodBad = isOK; + qualityDataType1.TagValeNormal = TagValeNormal; + qualityDataType1.TagValueDown = TagValueDown; + qualityDataType1.TagValueUp = TagValueUp; + ht.Add(qualityDataType1.tagID, qualityDataType1); + var TF2 = keyValues.ElementAt(i * 8 + 2).Value; + QualityDataType1 qualityDataType2; + qualityDataType2 = GetQualityDataType(TF2); + qualityDataType2.isGoodBad = isOK; + qualityDataType2.TagValeNormal = TagValeNormal; + qualityDataType2.TagValueDown = TagValueDown; + qualityDataType2.TagValueUp = TagValueUp; + ht.Add(qualityDataType2.tagID, qualityDataType2); + } + + + + //foreach (KeyValuePair _cd in keyValues) + //{ + // if (_cd.Key.ToString()[0].ToString() == "7") + // { + // tagFormatTemp = _cd.Value; + // if (tagIndex % 8 == 1) + // { + // isOK = Convert.ToInt32(tagFormatTemp.TagValue); + // } + // else if (tagIndex % 8 == 2) + // { + // var TF = _cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + // else if (tagIndex % 8 == 3) + // { + // var TF = (TagFormat)_cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + + // tagIndex++; + // } + // //Console.WriteLine($"key:{kv.Key} value:{kv.Value}"); + //} + return ht; + } + } + + //public static Hashtable ReadPLC_OpName_Entite(string opName) + //{ + // //lock (l) + // { + + // var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + + // var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + + // TagFormat tagFormatTemp; + // int tagIndex = 1; + // int isOK = 0; + + // Hashtable ht = new Hashtable(); + + + // foreach (KeyValuePair _cd in keyValues) + // { + // if (_cd.Key.ToString()[0].ToString() == "7") + // { + // tagFormatTemp = _cd.Value; + // if (tagIndex % 3 == 1) + // { + // isOK = Convert.ToInt32(tagFormatTemp.TagValue); + // } + // else if (tagIndex % 3 == 2) + // { + // var TF = _cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + // else if (tagIndex % 3 == 0) + // { + // var TF = (TagFormat)_cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + + // tagIndex++; + // } + // //Console.WriteLine($"key:{kv.Key} value:{kv.Value}"); + // } + // return ht; + // } + //} + public static QualityDataType1 GetQualityDataType(TagFormat TF) + { + QualityDataType1 qualityDataType; + + qualityDataType = new QualityDataType1(); + + qualityDataType.tagID = TF.TagID; + qualityDataType.tagTypeID = TF.TagTypeID;//变量类型 + qualityDataType.opName = TF.OpName; + qualityDataType.tagValueType = TF.TagTypeCodeID; + int.TryParse(TF.TagOrderBy, out int TagOrderBy); + qualityDataType.tagOrderBy = TagOrderBy; + int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy); + qualityDataType.tagItemOrderBy = TagItemOrderBy; + qualityDataType.tagValue = TF.TagValue;//变量值 + + return qualityDataType; + } + + public static bool BaseData_tagTable_QualityData_B5A_IndexInsert(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF) + { + string procedureName; + procedureName = "测量数据合格索引_增加"; + Id_tagCF = 0; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[7].Direction = ParameterDirection.Output; + + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString()); + return true; + } + return false; + } + public static bool BaseData_tagTable_QualityData_B5A_Insert(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false) + { + string procedureName; + procedureName = "测量数据合格_增加"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID"); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue"); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad"); + //是否保存无合格标志数据数据 + //thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置"); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目"); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置 + thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值"); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值"); + thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值"); + thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位"); + thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置"); + thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序"); + //table.Columns.Add("TagID", typeof(System.Int32)); + //table.Columns.Add("TagValue", typeof(System.String)); + //table.Columns.Add("IsGoodBad", typeof(System.Int32)); + //table.Columns.Add("测量位置", typeof(System.String)); + //table.Columns.Add("测量项目", typeof(System.String)); + //table.Columns.Add("工位号", typeof(System.String)); + //table.Columns.Add("理论值", typeof(System.String)); + //table.Columns.Add("上限值", typeof(System.String)); + //table.Columns.Add("下限值", typeof(System.String)); + //table.Columns.Add("测量单位", typeof(System.String)); + //table.Columns.Add("列位置", typeof(System.Int32)); + //table.Columns.Add("变量排序", typeof(System.Int32)); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt); + } + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/GetQualityData_GoodBad.cs b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/GetQualityData_GoodBad.cs new file mode 100644 index 0000000..45c05f8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/GetQualityData_GoodBad.cs @@ -0,0 +1,99 @@ +using System; + +using System.Data; + + + +namespace MisDataSaveDateMesRead +{ + + public partial class Funtion + { + /// + /// 数据表 + /// + /// + static public DataTable BuildDataTables_WWW() + { + DataTable table; + DataColumnCollection columns; + table = new DataTable(); + columns = table.Columns; + table.Columns.Add("TagID", typeof(System.String)); + table.Columns.Add("TagValue", typeof(System.String)); + table.Columns.Add("IsGoodBad", typeof(System.Int32)); + table.Columns.Add("测量位置", typeof(System.String)); + table.Columns.Add("测量项目", typeof(System.String)); + table.Columns.Add("工位号", typeof(System.String)); + table.Columns.Add("理论值", typeof(System.String)); + table.Columns.Add("上限值", typeof(System.String)); + table.Columns.Add("下限值", typeof(System.String)); + table.Columns.Add("测量单位", typeof(System.String)); + table.Columns.Add("列位置", typeof(System.Int32)); + table.Columns.Add("变量排序", typeof(System.Int32)); + + return table; + } + /// + /// 返回非标准real + /// + /// + /// + static public string GetNoNormalReal(object vDataValue) + { + try + { + string real_a; + string real_b; + string groupValueString; + int length; + + //int real_b_Int; + + length = ((System.Array)(vDataValue)).Length; + groupValueString = ""; + if (length != 2) + return "0.0"; + + real_a = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(0))).ToString(); + real_b = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(1))).ToString("00"); + groupValueString = real_a + "." + real_b; + return groupValueString; + } + catch + { + ////ApplicationLog.WriteLog(err, "GetNoNormalReal"); + return "0.0"; + + } + } + + /// + /// 29 工位具体零件合格标志 + /// + /// + static public string GetQualityData_GoodBad_String(bool[] QualityData_GoodBad) + { + string str; + str = ""; + if (QualityData_GoodBad != null) + { + + for (int i = 0; i < QualityData_GoodBad.Length; i++) + { + str = str + (Convert.ToInt32(QualityData_GoodBad[i])).ToString() + "|"; + } + + } + return str; + + } + /// + /// 返回非标准real + /// + /// + /// + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/CommFun_CATL.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/CommFun_CATL.cs new file mode 100644 index 0000000..84a1056 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/CommFun_CATL.cs @@ -0,0 +1,18 @@ + +using System.Threading; + +namespace MisDataFunDll +{ + public partial class CommFun_CATL + { + + // 由于现在没有接口,先模拟调用webapi,输入参数1.电芯码,返回参数1.对比结果 + public static int GetCellInfo(string cellCode) + { + int result = 1; + Thread.Sleep(200); + return result; + + } + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.Base.DB.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.Base.DB.cs new file mode 100644 index 0000000..77f7171 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.Base.DB.cs @@ -0,0 +1,299 @@ + +using DataLinkMesWork1; +using System.Data; +using System.Data.SqlClient; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + public static DataTable BaseData_tagTable_TagName() + { + DataTable dt = null; + string sql; + sql = "SELECT distinct[TagName],[变量类型代码] FROM[MES_基本变量_原始数据] "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable GetMesServerCodeFromMIS() + { + DataTable dt; + string sql; + sql = "exec MES_计划BOM_工位与名称_查询应用程序"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable dt_Signal() + { + DataTable dt; + string sql; + sql = "SELECT * FROM [MES_基本变量_原始数据]"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable dt_Device() + { + DataTable dt; + string sql; + sql = "SELECT * FROM [MES_基本变量设备类型对应表]"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable dt_TagTypeDataType() + { + DataTable dt; + string sql; + sql = "SELECT TOP (1000) [序号],[变量类型],[TagTypeDataType],[TagName],[变量类型代码],[TagTypeChange],[MesTagTypeChange],[WebTagTypeChange],[信号点名称][变量类型名称] FROM [MES_基本变量变量类型代码]"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + public static DataTable GetCheckOpName() + { + DataTable dt = new DataTable(); + string produceName = "MES_计划BOM_工位与名称_查询"; + SqlParameter[] thisParms = null; + + + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + + return dt; + } + + /// + /// 查询工步属性 + /// + /// + public static DataTable GetworkStepPropertyFromMIS() + { + DataTable dt; + string sql; + sql = "SELECT distinct 工位号,工步属性 FROM [MES_计划BOM_工位与名称] where 是否监控=1"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 查询返修工位号 + /// + /// + public static DataTable GetOpNameRepairFromMIS() + { + DataTable dt; + string sql; + sql = "SELECT distinct 工位号,返修工位号 FROM [MES_计划BOM_工位与名称] where 是否监控=1"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + + + /// + /// 测量工位号和工位名称 + /// + /// + public static DataTable BaseData_tagTable_QualityData_OpName_Name() + { + DataTable dt; + string sql = "SELECT distinct [工位号],[工位名称] FROM [MES_计划BOM_工位与名称] " + + " where (监控属性代码 = '" + 1 + "')" + + " ORDER BY 工位号 "; + //来源于SQL Server + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_计划BOM_工位与名称 + /// + /// + public static DataTable BaseData_tagTable_OpName() + { + //DataTable dt; + //string sql = "SELECT * FROM [MES_计划BOM_工位与名称] " + // + " where (监控属性代码 = '" + ApplicationConfig.MES_Code.ToString() + "')" + // + " ORDER BY 工位号 "; + //DataAccess.ExecuteDataTable(sql, out dt); + //return dt; + + //2022.07.27.LLX 处理了一下子 + DataTable dt; + string sql = "SELECT * FROM [MES_计划BOM_工位与名称] " + + " where (监控属性代码 = '" + 1 + "') and [是否通过监控系统保存数据] is not null" + + " ORDER BY 工位号 "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_DB数据结构_根据工位代码_获得普通变量 + /// + /// + public static DataTable BaseData_tagTable_OpcServerMES(int mesCode, string opName) + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 " + + " FROM MES_基本变量_原始数据 " + + " where 变量类型代码 = " + mesCode.ToString() + " and 是否启用 = 1" + + " and 工位号='" + opName + "'" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_DB数据结构_根据工位代码_获得普通变量 + /// + /// + public static DataTable BaseData_tagTable_OpcServerMES(int mesCode) + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 " + + " FROM MES_基本变量_原始数据 " + + " where 变量类型代码 = " + mesCode.ToString() + " and 是否启用 = 1" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// MES_基本变量_DB数据结构_获得激发变量 + /// + /// + public static DataTable BaseData_tagTable_All() + { + //string errorMessage; + DataTable dt = null; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 FROM [MES_基本变量_原始数据] " + + " where ((变量类型代码 >= 19 and 变量类型代码 <= 27) or (变量类型代码 = 101) or (变量类型代码 = 102) or (变量类型代码 = 105) or (变量类型代码 = 1000) or (变量类型代码 = 1001) or (变量类型代码 = 1002) or (变量类型代码 = 1003) or (变量类型代码 = 1004)) and (是否启用 = 1) " + + " and (监控属性代码 = '" + 1 + "')" + + " ORDER BY TagID "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_DB数据结构_获得激发变量 + /// + /// + public static DataTable BaseData_tagTable_All_B5A() + { + //string errorMessage; + DataTable dt = null; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 FROM [MES_基本变量_原始数据] " + + " where ((变量类型代码 = 101) or (变量类型代码 = 102) ) and (是否启用 = 1) " + + " and (监控属性代码 = '" + 1 + "')" + + " ORDER BY TagID "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 20170310 新加 + /// MES_基本变量_DB数据结构_获得所有普通变量(除101.102.103.104.105) + /// + /// + public static DataTable BaseData_tagTable_OpcServerMES_ALL_CF() + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 " + + " FROM MES_基本变量_原始数据 " + + " where 变量类型代码 <> 101 and 变量类型代码 <> 102 and 变量类型代码 <> 103 and 变量类型代码 <> 104 and 变量类型代码 <> 105 and 是否启用 = 1" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 发动机类型转换表 + /// SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码 + /// + /// + public static DataTable BaseData_tagTable_QualityData_EngineTypeID() + { + DataTable dt; + string sql; + sql = "SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码 "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位 + /// + /// + public static DataTable BaseData_tagTable_QualityData_GoodBad_MIS_OpName_B5A() + { + DataTable dt; + string sql; + sql = "SELECT distinct 工位号 " + + " FROM MES_基本变量_原始数据 " + + " where 变量特点 = 8 and 是否启用 = 1 " + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位的数据来源 + /// + /// + public static DataTable BaseData_tagTable_QualityData_GoodBad_MIS_OpName(string opName) + { + DataTable dt; + string sql; + sql = "SELECT TagID,工位号,数据来源 " + + " FROM MES_基本变量_原始数据 " + + " where OpcServer_OPNAME = '1' and 是否启用 = 1 " + + " and 工位号='" + opName + "'" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位的数据来源的测量变量 + /// + /// + public static DataTable BaseData_tagTable_QualityData_GoodBad_MIS_OpName(string opName, string opNameFrom) + { + DataTable dt; + string sql; + sql = "SELECT TagID " + + " FROM MES_基本变量_原始数据 " + + " where OpcServer_OPNAME = '2' and 是否启用 = 1 " + + " and 工位号='" + opName + "'" + + " and 数据来源='" + opNameFrom + "'" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_机型代码_查询 + /// + /// + static public void EngineType_Select(out DataTable dt) + { + dt = null; + string sql = "exec MES_基本变量_机型代码_查询"; + DataAccess.ExecuteDataTable(sql, out dt); + } + + + + + + + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.CommonUtils.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.CommonUtils.cs new file mode 100644 index 0000000..8150218 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.CommonUtils.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + /// + /// Source|Cmd|OpName|TagValue + /// + /// + /// + public static List GetCmdStringList(string cmd) + { + List list = new List(); + string item; + int index; + try + { + index = cmd.IndexOf('|'); + item = cmd.Substring(0, index); + list.Add(item); + + cmd = cmd.Substring(index + 1); + index = cmd.IndexOf('|'); + item = cmd.Substring(0, index); + list.Add(item); + + cmd = cmd.Substring(index + 1); + index = cmd.IndexOf('|'); + item = cmd.Substring(0, index); + list.Add(item); + + item = cmd.Substring(index + 1); + + list.Add(item); + + } + catch { } + + + return list; + } + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.DB.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.DB.cs new file mode 100644 index 0000000..a57f39a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.DB.cs @@ -0,0 +1,1835 @@ + +using DataLinkMesWork1; +using MesServerFunctions; +using Newtonsoft.Json; +using Opc.Ua.Export; +using System; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics.Eventing.Reader; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + + public class MobyTagType + { + /// + /// 配方号 + /// + public static string PLCRcipe = "配方号"; + /// + /// 工位号 + /// + public static string OpName = "工位号"; + /// + /// 订单号 + /// + public static string OrderForm = "订单号"; + /// + /// 订单号 + /// + public static string OrderForm_MES = "订单号_MES"; + /// + /// 产品型号代码 + /// + public static string EngineTypeID = "产品型号代码"; + /// + /// 变速器序列号 + /// 变速器序列号 + public static string EngineID = "变速器序列号"; + + /// + /// 发动机型号 + /// + public static string EngineType = "发动机型号"; + /// + /// 机型基本代码 + /// + public static string EngineTypeBasicID = "机型基本代码"; + /// + /// 机型基本代码 + /// + public static string EngineTypeBasic = "基本机型"; + /// + /// 变速器总成号 + /// + public static string EngineIDPrinte = "变速器总成号"; + /// + /// 托盘号 + /// + public static string PartPallet_Code = "托盘号"; + /// + /// 产品型号代码_MES + /// + public static string EngineTypeID_MES = "产品型号代码_MES"; + /// + /// 变速器序列号_MES + /// + public static string EngineID_MES = "变速器序列号_MES"; + /// + /// 发动机型号_MES + /// + public static string EngineType_MES = "发动机型号_MES"; + /// + /// 到达时间线外工位 + /// + public static string WorkStartOutSideIn = "到达时间线外工位"; + /// + /// 离开时间线外工位 + /// + public static string WorkStartOutSideOut = "离开时间线外工位"; + /// + /// 到达时间 + /// + public static string WorkStartIn = "到达时间"; + /// + /// 离开时间 + /// + public static string WorkStartOut = "离开时间"; + /// + /// 持续时间 + /// + public static string WorkStartTime = "持续时间"; + /// + /// 扫描条码 + /// + public static string BarCode = "扫描条码"; + /// + /// 工件到位 2 + /// + public static string WorkStart = "工件到位"; + /// + /// 传递机型 44 + /// + public static string EngineTypeGetOverPLC = "传递机型"; + /// + /// 申请上件 43 + /// + public static string PartLoad = "申请上件"; + /// + /// 允许保存 19 + /// + public static string MesRead = "允许保存"; + /// + /// 保存完成 20 + /// + public static string MesReadOver = "保存完成"; + /// + /// 允许工作 20 + /// + public static string FixAllow = "允许工作"; + + + + + /// [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + /// [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + /// [工号],[班次],[是否返修件],[合格放行],[不合格放行] + /// [到达时间],[离开时间],[持续时间] + // engineTypeID = Convert.ToInt32(thisParms[2].Value); + //engineType = thisParms[3].Value.ToString(); + //engineID = thisParms[4].Value.ToString(); + //palletCode = thisParms[5].Value.ToString(); + } + + /// + /// 测量数据工位_监控系统_MOBY_线首_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OpName_MIS_MOBY_Insert_FirstOpName(string opName, int engineTypeID, int engineTypeID_MES, string engineType, string engineType_MES, string engineID, string engineID_MES, int palletCode, string orderForm, string orderForm_MES) + { + string produceName = "测量数据工位_监控系统_MOBY_线首_增加"; + SqlParameter[] thisParms = new SqlParameter[10]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码_MES", engineTypeID_MES); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机型号_MES", engineType_MES); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@发动机号_MES", engineID_MES); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@订单号_MES", orderForm_MES); + thisParms[9] = new System.Data.SqlClient.SqlParameter("@托盘号", palletCode); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 测量数据工位_监控系统_MOBY_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OpName_MIS_MOBY_Insert(string opName, string tagType, string tagValue) + { + string produceName = "北汽福田工位状态监控MOBY_增加"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@变量类型", tagType); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@变量值", tagValue); + + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 生产计划_派工订单_工件追溯_校验 + /// + /// + /// + /// + public static DataTable WorkOrderCheck(string opName, string EngineID, string OrderFrom, string EngineType) + { + string produceName = "生产计划_派工订单_工件追溯_校验"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@机型", EngineType); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out DataTable dt); + return dt; + } + + /// + /// 接口_IOT接口_报工记录_是否报工判断 + /// + /// + /// + /// + public static DataTable IOT_ReqData_UpLoad_IsSend(string opName, string OrderFrom, string reqType) + { + string produceName = "接口_IOT接口_报工记录_是否报工判断"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@报工类型", reqType); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out DataTable dt); + return dt; + } + + /// + /// 测量数据工位_监控系统_MOBY_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OpName_MIS_MOBY_Insert_JZ(string opName, string engineID) + { + string produceName = "测量数据工位_监控系统_MOBY_静置工位_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + public static void BarCodeIsSecondVerification(string opName, out bool isSecondVerification) + { + isSecondVerification = false; + DataTable dt = new DataTable(); + string produceName = "测量数据工位_监控系统_是否二次验证_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + if (dt.Rows.Count > 0) + { + string isVerification = dt.Rows[0]["是否验证"].ToString(); + if (isVerification == "1") + { + isSecondVerification = true; + } + } + } + /// + /// 日志_工位操作_增加 + /// + /// + /// + /// + /// + /// + public static bool LogRecording_OP(string OpName, string type, string msgType, string content) + { + string produceName = "日志_工位操作_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@消息类型", type); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@操作类型", msgType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@内容", content); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 电子看板_工序内容_临时表_增加 + /// + /// + /// + public static bool MesServer_ProcessList_EngineTypeOver(string opName) + { + string produceName = "电子看板_工序内容_临时表_增加"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 电子看板_装配零件_临时表_增加 + /// + /// + /// + public static bool MesServer_Process_EngineTypeOver(string opName) + { + string produceName = "电子看板_装配零件_临时表_增加"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 测量数据工位_监控系统_MOBY_查询 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void Moby_Select(string opName, out string OrderForm, out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code, out int IsrepairBarcode, out string repairBarcode, out string EngineTypeString) + { + DataTable dt = new DataTable(); + OrderForm = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = "0"; + IsrepairBarcode = 0; + repairBarcode = "0"; + EngineTypeString = ""; + try + { + string procedureName; + procedureName = "测量数据工位_监控系统_MOBY_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + if (dt.Rows.Count > 0) + { + OrderForm = dt.Rows[0]["订单号"].ToString(); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); ; + EngineType = dt.Rows[0]["发动机型号"].ToString(); + EngineID = dt.Rows[0]["发动机号"].ToString(); + PartPallet_Code = dt.Rows[0]["托盘号"].ToString(); + } + } + catch + { + OrderForm = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = "0"; + IsrepairBarcode = 0; + repairBarcode = ""; + EngineTypeString = ""; + } + } + + /// + /// 测量数据工位_监控系统_MOBY_查询 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void Moby_Select(string opName, out string orderNum, + out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code, + out int IsrepairBarcode, out string repairBarcode, + out string workCode, out string projectName, out string splitCode, out string unidCode, out string engineType, out string engineTypeModel, out string startTime) + { + orderNum = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = ""; + IsrepairBarcode = 0; + repairBarcode = ""; + workCode = ""; // 制造编号 + projectName = ""; // 项目名称 + splitCode = ""; // 间隔号 + unidCode = ""; // 单元号 + engineType = ""; // 本体类型 + engineTypeModel = ""; // 附件类型 + startTime = ""; // 开始时间 + + try + { + string procedureName; + procedureName = "测量数据工位_监控系统_MOBY_查询"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", SqlDbType.NVarChar, 50, "订单号"); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码", SqlDbType.Int, 4, "产品型号代码"); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机型号", SqlDbType.NVarChar, 50, "发动机型号"); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机号", SqlDbType.NVarChar, 50, "发动机号"); + thisParms[4].Direction = ParameterDirection.Output; + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘号", SqlDbType.NVarChar, 50, "托盘号"); + thisParms[5].Direction = ParameterDirection.Output; + thisParms[6] = new System.Data.SqlClient.SqlParameter("@拆解标志", SqlDbType.Int, 4, "拆解标志"); + thisParms[6].Direction = ParameterDirection.Output; + thisParms[7] = new System.Data.SqlClient.SqlParameter("@拆解返修条码", SqlDbType.NVarChar, 50, "拆解返修条码"); + thisParms[7].Direction = ParameterDirection.Output; + thisParms[8] = new System.Data.SqlClient.SqlParameter("@制造编号", SqlDbType.NVarChar, 50, "制造编号"); + thisParms[8].Direction = ParameterDirection.Output; + thisParms[9] = new System.Data.SqlClient.SqlParameter("@间隔号", SqlDbType.NVarChar, 50, "间隔号"); + thisParms[9].Direction = ParameterDirection.Output; + thisParms[10] = new System.Data.SqlClient.SqlParameter("@单元号", SqlDbType.NVarChar, 50, "单元号"); + thisParms[10].Direction = ParameterDirection.Output; + thisParms[11] = new System.Data.SqlClient.SqlParameter("@项目名称", SqlDbType.NVarChar, 50, "项目名称"); + thisParms[11].Direction = ParameterDirection.Output; + thisParms[12] = new System.Data.SqlClient.SqlParameter("@本体类型", SqlDbType.NVarChar, 50, "本体类型"); + thisParms[12].Direction = ParameterDirection.Output; + thisParms[13] = new System.Data.SqlClient.SqlParameter("@附件类型", SqlDbType.NVarChar, 50, "附件类型"); + thisParms[13].Direction = ParameterDirection.Output; + thisParms[14] = new System.Data.SqlClient.SqlParameter("@开始时间", SqlDbType.NVarChar, 50, "开始时间"); + thisParms[14].Direction = ParameterDirection.Output; + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null && thisParms[4].Value != null && thisParms[5].Value != null && thisParms[6].Value != null && thisParms[7].Value != null) + { + orderNum = thisParms[1].Value.ToString(); + EngineTypeID = Convert.ToInt32(thisParms[2].Value); ; + EngineType = thisParms[3].Value.ToString(); + EngineID = thisParms[4].Value.ToString(); + PartPallet_Code = thisParms[5].Value.ToString(); + IsrepairBarcode = Convert.ToInt32(thisParms[6].Value); + repairBarcode = thisParms[7].Value.ToString(); + workCode = thisParms[8].Value.ToString(); // 制造编号 + projectName = thisParms[9].Value.ToString(); // 项目名称 + splitCode = thisParms[10].Value.ToString();// 间隔号 + unidCode = thisParms[11].Value.ToString(); // 单元号 + engineType = thisParms[12].Value.ToString(); // 本体类型 + engineTypeModel = thisParms[13].Value.ToString(); // 附件类型 + startTime = thisParms[14].Value.ToString(); // 开始时间 + } + } + catch + { + orderNum = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = ""; + IsrepairBarcode = 0; + repairBarcode = ""; + workCode = ""; // 制造编号 + projectName = ""; // 项目名称 + splitCode = ""; // 间隔号 + unidCode = ""; // 单元号 + engineType = ""; // 本体类型 + engineTypeModel = ""; // 附件类型 + } + } + + /// + /// 电子看板_工序内容_查询 + /// + /// 工位号 + /// 产品型号代码 + /// + static public void Process_Select(string opName, int engineTypeID, string EngineType, out DataTable dt) + { + dt = null; + string sql = "exec 电子看板_工序内容_查询 '" + opName + "'," + engineTypeID.ToString() + ",'" + EngineType + "'"; + DataAccess.ExecuteDataTable(sql, out dt); + } + /// + /// 电子看板_装配零件_物料验证_查询 + /// + /// 工位号 + /// 发动机号 + /// + static public bool PartMaterialVerify_Select(string opName, int engineTypeID, string engineType, out DataTable dt) + { + dt = null; + string procedureName; + procedureName = "电子看板_装配零件_临时表_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + /// + /// 电子看板_装配零件_临时表_判断_是否允许工作 + /// + /// + /// + /// + public static bool MesServer_Judge_IsCanWork(string opName, out int IsAllowWork) + { + IsAllowWork = 0; + string produceName = "电子看板_装配零件_临时表_判断_是否允许工作"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否允许工作", IsAllowWork); + thisParms[1].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + IsAllowWork = Convert.ToInt32(thisParms[1].Value); + return true; + } + return false; + } + + /// + /// [电子看板_装配零件_临时表_增加_北汽] + /// + /// + /// + public static bool MesServer_Process_EngineTypeOverBQ(string opName) + { + string produceName = "电子看板_装配零件_临时表_增加_北汽"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 发送页面点位 同时存入数据库状态 + /// + /// + public static void MobySendWebAndSaveData(string OpName, string tagType, string tagValue) + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, tagType, tagValue); + // 判断是否为涉及前端页面的信号,如果是则同步发送点位 + string tagName = ""; + switch (tagType) + { + case "工件到位": + tagName = "WorkStart"; + break; + case "传递机型": + tagName = "EngineTypeGetOverPLC"; + break; + case "申请上件": + tagName = "PartLoad"; + break; + case "允许工作": + tagName = "FixAllow"; + break; + case "允许保存": + tagName = "MesRead"; + break; + case "保存完成": + tagName = "MesReadOver"; + break; + default: + break; + } + if (tagName != "") + { + SendMessageFun.SendInfomation(tagName, Convert.ToString(Convert.ToInt32(tagValue)), OpName); + } + } + + /// + /// 电子看板_装配零件_临时表_修改_零件条码 + /// + /// + /// + /// + /// + public static bool PartMaterial_DM_Update(string opName, string barCode, out bool IsSuccess) + { + IsSuccess = false; + string produceName = "电子看板_装配零件_临时表_修改_零件条码"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@条码", barCode); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@条码是否符合", IsSuccess); + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + IsSuccess = Convert.ToBoolean(thisParms[2].Value); + return true; + } + return false; + } + + /// + /// 测量数据合格索引_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_IndexInsert(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF) + { + string procedureName; + procedureName = "测量数据合格索引_增加"; + Id_tagCF = 0; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[7].Direction = ParameterDirection.Output; + + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString()); + return true; + } + return false; + } + /// + /// 测量数据合格_增加 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_Insert(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false) + { + string procedureName; + procedureName = "测量数据合格_增加"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID"); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue"); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad"); + //是否保存无合格标志数据数据 + //thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置"); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目"); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置 + thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值"); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值"); + thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值"); + thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位"); + thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置"); + thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序"); + //table.Columns.Add("TagID", typeof(System.Int32)); + //table.Columns.Add("TagValue", typeof(System.String)); + //table.Columns.Add("IsGoodBad", typeof(System.Int32)); + //table.Columns.Add("测量位置", typeof(System.String)); + //table.Columns.Add("测量项目", typeof(System.String)); + //table.Columns.Add("工位号", typeof(System.String)); + //table.Columns.Add("理论值", typeof(System.String)); + //table.Columns.Add("上限值", typeof(System.String)); + //table.Columns.Add("下限值", typeof(System.String)); + //table.Columns.Add("测量单位", typeof(System.String)); + //table.Columns.Add("列位置", typeof(System.Int32)); + //table.Columns.Add("变量排序", typeof(System.Int32)); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt); + } + /// + /// 测量数据合格_手动拧紧_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_Insert(int engineTypeID, string engineType, string engineID, string tagValue, int isGoodBad, string opName, string partPallet, int tagID, int tagID_CF, string MaxValue, string MinValue) + { + string procedureName; + procedureName = "测量数据合格_手动拧紧_增加"; + SqlParameter[] thisParms = new SqlParameter[11]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineType", engineType); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", tagValue); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@托盘编号", partPallet); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@TagID", tagID); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID_CF); + thisParms[9] = new System.Data.SqlClient.SqlParameter("@上限值", MaxValue); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@下限值", MinValue); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// 测量数据合格索引_增加_电芯 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_IndexInsert_cell(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF) + { + string procedureName; + procedureName = "测量数据合格索引_增加_电芯"; + Id_tagCF = 0; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[7].Direction = ParameterDirection.Output; + + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString()); + return true; + } + return false; + } + /// + /// 测量数据合格_增加_电芯 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_Insert_cell(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false) + { + string procedureName; + procedureName = "测量数据合格_增加_电芯"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID"); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue"); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad"); + //是否保存无合格标志数据数据 + //thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置"); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目"); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置 + thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值"); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值"); + thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值"); + thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位"); + thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置"); + thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序"); + //table.Columns.Add("TagID", typeof(System.Int32)); + //table.Columns.Add("TagValue", typeof(System.String)); + //table.Columns.Add("IsGoodBad", typeof(System.Int32)); + //table.Columns.Add("测量位置", typeof(System.String)); + //table.Columns.Add("测量项目", typeof(System.String)); + //table.Columns.Add("工位号", typeof(System.String)); + //table.Columns.Add("理论值", typeof(System.String)); + //table.Columns.Add("上限值", typeof(System.String)); + //table.Columns.Add("下限值", typeof(System.String)); + //table.Columns.Add("测量单位", typeof(System.String)); + //table.Columns.Add("列位置", typeof(System.Int32)); + //table.Columns.Add("变量排序", typeof(System.Int32)); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt); + } + + /// + /// MES_装配数据_零部件追溯_增加 + /// + /// + /// + /// + public static bool Material_Insert(string opName, int m_ConfirmOkGo) + { + string produceName = "MES_装配数据_零部件追溯_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@放行方式", m_ConfirmOkGo); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + static public void WorkStartInsert_JZ(string opName, string engineID, int isOK) + { + string procedureName; + procedureName = "测量数据发动机在线状态_增加数据_JZ"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@是否合格", isOK.ToString()); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + static public void WorkStartInsert(string opName, int isOK) + { + string procedureName; + procedureName = "测量数据发动机在线状态_增加数据"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否合格", isOK.ToString()); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + /// + /// 接口_IOT接口_报工记录_增加 + /// + /// + public static void IOT_Data_UpLode_Res_Save(string opName, string OrderID, string EngineID, string ReqType, bool reqIsOk, string ResText) + { + string produceName = "接口_IOT接口_报工记录_增加"; + SqlParameter[] thisParms = new SqlParameter[6]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", OrderID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@报工类型", ReqType); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@报工结果", reqIsOk); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@结果报文", ResText); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// CallWebApi_FactoryMes_NGRecordSave + /// + /// + public static void CallWebApi_FactoryMes_NGRecordSave(string InterfaceName, int AID, string InterfaceUrl, string ReqText, string ResText) + { + string produceName = "CallWebApi_FactoryMes_NGRecordSave"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口名称", InterfaceName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@AID", AID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@接口地址", InterfaceUrl); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@请求内容", ReqText); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@响应内容", ResText); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 生产计划_派工订单_工件追溯_工位完工 + /// + /// + /// + /// + public static bool WorkOrderOpWorkOver(string opName, string EngineID, string OrderFrom) + { + string produceName = "生产计划_派工订单_工件追溯_工位完工"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 生产计划_派工订单_工件追溯_工位完工 + /// + /// + /// + /// + public static bool SaveQualityInterfaceData(string opName, string EngineID) + { + string produceName = "接口_质量数据_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 数据表 + /// + /// + static public DataTable BuildDataTables_WWW() + { + DataTable table; + DataColumnCollection columns; + table = new DataTable(); + columns = table.Columns; + table.Columns.Add("TagID", typeof(System.String)); + table.Columns.Add("TagValue", typeof(System.String)); + table.Columns.Add("IsGoodBad", typeof(System.Int32)); + table.Columns.Add("测量位置", typeof(System.String)); + table.Columns.Add("测量项目", typeof(System.String)); + table.Columns.Add("工位号", typeof(System.String)); + table.Columns.Add("理论值", typeof(System.String)); + table.Columns.Add("上限值", typeof(System.String)); + table.Columns.Add("下限值", typeof(System.String)); + table.Columns.Add("测量单位", typeof(System.String)); + table.Columns.Add("列位置", typeof(System.Int32)); + table.Columns.Add("变量排序", typeof(System.Int32)); + + return table; + } + + static public DataTable GetMobyTableByOpName(string opName) + { + DataTable dt; + string procedureName; + procedureName = "北汽福田工位状态监控MOBY_工位_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + return dt; + } + + /// + /// 生产计划_派工订单_工件追溯_工件下线 + /// + /// + /// + /// + public static bool WorkOrderOpWorkOutLine(string EngineID, string OrderFrom) + { + string produceName = "生产计划_派工订单_工件追溯_工件下线"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// XD_提前上料记录_获取 + /// + /// + /// + public static DataTable Get_ReqEarlyFeedingData(string opName) + { + DataTable dt = new DataTable(); + string produceName = "XD_提前上料记录_获取"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + /// + /// + /// + /// + /// + /// + /// + public static bool Location_MIS_MOBY_Insert(string opName, string tagType, string tagValue) + { + string produceName = "XD_库位Moby_增加"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@库位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@变量类型", tagType); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@变量值", tagValue); + + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + public static DataTable GetRequestReturnMaterials_Type(string opName, string type) + { + DataTable dt = new DataTable(); + string produceName = "XD_库位叫料_叫料类型装换"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@叫料类型", type); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + public static DataTable GetEngineType_Order(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int parType, out int isCheckOk, out string msg) + { + DataTable dt = new DataTable(); + isCheckOk = 2; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + parType = 0; + OrderForm = ""; + msg = ""; + string produceName = "XD_产品上线"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); + EngineType = dt.Rows[0]["产品型号"].ToString(); + EngineID = dt.Rows[0]["工件编号"].ToString(); + OrderForm = dt.Rows[0]["订单号"].ToString(); + parType = Convert.ToInt32(dt.Rows[0]["小机型"]); + isCheckOk = Convert.ToInt32(dt.Rows[0]["result"]); + msg = dt.Rows[0]["msg"].ToString(); + return dt; + } + } + return dt; + } + + public static DataTable GetEngineType_Order(string opName, string Program_No, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int isCheckOk, out int planCount, out int haveUplaodCount, out int remainingQuantity, out string msg) + { + DataTable dt = new DataTable(); + isCheckOk = 2; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + OrderForm = ""; + planCount = 0; + haveUplaodCount = 0; + remainingQuantity = 0; + msg = ""; + string produceName = "平芝_生产上线_判断机型订单是否匹配_分线"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + //thisParms[1] = new System.Data.SqlClient.SqlParameter("@PLC_机型代码", Program_No); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + EngineTypeID = Convert.ToInt32(dt.Rows[0]["机型代码"]); + EngineType = dt.Rows[0]["机型"].ToString(); + EngineID = dt.Rows[0]["变速箱总成号"].ToString(); + OrderForm = dt.Rows[0]["订单号"].ToString(); + isCheckOk = Convert.ToInt32(dt.Rows[0]["是否匹配"]); + planCount = Convert.ToInt32(dt.Rows[0]["计划上料数量"]); + haveUplaodCount = Convert.ToInt32(dt.Rows[0]["已上料数量"]); + remainingQuantity = Convert.ToInt32(dt.Rows[0]["待上料数量"]); + msg = dt.Rows[0]["msg"].ToString(); + return dt; + } + } + return dt; + } + + /// + /// 29 工位具体零件合格标志 + /// + /// + static public string GetQualityData_GoodBad_String(bool[] QualityData_GoodBad) + { + string str; + str = ""; + if (QualityData_GoodBad != null) + { + + for (int i = 0; i < QualityData_GoodBad.Length; i++) + { + str = str + (Convert.ToInt32(QualityData_GoodBad[i])).ToString() + "|"; + } + + } + return str; + + } + + /// + /// 返回非标准real + /// + /// + /// + static public string GetNoNormalReal(object vDataValue) + { + try + { + string real_a; + string real_b; + string groupValueString; + int length; + + //int real_b_Int; + + length = ((System.Array)(vDataValue)).Length; + groupValueString = ""; + if (length != 2) + return "0.0"; + + real_a = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(0))).ToString(); + real_b = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(1))).ToString("00"); + groupValueString = real_a + "." + real_b; + return groupValueString; + } + catch + { + ////ApplicationLog.WriteLog(err, "GetNoNormalReal"); + return "0.0"; + + } + } + + /// + /// 测量数据工位_监控系统_MOBY_查询_PDC + /// + /// + /// + /// + public static void Moby_Select_PDC(string EngineID, out string OrderForm, out string EngineType, out int EngineTypeCode) + { + DataTable dt = new DataTable(); + OrderForm = ""; + EngineType = ""; + EngineTypeCode = 0; + try + { + string procedureName; + procedureName = "测量数据工位_监控系统_MOBY_查询_PDC"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + if (dt.Rows.Count > 0) + { + OrderForm = dt.Rows[0]["订单号"].ToString(); + EngineType = dt.Rows[0]["产品型号"].ToString(); + EngineTypeCode = Convert.ToInt32(dt.Rows[0]["机型代码"].ToString()); + } + } + catch + { + OrderForm = ""; + EngineType = ""; + EngineTypeCode = 0; + } + } + + /// + /// 基本数据_工作日历_班次产量查询_Web页面显示_初始化查询 + /// + /// + /// + /// + public static void InitOpNameOuputCount(string opName, out int outputValue, out int nowOutputValue, + out int opNameBeatValue, out int NowOpNameBeatValue, out int classNumber) + { + outputValue = 0;//工位产量 + nowOutputValue = 0;//在线产量 + opNameBeatValue = 0;//工位节拍 + NowOpNameBeatValue = 0;//在线节拍 + classNumber = 0;//班次 + try + { + string procedureName; + procedureName = "Web页面显示_计划产量初始化查询"; + SqlParameter[] thisParms = new SqlParameter[6]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位产量", SqlDbType.Int, 4, "工位产量"); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工位节拍", SqlDbType.Int, 4, "工位节拍"); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线产量", SqlDbType.Int, 4, "在线产量"); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@在线节拍", SqlDbType.Int, 4, "在线节拍"); + thisParms[4].Direction = ParameterDirection.Output; + thisParms[5] = new System.Data.SqlClient.SqlParameter("@班次代码", SqlDbType.Int, 4, "班次代码"); + thisParms[5].Direction = ParameterDirection.Output; + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null && thisParms[4].Value != null && thisParms[5].Value != null) + { + outputValue = Convert.ToInt32(thisParms[1].Value); + opNameBeatValue = Convert.ToInt32(thisParms[2].Value); + nowOutputValue = Convert.ToInt32(thisParms[3].Value); + NowOpNameBeatValue = Convert.ToInt32(thisParms[4].Value); + classNumber = Convert.ToInt32(thisParms[5].Value); + } + } + catch + { + outputValue = 0; + opNameBeatValue = 0; + nowOutputValue = 0; + NowOpNameBeatValue = 0; + classNumber = 0; + } + } + + static public void GetImageFile(string opName, int engineTypeID, out byte[] pic) + { + string sql; + DataTable dt; + pic = null; + sql = "exec 电子看板_工位名称与产品型号产品图片_查询 '" + opName + "'," + engineTypeID.ToString(); + DataAccess.ExecuteDataTable(sql, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + pic = (byte[])dt.Rows[0]["产品图片"]; + } + } + } + + /// + /// 电子看板_工位机型_质量数据测量位置_查询_工作顺序 + /// + /// 工位号 + /// 产品型号代码 + /// + static public bool ShaftPositionSelect(string opNum, int EngineTypeID, out DataTable dt) + { + string procedureName = "电子看板_工位机型_质量数据测量位置_临时表_查询"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opNum); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", EngineTypeID); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + + + /// + /// 测量数据合格_查询 + /// + /// + /// + /// + /// + static public bool QualitySelect(string opName, string engineID, out DataTable dt) + { + string procedureName = "测量数据合格_查询"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + /// + /// 生产计划_派工订单_查询_工位执行_完工判断 + /// + /// + /// + /// + /// + public static void Select_OrderFormList_OrderComplete(string opName, out int isCompleted, out int num_plan, out int num_complete) + { + isCompleted = 0;//订单数量是否完全上线 + num_plan = 0;//计划数量 + num_complete = 0;//上线数量 + try + { + string procedureName; + procedureName = "生产计划_派工订单_查询_工位执行_完工判断"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@ISCOMPLETE", SqlDbType.Int, 4, "ISCOMPLETE"); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@NUM_PLAN", SqlDbType.Int, 4, "NUM_PLAN"); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@NUM_COMPLETE", SqlDbType.Int, 4, "NUM_COMPLETE"); + thisParms[3].Direction = ParameterDirection.Output; + + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null) + { + isCompleted = Convert.ToInt32(thisParms[1].Value); + num_plan = Convert.ToInt32(thisParms[2].Value); + num_complete = Convert.ToInt32(thisParms[3].Value); + } + } + catch + { + isCompleted = 0; + num_plan = 0; + num_complete = 0; + } + } + /// + /// 生产计划_派工订单_查询_工位执行 + /// + /// 工位号 + /// + static public void OrderFormList_Select(string opName, out DataTable dt) + { + dt = null; + string sql = "exec 生产计划_派工订单_查询_工位执行 '" + opName + "'"; + DataAccess.ExecuteDataTable(sql, out dt); + } + /// + /// MES界面显示_弹窗消息_查询 + /// + /// + /// + /// + public static bool ShowWindowNotice(string opname, out DataTable dt) + { + string procedureName = "MES界面显示_弹窗消息_查询"; + SqlParameter[] sqlParameters = new SqlParameter[1]; + sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname); + return DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out dt); + } + + /// + /// MES界面显示_消息滚动_查询 + /// + /// + /// + /// + public static bool ShowLEDNotice(string opname, out DataTable dt) + { + string procedureName = "MES界面显示_消息滚动_查询"; + SqlParameter[] sqlParameters = new SqlParameter[1]; + sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname); + return DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out dt); + } + /// + /// 电子看板_工位机型_物料检测测量位置_查询_物料检测 + /// + /// + /// + /// + static public bool MaterialCheckSelect(string opName, out DataTable dt) + { + string procedureName = "电子看板_工位机型_物料检测测量位置_查询_物料检测"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + /// + /// 电芯进站 离站 + /// + /// + /// + /// + public static bool Cell_CheckDataAdd(string opName, string EngineID, string operationTime, int isOK) + { + string produceName = "测量数据合格_增加数据_电芯"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@操作时间", operationTime); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + public static bool Cell_PassStation(string opName, string EngineID, string operationTime, int passType, int isOK = 1) + { + string produceName = "测量数据发动机在线状态_增加数据_电芯"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@操作时间", operationTime); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@过站类型", passType); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 报警接口记录 存储 + /// 关机(0)/开机(1)/报警(2)/故障(3) 运行(4) 待机(5) + /// 注意事项:当设备状态发生变化时,给表里插入一条数据。状态时间字段精确到年月日时分秒。当状态没变化时,不用重复去存数据,不同的故障告警,认为是不同的状态,当前如果是报警1,先存一条报警1,如果一直是报警1,就不用重复存报警1,当又产生了报警2时,需要给表里再存一条报警2。场景如下: + ////1.开机后,状态先存一条开机,3秒后,再继续存一条待机 + ////2.设备运行后,存一条运行 + ////3.有故障1时,存一条故障,内容为故障1 + ////4.有故障2时,存一条故障,内容为故障2 + ////5.故障1解除后,先存一条运行,如果还有故障2, 继续再存一条故障,内容为故障2 + ////6.故障2解除后,存一条运行或者待机(看设备具体是运行还是待机状态) + /// + /// 工位号 + /// 状态代码 + /// 故障代码 如状态为故障/报警,记录故障/报警代码。 + /// 故障名称 如状态为故障/报警,记录故障/报警名称 + /// 故障说明 如状态为故障/报警,记录故障/报警说明。 + /// 备注 + /// + public static bool errorPortSave(string opName, string DeviceStatus, string MalfunctionCode = null, string MalfunctionName = null, string Malfunctionexplain = null, string Remark = null, int? alarmRemove = null) + { + string produceName = "接口_工位运行状态_增加"; + SqlParameter[] thisParms = new SqlParameter[7]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@状态代码", DeviceStatus); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@故障代码", MalfunctionCode); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@故障名称", MalfunctionName); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@故障说明", Malfunctionexplain); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@备注", Remark); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@alarmRemove", (object)alarmRemove ?? DBNull.Value); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// 工位运行状态 存储 + /// + /// + /// + /// + public static bool WorkRunStatusSave(string opName, int toolPowered, int toolStart, float energy) + { + string produceName = "接口_工位使用情况_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@机床上电", toolPowered); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@循环开始", toolStart); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@能耗", energy); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// MES界面显示_弹窗消息_增加 + /// + /// + /// + /// + public static bool Web_Notice_Insert(string opName, string notice) + { + string produceName = "MES界面显示_弹窗消息_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@Notice", notice); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 基本数据_工作日历_班次产量查询_New + /// + /// + /// 在线产量 + /// 在线节拍 + static public void OpNameCount_New(string opName, out int opNameCount, out int opNameCountTime) + { + opNameCount = 0; + opNameCountTime = 0; + string procedureName; + procedureName = "基本数据_工作日历_班次产量查询_New"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@在线产量", 0); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@在线节拍", 0); + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + opNameCount = Convert.ToInt32(thisParms[1].Value); + opNameCountTime = Convert.ToInt32(thisParms[2].Value); + } + } + /// + /// 基本数据_工作日历_班次产量查询_New + /// + /// + /// 在线产量 + /// 在线节拍 + static public void OpNameCount_BQ(string opName, out int opNameCount, out int opNameCountTime) + { + opNameCount = 0; + opNameCountTime = 0; + string procedureName; + procedureName = "基本数据_工作日历_班次产量查询_北汽"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@在线产量", 0); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@在线节拍", 0); + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + opNameCount = Convert.ToInt32(thisParms[1].Value); + opNameCountTime = Convert.ToInt32(thisParms[2].Value); + } + } + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_增加 + /// + /// + /// + public static bool MesServer_ShaftPosition_EngineTypeOver(string opName) + { + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_增加"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况 + /// + /// + /// + /// + /// + /// + public static bool MesServer_ShaftPosition_Select_FinishResult(string opName, out int workGroupIndex, out string BoltCode, out bool sn_WorkingStepIsOver, out bool isHaveNg) + { + workGroupIndex = 0; + BoltCode = ""; + sn_WorkingStepIsOver = true; + isHaveNg = false; + + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@组号", SqlDbType.Int, 4); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@套筒号", SqlDbType.NVarChar, 50); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[4].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + workGroupIndex = Convert.ToInt32(thisParms[1].Value); + BoltCode = thisParms[2].Value.ToString(); + sn_WorkingStepIsOver = Convert.ToBoolean(thisParms[3].Value); + isHaveNg = Convert.ToBoolean(thisParms[3].Value); + return true; + } + return false; + } + + + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_修改 + /// + /// + /// + /// + /// + /// + public static bool MesServer_ShaftPosition_Update(string opName, int workGroupIndex, int IsOK, out bool IsFinish) + { + IsFinish = true; + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_修改"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@组号", workGroupIndex); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", IsOK); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[3].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + IsFinish = Convert.ToBoolean(thisParms[3].Value); + return true; + } + return false; + } + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况 + /// + /// 工位号 + /// 拧紧序号 + /// 套筒号 + /// 工步属性 + /// 是否全部完成 + /// + public static bool MesServer_ShaftPosition_Select_FinishResult(string opName, out int ProcessCode, out int BoltCode, out int workStepProperty, out bool sn_WorkingStepIsOver, out bool isHaveNg) + { + BoltCode = 0; + ProcessCode = 512; + workStepProperty = 0; + sn_WorkingStepIsOver = true; + isHaveNg = false; + + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况"; + SqlParameter[] thisParms = new SqlParameter[6]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@拧紧序号", SqlDbType.Int, 4); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@套筒号", SqlDbType.Int, 4); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工步属性", SqlDbType.Int, 4); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[4].Direction = ParameterDirection.Output; + thisParms[5] = new System.Data.SqlClient.SqlParameter("@是否存在不合格", SqlDbType.Int, 4); + thisParms[5].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + ProcessCode = Convert.ToInt32(thisParms[1].Value); + BoltCode = Convert.ToInt32(thisParms[2].Value); + workStepProperty = Convert.ToInt32(thisParms[3].Value); + sn_WorkingStepIsOver = Convert.ToBoolean(thisParms[4].Value); + isHaveNg = Convert.ToBoolean(thisParms[5].Value); + return true; + } + return false; + } + + + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_修改_重新拧紧 + /// + /// 工位号 + /// 拧紧序号 + /// + public static bool MesServer_ShaftPosition_FixAllow_Again(string opName, int ProcessCode) + { + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_修改_重新拧紧"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@组号", ProcessCode); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + return true; + } + return false; + } + + /// + /// 测量数据项目 + /// 用于B5A项目 + /// + /// + public static DataTable BaseData_tagTable_QualityData_Item_B5A() + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 FROM [MES_基本变量_原始数据] " + + " where (TagID <> 0 ) and " + + " ((变量类型代码 = 9) " + + " or (变量类型代码 = 10) " + + " or (变量类型代码 = 11) " + + " or (变量类型代码 = 80) " + + " or (变量类型代码 = 101) " + + " or (变量类型代码 = 102) " + + + " or (变量类型代码 = 78) " + + " or (变量类型代码 = 79) " + + " or (变量类型代码 = 41) " + + " or (变量类型代码 = 51) " + + " or (变量类型代码 = 8) " + + " or (变量类型代码 = 21) " + + + " or (变量类型代码 = 105)) " + + " and (是否启用 = 1)"; + + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 测量数据合格索引_分线数据_删除 + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_SubTable_Delete + (string engineID, string opName) + { + string procedureName; + procedureName = "测量数据合格索引_分线数据_删除"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// MES_装配数据_零部件追溯_增加_不合格 + /// + /// + /// + /// + public static bool Material_Insert_NG(string opName, int m_ConfirmOkGo) + { + string produceName = "MES_装配数据_零部件追溯_增加_不合格"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@放行方式", m_ConfirmOkGo); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 测量数据发动机在线状态_查询_是否已工作 + /// + /// + /// 新零件号(机型) + /// + public static DataTable EngineIsTwoWork(string opName, string OrderForm, string EngineID) + { + DataTable dt = new DataTable(); + string produceName = "测量数据发动机在线状态_查询_是否已工作"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", OrderForm); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@总成号", EngineID); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + static public DataTable CheckAllFinish(string opName, string EngineID, int type) + { + string procedureName; + DataTable dt = new DataTable(); + procedureName = "测量数据工位_测试工位状态_修改"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@type", type); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + return dt; + } + + + + + + + + + + + + + + + + + + /// + /// 报警工位记录表_新增 + /// + /// + /// + /// + /// + /// + static public void Alarm_Insert2(int TagID, string opName, string Text, int Status, string errType) + { + //@TagID , + //@工位号, + // @报警内容, + // @报警类型, + // @报警状态 + string procedureName; + procedureName = "报警工位记录表_新增"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@TagID", TagID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@报警内容", Text); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@报警类型", errType); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@报警状态", Status); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + + public static DataTable XD_MaterialsVerify(string opName, string engineID, string materialsCode, int MaterialsTypeCode) + { + DataTable dt = new DataTable(); + string produceName = "XD_物料记录_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工件编号", engineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@物料编码", materialsCode); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@物料类型编号", MaterialsTypeCode); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + /// + /// 报警工位记录表_MOBY_查询 + /// + public static void Alarm_Moby_Search(out DataTable dt) + { + string procedureName; + procedureName = "报警工位记录表_MOBY_查询"; + SqlParameter[] thisParms = new SqlParameter[0]; + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + + /// + /// 生产计划_派工订单_配送信息_验证记录_校验 + /// + /// + /// + public static DataTable Get_MaterialsScanOverRes(string opName, string order, string engineID, string materialsCode) + { + DataTable dt = new DataTable(); + string produceName = "生产计划_派工订单_配送信息_验证记录_校验"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", order); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", engineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@物料编码", materialsCode); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + + public static DataTable Rrunning_AGV_Arrive(string opName) + { + DataTable dt = new DataTable(); + string produceName = "XD_磨合_AGV到达"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@库位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + public static DataTable Rrunning_AGV_Leave(string opName) + { + DataTable dt = new DataTable(); + string produceName = "XD_磨合_AGV离开"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@库位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + public static DataTable Rrunning_GetNextStoreData(string opName, string EngineID, string EngineType) + { + DataTable dt = new DataTable(); + string produceName = "XD_磨合_获取下一序"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@库位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品编号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号", EngineType); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + public static DataTable Rrunning_UpdateOpCallStatus(string opName, int status) + { + DataTable dt = new DataTable(); + string produceName = "XD_磨合_状态_是否呼叫_更新"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@库位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否呼叫", status); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.MES.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.MES.cs new file mode 100644 index 0000000..f62ac3f --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.MES.cs @@ -0,0 +1,163 @@ +using DataLinkMesWork1; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + static object locker = new object(); + /// + ///引用程序集Hashtable + /// + public static Hashtable Hashtable_assembly = new Hashtable(); + public static Hashtable hashtable_MesServerCode = new Hashtable(); + public static Hashtable hashtable_MesDll = new Hashtable(); + public static Hashtable hashtable_TagTypeTagName = new Hashtable(); + public static Hashtable hashtable_TagName = new Hashtable(); + + /// + /// + /// + /// 变量名称对应的变量类型代码 + /// 变量类型代码对应的变量名称 + public static void GetBaseData_tagTable_TagName(out Hashtable hashtable_TagName, out Hashtable hashtable_TagTypeTagName) + { + hashtable_TagName = new Hashtable(); + hashtable_TagTypeTagName = new Hashtable(); + + string tagName; + string tagTypeCode; + DataTable dt;//GetMesServerCodeFromMIS + dt = BaseData_tagTable_TagName(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + tagName = dt.Rows[i]["TagName"].ToString(); + tagTypeCode = dt.Rows[i]["变量类型代码"].ToString(); + if (!hashtable_TagName.Contains(tagName)) + { + hashtable_TagName.Add(tagName, tagTypeCode); + } + if (!hashtable_TagTypeTagName.Contains(tagTypeCode)) + { + hashtable_TagTypeTagName.Add(tagTypeCode, tagName); + } + } + } + } + + public static void GetMesServerCodeAndMesDll(out Hashtable hashtable_MesServerCode, out Hashtable hashtable_MesDll) + { + hashtable_MesServerCode = new Hashtable(); + hashtable_MesDll = new Hashtable(); + + string OpName; + string MesServerCode; + string MesDll; + DataTable dt;//GetMesServerCodeFromMIS + dt = GetMesServerCodeFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + MesServerCode = dt.Rows[i]["MesServerCode"].ToString(); + MesDll = dt.Rows[i]["MesDll"].ToString(); + if (!hashtable_MesDll.Contains(OpName)) + { + hashtable_MesDll.Add(OpName, MesDll); + } + if (!hashtable_MesServerCode.Contains(OpName)) + { + hashtable_MesServerCode.Add(OpName, MesServerCode); + } + } + } + } + + + /// + /// MesServerFunction + /// + /// + /// + /// + public static void TransferInfToMES(object text) + { + try + { + string recData = text.ToString(); + List dataArray = GetCmdStringList(recData); + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + string mesServerdllName; + //获得工位对应的 dll + if (!GetMesServerDllNameByOpName(out mesServerdllName, m_OpName)) return; + if (mesServerdllName == null) return; + if (mesServerdllName.Length < 1) return; + + string ResultOK = ""; + object[] Paramsters = new object[1]; + Paramsters[0] = text; + + System.Reflection.Assembly assembly = null; + + bool IsOK = Hashtable_assembly.ContainsKey(mesServerdllName); + if (IsOK) + { + assembly = (System.Reflection.Assembly)Hashtable_assembly[mesServerdllName]; + } + else + { + assembly = System.Reflection.Assembly.Load(mesServerdllName); + if (assembly == null) + { + return; + } + Hashtable_assembly.Add(mesServerdllName, assembly); + } + ResultOK = Reflection.ReflectionMethod(assembly, "MesServerFunctions", "FunctionMES", "FunWork", Paramsters); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "TransferInf"); + } + + } + /// + /// 获得工位对应的 dll + /// + /// + /// + /// + private static bool GetMesServerDllNameByOpName(out string mesServerdllName, string opName) + { + try + { + mesServerdllName = hashtable_MesDll[opName].ToString(); + return true; + } + catch + { + mesServerdllName = ""; + return false; + } + } + + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.ShaftPositionData.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.ShaftPositionData.cs new file mode 100644 index 0000000..563c988 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.ShaftPositionData.cs @@ -0,0 +1,156 @@ +using DataLinkMesWork1; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataFunDll +{ + public partial class ShaftPosition + { + /// + /// 测量数据合格_电子看板_质量数据_临时表_增加_返修工位 + /// @EngineID nvarchar(50)=null, + /// @EngineType nvarchar(50)=null, + /// @EngineTypeID int = null, + /// @工位号 nvarchar(50)=null, + /// @工位号返修工位 nvarchar(50)=null, + /// @订单号 nvarchar(50)=null, + /// @合格标志 int + /// + /// 工件号 + /// 机型 + /// 机型代码 + /// 工位号(被返修的工位号) + /// 工位号返修工位 + /// 订单号 + /// 合格标志 + static public void ShaftPosition_Data_OpNameRepair_Insert(string engineID, string engineType, int engineTypeID, string opName, string opNameRepair, string orderForm, int isOK) + { + string procedureName; + procedureName = "测量数据合格_电子看板_质量数据_临时表_增加_返修工位"; + SqlParameter[] thisParmsSql = new SqlParameter[7]; + thisParmsSql[0] = new SqlParameter("@EngineID", engineID); + thisParmsSql[1] = new SqlParameter("@EngineType", engineType); + thisParmsSql[2] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[3] = new SqlParameter("@工位号", opName); + thisParmsSql[4] = new SqlParameter("@工位号返修工位", opNameRepair); + thisParmsSql[5] = new SqlParameter("@订单号", orderForm); + thisParmsSql[6] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// 测量数据合格_电子看板_质量数据_临时表_增加 + /// @EngineID nvarchar(50)=null, + /// @EngineType nvarchar(50)=null, + /// @EngineTypeID int = null, + /// @工位号 nvarchar(50)=null, + /// @订单号 nvarchar(50)=null, + /// @合格标志 int + /// + /// 工件号 + /// 机型 + /// 机型代码 + /// 工位号 + /// 订单号 + /// 合格标志 + static public void ShaftPosition_Data_Insert(string engineID, string engineType, int engineTypeID, string opName, string orderForm, int isOK) + { + string procedureName; + procedureName = "测量数据合格_电子看板_质量数据_临时表_增加"; + SqlParameter[] thisParmsSql = new SqlParameter[6]; + thisParmsSql[0] = new SqlParameter("@EngineID", engineID); + thisParmsSql[1] = new SqlParameter("@EngineType", engineType); + thisParmsSql[2] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[3] = new SqlParameter("@工位号", opName); + thisParmsSql[4] = new SqlParameter("@订单号", orderForm); + thisParmsSql[5] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + static public void ShaftPosition_Data_Insert_RepairOpName(string opName, int shaftStep, string engineID, string engineType, int engineTypeID, int orderBy, string tagValue, int isOK) + { + string procedureName; + procedureName = "电子看板_质量数据_临时表_增加_备用拧紧工位"; + SqlParameter[] thisParmsSql = new SqlParameter[8]; + thisParmsSql[0] = new SqlParameter("@工位号", opName); + thisParmsSql[1] = new SqlParameter("@序号", shaftStep); + thisParmsSql[2] = new SqlParameter("@EngineID", engineID); + thisParmsSql[3] = new SqlParameter("@EngineType", engineType); + thisParmsSql[4] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[5] = new SqlParameter("@变量排序", orderBy); + thisParmsSql[6] = new SqlParameter("@测量值", tagValue); + thisParmsSql[7] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// 电子看板_质量数据_临时表_增加 + /// + /// 工位号 + /// 序号 + /// 工件号 + /// 机型 + /// 机型代码 + /// 变量代码 + /// 变量值 + /// 合格标志 + static public void ShaftPosition_Data_Insert(string opName, int shaftStep, string engineID, string engineType, int engineTypeID, int tagID, string tagValue, int isOK) + { + string procedureName; + procedureName = "电子看板_质量数据_临时表_增加"; + SqlParameter[] thisParmsSql = new SqlParameter[8]; + thisParmsSql[0] = new SqlParameter("@工位号", opName); + thisParmsSql[1] = new SqlParameter("@序号", shaftStep); + thisParmsSql[2] = new SqlParameter("@EngineID", engineID); + thisParmsSql[3] = new SqlParameter("@EngineType", engineType); + thisParmsSql[4] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[5] = new SqlParameter("@TagID", tagID); + thisParmsSql[6] = new SqlParameter("@测量值", tagValue); + thisParmsSql[7] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// 电子看板_工位机型_质量数据测量位置_查询_工作顺序 + /// + /// + /// + /// + static public void ShaftPosition_Select_WorkingStep(string opName, int engineTypeID, out DataTable dt) + { + dt = null; + + string sql = "exec 电子看板_工位机型_质量数据测量位置_查询_工作顺序 '" + opName + "'," + engineTypeID.ToString(); + DataAccess.ExecuteDataTable(sql, out dt); + } + + /// + /// 电子看板_质量数据_临时表_删除 + /// + /// 工位号 + /// 列位置 + /// EngineID + static public void ShaftPosition_Data_Delete(string opName, int shaftStep, string engineID) + { + string procedureName; + procedureName = "电子看板_质量数据_临时表_删除"; + SqlParameter[] thisParmsSql = new SqlParameter[3]; + thisParmsSql[0] = new SqlParameter("@工位号", opName); + thisParmsSql[1] = new SqlParameter("@列位置", shaftStep); + thisParmsSql[2] = new SqlParameter("@EngineID", engineID); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.TagTypeCodeID.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.TagTypeCodeID.cs new file mode 100644 index 0000000..ad1531b --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.TagTypeCodeID.cs @@ -0,0 +1,462 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +///1 X WorkStart 2 工件到位(PLC) 工件到位。托盘到达工位,并且托盘上有工件。 +///2 X RepairPartStatusPLC 3 RepairPartStatusPLC 备用 +///3 STRING RepairPathString 4 RepairPathString "工位返修字符串(121211112222111),前2位是西门子字符串格式,第一位是总长度,第二位是实际长度" +///4 X EngineTypeGetOverMES 5 传递机型(MES) MES传递总成信息给PLC(上线工位) +///5 X PartPalletGoOver 6 PartPalletGoOver 上线工位。0:正常工作;1:空托盘放行,PLC读取到此标志不走申请上线逻辑。 +///6 X MaterialVerifyOver 7 MaterialVerifyOver MES保存完质量数据,物料数据等与PLC信号交互完成后通知PLC,所以工步都完成,才可以放行工件,正常工作时工件放行的必要条件。 +///7 X FalseGo 8 FalseGo 按MES界面[不合格放行]按钮,MES发送此信号。操作者判断工件不合格,通知设备,按不合格方式放行工件,工件流转到返修下线工位后,返修下线。MES工作完成MES0.3=1,MES合格放行MES0.5=0,MES0.4=1 +///8 INT EngineTypeID 9 EngineTypeID MES发动机机型标志(必须PLC) +///9 STRING EngineID 10 EngineID MES发动机编号(必须PLC) +///10 STRING EngineType 11 机型(MES) MES发动机机型(必须PLC) +///11 X PartPalletStatus 13 PartPalletStatus MES激发变量托盘到位离开(必须PLC) +///12 X HeartBeatPLC 14 HeartBeatPLC 心跳处理:PLC收到MES心跳信号后,PLC延时5秒后,数值取反再写回PLC,写回PLC开始计时,如果5秒钟MES无反馈报通讯故障。 +///13 X HeartBeatMIS 15 HeartBeatMIS 间隔时间5S,心跳处理。收到PLC心跳信号后,MES按原值回写。PLC收到MES信号后延时5秒,取反写入,以此循环。 +///14 X TargetTimeRead 16 TargetTimeRead MES允许可读工位运行时间 +///15 Int MachineTargetTime 17 MachineTargetTime 目标运行时间 +///16 Int MachineActualTime 18 MachineActualTime 实际运行时间 +///17 X MesRead 19 允许保存(PLC) 质量数据可以读数据 +///18 X MesReadOver 20 保存完成(MES) MES保存完数据(必须MIS) +///19 INT QualityMask 21 合格标志(PLC) 质量数据工位合格标志0:没有工作;1:合格 ;2 :不合格(必须PLC) +///20 B PalletInfo 22 PalletInfo 0空托盘,1合格件,2不合格件 +///21 INT RepairStatusPLC 23 RepairStatusPLC 0正常件,1返修件 +///22 INT OrderNo 24 订单号(MES) 订单号(MES) +///23 X StorageNo 25 库位号(MES) 库位号(MES) +///24 X AllowPass 26 允许放行(MES) 允许放行 +///25 X PartLoadFinish 27 PartLoadFinish PartLoadFinish +///26 X Reserved_7 28 Reserved_7 备用 +///27 X Reserved_8 29 Reserved_8 备用 +///28 X Reserved_9 30 Reserved_9 备用 +///29 X Reserved_10 31 Reserved_10 备用 +///30 X Reserved_11 32 Reserved_11 备用 +///31 X Reserved_12 33 Reserved_12 备用 +///32 X Reserved_13 34 Reserved_13 备用 +///33 X Reserved_14 35 Reserved_14 备用 +///34 Int PLCSPareint1 36 PLCSPareint1 备用 +///35 Int PLCSPareint2 37 PLCSPareint2 备用 +///36 Int PLCSPareint3 38 PLCSPareint3 备用 +///37 STRING PLCSarestring1 39 PLCSarestring1 备用 +///38 STRING PLCSarestring2 40 PLCSarestring2 备用 +///39 STRING MarkID 42 MarkID 机体打标号(MES)前2位是西门子字符串格式,第一位是总长度,第二位是实际长度 +///40 X PartLoad 43 PartLoad 上线工位,PLC向MES申请总成编号。收到该信号后,MES将机型标志(DBB22 ~23)、总成号(DBB24 ~63)、总成机型DBB64 ~103写入PLC。之后MES通过信号“传递机型(DBX0.1)”通知PLC。 +///41 X EngineTypeGetOverPLC 44 传递机型(PLC) PLC将机型标志(DBB50…51)、工件编号(DBB52…101)、产品型号(DBB102…187)、托盘编号(DBB188…189)准备完毕后,通知MES。 +///42 X PartLoadOK 48 PartLoadOK 备用 +///43 X Reserved_18 49 Reserved_18 备用 +///44 X PalletDown 50 PalletDown 暂时保留,项目未使用 +///45 X ConfirmOkGo 51 ConfirmOkGo 按MES界面[合格放行]按钮,MES发送此信号。操作者判断工件合格,通知设备,工件按合格方式放行工件。MES工作完成MES0.3=1,MES合格放行MES0.5=1,MES0.4=0 +///46 X ResetDevice 52 ResetDevice 针对手动工位,无HMI,需要复位设备在MES页面操作。 +///47 X UnloadCompleted 53 UnloadCompleted 暂时保留,项目未使用 +///48 X MachineTime_ReadOver 54 MachineTime_ReadOver 备用 +///49 X Reserved_19 58 Reserved_19 备用 +///50 X FixOK 59 FixOK 手动拧紧工位,单工步螺栓拧紧完成,通知PC读取数据。 +///51 X Reserved_21 61 Reserved_21 备用 +///52 X Reserved_22 62 Reserved_22 备用 +///53 X Reserved_23 63 Reserved_23 备用 +///54 X Reserved_24 64 Reserved_24 备用 +///55 X Reserved_25 65 Reserved_25 备用 +///56 X FixAllow 66 FixAllow "设备工作的必须信号,对于有物料验证的工位,MES验证完成给出此信号,对于无物料验证工位,MES直接给出此信号。" +///57 X FixOver 67 FixOver 用于手动拧紧且有质量数据工位。通知设备当前工步拧紧螺钉工作结束。 +///58 X MatchingCompleted 68 MatchingCompleted 分线上总线,匹配成功是1;不成功是0。 +///59 X Match 69 Match 分线上总线,匹配成功是1;不成功是0。 +///60 X Reserved_2 70 Reserved_2 备用 +///61 X IsAutoGetEngineID 71 IsAutoGetEngineID 自动手动申请工件编号。0是自动方式;1:手动方式。暂时保留,生成流水号方式是在数据库中实现的 +///62 X RepairUplineMES 72 RepairUplineMES 上线清空MOBY(针对上线工位):通知PLC从新开始申请上线流程 +///63 INT EngineTypeID_MES 73 机型代码(MES) MES发动机机型标志(必须MES) +///64 STRING EngineID_MES 74 工件编号(MES) MES发动机编号(必须MES) +///65 STRING EngineType_MES 75 EngineType_MES MES发动机机型(必须MES) +///66 X Reserved_20 76 Reserved_20 备用 +///67 INT ProcessCode 77 ProcessCode 手动拧紧工位:由MES通知PLC拧紧序号 +///68 B OnLineState 79 OnLineState 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线:0正常状态,实现正常功能。1离线:设备脱离MES工作,进入不交互模式。 +///69 INT PartPalletCode 80 托盘号(MES) 托盘编号(B5A) +///70 INT BoltCode 88 BoltCode 手动拧紧工位:指导PLC所用套筒 +///71 INT RepairStatus 93 RepairStatus "0正常件,1返修件。对于上线工位MES给出是正常上线还是返修上线,返修路径" +///72 DInt Reserved_15 110 Reserved_15 备用 +///73 DInt Reserved_16 111 Reserved_16 备用 +///74 B Reserved_17 112 Reserved_17 备用 +///75 INT SPareint1 113 SPareint1 备用int1 +///76 INT SPareint2 114 SPareint2 备用int2 +///77 INT SPareint3 115 SPareint3 备用int3 +///78 STRING Sparestring1 116 Sparestring1 备用字符串1 +///79 STRING Sparestring2 117 Sparestring2 备用字符串2 +///80 X MachineStatusPutOn 1000 机床上电(PLC) 机床上电(必须PLC) +///81 X MachineStatusWorkOn 1001 循环开始(PLC) 循环开始(必须PLC) +///82 X MachineStatusAlarm 1002 设备报警(PLC) 机床故障(必须PLC) +///83 X MachineStatusNoPart 1003 MachineStatusNoPart 上料无件(必须PLC) +///84 X MachineStatusBlock 1004 MachineStatusBlock 下料堵塞(必须PLC) + + +namespace MisDataFunDll +{ + /// + /// 这是变量类型代码的配置,几乎是不变的 + /// 请不要随意修改,为了保证变量版本同一,并且方便维护,请联系发行人修改! + /// 请注意,此修改为全局修改! + /// + public enum EnumTagTypeCodeID + { + /// + /// 工件到位(PLC) + /// 变量类型:Bool + /// 解释:托盘到达工位,并且托盘上有工件。 + /// + WorkStart = 2, + /// + /// + /// + RepairPartStatusPLC = 3, + /// + /// 工位返修字符串 + /// 变量类型:String + /// 解释:工位返修字符串 + /// + RepairPathString = 4, + /// + /// 传递机型(MES) + /// 变量类型:Bool + /// 解释:MES传递总成信息给PLC(上线工位) + /// + EngineTypeGetOverMES = 5, + /// + /// + /// + PartPalletGoOver = 6, + /// + /// + /// + MaterialVerifyOver = 7, + /// + /// + /// + FalseGo = 8, + /// + /// + /// + EngineTypeID = 9, + /// + /// + /// + EngineID = 10, + /// + /// 机型(MES) + /// 变量类型:String + /// + EngineType = 11, + /// + /// + /// + PartPalletStatus = 13, + /// + /// + /// + HeartBeatPLC = 14, + /// + /// + /// + HeartBeatMIS = 15, + /// + /// + /// + TargetTimeRead = 16, + /// + /// + /// + MachineTargetTime = 17, + /// + /// + /// + MachineActualTime = 18, + /// + /// 允许保存(PLC) + /// 变量类型:Bool + /// + MesRead = 19, + /// + /// 保存完成(MES) + /// 变量类型:Bool + /// + MesReadOver = 20, + /// + /// 合格标志(PLC) + /// 变量类型:Int + /// + QualityMask = 21, + /// + /// + /// + PalletInfo = 22, + /// + /// + /// + RepairStatusPLC = 23, + /// + /// 订单号(MES) + /// 变量类型:Int + /// + OrderNo = 24, + /// + /// 库位号(MES) + /// 变量类型:Bool + /// + StorageNo = 25, + /// + /// 允许放行(MES) + /// 变量类型:Bool + /// + AllowPass = 26, + /// + /// + /// + PartLoadFinish = 27, + /// + /// + /// + Reserved_7 = 28, + /// + /// + /// + Reserved_8 = 29, + /// + /// + /// + Reserved_9 = 30, + /// + /// + /// + Reserved_10 = 31, + /// + /// + /// + Reserved_11 = 32, + /// + /// + /// + Reserved_12 = 33, + /// + /// + /// + Reserved_13 = 34, + /// + /// + /// + Reserved_14 = 35, + /// + /// + /// + PLCSPareint1 = 36, + /// + /// + /// + PLCSPareint2 = 37, + /// + /// + /// + PLCSPareint3 = 38, + /// + /// 订单号(PLC) + /// + OrderFormPLC = 39, + /// + /// + /// + PLCSarestring2 = 40, + /// + /// + /// + MarkID = 42, + /// + /// + /// + PartLoad = 43, + /// + /// 传递机型(PLC) + /// 变量类型:Bool + /// + EngineTypeGetOverPLC = 44, + /// + /// + /// + PartLoadOK = 48, + /// + /// + /// + Reserved_18 = 49, + /// + /// + /// + PalletDown = 50, + /// + /// + /// + ConfirmOkGo = 51, + /// + /// + /// + ResetDevice = 52, + /// + /// + /// + UnloadCompleted = 53, + /// + /// + /// + MachineTime_ReadOver = 54, + /// + /// + /// + Reserved_19 = 58, + /// + /// + /// + FixOK = 59, + /// + /// + /// + Reserved_21 = 61, + /// + /// + /// + Reserved_22 = 62, + /// + /// + /// + Reserved_23 = 63, + /// + /// + /// + Reserved_24 = 64, + /// + /// + /// + Reserved_25 = 65, + /// + /// + /// + FixAllow = 66, + /// + /// + /// + FixOver = 67, + /// + /// + /// + MatchingCompleted = 68, + /// + /// + /// + Match = 69, + /// + /// + /// + Reserved_2 = 70, + /// + /// + /// + IsAutoGetEngineID = 71, + /// + /// + /// + RepairUplineMES = 72, + /// + /// 机型代码(MES) + /// 变量类型:Int + /// + EngineTypeID_MES = 73, + /// + /// 工件编号(MES) + /// 变量类型:String + /// + EngineID_MES = 74, + /// + /// + /// + EngineType_MES = 75, + /// + /// + /// + Reserved_20 = 76, + /// + /// + /// + ProcessCode = 77, + /// + /// + /// + OnLineState = 79, + /// + /// 托盘号(MES) + /// 变量类型:Int + /// + PartPalletCode = 80, + /// + /// + /// + BoltCode = 88, + /// + /// + /// + RepairStatus = 93, + /// + /// + /// + Reserved_15 = 110, + /// + /// + /// + Reserved_16 = 111, + /// + /// + /// + Reserved_17 = 112, + /// + /// + /// + SPareint1 = 113, + /// + /// + /// + SPareint2 = 114, + /// + /// + /// + /// + /// MES订单号 + /// + OrdeFormMES = 116, + /// + /// + /// + Sparestring2 = 117, + /// + /// 机床上电(PLC) + /// 变量类型:Bool + /// + MachineStatusPutOn = 1000, + /// + /// 循环开始(PLC) + /// 变量类型:Bool + /// + MachineStatusWorkOn = 1001, + /// + /// 设备报警(PLC) + /// 变量类型:Bool + /// + MachineStatusAlarm = 1002, + /// + /// 上料无件(PLC) + /// 变量类型:Bool + /// + MachineStatusNoPart = 1003, + /// + /// 下料堵塞(PLC) + /// 变量类型:Bool + /// + MachineStatusBlock = 1004, + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/Reflection.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/Reflection.cs new file mode 100644 index 0000000..d7bd835 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/Reflection.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Web; +using System.ComponentModel; + +namespace MisDataFunDll +{ + /// + /// + /// + public class Reflection + { + /// + /// 通过反射调用动态连接库方法 + /// + /// 程序集(DLL) + /// 命名空间名称,如果无命名空间写“” + /// 类名 + /// 方法名 + /// 函数参数数组 + static public string ReflectionMethod(Assembly assembly, string Namespace, string Classname, string Method, object[] Paramsters) + { + try + { + + Type t; + //类 + if (Namespace == "") + { + t = assembly.GetType(Classname); + } + else + { + t = assembly.GetType(Namespace + "." + Classname); + } + if (t == null) + { + return "类不存在"; + } + ////方法 + MethodInfo mi = t.GetMethod(Method); //获取方法 + if (mi == null) + { + return "方法不存在"; + } + ParameterInfo[] paramsInfo = mi.GetParameters(); + for (int i = 0; i < paramsInfo.Length; i++) + { + Type tType = paramsInfo[i].ParameterType; + //改变参数类型 + Paramsters[i]= SD_ChanageType(Paramsters[i],tType); + } + /// 建一个实例化的类 + object instanceObject = Activator.CreateInstance(t); + mi.Invoke(instanceObject, Paramsters); + return "ok"; + } + catch(Exception err) + { + return err.ToString(); + + } + + } + /// + /// + /// + /// + /// + /// + public static object SD_ChanageType(object value, Type convertsionType) + { + //判断convertsionType类型是否为泛型,因为nullable是泛型类, + if (convertsionType.IsGenericType && + //判断convertsionType是否为nullable泛型类 + convertsionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) + { + if (value == null || value.ToString().Length == 0) + { + return null; + } + + //如果convertsionType为nullable类,声明一个NullableConverter类,该类提供从Nullable类到基础基元类型的转换 + NullableConverter nullableConverter = new NullableConverter(convertsionType); + //将convertsionType转换为nullable对的基础基元类型 + convertsionType = nullableConverter.UnderlyingType; + } + return Convert.ChangeType(value, convertsionType); + } + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/LoadTagTypeCodeID.cs b/Common/09MesDataFunction/MesDataFunction/LoadTagTypeCodeID.cs new file mode 100644 index 0000000..8418da8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/LoadTagTypeCodeID.cs @@ -0,0 +1,128 @@ +//using BasicData; +//using MesWork; +//using OpcBasic; +using MesServerWork; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static MesServerWork.MIS_BASE; + +namespace MesDataFunction +{ + public class LoadTagTypeCodeID + { + + + public static void Load(string path) + { + MIS_BASE.hashtable_TagType = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeTagName = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_MesTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_WebTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeDataType = new NameValueCollection(); + + var dt = NPOITest.ExeclHelper.ExcelToDataTable(path, "变量类型代码", true); + for (int i = 0; i < dt.Rows.Count; i++) + { + //序号 变量类型 TagTypeDataType TagName 变量类型代码 TagTypeChange MesTagTypeChange WebTagTypeChange 信号点名称 变量类型名称 + + var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString(); + var TagName = dt.Rows[i]["TagName"].ToString(); + var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString(); + var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString(); + var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString(); + var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString(); + + //OpcOperation.hashtable_TagType.Add(TagName, 变量类型代码); + //OpcOperation.hashtable_TagTypeTagName.Add(变量类型代码, TagName); + //OpcOperation.hashtable_TagTypeChange.Add(TagName, TagTypeChange); + //OpcOperation.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange); + //OpcOperation.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange); + //OpcOperation.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType); + if (!MIS_BASE.hashtable_TagType.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagType.Add(TagName, 变量类型代码); + if (!MIS_BASE.hashtable_TagTypeTagName.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeTagName.Add(变量类型代码, TagName); + if (!MIS_BASE.hashtable_TagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagTypeChange.Add(TagName, TagTypeChange); + if (!MIS_BASE.hashtable_MesTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange); + if (!MIS_BASE.hashtable_WebTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange); + if (!MIS_BASE.hashtable_TagTypeDataType.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType); + } + HashtableList.hashtable_TagTypeTagName_Temp = new Hashtable(); + foreach (string key in MIS_BASE.hashtable_TagTypeTagName.Keys) + { + HashtableList.hashtable_TagTypeTagName_Temp.Add(key, MIS_BASE.hashtable_TagTypeTagName[key]); + } + HashtableList.hashtable_TagTypeDataType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagTypeDataType.Keys) + { + HashtableList.hashtable_TagTypeDataType_Temp.Add(key, MIS_BASE.hashtable_TagTypeDataType[key]); + } + HashtableList.hashtable_TagType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagType.Keys) + { + HashtableList.hashtable_TagType_Temp.Add(key, MIS_BASE.hashtable_TagType[key]); + } + } + + public static void Load(DataTable dt) + { + MIS_BASE.hashtable_TagType = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeTagName = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_MesTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_WebTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeDataType = new NameValueCollection(); + + for (int i = 0; i < dt.Rows.Count; i++) + { + //序号 变量类型 TagTypeDataType TagName 变量类型代码 TagTypeChange MesTagTypeChange WebTagTypeChange 信号点名称 变量类型名称 + var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString(); + var TagName = dt.Rows[i]["TagName"].ToString(); + var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString(); + var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString(); + var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString(); + var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString(); + if (!MIS_BASE.hashtable_TagType.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagType.Add(TagName, 变量类型代码); + if (!MIS_BASE.hashtable_TagTypeTagName.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeTagName.Add(变量类型代码, TagName); + if (!MIS_BASE.hashtable_TagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagTypeChange.Add(TagName, TagTypeChange); + if (!MIS_BASE.hashtable_MesTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange); + if (!MIS_BASE.hashtable_WebTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange); + if (!MIS_BASE.hashtable_TagTypeDataType.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType); + } + HashtableList.hashtable_TagTypeTagName_Temp = new Hashtable(); + foreach (string key in MIS_BASE.hashtable_TagTypeTagName.Keys) + { + HashtableList.hashtable_TagTypeTagName_Temp.Add(key, MIS_BASE.hashtable_TagTypeTagName[key]); + } + HashtableList.hashtable_TagTypeDataType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagTypeDataType.Keys) + { + HashtableList.hashtable_TagTypeDataType_Temp.Add(key, MIS_BASE.hashtable_TagTypeDataType[key]); + } + HashtableList.hashtable_TagType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagType.Keys) + { + HashtableList.hashtable_TagType_Temp.Add(key, MIS_BASE.hashtable_TagType[key]); + } + } + + } + +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/InitTagValueListData.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/InitTagValueListData.cs new file mode 100644 index 0000000..e4cc6aa --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/InitTagValueListData.cs @@ -0,0 +1,83 @@ +//using DataLinkMesWork; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +//using SystemFramework; + +namespace MesServerWork +{ + public class InitTagValueListData + { + public InitTagValueListData() + { + DataTable dt = ReadMesServerData(); + + InitMesReadTagKey(); + initAllItemValue(dt); + } + + DataTable ReadMesServerData() + { + return null;// MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 监控属性代码 = '{1}'").CopyToDataTable(); + } + + void InitMesReadTagKey() + { + DataTable dt = null;// MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=19 and 监控属性代码 = '{1}'").CopyToDataTable(); ; + + for (int i = 0; i < dt.Rows.Count; i++) + { + if (MesReadTagKey_Hash.ContainsKey(dt.Rows[i]["工位号"].ToString())) + { + MesReadTagKey_Hash[dt.Rows[i]["工位号"].ToString()] = dt.Rows[i]["TagID"].ToString(); + } + else + { + MesReadTagKey_Hash.Add(dt.Rows[i]["工位号"].ToString(), dt.Rows[i]["TagID"].ToString()); + } + + } + + } + void initAllItemValue(DataTable dt) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + if (ItemValue_Hash.ContainsKey(dt.Rows[i]["TagID"])) + { + if (Convert.ToInt32(dt.Rows[i]["列位置"]) != 0) + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString() + "(" + dt.Rows[i]["列位置"].ToString() + ")"; + } + else + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString(); + } + + } + else + { + if (Convert.ToInt32(dt.Rows[i]["列位置"]) != 0) + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString() + "(" + dt.Rows[i]["列位置"].ToString() + ")"; + } + else + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString(); + } + } + + } + + + } + + + public static Hashtable MesReadTagKey_Hash = new Hashtable(); + public static Hashtable ItemValue_Hash = new Hashtable(); + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Barcode.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Barcode.cs new file mode 100644 index 0000000..1df2dfe --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Barcode.cs @@ -0,0 +1,95 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerBarcode = new object(); + + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + static public void Barcode(object e) + { + lock (lockerBarcode) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (EngineGetOver_PLC_NextWorkStep && IsSuccess) + { + if (IsAllowWork == 1) + { + BaseDataSystemMES.Material_Insert(OpName, 1); + + //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, OpName); + // return; + //} + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + } + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.ConfirmOkGo.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.ConfirmOkGo.cs new file mode 100644 index 0000000..26b9cfa --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.ConfirmOkGo.cs @@ -0,0 +1,47 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerConfirmOkGo = new object(); + + static public void ConfirmOkGo(object e) + { + lock (lockerConfirmOkGo) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.EngineTypeGetOver_PLC_Work.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.EngineTypeGetOver_PLC_Work.cs new file mode 100644 index 0000000..670819c --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.EngineTypeGetOver_PLC_Work.cs @@ -0,0 +1,139 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerEngineTypeGetOver_PLC_Work = new object(); + + + static public void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + lock (lockerEngineTypeGetOver_PLC_Work) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + //string OrderForm = "";//订单号 + DataTable dt; + + if (EngineTypeID <= 0) + { + AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //第一步,查询订单号,保存机型、机型代码、总成号、托盘号、订单号到数据库 + BaseDataSystemMES.GetEngineID_Select(OpName, EngineID, out dt); + if (dt != null && dt.Rows.Count > 0) + { + OrderForm = Convert.ToString(dt.Rows[0]["订单号"]); + } + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, OrderForm, EngineTypeID, EngineType, EngineID, PartPallet_Code, 0, 0, ""); + SaveMobyMessage(OpName, EngineTypeID, EngineType, EngineID, OrderForm); + + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + //通知web显示 + Sendmessage("5123", "1111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + SendInfomation("NgGO", "1", OpName);//显示不合格标志 + return; + } + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + + + } + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + static private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + static private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.FalseGO.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.FalseGO.cs new file mode 100644 index 0000000..92ee314 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.FalseGO.cs @@ -0,0 +1,48 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerFalseGO = new object(); + + + static public void FalseGO(object e) + { + lock (lockerConfirmOkGo) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + //BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Material_Insert.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Material_Insert.cs new file mode 100644 index 0000000..fc78eb6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Material_Insert.cs @@ -0,0 +1,59 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerMaterial_Insert = new object(); + + static public void Material_Insert(string OpName) + { + lock (lockerMaterial_Insert) + { + try + { + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + int IsAllowWork; + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (EngineGetOver_PLC_NextWorkStep&&IsAllowWork == 1) + { + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.MesReadOver.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.MesReadOver.cs new file mode 100644 index 0000000..260cd1a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.MesReadOver.cs @@ -0,0 +1,66 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerMesReadOver = new object(); + + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + static public void MesReadOver(object e) + { + lock (lockerMesReadOver) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + var tagValue = msgEvent.TagValue.ToString(); + + if (tagValue == "1" | tagValue.ToLower() == "true") + { + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + if (qualityMask == 1)//全部OK,给出合格放行 + { + //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + MIS_BASE.Write_ConfirmOkGo(OpName, true); + //MIS_BASE.Write_FalseGO(OpName, false); + } + else + { + //MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FalseGO(OpName, true); + } + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.SendMessage.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.SendMessage.cs new file mode 100644 index 0000000..92bfe0a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.SendMessage.cs @@ -0,0 +1,162 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + + /// + /// 发送提示消息 + /// + /// + static private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + static public string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + static private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + static void Sendmessage(string MessageNumm, string Value, string OpName) + { + for (int i = 0; i < MessageNumm.Length; i++) + { + Sendmessage(MessageNumm[i], Value[i].ToString(), OpName); + + } + } + /// + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + static string Sendmessage(char Num, string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + ///// + ///// 向WEB发送信息(value为字符串) + ///// + ///// 消息种类 + ///// 消息内容 + ///// 工位号 + //string SendInfomation(string Command, string Value, string OpName) + //{ + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // return AsyncSendMessage(SendMessage); + //} + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WebSubmit.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WebSubmit.cs new file mode 100644 index 0000000..e472489 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WebSubmit.cs @@ -0,0 +1,282 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using System.Threading; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerWebSubmit = new object(); + + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + static public void WebSubmit(object e) + { + lock (lockerWebSubmit) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName, 0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + static public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + static private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + static private void InitializeSingalToWeb(string Opname) + { + + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + + if (S_EngineGetOver == true) + { + + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("5123", "1111", Opname); + } + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WorkStart.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WorkStart.cs new file mode 100644 index 0000000..ec1d4c4 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WorkStart.cs @@ -0,0 +1,45 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +////using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using System.Threading; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerWorkStart = new object(); + + + + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + static private void WorkStart(object e) + { + lock (lockerWorkStart) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.TagID.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.TagID.cs new file mode 100644 index 0000000..bc3387a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.TagID.cs @@ -0,0 +1,805 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +using MisDataFunDll; +//using MesWork; + + +namespace MesServerWork +{ + public partial class MIS_BASE // : Form + { + /// + /// 全部数据列表 + /// + public static DataTable BasicDataTagValue; + /// + /// MES_基本数据_测量范围 + /// + public static DataTable BasicDataTagValueUpDown; + /// + /// 是否通过监控系统保存数据 + /// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + /// + static public Hashtable hashtable_tagTable_OpName_SaveData; + /// + /// 变量代码与列位置 + /// + static public Hashtable hashtable_tagTable_TagID_TagOrderBy; + /// + /// 变量代码与变量排序 + /// + static public Hashtable hashtable_tagTable_TagID_TagItemOrderBy; + /// + /// 变量代码与变量特点 + /// 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志 + /// + static public Hashtable hashtable_tagTable_TagID_TagProperty; + /// + /// 发动机类型转换表 + /// SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码 + /// + public static Hashtable hashtable_EngineTypeID; + + /// + /// 工位号与工位上下线类型 + /// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + /// (5分线上线 总线)(6分线上线 分线) + /// + public static Hashtable hashtableOpName_OpType; + /// + /// 工位号与大屏幕代码 + /// 对应LED大屏幕(1,2,3,4) + /// + public static Hashtable hashtableOpName_LedID; + /// + /// 大屏幕显示产量端口(41104) + /// + public static Hashtable hashtableOpName_LedID_Port; + + /// + /// 大屏幕显示Andon大屏幕代码 1 + /// + public static Hashtable hashtableOpName_AndonID; + + /// + /// 大屏幕显示Andon端口 (41105) + /// + public static Hashtable hashtableOpName_AndonID_Port; + + + /// + /// 是否有打印机(0,1) + /// + public static Hashtable hashtableOpName_IsPrinter; + + /// + /// 打印机通讯端口 + /// + public static Hashtable hashtableOpName_IsPrinter_Port; + + + + /// + /// 工位号与目标循环时间 + /// + public static Hashtable hashtableOpName_TargetTime; + /// + /// 工位号与线体类型 + /// + public static Hashtable hashtableOpName_LineType; + /// + /// 是否有工位计算机 + /// + public static Hashtable hashtableOpName_IsHaveComputer; + /// + /// 变量名称 + /// + public static Hashtable hashtableTagID_TagName; + /// + /// 工位号 + /// + public static Hashtable hashtableTagID_OpName; + /// + /// 数据来源 + /// + public static Hashtable hashtableTagID_OpNameFrom; + + /// + /// 工位名称 + /// + static Hashtable hashtableTagID_OpName_Name; + /// + /// 测量位置 + /// + public static Hashtable hashtableTagID_ShaftID; + /// + /// 测量项目 + /// + public static Hashtable hashtableTagID_ItemVale; + /// + /// 变量代码与变量类型 + /// + public static Hashtable hashtable_tagTable_TagID_TagTypeID_All; + + + + /// + ///工位号与机床状态 + /// [测量数据机床状态] + /// + public static Hashtable m_MachineStatus_OpName; + /// + ///工位号与工件离开 1->0 =0 无工件或工件离开 + ///工位号与工件到位 0->1 =1 有工件或工件到达 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_WorkStart_OpName; + + /// + ///工位号与工件到位时间 + ///工位号与工件到位 0->1 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_WorkStart_OpName_Time; + + /// + ///工位号与工件到位时间 + ///工位号与工件到位 0->1,零件运动方向 + /// + public static Hashtable m_WorkStart_OpName_PartMoveDirection; + + + /// + ///工位号与发动机号 + /// + public static Hashtable m_EngineTrace_OpName; + /// + ///工位号与发动机号_时间 + /// + public static Hashtable m_EngineTrace_OpName_Time; + /// + ///工位号与合格标志 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_QualityMask_OpName; + + /// + ///工位号与机型 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_EngineNumberType_OpName; + /// + ///工位号与发动机号 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_EngineNumber_OpName; + + /// + ///工位号与订单号 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_OrderForm_OpName; + /// + ///工位号与操作者工号 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_OperatorCode_OpName; + + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位 + /// 全部测量数据的测量工位的数据来源 + /// 全部测量数据的测量工位的数据来源的测量变量 + /// + public static Hashtable hashtable_QualityData_GoodBad_MIS_OpName; + /// + /// 列位置 + /// + public static Hashtable hashtable_QualityData_GoodBad_Index; + + /// + /// MesServerCode + /// + public static Hashtable hashtable_MesServerCode; + /// + /// MesDll + /// + public static Hashtable hashtable_MesDll; + /// + /// 各个工位是否允许工作 + /// + public static Hashtable hashtable_IsAllowWork; + + /// + /// 返修工位是否需要强制合格放行 + /// //20141104 ljl + /// + public static Hashtable hashtable_IsConfirmOkGo; + + + /// + /// 工步属性哈西表 + /// + public static Hashtable hashtable_workStepProperty; + + /// + /// 工作顺序哈西表 + /// + public static Hashtable hashtable_WorkGroupIndex; + + /// + /// 返修工位哈西表 + /// + public static Hashtable hashtable_OpNameRepair; + + /// + /// 记录工件到位的发动机机型代码 + /// + public static Hashtable hashtable_EngineGetOver_EngineTypeID; + /// + /// 记录工件到位的发动机机型 + /// + public static Hashtable hashtable_EngineGetOver_EngineType; + /// + /// 记录工件到位的发动机号 + /// + public static Hashtable hashtable_EngineGetOver_EngineID; + /// + /// 记录工件到位的订单号 + /// + public static Hashtable hashtable_EngineGetOver_OrderForm; + + /// + /// 拧紧/压装过程中的合格标志 + /// + public static Hashtable hashtable_QualityMesRead; + + + /// + /// 物料检测哈希表 + /// + public static Hashtable hashtable_CheckMaterial; + + /// + /// 托盘状态哈希表 + /// + public static Hashtable hashtable_PalletInfo; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床上电开始时间 + ///机床上电产生 0->1 + ///机床上电解除 1->0 + /// + public static Hashtable m_MachineStatusPutOn_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位循环开始 开始时间 + ///循环开始产生 0->1 + ///循环开始解除 1->0 + /// + public static Hashtable m_MachineStatusWorkOn_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床故障开始时间 + ///机床故障产生 0->1 + ///机床故障解除 1->0 + /// + public static Hashtable m_MachineStatusAlarm_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位上料无件开始时间 + ///上料无件产生 0->1 + ///上料无件解除 1->0 + /// + public static Hashtable m_MachineStatusNoPart_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位下料堵塞开始时间 + ///下料堵塞产生 0->1 + ///下料堵塞解除 1->0 + /// + public static Hashtable m_MachineStatusBlock_OpName_Time; + + /// + ///工位号与托盘离开 1->0 + ///工位号与托盘到位 0->1 + ///[测量数据_监控系统_托盘到位] + /// + public static Hashtable m_PartPalletStatus_OpName; + /// + ///工位号与托盘离开 1->0 + ///工位号与托盘到位 0->1 + ///[测量数据_监控系统_托盘到位] + /// + public static Hashtable m_PartPalletStatus_OpName_Time; + /// + /// 托盘到位(1)托盘离开(0) (DBX101.7)(13) + /// + /// + /// + + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床上电开始时间 + ///机床上电产生 0->1 + ///机床上电解除 1->0 + /// + public static Hashtable m_MachineStatusPutOn_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位循环开始 开始时间 + ///循环开始产生 0->1 + ///循环开始解除 1->0 + /// + public static Hashtable m_MachineStatusWorkOn_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床故障开始时间 + ///机床故障产生 0->1 + ///机床故障解除 1->0 + /// + public static Hashtable m_MachineStatusAlarm_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位上料无件开始时间 + ///上料无件产生 0->1 + ///上料无件解除 1->0 + /// + public static Hashtable m_MachineStatusNoPart_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位下料堵塞开始时间 + ///下料堵塞产生 0->1 + ///下料堵塞解除 1->0 + /// + public static Hashtable m_MachineStatusBlock_OpName; + + public static NameValueCollection hashtable_TagTypeDataType ; + public static NameValueCollection hashtable_TagType; + /// + /// 托盘代码(DBB86)(80) + /// + /// + /// + + /// + /// 创建MesServerCode哈西表 + /// + static public void InitHashtable_MesServerCode() + { + hashtable_MesServerCode = new Hashtable(); + hashtable_IsAllowWork = new Hashtable(); + hashtable_WorkGroupIndex = new Hashtable(); + hashtable_EngineGetOver_EngineTypeID = new Hashtable(); + hashtable_EngineGetOver_EngineType = new Hashtable(); + hashtable_EngineGetOver_EngineID = new Hashtable(); + hashtable_EngineGetOver_OrderForm = new Hashtable(); + hashtable_QualityMesRead = new Hashtable(); + hashtable_CheckMaterial = new Hashtable(); + hashtable_PalletInfo = new Hashtable(); + hashtable_IsConfirmOkGo = new Hashtable(); + hashtable_MesDll = new Hashtable(); + + string OpName; + string MesServerCode; + string MesDll; + string workStepProperty; + string OpNameRepair; + DataTable dt; + dt = MisDataFun.GetMesServerCodeFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + MesServerCode = dt.Rows[i]["MesServerCode"].ToString(); + MesDll = dt.Rows[i]["MesDll"].ToString(); + hashtable_MesDll.Add(OpName, MesDll); + hashtable_MesServerCode.Add(OpName, MesServerCode); + hashtable_IsAllowWork.Add(OpName, 1); + hashtable_IsConfirmOkGo.Add(OpName, 0);//20141104 ljl + hashtable_PalletInfo.Add(OpName, 0);//20141104 ljl + hashtable_WorkGroupIndex.Add(OpName, 1); + hashtable_EngineGetOver_EngineTypeID.Add(OpName, 0); + hashtable_EngineGetOver_EngineType.Add(OpName, ""); + hashtable_EngineGetOver_EngineID.Add(OpName, ""); + hashtable_EngineGetOver_OrderForm.Add(OpName, ""); + hashtable_QualityMesRead.Add(OpName, 0); + hashtable_CheckMaterial.Add(OpName, new bool[16]); + } + } + HashtableList.hashtable_MesServerCode_Temp = hashtable_MesServerCode; + HashtableList.hashtable_MesDll_Temp = hashtable_MesDll; + + HashtableList.hashtable_EngineGetOver_EngineID_Temp = hashtable_EngineGetOver_EngineID; + HashtableList.hashtable_EngineGetOver_EngineTypeID_Temp = hashtable_EngineGetOver_EngineTypeID; + HashtableList.hashtable_EngineGetOver_EngineType_Temp = hashtable_EngineGetOver_EngineType; + HashtableList.hashtable_EngineGetOver_OrderForm_Temp = hashtable_EngineGetOver_OrderForm; + + //初始化工步属性 + hashtable_workStepProperty = new Hashtable(); + dt = MisDataFun.GetworkStepPropertyFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + workStepProperty = dt.Rows[i]["工步属性"].ToString(); + hashtable_workStepProperty.Add(OpName, workStepProperty); + } + } + + //返修工位 + hashtable_OpNameRepair = new Hashtable(); + dt = MisDataFun.GetOpNameRepairFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + OpNameRepair = dt.Rows[i]["返修工位号"].ToString(); + hashtable_OpNameRepair.Add(OpName, OpNameRepair); + } + } + + HashtableList.hashtable_OpNameRepair_Temp = hashtable_OpNameRepair; + HashtableList.hashtable_workStepProperty_Temp = hashtable_workStepProperty; + HashtableList.hashtable_QualityMesRead_Temp = hashtable_QualityMesRead; + HashtableList.hashtable_IsAllowWork_Temp = hashtable_IsAllowWork; + HashtableList.hashtable_WorkGroupIndex_Temp = hashtable_WorkGroupIndex; + + + + } + + + /// + /// 创建合格标志哈西表 + /// + private static void InitHashtable_QualityData_GoodBad() + { + //列位置 + string index; + // + int tagID; + DataTable dt ; + dt = MisDataFun.BaseData_tagTable_All_B5A(); + + hashtable_QualityData_GoodBad_Index = new Hashtable(); + for (int i = 0; i < dt.Rows.Count; i++) + { + tagID = Convert.ToInt32(dt.Rows[i]["TagID"]); + index = (dt.Rows[i]["列位置"]).ToString(); + hashtable_QualityData_GoodBad_Index.Add(tagID, index); + } + + hashtable_EngineTypeID = new Hashtable(); + dt = MisDataFun.BaseData_tagTable_QualityData_EngineTypeID(); + for (int i = 0; i < dt.Rows.Count; i++) + { + tagID = Convert.ToInt32(dt.Rows[i]["发动机机型代码"]); + index = (dt.Rows[i]["ID"]).ToString(); + hashtable_EngineTypeID.Add(tagID, index); + } + //工位号 + DataTable dt_OpName; + //工位号数据来源 + DataTable dt_OpNameFrom; + //数据来源对应的TagID + DataTable dt_OpNameTagID; + string opName; + string opNameFrom; + hashtable_QualityData_GoodBad_MIS_OpName = new Hashtable(); + // 测量合格标志 + // 全部测量数据的测量工位的数据来源 + Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom; + + // 测量合格标志 + // 全部测量数据的测量工位的数据来源的测量变量 + Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID; + dt_OpName = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName_B5A(); + if (dt_OpName != null) + { + //有不合格标志的测量工位 + for (int i = 0; i < dt_OpName.Rows.Count; i++) + { + //有不合格标志的测量工位 对应的 数据来源工位号 + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom = new Hashtable(); + opName = dt_OpName.Rows[i]["工位号"].ToString(); + dt_OpNameFrom = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName); + if (dt_OpNameFrom != null) + { + for (int j = 0; j < dt_OpNameFrom.Rows.Count; j++) + { + opNameFrom = dt_OpNameFrom.Rows[j]["数据来源"].ToString(); + dt_OpNameTagID = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName, opNameFrom); + // + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID = new Hashtable(); + if (dt_OpNameTagID != null) + { + for (int k = 0; k < dt_OpNameTagID.Rows.Count; k++) + { + tagID = Convert.ToInt32(dt_OpNameTagID.Rows[k]["TagID"]); + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID.Add(tagID, tagID); + } + } + tagID = Convert.ToInt32(dt_OpNameFrom.Rows[j]["TagID"]); + //全部测量数据的测量工位的数据来源的测量变量 + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom.Add(tagID, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID); + } + } + hashtable_QualityData_GoodBad_MIS_OpName.Add(opName, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom); + } + } + } + + + public static NameValueCollection hashtable_TagTypeID_OpName_ToTagID; + + /// + /// 变量代码与其他字段的对应关系 + /// + public static void InitHashtableTagID() + { + //变量代码 + string tagID; + //变量名称 + string tagName; + //工位号 + string opNmae; + //测量位置 + string shaftID; + //测量项目 + string itemVale; + //变量排序 + int tagItemOrderBy; + //变量特点 + // 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志 + int tagProperty; + //列位置 + int tagOrderBy; + InitHashtable_QualityData_GoodBad(); + //MesServerCode哈希表创建 + InitHashtable_MesServerCode(); + //列位置 + hashtable_tagTable_TagID_TagOrderBy = new Hashtable(); + // 变量代码与变量排序 + hashtable_tagTable_TagID_TagItemOrderBy = new Hashtable(); + // 变量代码与变量特点 + // 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志 + hashtable_tagTable_TagID_TagProperty = new Hashtable(); + hashtable_tagTable_OpName_SaveData = new Hashtable(); + //工位号与机床状态 + //[测量数据发动机在线状态] + m_MachineStatus_OpName = new Hashtable(); + ////工位号与工件离开 0 + ////工位号与工件到位 1 + ////[测量数据发动机在线状态] + //m_WorkStart_OpName = new Hashtable(); + ////工位号与工件到位时间 + ////工位号与工件到位 0->1 + ////[测量数据发动机在线状态] + //m_WorkStart_OpName_Time = new Hashtable(); + //工位号与发动机号 + //[测量数据发动机在线状态] + m_EngineTrace_OpName = new Hashtable(); + m_EngineTrace_OpName_Time = new Hashtable(); + //工位号与合格标志 + //[测量数据发动机在线状态] + m_QualityMask_OpName = new Hashtable(); + //工位号与目标循环时间 + hashtableOpName_TargetTime = new Hashtable(); + //工位号与线体类型 + hashtableOpName_LineType = new Hashtable(); + //是否有工位计算机 + hashtableOpName_IsHaveComputer = new Hashtable(); + + //工位号与机型 + //[测量数据发动机在线状态] + m_EngineNumberType_OpName = new Hashtable(); + //工位号与发动机号 + //[测量数据发动机在线状态] + m_EngineNumber_OpName = new Hashtable(); + //工位号与订单号 + //[测量数据发动机在线状态] + m_OrderForm_OpName = new Hashtable(); + //工位号与操作者工号 + //[测量数据发动机在线状态] + m_OperatorCode_OpName = new Hashtable(); + + + // + // 变量名称 + // + hashtableTagID_TagName = new Hashtable(); + // + // 工位号 + // + hashtableTagID_OpName = new Hashtable(); + // + // 数据来源 + // + hashtableTagID_OpNameFrom = new Hashtable(); + // + // 工位名称 + // + hashtableTagID_OpName_Name = new Hashtable(); + // + // 测量位置 + // + hashtableTagID_ShaftID = new Hashtable(); + // + // 测量项目 + // + hashtableTagID_ItemVale = new Hashtable(); + + hashtable_tagTable_TagID_TagTypeID_All = new Hashtable(); + + // 工位号与工位上下线类型 + // (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + // (5 分线上线 总线) (6 分线上线 总线) + hashtableOpName_OpType = new Hashtable(); + // 工位号与大屏幕代码 + // 对应LED大屏幕(1,2,3,4) + hashtableOpName_LedID = new Hashtable(); + + + + + // 大屏幕显示产量端口(41104) + hashtableOpName_LedID_Port = new Hashtable(); + // 大屏幕显示Andon大屏幕代码 1 + hashtableOpName_AndonID = new Hashtable(); + // 大屏幕显示Andon端口 (41105) + hashtableOpName_AndonID_Port = new Hashtable(); + // 是否有打印机(0,1) + hashtableOpName_IsPrinter = new Hashtable(); + // 打印机通讯端口 (缸盖打印机 41101) (发动机上线打印机 41102) (发动机下线打印机 41103) + hashtableOpName_IsPrinter_Port = new Hashtable(); + + m_WorkStart_OpName_Time = new Hashtable(); + m_WorkStart_OpName = new Hashtable(); + + + m_MachineStatusPutOn_OpName_Time = new Hashtable(); + m_MachineStatusPutOn_OpName = new Hashtable(); + m_MachineStatusWorkOn_OpName_Time = new Hashtable(); + m_MachineStatusWorkOn_OpName = new Hashtable(); + m_MachineStatusAlarm_OpName_Time = new Hashtable(); + m_MachineStatusAlarm_OpName = new Hashtable(); + m_MachineStatusNoPart_OpName_Time = new Hashtable(); + m_MachineStatusNoPart_OpName = new Hashtable(); + m_MachineStatusBlock_OpName_Time = new Hashtable(); + m_MachineStatusBlock_OpName = new Hashtable(); + + + + + m_WorkStart_OpName_PartMoveDirection = new Hashtable(); + m_PartPalletStatus_OpName_Time = new Hashtable(); + m_PartPalletStatus_OpName = new Hashtable(); + + hashtable_TagTypeID_OpName_ToTagID = new NameValueCollection(); + + + + DataTable dt; + DateTime dateTime; + dateTime = DateTime.Now; + dt = MisDataFun.BaseData_tagTable_All(); + + //变量类型代码 + int TagTypeID; + for (int i = 0; i < dt.Rows.Count; i++) + { + tagID = dt.Rows[i]["TagID"].ToString (); + tagName = Convert.ToString(dt.Rows[i]["TagName"]); + opNmae = Convert.ToString(dt.Rows[i]["工位号"]); + shaftID = Convert.ToString(dt.Rows[i]["测量位置"]); + itemVale = Convert.ToString(dt.Rows[i]["测量项目"]); + TagTypeID = Convert.ToInt32(dt.Rows[i]["变量类型代码"]); + tagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]); + tagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]); + tagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]); + + hashtableTagID_TagName.Add(tagID, tagName); + hashtableTagID_OpName.Add(tagID, opNmae); + hashtableTagID_ShaftID.Add(tagID, shaftID); + hashtableTagID_ItemVale.Add(tagID, itemVale);//列位置 + hashtable_tagTable_TagID_TagTypeID_All.Add(tagID, TagTypeID); + hashtable_tagTable_TagID_TagItemOrderBy.Add(tagID, tagItemOrderBy); + hashtable_tagTable_TagID_TagProperty.Add(tagID, tagProperty); + hashtable_tagTable_TagID_TagOrderBy.Add(tagID, tagOrderBy); + + + } + dt = MisDataFun.BaseData_tagTable_OpName(); + for (int i = 0; i < dt.Rows.Count; i++) + { + //是否通过监控系统保存数据 + // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + hashtable_tagTable_OpName_SaveData.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否通过监控系统保存数据"])); + + hashtableOpName_TargetTime.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["目标循环时间"])); + hashtableOpName_LineType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["线体类型"])); + hashtableOpName_IsHaveComputer.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["是否有工位计算机"])); + //用于LED显示 + // [MES_计划BOM_工位与名称] + // 工位上下线类型 + //(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + hashtableOpName_OpType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["工位上下线类型"])); + hashtableOpName_LedID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕代码"])); + m_WorkStart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_WorkStart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + + + m_MachineStatusPutOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusPutOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusWorkOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusWorkOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusAlarm_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusAlarm_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusNoPart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusNoPart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusBlock_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusBlock_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + + + + m_WorkStart_OpName_PartMoveDirection.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + + + m_PartPalletStatus_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_PartPalletStatus_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + try + { + hashtableOpName_LedID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示产量端口"])); + } + catch { } + try + { + hashtableOpName_AndonID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon大屏幕代码"])); + } + catch { } + try + { + hashtableOpName_AndonID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon端口"])); + } + catch { } + try { hashtableOpName_IsPrinter.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否有打印机"])); } + catch { } + try + { + hashtableOpName_IsPrinter_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["打印机通讯端口"])); + } + catch { } + } + + + //20170310 CLB新加 + dt = MisDataFun.BaseData_tagTable_OpcServerMES_ALL_CF(); + for (int i = 0; i < dt.Rows.Count; i++) + { + try + { + hashtable_TagTypeID_OpName_ToTagID.Add(Convert.ToString(dt.Rows[i]["工位号"]) + "_" + Convert.ToString(dt.Rows[i]["变量类型代码"]), Convert.ToString(dt.Rows[i]["TagID"])); + //hashtable_TagTypeID_OpName_ToTagID; + } + catch(Exception err) + { + + } + } + + + + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.cs new file mode 100644 index 0000000..19cfd3a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.cs @@ -0,0 +1,91 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +using MisDataFunDll; +//using MesWork; + + +namespace MesServerWork +{ + public partial class MIS_BASE // : Form + { + public class HashtableList + { + /// + /// MesServerCode + /// + static public Hashtable hashtable_MesServerCode_Temp; + /// + /// MesDll + /// + static public Hashtable hashtable_MesDll_Temp; + static public NameValueCollection hashtable_TagTypeDataType_Temp; + static public NameValueCollection hashtable_TagType_Temp; + static public Hashtable hashtable_TagTypeTagName_Temp; + + static public Hashtable hashtable_EngineGetOver_EngineTypeID_Temp; + static public Hashtable hashtable_EngineGetOver_EngineType_Temp; + static public Hashtable hashtable_EngineGetOver_EngineID_Temp; + static public Hashtable hashtable_EngineGetOver_OrderForm_Temp; + + static public Hashtable hashtable_OpNameRepair_Temp; + + static public Hashtable hashtable_WorkGroupIndex_Temp; + static public Hashtable hashtable_workStepProperty_Temp; + static public Hashtable hashtable_QualityMesRead_Temp; + static public Hashtable hashtable_IsAllowWork_Temp; + /// + /// 工位号与工位上下线类型 + /// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + /// 5 分线上线(总线) 6 分线上线(分线) + /// + static public Hashtable hashtableOpName_OpType_Temp; + + static public Hashtable hashtable_tagTable_OpName_SaveData_Temp; + + + public Hashtable hashtable_tagTable_OpName_SaveData; + + + /// + /// + /// 工位号与工位上下线类型 + /// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + /// 5 分线上线(总线) 6 分线上线(分线) + /// + public Hashtable hashtableOpName_OpType; + public Hashtable hashtable_IsAllowWork; + public Hashtable hashtable_QualityMesRead; + public Hashtable hashtable_workStepProperty; + public Hashtable hashtable_OpNameRepair; + /// + /// MesServerCode + /// + public Hashtable hashtable_MesServerCode; + public Hashtable hashtable_TagTypeTagName; + + /// + /// MesDll + /// + public Hashtable hashtable_MesDll; + public NameValueCollection hashtable_TagTypeDataType; + public NameValueCollection hashtable_TagType; + + + public Hashtable hashtable_EngineGetOver_EngineTypeID; + public Hashtable hashtable_EngineGetOver_EngineType; + public Hashtable hashtable_EngineGetOver_EngineID; + public Hashtable hashtable_EngineGetOver_OrderForm; + + public Hashtable hashtable_WorkGroupIndex; + + public DataTable BasicDataTagValue; + public DataTable BasicDataTagValueUpDown; + public Hashtable hashtable_EngineTypeID; + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Machine.ServicePlan.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Machine.ServicePlan.cs new file mode 100644 index 0000000..61d5684 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Machine.ServicePlan.cs @@ -0,0 +1,98 @@ +using System; +using System.Data; +using System.Windows.Forms; +//using bizFacade; +//using DataLinkMesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + /// + /// 设备保养计划 + /// + /// + /// + /// + public delegate void MachinePlan_Invoke(string OpName, string MachineType, string PlanID); + /// + /// 设备保养计划 + /// + public MachinePlan_Invoke machinePlan_Invoke; + /// + /// 设备保养 + /// + /// + /// 设备保养类型 + /// 工作日历流水号 + public void MachinePlan(string OpName, string MachineType, string PlanID) + { + try + { + string SendMessage; + SendMessage = "MES|MachinePlan|" + OpName + "|" + MachineType + "&" + PlanID; + asyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MachinePlan"); + } + } + + /// + /// 设备保养计划Timer + /// + private Timer timer_Machine; + /// + /// 初始化设备保养计划 + /// + public void InitMachinePlan(MachinePlan_Invoke machinePlan_Invoke) + { + this.machinePlan_Invoke = machinePlan_Invoke; + timer_Machine = new Timer(); + timer_Machine.Interval = 60000;//每隔一分钟查询一次 + timer_Machine.Tick += new EventHandler(timer_Machine_Tick); + timer_Machine.Start(); + } + + /// + /// 分钟调度 + /// + /// + /// + private void timer_Machine_Tick(object sender, EventArgs e) + { + try + { + //if (ApplicationConfig.Is_MachinePlan == 1) + //{ + // DataTable dt; + // string opName; + // string machineType;//保养类型代码 + // string planID;//工作日历流水号 + // BaseDataSystemMES.MachinePlan_Select(out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // for (int i = 0; i < dt.Rows.Count; i++) + // { + // opName = dt.Rows[i]["工位号"].ToString(); + // machineType = dt.Rows[i]["保养类型代码"].ToString(); + // planID = dt.Rows[i]["工作日历流水号"].ToString(); + // BaseDataSystemMES.Rolling_news_Add(opName, opName + "工位有设备保养计划,请相关人员进行保养!!!"); + // BeginInvoke(machinePlan_Invoke, new object[] { opName, machineType, planID }); + // } + // } + // } + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "timer_Machine_Tick"); + } + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Read.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Read.cs new file mode 100644 index 0000000..f768d82 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Read.cs @@ -0,0 +1,1196 @@ + +using MisDataFunDll; +using System; +using SystemFramework; +//using SystemFramework; +//using bizFacade; + +namespace MesServerWork +{ + + public partial class MIS_BASE + { + + + /// + /// 通过TagTypeName读取PLC数据 + /// + /// + /// + static private void Read_TagValueByTagTypeName(string cmd, string opName, out string tagValue) + { + tagValue = "-1"; + int tagTypeID; + try + { + tagTypeID = Convert.ToInt32(MIS_BASE.hashtable_TagType[cmd]); + string msg = "MES|" + tagTypeID.ToString() + "|" + opName + "|" + tagValue; + //tagValue = ChatService.MesReadWhisperMessage(msg); + MIS_BASE.ReadTagValue(tagTypeID, opName, out tagValue); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeName_FUNC;工位号:" + opName + ";命令:" + cmd + ";值:" + tagValue); + } + + } + + /// + /// 通过TagID读取对应值 + /// + /// + /// + public static void Read_TagValueByTagID(string TagID, out object tagValue) + { + tagValue = "0"; + try + { + tagValue = MIS_BASE.ReadPLC(TagID).ToString(); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagID_FUNC"); + } + } + + /// + /// 根据变量类型代码、工位号获得对应值 + /// + /// + /// + /// + public static void Read_TagValueByTagTypeID(int tagTypeID, string opName, out string tagValueStr) + { + tagValueStr = "-1"; + + try + { + MIS_BASE.ReadTagValue(tagTypeID, opName, out tagValueStr); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeID_FUNC"); + } + } + + /// + /// 根据变量类型代码、工位号获得对应值 + /// + /// + /// + /// + public static void Read_TagValueByTagTypeID(int tagTypeID, string opName, out object tagValueStr) + { + tagValueStr = "-1"; + + try + { + tagValueStr = MIS_BASE.ReadPLC(tagTypeID, opName); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeID_FUNC"); + } + } + /// + /// 根据变量类型代码、工位号获得对应值 + /// + /// + /// + /// + public static string Read_TagValueByTagTypeID(int tagTypeID, string opName) + { + string tagValueStr = "-1"; + try + { + MIS_BASE.ReadTagValue(tagTypeID, opName, out tagValueStr); + + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeID_FUNC"); + } + return tagValueStr; + } + + /// + /// 读取数据通过(TagTypeName&opName) + /// + /// + /// + public static void Read_TagTypeName(string cmd, string opName, out string tagValueStr) + { + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + } + + /// + /// 读取数据通过(TagTypeID&opName) + /// + /// + /// + public static void Read_TagTypeID(int tagTypeID, string opName, out string tagValueStr) + { + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + } + + + + + + + /// + /// 订单号(string)(25) + /// + /// + /// + public static void Read_OrderForm(string opName, out string tagValue) + { + int tagTypeID = 39; + tagValue = ""; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValue); + } + /// + /// 总成编号(string)(26) + /// + /// + /// + public static void Read_AssemblyCode(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "AssemblyCode"; + Read_TagValueByTagTypeName(cmd, opName, out tagValue); + //tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + /// + /// 配方号1(dint)(27) + /// + /// + /// + public static void Read_Recipe1(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe1"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + /// + /// 配方号2(dint)(28) + /// + /// + /// + public static void Read_Recipe2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 订单号(string)(116) + /// + /// + /// + public static void Read_OrderForm_MES(string opName, out string tagValue) + { + int tagTypeID = 116; + tagValue = ""; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValue); + //tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + /// + /// 总成编号(string)(62) + /// + /// + /// + public static void Read_AssemblyCode_MES(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "AssemblyCode_MES"; + Read_TagValueByTagTypeName(cmd, opName, out tagValue); + //tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + /// + /// 配方号1(dint)(63) + /// + /// + /// + public static void Read_Recipe1_MES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe1_MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + /// + /// 配方号2(dint)(64) + /// + /// + /// + public static void Read_Recipe2_MES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe2_MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 匹配结果(DBX3.4)(69) + /// 匹配是否成功 + /// + /// + /// + public static void Read_MatchSuccess(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Match"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 是否匹配(DBX3.3)(68) + /// + /// + /// + public static void Read_MatchingCompleted(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "MatchingCompleted"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// MES保存完数据(必须MIS)(X102.2)(20) + /// + /// + /// + public static void Read_MesReadOver(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 20; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 发动机到位(X0.1)(2) + /// + /// + /// + public static void Read_WorkStart(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 2; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + /// + /// 发动机机型标志(INT4)(9) + /// + public static void Read_EngineTypeID(string opName, out int tagValue) + { + int tagTypeID = 9; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + /// + /// 发动机ID(STRING6.38)(10) + /// + public static void Read_EngineID(string opName, out string tagValue) + { + int tagTypeID = 10; + tagValue = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = tagValueStr; + } + //public static void Read_OrderForm(string opName, out string tagValue) + //{ + // tagValue = ""; + // string tagTypeID = "39"; + // string tagValueStr; + // tagValueStr = DtWebApi.ReadWritePLC.ReadPLC(tagTypeID, opName).ToString(); + // tagValue = tagValueStr; + //} + /// + /// 发动机型号(STRING46.38)(11) + /// + public static void Read_EngineType(string opName, out string tagValue) + { + int tagTypeID = 11; + tagValue = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = tagValueStr; + + } + + /// + /// 工位直通(X101.6)(1006) + /// + public static void Read_PartGoOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartGoOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 托盘到位(1)托盘离开(0) (DBX101.5)(13) + /// + public static void Read_PartPalletStatus(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "PartPalletStatus"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + /// + /// 加工时间变量目标时间 (DINT 106)(17) + /// + public static void Read_MachineTime_TargetTime(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "TargetTime"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + /// + /// 加工时间变量实际时间 (DINT 110)(18) + /// + public static void Read_MachineTime_ActualTime(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "ActualTime"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 质量数据总成合格标志(INT104)(21) + /// + public static void Read_QualityMask(string opName, out int tagValue) + { + tagValue = 0; + int tagTypeID = 21; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + if (tagValueStr == "1" | tagValueStr.ToLower () == "true") + { + tagValueStr = "1"; + } + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 机体流向标志(1 BYTE): + /// 0普通工位: + /// 1:上线(发动机上线); + /// 2:下线(发动机下线);(INT114)(41) + /// + public static void Read_PartMoveDirection(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartMoveDirection"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + + /// + /// 强制MES(X103.0)(78) + /// + public static void Read_Mes_MustTest(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "IsMES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + /// + /// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79) + /// + public static void Read_OnLineState(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "OnLineState"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 变量类型代码=44 CF0.4 + /// PLC向MES传递机型,机型代码,零件编号完成,通知PLC。 + /// 机型可读 + /// + /// + /// + public static void Read_EngineGetOver_PLC(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 44; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// X100.2允许保存质量数据(19) + /// + /// + /// + public static void Read_QualityData_Read_CF(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 19; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt64(tagValueStr)); + + } + + /// + /// MES向PLC传递机型(DBX2.1)(5) + /// + /// + /// + public static void Read_EngineTypeGetOver_MES(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 5; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// X2.3 工作完成(7) + /// + /// + /// + public static void Read_MaterialVerifyOver(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 7; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 申请上线(DBX0.3)(43) + /// + /// + /// + public static void Read_PartLoad(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 43; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 上线完成(DBX0.3)(48) + /// + /// + /// + public static void Read_PartLoad_OK(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "PartLoadOK"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 合格放行(51) + /// + /// + /// + public static void Read_ConfirmOkGo(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "ConfirmOkGo"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 拧紧结束(DBX1.1)(59) + /// + /// + /// + public static void Read_FixOK(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "FixOK"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 蘑菇按钮(DBX1.3)(61) + /// + /// + /// + public static void Read_NextPushButton(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "NextPushButton"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 允许拧紧(DBX3.1)(66) + /// + /// + /// + public static void Read_FixAllow(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 66; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 拧紧结束确认(DBX3.2)(67) + /// + /// + /// + public static void Read_FixOver(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "FixOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + ///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1 + ///MES设定完返修返修上线后,MES清空该信号 + ///DBX3.7(72) + /// + /// + /// + public static void Read_RepairUpline_MES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "RepairUplineMES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + + /// + /// 匹配结果(DBX3.4)(69) + /// + /// + /// + public static void Read_Match(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Match"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 发动机机型代码(DBB404)(73)[false] + /// + /// + /// + public static void Read_EngineTypeID_MES(string opName, out int EngineTypeID) + { + int tagTypeID = 73; + EngineTypeID = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + EngineTypeID = Convert.ToInt32(tagValueStr); + + } + + /// + /// 发动机机型(DBB446)(75) + /// + /// + /// + public static void Read_EngineType_MES(string opName, out string EngineType) + { + int tagTypeID = 75; + EngineType = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + EngineType = tagValueStr; + + } + + /// + /// 发动机号(DBB406)(74) + /// + /// + /// + public static void Read_EngineID_MES(string opName, out string EngineID) + { + int tagTypeID = 74; + EngineID = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + EngineID = tagValueStr; + + } + + /// + /// 拧紧序号(77) + /// + /// + /// + public static void Read_ProcessCode(string opName, out int tagValue) + { + int tagTypeID = 77; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// 套筒号、子程序代码子程序(DBB26)(2025)[false] + /// + /// + /// + public static void Read_BoltCode(string opName, out int tagValue) + { + int tagTypeID = 88; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// 托盘代码(DBB86)(80) + /// + public static void Read_PalletCode(string opName, out int tagValue) + { + int tagTypeID = 80; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + /// + /// 获得机型,零件编号,机型代码,托盘号,(从PLC) + /// + /// + /// + /// + /// + /// + public static void GetEngineTypeFromPLC(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code,out string OrderForm) + { + Read_EngineTypeID(opName,out EngineTypeID); + Read_EngineType(opName, out EngineType); + Read_EngineID(opName, out EngineID); + Read_OrderForm(opName, out OrderForm); + Read_PalletCode(opName, out PartPallet_Code); + } + /// + /// /// 获得机型,零件编号,机型代码,托盘号,(从MES) + /// + /// + /// + /// + /// + /// + public static void GetEngineTypeFromPLC_MES(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm) + { + Read_EngineTypeID_MES(opName, out EngineTypeID); + Read_EngineType_MES(opName, out EngineType); + Read_EngineID_MES(opName, out EngineID); + Read_OrderForm_MES(opName, out OrderForm); + } + + /// + /// 获得机型,零件编号,机型代码,托盘号,(从DB) + /// + /// + /// + /// + /// + /// + public static void GetEngineTypeFromDB(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code) + { + string orderForm = ""; + int isRepair = 0; + string repairCode = ""; + string palletCode = "0"; + string EngineTypeString = ""; + MisDataFun.Moby_Select(opName, + out orderForm, out EngineTypeID, out EngineType, + out EngineID, out palletCode, out isRepair, out repairCode, out EngineTypeString); + PartPallet_Code = Convert.ToInt32(palletCode); + } + + /// + /// 0:不修改;1:可以修改。(上线工位)通知PLC。(DBX1.2)(76) + /// + /// + /// + public static void Read_PartPalletCode_PLC_ToMES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartPalletCodePLCToMES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 通知写入托盘号(DBX3.5)(70) + /// + /// + /// + public static void Read_PartPalletCode_PLC(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartPalletCodePLC"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 变量类型代码=86,打印第一行(机型),用于线首打印机。STRING 486 .38 + /// + /// + /// + public static void Read_PrintBarCode1_MES(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "PrintBarCode1MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = tagValueStr; + + } + + /// + /// 变量类型代码=87,打印第二行(流水号),用于线首打印机。STRING 526 .38 + /// + /// + /// + public static void Read_PrintBarCode2_MES(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "PrintBarCode2MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = tagValueStr; + + } + + + /// + /// 上线工位。0:正常工作;1:空托盘放行(DBX2.2)(6) + /// + /// + /// + public static void Read_PartPalletGoOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartPalletGoOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71) + /// + /// + /// + public static void Read_IsAutoGetEngineID(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "IsAutoGetEngineID"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 正常拧紧时选择(DBX100.3)(81) + /// + /// + /// + public static void Read_Normal(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Normal"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 备用拧紧时选择(DBX100.4)(82) + /// + /// + /// + public static void Read_UnNormal(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "UnNormal"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 允许拧紧2(DBX100.5)(83) + /// + /// + /// + public static void Read_FixAllow_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "FixAllow2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 拧紧结束2(DBX100.6)(84) + /// + /// + /// + public static void Read_FixOK_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "FixOK2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 拧紧结束确认2(DBX100.7)(85) + /// + /// + /// + public static void Read_FixOver_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "FixOver2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 拧紧顺序2(DBX101.7)(1007) + /// MES通知PLC开始拧紧顺序(0为其他位,1为第一位置)(必须MES) + /// + /// + /// + public static void Read_WriteShaft_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "WriteShaft2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + + /// + /// 返修上线(DBX2.6)(52) + /// + /// + /// + public static void Read_PartLoadFinish(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartLoadFinish"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 返修上线后,PLC确认(DBX1.0)(58) + /// + /// + /// + public static void Read_PartLoadOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartLoadOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 变量类型代码=22,读取托盘信息 DBW126 + /// + /// + /// + public static void Read_PalletInfo(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PalletInfo"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 变量类型代码=23,读取托盘信息 DBW194 + /// + /// + /// + public static void Read_RepairStatus_PLC(string opName, out int tagValue) + { + int tagTypeID = 23; + tagValue = 0; + string cmd = "RepairStatusPLC"; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// PLC将MOBY信息成功写入到了对应的DB,然后通知MES(DBX1.5)(63) + /// + /// + /// + public static void Read_PalletMobyReadOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PalletMobyReadOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// 在线返修状态(DBX4.0)(91) + /// + /// + /// + public static void Read_OnlineRepair(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "OnlineRepair"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 离线返修状态(DBX4.1)(92) + /// + /// + /// + public static void Read_OutLineRepair(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "OutLineRepair"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// MES通知PLC修改托盘状态成功(DBX4.2)(93) + /// + /// + /// + public static void Read_UpdatePalletOK(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "UpdatePalletOK"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + + /// + /// MES向PLC要求申请下线(DBX0.7)(50) + /// + /// + /// + public static void Read_PalletDown(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "PalletDown"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + + /// + /// 物料检测(99) + /// + /// + /// + public static void Read_CheckMaterial(string opName, out object tagValue) + { + tagValue = new bool[16]; + string cmd = "CheckMaterial"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 备用功能是否启用(95) + /// + /// + /// + public static void Read_BakOpNameIsWork(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "BakOpNameIsWork"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + + /// + /// 质量呼叫(DBX301.2)(2011) + /// + /// + /// + public static void Read_QualityCall(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "QualityCall"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + /// + /// 物料呼叫(DBX301.3)(2012) + /// + /// + /// + public static void Read_MaterialCall(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "MaterialCall"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 故障呼叫(DBX301.4)(2013) + /// + /// + /// + public static void Read_FaultCall(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "FaultCall"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + public static void Read_PartScanCode(int tagTypeID, string opName, out string tagValue) + { + tagValue = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = tagValueStr; + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Write.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Write.cs new file mode 100644 index 0000000..7d1826b --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Write.cs @@ -0,0 +1,574 @@ +using System; +//using SystemFramework; + + +namespace MesServerWork +{ + + public partial class MIS_BASE + { + + + //static public void WritePLC(int tagType, string opName, object tagValue) + //{ + // Write_TagTypeID(tagType, opName, tagValue); + //} + /// + /// + /// + /// + public delegate void DemoHandler(object sender, DeviceDriver_BasicData.CustomeEvetnArgs e); + /// + /// + /// + public static event DemoHandler OPCTagDataDemo; + + /// + /// 根据tagType,工位号写入PLC对应值 + /// + /// + /// + static private void Write_TagValueByTagTypeName(string cmd, string opName,object tagValue) + { + int tagTypeID = 0; + string msg; + try + { + tagTypeID = Convert.ToInt32(MIS_BASE.hashtable_TagType[cmd]); + MIS_BASE.WriteTagValue(tagTypeID, opName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Write_TagValueByTagTypeName_FUNC"); + } + + } + + /// + /// 根据TagTypeID,工位号写入PLC对应值 + /// + /// + /// + static public void Write_TagValueByTagTypeID(int tagTypeID, string opName, object tagValue) + { + string msg; + object tagValueOb; + object newTagValue= tagValue; + try + { + MIS_BASE.WriteTagValue(tagTypeID, opName, tagValue); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Write_TagValueByTagTypeID_FUNC"); + } + + } + + /// + /// 通过TagID写入PLC数据 + /// + /// + /// + public static void Write_TagID(string TagID, object tagValue) + { + try + { + MIS_BASE.WritePLC(TagID, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Write_TagValueByTagID_FUNC"); + } + } + + + /// + /// 清空MES信号 MES传递机型(5) 允许工作(66) 合格放行(51) 不合格放行(8) 拧紧结束(67) 工作完成(7) 保存完成(20) 加工时间保存完成(54) 匹配完成(68) 默认false + /// + /// + /// + public static void Write_ClearMesMoby(string opName) + { + MIS_BASE.Write_EngineTypeGetOver_MES(opName, false); + MIS_BASE.Write_FixAllow(opName, false); + MIS_BASE.Write_ConfirmOkGo(opName, false); + MIS_BASE.Write_FalseGO(opName, false); + MIS_BASE.Write_FixOver(opName, false); + MIS_BASE.Write_MesWorkFinish(opName, false); + MIS_BASE.Write_MesReadOver(opName, false); + MIS_BASE.Write_MachineTime_ReadOver(opName, false); + MIS_BASE.Write_MatchingCompleted(opName, false); + } + + + /// + /// 订单号(string)(25) + /// + /// + /// + public static void Write_OrderForm(string opName, string tagValue) + { + string cmd = "OrderForm"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 总成编号(string)(26) + /// + /// + /// + public static void Write_AssemblyCode(string opName, string tagValue) + { + string cmd = "AssemblyCode"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号1(dint)(27) + /// + /// + /// + public static void Write_Recipe1(string opName, int tagValue) + { + string cmd = "Recipe1"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号2(dint)(28) + /// + /// + /// + public static void Write_Recipe2(string opName, int tagValue) + { + tagValue = 0; + string cmd = "Recipe2"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + + /// + /// 总成编号(string)(62) + /// + /// + /// + public static void Write_AssemblyCode_MES(string opName, string tagValue) + { + + string cmd = "AssemblyCode_MES"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号1(dint)(63) + /// + /// + /// + public static void Write_Recipe1_MES(string opName, int tagValue) + { + string cmd = "Recipe1_MES"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号2(dint)(64) + /// + /// + /// + public static void Write_Recipe2_MES(string opName, int tagValue) + { + string cmd = "Recipe2_MES"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + /// + /// 各个工位返修状态(4) + /// + /// + /// + public static void Write_RepairPathString(string opName, string tagValue) + { + string cmd = "RepairPathString"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + /// + /// 加工时间保存完数据 DBX102.1 (54) + /// + /// + /// + public static void Write_MachineTime_ReadOver(string opName, bool tagValue) + { + + int tagTypeID = 54; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79) + /// + /// + /// + public static void Write_OnLineState(string opName, int tagValue) + { + string cmd = "OnLineState"; + Write_TagValueByTagTypeName(cmd, opName,Convert .ToInt16 ( tagValue)); + } + + /// + /// 托盘编号(PLC)(80) + /// + /// + /// + public static void Write_PalletCode(string opName, int tagValue) + { + string cmd = "PartPalletCode"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + /// + /// MES向PLC传递机型(5) + /// + /// + /// + public static void Write_EngineTypeGetOver_MES(string opName, bool tagValue) + { + int tagTypeID = 5; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// PLC向MES传递机型(44) + /// + /// + /// + public static void Write_EngineTypeGetOver_PLC(string opName, bool tagValue) + { + string cmd = "EngineTypeGetOverPLC"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + /// + /// PLC向MES质量数据可以读 允许保存(19) DBX587.0 + /// + /// + /// + public static void Write_MesRead_PLC(string opName, bool tagValue) + { + string cmd = "MesRead"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + /// + /// 工件到位 + /// + /// + /// + public static void Write_WorkStart(string opName, bool tagValue) + { + string cmd = "WorkStart"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + /// + /// 拧紧结束确认(67) + /// + /// + /// + public static void Write_FixOver(string opName, bool tagValue) + { + + int tagTypeID = 67; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + ///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1 + ///MES设定完返修返修上线后,MES清空该信号 + ///DBX3.7(72) + /// + /// + /// + public static void Write_RepairUpline_MES(string opName, bool tagValue) + { + int tagTypeID = 72; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 匹配完成(68) + /// + /// + /// + public static void Write_MatchingCompleted(string opName, bool tagValue) + { + int tagTypeID = 68; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + + + + /// + /// 匹配结果(69) + /// + /// + /// + public static void Write_Match(string opName, bool tagValue) + { + int tagTypeID = 69; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + + } + + /// + /// 空托盘放行(DBX2.2)(6) + /// + /// + /// + public static void Write_PartPalletGoOver(string opName, int tagValue) + { + int tagTypeID = 6; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + + /// + /// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71) + /// + /// + /// + public static void Write_IsAutoGetEngineID(string opName, int tagValue) + { + string cmd = "IsAutoGetEngineID"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + + /// + /// 正常拧紧时选择(DBX100.3)(81) + /// + /// + /// + public static void Write_Normal(string opName, int tagValue) + { + string cmd = "Normal"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + /// + /// 备用拧紧时选择(DBX100.4)(82) + /// + /// + /// + public static void Write_UnNormal(string opName, int tagValue) + { + string cmd = "UnNormal"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + /// + /// 变量类型代码=52,复位设备(MES)DBX0.6 + /// 通知PLC复位设备 + /// + /// + /// + public static void Write_ResetDevice(string opName, bool tagValue) + { + string cmd = "PartLoadFinish"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + /// + ///托盘状态(22) + /// + /// + /// + public static void Write_PalletInfo(string opName, int tagValue) + { + string cmd = "PalletInfo"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + /// + /// 返修标志(93) + /// + /// + /// + public static void Write_RepairStatusMES(string opName, int tagValue) + { + string cmd = "RepairStatusMES"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + /// + /// MES通知PLC修改托盘状态成功 + /// + /// + /// + public static void Write_UpdatePalletOK(string opName, bool tagValue) + { + string cmd = "UpdatePalletOK"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + #region MES交互区写值 + + /// + /// 工作完成(7)(MES) + /// + /// + /// + public static void Write_MesWorkFinish(string opName, bool tagValue) + { + int tagTypeID = 7; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// 合格方式放行(51)(MES) + /// + /// + /// + public static void Write_ConfirmOkGo(string opName, bool tagValue) + { + int tagTypeID = 51; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 允许拧紧(66)(MES) + /// + /// + /// + public static void Write_FixAllow(string opName, bool tagValue) + { + int tagTypeID = 66; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 不合格放行(8) + /// + /// + /// + public static void Write_FalseGO(string opName, bool tagValue) + { + int tagTypeID = 8; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 拧紧序号(77) + /// + /// + /// + public static void Write_ProcessCode(string opName, int tagValue) + { + int tagTypeID = 77; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + + /// + /// 套筒号(88) + /// + /// + /// + public static void Write_BoltCode(string opName, int tagValue) + { + int tagTypeID = 88; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// MES保存完数据(必须MIS)(X102.2)(20) + /// + /// + /// + public static void Write_MesReadOver(string opName, bool tagValue) + { + int tagTypeID = 20; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// 工作完成(7) + /// + /// + /// + public static void Write_MaterialVerifyOver(string opName, bool tagValue) + { + string cmd = "MaterialVerifyOver"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + public static void Write_TagTypeID(int tagTypeID, string opName, object tagValue) + { + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 变量类型代码=73,机型代码。DBB404~405 机型标志 + /// + /// + /// + public static void Write_EngineTypeID_MES(string opName, int tagValue) + { + int tagTypeID = 73; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + public static void Write_OpNameIsOk(string opName,int qualityMask) + { + + // -99 是复位 + if (qualityMask == -99) + { + Write_TagValueByTagTypeID(51, opName, false); + Write_TagValueByTagTypeID(8, opName, false); + } + else if(qualityMask == 1) + { + // 51 合格放行 + Write_TagValueByTagTypeID(51, opName, true); + } + else + { + // 8 不合格放行 + Write_TagValueByTagTypeID(8, opName, true); + } + } + + /// + /// 变量类型代码=74,零件编号。DBB406~445 发动机编号 + /// + /// + /// + public static void Write_EngineID_MES(string opName, string tagValue) + { + int tagTypeID = 74; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// 变量类型代码=75,零件机型。DBB446~485 发动机机型 + /// + /// + /// + public static void Write_EngineType_MES(string opName, string tagValue) + { + int tagTypeID = 75; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 订单号(string)(116) + /// + /// + /// + public static void Write_OrderForm_MES(string opName, string tagValue) + { + int tagTypeID = 116; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + #endregion + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.QualityData.Read.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.QualityData.Read.cs new file mode 100644 index 0000000..92dbfdf --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.QualityData.Read.cs @@ -0,0 +1,75 @@ +using System; +using System.Data; +using System.Collections; +using MisDataFunDll; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + + /// + /// 读取质量数据 + /// + /// + public static void ReadPLC_Sync_ValueList(string opName, out Hashtable valueList) + { + valueList = null; + ReadPLCData(opName, out valueList); + } + /// + /// 根据工位号 同步读取数据 + /// + /// 工位号 + /// PLC仅仅值列表 + private static void ReadPLCData(string opName, out Hashtable valueList) + { + valueList = new Hashtable(); + + System.Data.DataTable dt; + dt = MisDataFun.BaseData_tagTable_QualityData_Item_B5A(); + + object tagValueStr = "0"; + for (int i = 0; i < dt.Rows.Count; i++) + { + if (opName == dt.Rows[i]["工位号"].ToString()) + { + + DeviceDriver_BasicData.CustomeEvetnArgs qualityDataType; + qualityDataType = new DeviceDriver_BasicData.CustomeEvetnArgs(); + + qualityDataType.TagID = dt.Rows[i]["TagID"].ToString (); + qualityDataType.TagTypeID = Convert.ToInt32(dt.Rows[i]["TagTypeID"]);//变量类型 + qualityDataType.OpName = opName;// + qualityDataType.IsGoodBad = 192;// + qualityDataType.TagQuality = 192;// + qualityDataType.TagValueType = Convert.ToInt32(dt.Rows[i]["变量类型代码"]); + qualityDataType.TagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]); + qualityDataType.TagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]); + qualityDataType.TagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]); ;//变量特点 + + MIS_BASE.Read_TagValueByTagID(qualityDataType.TagID.ToString(), out tagValueStr); + + if (Convert.ToInt32(qualityDataType.TagTypeID) == 18) + { + qualityDataType.TagValue = Convert.ToInt32(tagValueStr);//变量值 + } + else + { + qualityDataType.TagValue = tagValueStr;//变量值 + } + valueList.Add(qualityDataType.TagID, qualityDataType); + } + } + } + } + + public class QualityDataSaveList + { + public Hashtable valuList; + public DataTable BasicDataTagValue; + public DataTable BasicDataTagValueUpDown; + public Hashtable hashtable_EngineTypeID; + public Hashtable hashtable_tagTable_OpName_SaveData; + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS_BASE.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS_BASE.cs new file mode 100644 index 0000000..bd2012d --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS_BASE.cs @@ -0,0 +1,341 @@ +using BasicData; + +using MesWork; +using Newtonsoft.Json; +using NPOI.Util; +using OpcBasic; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Net.Http; +using System.Runtime.Remoting.Messaging; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerWork +{ + + /* +HeartBeatMIS 15 +EngineTypeGetOverMES 5 +PartPalletGoOver 6 +MaterialVerifyOver 7 +FalseGo 8 +ConfirmOkGo 51 +PartLoadFinish 52 +UnloadCompleted 53 +MachineTime_ReadOver 54 +FixAllow 66 +FixOver 67 +MatchingCompleted 68 +Match 69 +Reserved_1 70 +IsAutoGetEngineID 71 +RepairUplineMES 72 +ProcessCode 77 +BoltCode 88 +RepairStatus 93 +Reserved_3 24 +Reserved_4 25 +Reserved_5 26 +Reserved_6 27 +Reserved_7 28 +Reserved_8 29 +Reserved_9 30 +Reserved_10 31 +Reserved_11 32 +Reserved_12 33 +Reserved_13 34 +Reserved_14 35 +MesReadOver 20 +Reserved_15 110 +Reserved_16 111 +Reserved_17 112 +OnLineState 79 +EngineTypeID_MES 73 +EngineID_MES 74 +EngineType_MES 75 +MarkID 42 +RepairPathString 4 +SPareint1 113 +SPareint2 114 +SPareint3 115 +Sparestring1 116 +Sparestring2 117 +HeartBeatPLC 14 +WorkStart 2 +RepairPartStatusPLC 3 +PartLoad 43 +EngineTypeGetOverPLC 44 +PartLoadOK 48 +Reserved_18 49 +PalletDown 50 +Reserved_19 58 +FixOK 59 +Reserved_20 76 +Reserved_21 61 +Reserved_22 62 +Reserved_23 63 +Reserved_24 64 +Reserved_25 65 +EngineTypeID 9 +EngineID 10 +EngineType 11 +PartPalletCode 80 +PalletInfo 22 +MesRead 19 +PutOn 1000 +WorkOn 1001 +Alarm 1002 +NoPart 1003 +Block 1004 +PartPalletStatus 13 +TargetTimeRead 16 +QualityMask 21 +RepairStatusPLC 23 +MachineTargetTime 17 +MachineActualTime 18 +PLCSPareint1 36 +PLCSPareint2 37 +PLCSPareint3 38 +PLCSarestring1 39 +PLCSarestring2 40 + */ + + + + public partial class MIS_BASE + { + + + /// + ///引用程序集Hashtable + /// + public static Hashtable Hashtable_assembly = new Hashtable(); + /// + /// + /// + static public NameValueCollection hashtable_TagTypeTagName = null; + + /// + /// + /// + static public NameValueCollection hashtable_TagTypeChange = null; + /// + /// + /// + static public NameValueCollection hashtable_WebTagTypeChange = null; + /// + /// + /// + static public NameValueCollection hashtable_MesTagTypeChange = null; + /// + /// + /// + static readonly object l = new object(); + /// + /// + /// + /// + /// + /// + public static object ReadPLC(int tagTypeCodeID, string opName) + { + try + { + return PlcLinkForm.ReadPLC(tagTypeCodeID, opName); + + } + catch { return "-3"; } + } + /// + /// + /// + /// + /// + private static object ReadPLC(string tagID) + { + return PlcLinkForm.ReadPLC(tagID); + } + /// + /// 20230218 + /// 按组读质量数据,返回带合格标志的质量数据列表 + /// + /// + /// + public static Hashtable ReadPLC_Sync_DataList_MesRead_ByOnlyDataGroup(string opName) + { + lock (l) + { + + var tagValues = GetDbAndMaxLengthByOpNameByBytes(opName); + + var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + + TagFormat tagFormatTemp; + int tagIndex = 1; + int isOK = 0; + + Hashtable ht = new Hashtable(); + + + foreach (KeyValuePair _cd in keyValues) + { + if (_cd.Key.ToString()[0].ToString() == "7") + { + tagFormatTemp = (TagFormat)_cd.Value; + if (tagIndex % 3 == 1) + { + isOK = Convert.ToInt32(tagFormatTemp.TagValue); + } + else if (tagIndex % 3 == 2) + { + var TF = (TagFormat)_cd.Value; + + QualityDataType qualityDataType; + qualityDataType = GetQualityDataType(TF); + qualityDataType.isGoodBad = isOK; + ht.Add(qualityDataType.tagID, qualityDataType); + } + else if (tagIndex % 3 == 0) + { + var TF = (TagFormat)_cd.Value; + + QualityDataType qualityDataType; + qualityDataType = GetQualityDataType(TF); + qualityDataType.isGoodBad = isOK; + ht.Add(qualityDataType.tagID, qualityDataType); + } + + tagIndex++; + } + //Console.WriteLine($"key:{kv.Key} value:{kv.Value}"); + } + return ht; + } + } + + public static ConcurrentDictionary GetDbAndMaxLengthByOpNameByBytes(string opName) + { + string tagStartAdr = ""; + ushort tagAdrListMaxLength = 0; + PlcLinkForm.GetDbAndMaxLengthByOpName(opName, out tagStartAdr, out tagAdrListMaxLength); + var tagAdrListTagFormat = PlcLinkForm.ReadQualityDataList(opName, tagStartAdr, tagAdrListMaxLength); + return tagAdrListTagFormat; + } + + + public static BasicData.QualityDataType GetQualityDataType(TagFormat TF) + { + QualityDataType qualityDataType; + + qualityDataType = new QualityDataType(); + + qualityDataType.tagID = TF.TagID; + qualityDataType.tagTypeID = TF.TagTypeID;//变量类型 + qualityDataType.opName = TF.OpName; + qualityDataType.tagQuality = TF.Code; + qualityDataType.tagValueType = TF.TagTypeCodeID; + int.TryParse(TF.TagOrderBy, out int TagOrderBy); + qualityDataType.tagOrderBy = TagOrderBy; + int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy); + qualityDataType.tagItemOrderBy = TagItemOrderBy; + qualityDataType.tagProperty = Convert.ToInt32( TF.TagProperty);//变量特点 + qualityDataType.tagValue = TF.TagValue;//变量值 + + return qualityDataType; + } + /// + /// + /// + /// + /// + /// + private static void ReadTagValue(int tagTypeCodeID, string opName, out string tagValue) + { + tagValue = "0"; + try + { + var tagValueObj = PlcLinkForm.ReadPLC(tagTypeCodeID, opName); + var type = tagValueObj.GetType().Name.ToLower(); + if (type == "bool" | type == "boolean") + { + var val = tagValueObj.ToString().ToLower(); + + if (val == "true") + { + tagValue = "1"; + } + } + else + { + tagValue = tagValueObj.ToString(); + } + } + catch { } + } + + /// + /// + /// + /// + /// + /// + private static bool WritePLC(string tagID, object tagValue) + { + return PlcLinkForm.WritePLC(tagID, tagValue); + } + /// + /// + /// + /// + /// + /// + /// + public static bool WritePLC(int tagTypeCodeID, string opName, object tagValue) + { + return PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue); + } + /// + /// + /// + /// + /// + /// + /// + private static bool WriteTagValue(int tagTypeCodeID, string opName, object tagValue) + { + return PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue); + } + + public static ConcurrentDictionary ReadPLC_OpName(string opName) + { + try + { + string tagStartAdr = ""; + ushort tagAdrListMaxLength = 0; + PlcLinkForm.GetDbAndMaxLengthByOpName(opName, out tagStartAdr, out tagAdrListMaxLength); + var tagAdrListTagFormat0 = PlcLinkForm.ReadQualityDataList(opName, tagStartAdr, tagAdrListMaxLength); + + var pp = JsonConvert.SerializeObject(tagAdrListTagFormat0); + var tagAdrListTagFormat = JsonConvert.DeserializeObject>(pp); + + + return tagAdrListTagFormat; + } + catch (Exception err) + { + return null; + + } + + } + + } + + + +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesWorkPlc.cs b/Common/09MesDataFunction/MesDataFunction/MesWorkPlc.cs new file mode 100644 index 0000000..68db1b0 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesWorkPlc.cs @@ -0,0 +1,41 @@ + +using MesWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class MesWorkPlc: PlcLinkForm + { + + public static Action D_OPCTagData_TagDataOnChangeMIS = null; + + /// + /// 监控数据的所有变化,从这里产生 + /// + /// + /// + public override void OPCTagData_TagDataOnChangeMIS(object sender, DeviceDriver_BasicData.CustomeEvetnArgs e) + { + Console.WriteLine($"【【{e.TagName}【【{e.TagValueBefore}->{e.TagValue}【【{e.TagKeepTime}"); + + if (D_OPCTagData_TagDataOnChangeMIS != null) + D_OPCTagData_TagDataOnChangeMIS(e); + // OPCTagData_TagDataOnChange(sender, e); + } + + /// + /// 定时触发,检测PLC在线状态,周期:3 s + /// + /// + /// + public override void PlcStateEvent(object sender, DeviceDriver_BasicData.PlcStateEvetnArgs eState) + { + + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/Heartbeat.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/Heartbeat.cs new file mode 100644 index 0000000..75d41ea --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/Heartbeat.cs @@ -0,0 +1,25 @@ +//using bizFacade; +using System; +using System.Collections; +using System.Data; +//using SystemFramework; + +namespace MisDataFunction +{ + partial class Function + { + + private static void Heartbeat(string opName, string tagValue) + { + if (tagValue == "1") + { + Write_TagValueByTagTypeID(15, opName, true); + } + else + { + Write_TagValueByTagTypeID(15, opName, false); + } + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MIS.Interface.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MIS.Interface.cs new file mode 100644 index 0000000..904c975 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MIS.Interface.cs @@ -0,0 +1,326 @@ + +using bizFacade; +using DoWhatPlc; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +//using SystemFramework; + +namespace MisDataFunction +{ + public partial class Function: MIS_BASE + { + + + + /// + /// 处理MIS逻辑 TagName 变量类型代码 变量类型名称 + /// WorkStart 2 工件到位。托盘到达工位,并且托盘上有工件。 + ///RepairPartStatusPLC 3 备用 + ///RepairPathString 4 工位返修字符串(121211112222111),前2位是西门子字符串格式,第一位是总长度,第二位是实际长度 + ///EngineTypeGetOverMES 5 MES传递总成信息给PLC(上线工位) + ///PartPalletGoOver 6 上线工位。0:正常工作;1:空托盘放行,PLC读取到此标志不走申请上线逻辑。 + ///MaterialVerifyOver 7 MES保存完质量数据,物料数据等与PLC信号交互完成后通知PLC,所以工步都完成,才可以放行工件,正常工作时工件放行的必要条件。 + ///FalseGo 8 按MES界面[不合格放行] 按钮,MES发送此信号。操作者判断工件不合格,通知设备,按不合格方式放行工件,工件流转到返修下线工位后,返修下线。MES工作完成MES0.3=1,MES合格放行MES0.5=0,MES0.4=1 + ///EngineTypeID 9 MES发动机机型标志(必须PLC) + ///EngineID 10 MES发动机编号(必须PLC) + ///EngineType 11 MES发动机机型(必须PLC) + ///PartPalletStatus 13 MES激发变量托盘到位离开(必须PLC) + ///HeartBeatPLC 14 心跳处理:PLC收到MES心跳信号后,PLC延时5秒后,数值取反再写回PLC,写回PLC开始计时,如果5秒钟MES无反馈报通讯故障。 + ///HeartBeatMIS 15 间隔时间5S,心跳处理。收到PLC心跳信号后,MES按原值回写。PLC收到MES信号后延时5秒,取反写入,以此循环。 + ///TargetTimeRead 16 MES允许可读工位运行时间 + ///MachineTargetTime 17 目标运行时间 + ///MachineActualTime 18 实际运行时间 + ///MesRead 19 质量数据可以读数据 + ///MesReadOver 20 MES保存完数据(必须MIS) + ///QualityMask 21 质量数据工位合格标志0:没有工作;1:合格 ;2 :不合格(必须PLC) + ///PalletInfo 22 0空托盘,1合格件,2不合格件 + ///RepairStatusPLC 23 0正常件,1返修件 + ///Reserved_3 24 备用 + ///Reserved_4 25 备用 + ///Reserved_5 26 备用 + ///Reserved_6 27 备用 + ///Reserved_7 28 备用 + ///Reserved_8 29 备用 + ///Reserved_9 30 备用 + ///Reserved_10 31 备用 + ///Reserved_11 32 备用 + ///Reserved_12 33 备用 + ///Reserved_13 34 备用 + ///Reserved_14 35 备用 + ///PLCSPareint1 36 备用 + ///PLCSPareint2 37 备用 + ///PLCSPareint3 38 备用 + ///PLCSarestring1 39 备用 + ///PLCSarestring2 40 备用 + ///MarkID 42 机体打标号(MES)前2位是西门子字符串格式,第一位是总长度,第二位是实际长度 + ///PartLoad 43 上线工位,PLC向MES申请总成编号。收到该信号后,MES将机型标志(DBB22 ~23)、总成号(DBB24 ~63)、总成机型DBB64 ~103写入PLC。之后MES通过信号“传递机型(DBX0.1)”通知PLC。 + ///EngineTypeGetOverPLC 44 PLC将机型标志(DBB50…51)、工件编号(DBB52…101)、产品型号(DBB102…187)、托盘编号(DBB188…189)准备完毕后,通知MES。 + ///PartLoadOK 48 备用 + ///Reserved_18 49 备用 + ///PalletDown 50 暂时保留,项目未使用 + ///ConfirmOkGo 51 按MES界面[合格放行] 按钮,MES发送此信号。操作者判断工件合格,通知设备,工件按合格方式放行工件。MES工作完成MES0.3=1,MES合格放行MES0.5=1,MES0.4=0 + ///ResetDevice 52 针对手动工位,无HMI,需要复位设备在MES页面操作。 + ///UnloadCompleted 53 暂时保留,项目未使用 + ///MachineTime_ReadOver 54 备用 + ///Reserved_19 58 备用 + ///FixOK 59 手动拧紧工位,单工步螺栓拧紧完成,通知PC读取数据。 + ///Reserved_21 61 备用 + ///Reserved_22 62 备用 + ///Reserved_23 63 备用 + ///Reserved_24 64 备用 + ///Reserved_25 65 备用 + ///FixAllow 66 设备工作的必须信号,对于有物料验证的工位,MES验证完成给出此信号,对于无物料验证工位,MES直接给出此信号。 + ///FixOver 67 用于手动拧紧且有质量数据工位。通知设备当前工步拧紧螺钉工作结束。 + ///MatchingCompleted 68 分线上总线,匹配成功是1;不成功是0。 + ///Match 69 分线上总线,匹配成功是1;不成功是0。 + ///Reserved_2 70 备用 + ///IsAutoGetEngineID 71 自动手动申请工件编号。0是自动方式;1:手动方式。暂时保留,生成流水号方式是在数据库中实现的 + ///RepairUplineMES 72 上线清空MOBY(针对上线工位):通知PLC从新开始申请上线流程 + ///EngineTypeID_MES 73 MES发动机机型标志(必须MES) + ///EngineID_MES 74 MES发动机编号(必须MES) + ///EngineType_MES 75 MES发动机机型(必须MES) + ///Reserved_20 76 备用 + ///ProcessCode 77 手动拧紧工位:由MES通知PLC拧紧序号 + ///OnLineState 79 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线:0正常状态,实现正常功能。1离线:设备脱离MES工作,进入不交互模式。 + ///PartPalletCode 80 托盘编号(B5A) + ///BoltCode 88 手动拧紧工位:指导PLC所用套筒 + ///RepairStatus 93 0正常件,1返修件。对于上线工位MES给出是正常上线还是返修上线,返修路径 + ///Reserved_15 110 备用 + ///Reserved_16 111 备用 + ///Reserved_17 112 备用 + ///SPareint1 113 备用int1 + ///SPareint2 114 备用int2 + ///SPareint3 115 备用int3 + ///Sparestring1 116 备用字符串1 + ///Sparestring2 117 备用字符串2 + ///MachineStatusPutOn 1000 机床上电(必须PLC) + ///MachineStatusWorkOn 1001 循环开始(必须PLC) + ///MachineStatusAlarm 1002 机床故障(必须PLC) + ///MachineStatusNoPart 1003 上料无件(必须PLC) + ///MachineStatusBlock 1004 下料堵塞(必须PLC) + ///Alarm 103 设备报警 + /// + /// + public static void MIS_Funtion(object e) + { + try + { + + string recData = e.ToString(); + string[] dataArray = recData.Split('|'); + if (dataArray.Length != 4) + return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.ReturnValueString rv = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + //Console.WriteLine($"【【{rv.TagID}【【【【{ rv.TagKeepTime}"); + + int tagType; + string opName; + string tagValue; + int tagid; + DoWhatPlc.ReturnValueString msgEvent = rv; + if (msgEvent.TagValue == null) return; + tagType = Convert.ToInt32(msgEvent.TagTypeID); + opName = msgEvent.OpName.ToString(); + tagid = Convert.ToInt32(msgEvent.TagID); + + + //int tagType; + //string opName; + //string tagValue; + //int tagid; + //DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + //if (msgEvent.TagValue == null) return; + //tagType = Convert.ToInt32(msgEvent.TagType); + //opName = msgEvent.OpName.ToString(); + //tagid = Convert.ToInt32(msgEvent.TagKey); + switch (Convert.ToInt32(msgEvent.TagTypeCodeID)) + { + case 11: + switch (msgEvent.TagValue.ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + break; + default: + tagValue = msgEvent.TagValue.ToString(); + break; + } + ///根据信号处理逻辑 + switch (tagType) + { + case 19: + //允许保存 + MesRead(opName, tagValue, tagid); + break; + case 14: + //心跳 + Heartbeat(opName, tagValue); + break; + case 44://PLC传递机型过后 才允许保存过站信息,否则不允许保存 + //if (tagValue == "1") + //{ + // IsEngTypeGetOver_Write(opName, true); + + // EngineData Enginedata = new EngineData(DtWebApi.ReadWritePLC.ReadPLC("10", opName).ToString(), Convert.ToInt32(DtWebApi.ReadWritePLC.ReadPLC("80", opName))); + // //EngineData Enginedata = new EngineData(MesDataFunction.OpcOperation.ReadPLC(10, opName).ToString(), Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(80, opName))); + // //保存产品编号、托盘号 保存过站信息用 + // EngineData_Hash_Write(opName, Enginedata); + //} + break; + case 2://工件到位 + WorkStart( rv); + + + //WorkStart(opName, tagValue); + break; + case 51: + if (hashtableOpName_IsHaveComputer[opName].ToString() == "1") + { + SaveProductLeaveData(opName, 1); + } + + break; + case 8: + if (hashtableOpName_IsHaveComputer[opName].ToString() == "1") + { + SaveProductLeaveData(opName, 2); + } + break; + case 103: + + Alarm_Insert(rv); + + break; + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + } + } + private static void Alarm_Insert(ReturnValueString rv) + { + string TagID; + string opName; + string tagTypeID; + int TagValue; + + DateTime alarmStartTime; + DateTime alarmEndTime; + int TimeDiff; + string TagOrderBy; + string Text1; + string Text2; + TagID = rv.TagID; + tagTypeID = rv.TagTypeID; + opName = rv.OpName; + TagValue = Convert.ToInt32( rv.TagValue); + + alarmStartTime = Convert.ToDateTime( rv.TimeStampBefore); + alarmEndTime = Convert.ToDateTime( rv.TimeStamp); + TimeDiff = Convert.ToInt32(rv.TagKeepTime); + TagOrderBy = rv.TagOrderBy; + Text1 = rv.ItemName; + Text2 = rv.ShaftID; + + BaseDataSystemMES.Alarm_Insert(TagID, tagTypeID, opName, TagValue, + alarmStartTime, alarmEndTime, TimeDiff, Text1, Text2, TagOrderBy); + } + private static void WorkStart(ReturnValueString rv) + { + + + + var ro = rv.ReturnValueToObject(); + + string opName = ro.OpName; + DateTime arrivedTime = ro.TimeStampBefore; + DateTime leavedTime = ro.TimeStamp; + int TimeDiff = ro.TagKeepTime; + int targetTime = 0; + string isPass = ""; + + int QualityMark=0; + string tagValue="0"; + switch (ro.TagValue.ToString().ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + //if (ro.TagValue.ToString() == "0") + //{ + // //Write_TagTypeID(5, opName, false);//MES传递机型 + // //Write_TagTypeID(66, opName, false);//允许工作 + // //Write_TagTypeID(51, opName, false);//合格放行 + // //Write_TagTypeID(8, opName, false);//不合格放行 + // //Write_TagTypeID(7, opName, false);//工作完成 + // //Write_TagTypeID(20, opName, false);//保存完成 + + // //string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString(); + // //if (Convert.ToInt32(isHaveComputer) == 0)//自动工位 读合格标志 + // //{ + // // if (IsEngTypeGetOver_Read(opName)) + // // { + // // //PLC未传递机型 不保存过站信息 + // // SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(DtWebApi.ReadWritePLC.ReadPLC("21", opName))); + // // //SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(21, opName))); + // // } + + // //} + + // ////清空信号 + // ////m_WorkStart_OpName[opName] = 0;//清空工件到位标志 + // ////通知WEB更新产量 + // //SendActuallyCount(opName, 0); + //} + + QualityMark = Convert.ToInt32(ReadPLC(21, opName)); + + if (QualityMark == 1) + { + isPass = "1"; + } + else + { + isPass = "0"; + } + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(opName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code,out OrderForm); + + //EngineData Enginedata = (EngineData)EngineData_Hash_Read(opName); + BaseDataSystemMES.WorkStartInsert_AutoWorkStation(opName, EngineID, PartPallet_Code, arrivedTime, leavedTime, TimeDiff, targetTime, null, isPass, 0); + + } + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MesRead.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MesRead.cs new file mode 100644 index 0000000..f716152 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MesRead.cs @@ -0,0 +1,465 @@ +//using BasicData; +using bizFacade; +using DoWhatPlc; +using Newtonsoft.Json; +//using bizFacade; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +//using SystemFramework; + +namespace MisDataFunction +{ + partial class Function + { + /// + /// 获取质量数据Hashtable + /// + /// + /// + //static public Hashtable ReadPLC_Sync_DataList_MesRead(string opName) + //{ + // return (Hashtable)MesDataFunction.OpcOperation.ReadPLC_Sync_DataList_MesRead(opName); + //} + static object lockerReadPLC_Sync_DataList_MesRead1 = new object(); + public static void ReadPLC_Sync_DataList_MesRead(string opName, out Hashtable valueList, out DataTable BasicDataTagValue, out DataTable BasicDataTagValueUpDown, out Hashtable hashtable_EngineTypeID, out Hashtable hashtable_tagTable_OpName_SaveData) + { + //QualityDataSaveList QualityDataType + valueList = new Hashtable(); + //var qualityDataSaveList = DtWebApi.SaveData.ReadPLC_Sync_DataList_MesRead(opName); + var qualityDataSaveList = MesServerWork.MIS_BASE.ReadPLC_Sync_DataList_MesRead(opName); + foreach (DictionaryEntry de in qualityDataSaveList.valuList) + { + valueList.Add(de.Key, JsonConvert.DeserializeObject(de.Value.ToString())); + } + BasicDataTagValue = qualityDataSaveList.BasicDataTagValue; + BasicDataTagValueUpDown = qualityDataSaveList.BasicDataTagValueUpDown; + hashtable_EngineTypeID = qualityDataSaveList.hashtable_EngineTypeID; + hashtable_tagTable_OpName_SaveData = qualityDataSaveList.hashtable_tagTable_OpName_SaveData; + } + public static Hashtable ReadPLC_Sync_DataList_MesRead(string opName) + { + lock (lockerReadPLC_Sync_DataList_MesRead1) + { + Hashtable ht = new Hashtable(); + var cd = ReadPLC_GroupData(opName); + //var cd = PlcLinkForm.ReadPLC_GroupData(opName); + + foreach (var _cd in cd) + { + var tagID = Convert.ToInt32(_cd.TagID); + var TF =_cd.TF; + + QualityDataType qualityDataType; + qualityDataType = new QualityDataType(); + + qualityDataType.tagID = TF.TagID; + qualityDataType.tagTypeID = TF.TagTypeID;//变量类型 + qualityDataType.opName = opName; + qualityDataType.isGoodBad = 192; + int.TryParse(TF.TagQuality, out int TagQuality); + qualityDataType.tagQuality = TagQuality; + qualityDataType.tagValueType = TF.TagTypeCodeID; + int.TryParse(TF.TagOrderBy, out int TagOrderBy); + qualityDataType.tagOrderBy = TagOrderBy; + int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy); + qualityDataType.tagItemOrderBy = TagItemOrderBy; + qualityDataType.tagProperty = TF.TagProperty;//变量特点 + qualityDataType.tagValue = TF.TagValue;//变量值 + + ht.Add(tagID, qualityDataType); + } + return ht; + } + + } + + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private static void MesRead(string opName, string tagValue, int tagid) + { + if (tagValue == "0") + { + Write_TagValueByTagTypeID(20, opName, false); + } + else + { + SaveQualityData(opName, Convert.ToInt32(tagValue), tagid); + } + } + + private static void SaveQualityData(string opName, int tagValue, int tagID) + { + try + { + int id_tagCF; + int qualityMask = 0; + int engineTypeID = 0; + string engineID = ""; + string engineType = ""; + string engineTraceCode = ""; + string engineCap = ""; + string partPallet = ""; + DataTable dt_WWW; + dt_WWW = BaseDataSystemMES.BuildDataTables_WWW(); + Hashtable valueList; + //valueList = ReadPLC_Sync_DataList_MesRead(opName); + ReadPLC_Sync_DataList_MesRead(opName, out valueList, out BasicDataTagValue, out BasicDataTagValueUpDown, out hashtable_EngineTypeID, out hashtable_tagTable_OpName_SaveData); + valueList = GetQualityData_GoodBad_Values(valueList); + int mes_MustTest = 0; + int onLineState = 0; + int partMoveDirection = 0; + int pressIsOK = 0; + int pressIsNoOK = 0; + BaseDataSystemMES.GetQualityDataTable_B5A(valueList, opName, BasicDataTagValue, + BasicDataTagValueUpDown, + out dt_WWW,//数据列表 + out qualityMask,//工位合格标志 + out engineTypeID,//发动机类型代码 + out engineID,//发动机编号 + out engineType, //发动机型号 + out partPallet,//托盘编号 + out engineTraceCode, //发动机条码 + out engineCap,//缸盖号, + hashtable_EngineTypeID,//发动机类型转换表 + out mes_MustTest, out onLineState, out partMoveDirection, out pressIsOK, out pressIsNoOK); + + + + + // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + if (Convert.ToInt32(hashtable_tagTable_OpName_SaveData[opName]) != 0) + { + DateTime lastupdatetime = DateTime.Now; + + BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF); + BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW); + + } + Write_TagValueByTagTypeID(20, opName, true); + #region + //string orderForm = ""; + //string operatorCode = ""; + //int shiftCode = 1; + //DateTime arrivedTime; + //DateTime leavedTime; + //int TimeDiff; + //int targetTime = 0; + //string lineType = ""; + //string isPass; + //int machineWorkOn = 0; + //int arrivedOrLeaved = 2; + //int cartColorOpName = 0; + //int cartColorConfirm = 0; + //// int partMoveDirection; + //int partGoOver = 0; + //if (qualityMask == 1) + //{ + // isPass = "PASS"; + //} + //else + //{ + // isPass = "FAIL"; + //} + + ////工位上下线类型 + ////(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + //int OpNameUpDownType; + //OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]); + //arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName]; + //leavedTime = DateTime.Now; + //TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds); + + //lineType = hashtableOpName_LineType[opName].ToString(); + + //string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString(); + ////isHaveComputer = MIS_BASE.hashtable_tagTable_OpName_SaveData[opName].ToString(); + ////有计算机的工位,通过工位计算机保存[测量数据发动机在线状态]。 + //if (Convert.ToInt32(isHaveComputer) == 0) + //{ + // //1->0 工件离开 工件刚刚离开 + // if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1) + // { + + // //[测量数据发动机在线状态] + // QualityDataSystem.WorkStartInsert + // (opName, orderForm, engineTypeID, engineType, engineID, partPallet.ToString(), operatorCode, shiftCode, + // arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, machineWorkOn, + // arrivedOrLeaved, cartColorOpName, cartColorConfirm, partMoveDirection, partGoOver, mes_MustTest, onLineState, OpNameUpDownType); + // } + //} + #endregion + } + catch (Exception err) + { + Write_TagValueByTagTypeID(20, opName, true); + ////ApplicationLog.WriteLog(err, err.Message); + } + + } + public static void SaveQualityData_Mes(string opName, int tagID) + { + try + { + int id_tagCF; + int qualityMask = 0; + int engineTypeID = 0; + string engineID = ""; + string engineType = ""; + string engineTraceCode = ""; + string engineCap = ""; + string partPallet = ""; + DataTable dt_WWW; + dt_WWW = BaseDataSystemMES.BuildDataTables_WWW(); + Hashtable valueList; + valueList = ReadPLC_Sync_DataList_MesRead(opName); + valueList = GetQualityData_GoodBad_Values(valueList); + int mes_MustTest = 0; + int onLineState = 0; + int partMoveDirection = 0; + int pressIsOK = 0; + int pressIsNoOK = 0; + BaseDataSystemMES.GetQualityDataTable_B5A(valueList, opName, BasicDataTagValue, + BasicDataTagValueUpDown, + out dt_WWW,//数据列表 + out qualityMask,//工位合格标志 + out engineTypeID,//发动机类型代码 + out engineID,//发动机编号 + out engineType, //发动机型号 + out partPallet,//托盘编号 + out engineTraceCode, //发动机条码 + out engineCap,//缸盖号, + hashtable_EngineTypeID,//发动机类型转换表 + out mes_MustTest, out onLineState, out partMoveDirection, out pressIsOK, out pressIsNoOK); + // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + if (Convert.ToInt32(hashtable_tagTable_OpName_SaveData[opName]) != 0) + { + DateTime lastupdatetime = DateTime.Now; + BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF); + //BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW); + + } + + + } + catch (Exception err) + { + Write_TagValueByTagTypeID(20, opName, true); + ////ApplicationLog.WriteLog(err, err.Message); + } + + } + + /// + /// 确定合格标志 + /// + /// + /// + static public Hashtable GetQualityData_GoodBad_Values(Hashtable valuList) + { + try + { + Hashtable valuList_Temp; + valuList_Temp = (Hashtable)valuList.Clone(); + int[] value_GoodBad_New = new int[128]; + int tagID; + QualityDataType value; + //1:获得合格标志 + foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例 + { + tagID = Convert.ToInt32(de.Key); + value = (QualityDataType)de.Value; + + //拧紧数据合格标志 + if (value.tagProperty == 1) + { + if (value.tagTypeID == 8203) + { + value_GoodBad_New = (int[])value.tagValue; + break; + } + else + { + value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue); + } + } + //拧紧数据合格标志 + if (value.tagProperty == 8) + { + if (value.tagTypeID == 8203) + { + value_GoodBad_New = (int[])value.tagValue; + break; + } + else + { + value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue); + } + } + //压装数据合格标志 + if (value.tagProperty == 7) + { + value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue); + } + } + //将合格标志赋予每个变量 + foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例 + { + tagID = Convert.ToInt32(de.Key); + value = (QualityDataType)de.Value; + //201706061720新加 + if (value .tagTypeID ==11) + { + if (value.tagValue.ToString ()=="False") + { + value.tagValue ="0"; + } + else + { + value.tagValue = "1"; + } + valuList_Temp[tagID] = value; + //value.tagValue = Convert.ToInt32(value.tagValue); + } + + + //测量变量 + if (value.tagProperty == 2 || value.tagProperty == 6) + { + try + { + if (value_GoodBad_New != null) + { + value.isGoodBad = Convert.ToInt32(value_GoodBad_New[value.tagOrderBy - 1]); + valuList_Temp[tagID] = value; + } + else + { + value.isGoodBad = 0; + valuList_Temp[tagID] = value; + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + } + + + + } + return valuList_Temp; + } + catch//转换出了故障时 + { + return valuList; + } + } + + + + /// + /// 制定工位PLC是否传递过机型 (默认不传递机型不保存过站信息) + /// + static Hashtable EngTypeGetOver = new Hashtable(); + + static Hashtable EngineData_Hash = new Hashtable(); //保存 + + public static void IsEngTypeGetOver_Write(string OpName, bool value) + { + if (EngTypeGetOver.ContainsKey(OpName)) + { + EngTypeGetOver[OpName] = value; + } + else + { + EngTypeGetOver.Add(OpName, value); + } + } + + + public static bool IsEngTypeGetOver_Read(string OpName) + { + if (EngTypeGetOver.ContainsKey(OpName)) + { + return Convert.ToBoolean(EngTypeGetOver[OpName]); + } + else + { + return true; + } + } + + public static void EngineData_Hash_Write(string OpName, object value) + { + if (EngineData_Hash.ContainsKey(OpName)) + { + EngineData_Hash[OpName] = value; + + } + else + { + EngineData_Hash.Add(OpName, value); + } + } + + public static object EngineData_Hash_Read(string OpName) + { + if (EngineData_Hash.ContainsKey(OpName)) + { + return EngineData_Hash[OpName]; + } + else + { + return null; + } + + } + + + private DataTable ChangeQualificationMark(DataTable dt) + { + var dtNew = dt.Copy(); + for (int i = 0; i < dt.Rows.Count; i++) + { + var 变量排序 = dt.Rows[i]["变量排序"].ToString(); + if (变量排序 == "0") + { + + } + } + + + return dtNew; + } + + + + + } + struct EngineData + { + public EngineData(string engineID, int pallet) + { + EngineID = engineID; + Pallet = pallet; + } + + public string EngineID;//工件编号 + //public string EngineType; + //public int EngineTypeID; + public int Pallet;//托盘号 + + } + + + + + + +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/WorkStart.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/WorkStart.cs new file mode 100644 index 0000000..0ab46b5 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/WorkStart.cs @@ -0,0 +1,236 @@ +//using BasicData; +using bizFacade; +//using DataBaseAccess; +//using bizFacade; +using DataLinkMesWork; +using MesServerWork; +using System; +using System.Collections; +using System.Data; +using System.Data.SqlClient; +//using SystemFramework; + +namespace MisDataFunction +{ + partial class Function + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private static void WorkStart(string opName, string tagValue) + { + try + { + //工位没有工件,或工件刚刚离开 工件离开工位后,清空该工位的发动机号 + if (tagValue == "0") + { + Write_TagValueByTagTypeID(5, opName, false);//MES传递机型 + Write_TagValueByTagTypeID(66, opName, false);//允许工作 + Write_TagValueByTagTypeID(51, opName, false);//合格放行 + Write_TagValueByTagTypeID(8, opName, false);//不合格放行 + Write_TagValueByTagTypeID(7, opName, false);//工作完成 + Write_TagValueByTagTypeID(20, opName, false);//保存完成 + + //string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString(); + //if (Convert.ToInt32(isHaveComputer) == 0)//自动工位 读合格标志 + { + if (IsEngTypeGetOver_Read(opName)) + { + //PLC未传递机型 不保存过站信息 + SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(Read_TagValueByTagTypeID(21, opName))); + //SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(21, opName))); + } + + } + + //清空信号 + //m_WorkStart_OpName[opName] = 0;//清空工件到位标志 + //通知WEB更新产量 + SendActuallyCount(opName,0); + } + else + { + //保存工件到达数据 + //m_WorkStart_OpName_Time[opName] = DateTime.Now; + //m_WorkStart_OpName[opName] = 1; + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + } + /// + /// 保存过站信息 (数据库读机型信息) + /// + /// + /// + static void SaveProductLeaveData(string opName, int QualityMark) + { + try + { + if (!IsEngTypeGetOver_Read(opName)) + { + //PLC未传递机型 不保存过站信息 + return; + } + IsEngTypeGetOver_Write(opName, false);//清空传递机型标志 + + DateTime arrivedTime; + DateTime leavedTime; + int TimeDiff; + int targetTime = 0; + string lineType = ""; + string isPass; + if (QualityMark == 1) + { + isPass = "PASS"; + } + else + { + isPass = "FAIL"; + } + //工位上下线类型 + //(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + int OpNameUpDownType; + OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]); + arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName]; + leavedTime = DateTime.Now; + TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds); + lineType = hashtableOpName_LineType[opName].ToString(); + + //1->0 工件离开 工件刚刚离开 + //if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1) + //{ + // WorkStartInsert(opName, arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, OpNameUpDownType); + //} + //通知WEB更新产量 + SendActuallyCount(opName, 0); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + + + } + /// + /// 保存过站信息 (数据库读机型信息) + /// + /// + /// + static void SaveProductLeaveData_AutoWorkStation(string opName, int QualityMark) + { + try + { + if (!IsEngTypeGetOver_Read(opName)) + { + //PLC未传递机型 不保存过站信息 + return; + } + IsEngTypeGetOver_Write(opName, false);//清空传递机型标志 + + DateTime arrivedTime; + DateTime leavedTime; + int TimeDiff; + int targetTime = 0; + string lineType = ""; + string isPass; + if (QualityMark == 1) + { + isPass = "PASS"; + } + else + { + isPass = "FAIL"; + } + //工位上下线类型 + //(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + int OpNameUpDownType; + //OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]); + // arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName]; + leavedTime = DateTime.Now; + //TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds); + //lineType = hashtableOpName_LineType[opName].ToString(); + + //1->0 工件离开 工件刚刚离开 + //if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1) + //{ + // //查询工件编号、托盘号 + //EngineData Enginedata = (EngineData)EngineData_Hash_Read(opName); + //WorkStartInsert_AutoWorkStation(opName, Enginedata.EngineID, Enginedata.Pallet, arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, OpNameUpDownType); + //} + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + + + } + + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + /// + /// + /// + /// + static public void WorkStartInsert(string opName, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, int Target, string lineType, string isPass, int OpNameUpDownType) + { + string procedureName; + procedureName = "测量数据发动机在线状态_增加数据"; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@目标时间", Target); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@线体类型", lineType); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@工位上下线类型", OpNameUpDownType); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + static void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + + MIS_BASE.asyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + } + } + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/Properties/AssemblyInfo.cs b/Common/09MesDataFunction/MesDataFunction/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..057bcf1 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MesDataFunction")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MesDataFunction")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("90e76fb4-646d-45e2-95db-0b8ab4e465d6")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/PP.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PP.cs new file mode 100644 index 0000000..a861074 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PP.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class PP + { + + public static string ConnectionString_MES { get; set; } + public static string PrintURL { get; set; } + public static int IsDemoMesServer { get; set; } + + + + + + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrintTo.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrintTo.cs new file mode 100644 index 0000000..7e3d91d --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrintTo.cs @@ -0,0 +1,65 @@ +using MesWork; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class PrintTo + { + + /// + /// + /// + /// + public static bool Print(bool isSinglePrint,string url,string[] strArray) + { + if (PP.IsDemoMesServer == 1) + { + var list = new List(); + foreach (string str in strArray) + { + var printStr = str; + if (isSinglePrint) + { + printStr = str.Replace("^XB", ""); + } + list.Add(printStr); + } + + File.WriteAllText($"PrintContent_{DateTime .Now.ToString ("yyyy_MM_dd_HH_mm_ss")}.print", string.Join (" ", list)); + + return true; + } + + + var sucess = false; + try + { + var client = new System.Net.Sockets.TcpClient(); + client.Connect(url.Split(':')[0], Convert.ToInt32(url.Split(':')[1])); + + foreach (string str in strArray) + { + var printStr = str; + if (isSinglePrint) + { + printStr = str.Replace("^XB", ""); + } + client.Client.Send(System.Text.Encoding.ASCII.GetBytes(printStr)); + } + client.Close(); + + sucess = true; + } + catch (Exception err) { } + + return sucess; + } + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/Print_Sql.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/Print_Sql.cs new file mode 100644 index 0000000..69fb29d --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/Print_Sql.cs @@ -0,0 +1,80 @@ +using MesDataFunction; +using MesWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class Print_Sql + { + + + public static bool Select_Print_Template(out DataTable dt_Print_Template) + { + /* +SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] + */ + + bool success = false; + var sql = +@" +SELECT [IDG],[TemplateName],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] +ORDER BY [UpdateTime] +"; + success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2); + dt_Print_Template = dt; + return success; + + } + + public static bool Select_Print_TemplateStr(string IDG, out string templateStr) + { + /* +SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] + */ + templateStr = ""; + bool success = false; + var sql = + $" DECLARE @IDG nvarchar(50) = '{IDG}'" + +@" +SELECT [TemplateContent] FROM [OL_Repair_Print_Template] +WHERE [IDG] = @IDG +"; + success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2); + if (dt.Rows.Count > 0) + { + templateStr = dt.Rows[0]["TemplateContent"].ToString(); + } + return success; + + } + + public static bool Select_Print_Template_Def(out string templateStr) + { + /* +SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] + */ + templateStr = ""; + bool success = false; + var sql = +@" +SELECT top 1 [TemplateContent] FROM [OL_Repair_Print_Template] +WHERE [DefSelect]= 'True' +"; + success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2); + if (dt.Rows.Count > 0) + { + templateStr = dt.Rows[0]["TemplateContent"].ToString(); + } + return success; + + } + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrinterCommandCenter.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrinterCommandCenter.cs new file mode 100644 index 0000000..9b83dcc --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrinterCommandCenter.cs @@ -0,0 +1,33 @@ +using MesWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class PrinterCommandCenter + { + + public static bool PrintToPrinter(string code) + { + bool success = false; + + Print_Sql.Select_Print_Template_Def(out string templateStr); + var printContent = Template_Make_Zpl(templateStr, code); + + PrintTo.Print(true, PP.PrintURL, new string[] { printContent }); + + return success; + } + + + public static string Template_Make_Zpl(string templateStr,string TowCode) + { + return templateStr.Replace("@TowCode", TowCode); + } + + + } +} diff --git a/Common/MyLog4Net/00_MyLog4Net.csproj b/Common/MyLog4Net/00_MyLog4Net.csproj new file mode 100644 index 0000000..1c1c6ad --- /dev/null +++ b/Common/MyLog4Net/00_MyLog4Net.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F} + Library + Properties + MyLog4Net + MyLog4Net + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\log4net.2.0.14\lib\net45\log4net.dll + + + + + + + + + + + + + + + + + + + + + Always + + + + \ No newline at end of file diff --git a/Common/MyLog4Net/MyLogEventArgs.cs b/Common/MyLog4Net/MyLogEventArgs.cs new file mode 100644 index 0000000..a913363 --- /dev/null +++ b/Common/MyLog4Net/MyLogEventArgs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyLog4Net +{ + public class MyLogEventArgs : EventArgs + { + public string Message { get; set; } + public string Module { get; set; } + } +} diff --git a/Common/MyLog4Net/MyLogHelper.cs b/Common/MyLog4Net/MyLogHelper.cs new file mode 100644 index 0000000..cb446e4 --- /dev/null +++ b/Common/MyLog4Net/MyLogHelper.cs @@ -0,0 +1,65 @@ +using log4net; +using System; + +namespace MyLog4Net +{ + public class MyLogHelper + { + public delegate void MyLogEventHandler(object sender, MyLogEventArgs e); + public static event MyLogEventHandler LogCommit; + + /// + /// 普通日志 + /// + /// 日志内容 + public static void Info(string module, string message) + { + ILog log = LogManager.GetLogger(module); + if (log.IsInfoEnabled) + { + log.Info(message); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + /// + /// 错误日志带异常 + /// + /// 错误日志 + public static void Error(string module, string message, Exception ex) + { + ILog log = LogManager.GetLogger(module); + if (log.IsErrorEnabled) + { + log.Error(message, ex); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + + /// + /// 错误日志不带异常 + /// + /// 错误日志 + public static void Error(string module, string message) + { + ILog log = LogManager.GetLogger(module); + if (log.IsErrorEnabled) + { + log.Error(message); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + } + +} diff --git a/Common/MyLog4Net/Properties/AssemblyInfo.cs b/Common/MyLog4Net/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1228254 --- /dev/null +++ b/Common/MyLog4Net/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Log4Net")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Log4Net")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1dc48c83-1842-4de8-acaf-26e1e7f7c58f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] diff --git a/Common/MyLog4Net/log4net.config b/Common/MyLog4Net/log4net.config new file mode 100644 index 0000000..92f4d40 --- /dev/null +++ b/Common/MyLog4Net/log4net.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Common/MyLog4Net/packages.config b/Common/MyLog4Net/packages.config new file mode 100644 index 0000000..a0798f9 --- /dev/null +++ b/Common/MyLog4Net/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DatabaseScripts/AGV举升回调_现场总装.sql b/DatabaseScripts/AGV举升回调_现场总装.sql new file mode 100644 index 0000000..0a24d11 --- /dev/null +++ b/DatabaseScripts/AGV举升回调_现场总装.sql @@ -0,0 +1,95 @@ +-- 现场总装数据库:MESBasicDB_XD_ZZ +-- 用途:支持 AGV lower/raise 回调与 PLC 允许下降/举升放行查询。 +-- 说明:请在目标库手工执行。本脚本不直接修改 AGV_光栅请求记录 表结构。 + +SET NOCOUNT ON; +GO + +-- 1. 增加变量类型代码。500/501 是 MES 写 PLC 请求位,550/551 是 PLC 允许位。 +IF NOT EXISTS (SELECT 1 FROM [dbo].[MES_基本变量变量类型代码] WHERE [变量类型代码] = 500) +BEGIN + INSERT INTO [dbo].[MES_基本变量变量类型代码] + ([变量类型], [TagTypeDataType], [TagName], [变量类型代码], [TagTypeChange], [MesTagTypeChange], [WebTagTypeChange], [信号点名称], [变量类型名称]) + VALUES + (N'X', 11, N'AGV请求下降', 500, 1, 0, 1, N'AGV请求下降', N'AGV请求下降'); +END + +IF NOT EXISTS (SELECT 1 FROM [dbo].[MES_基本变量变量类型代码] WHERE [变量类型代码] = 501) +BEGIN + INSERT INTO [dbo].[MES_基本变量变量类型代码] + ([变量类型], [TagTypeDataType], [TagName], [变量类型代码], [TagTypeChange], [MesTagTypeChange], [WebTagTypeChange], [信号点名称], [变量类型名称]) + VALUES + (N'X', 11, N'AGV请求举升', 501, 1, 0, 1, N'AGV请求举升', N'AGV请求举升'); +END + +IF NOT EXISTS (SELECT 1 FROM [dbo].[MES_基本变量变量类型代码] WHERE [变量类型代码] = 550) +BEGIN + INSERT INTO [dbo].[MES_基本变量变量类型代码] + ([变量类型], [TagTypeDataType], [TagName], [变量类型代码], [TagTypeChange], [MesTagTypeChange], [WebTagTypeChange], [信号点名称], [变量类型名称]) + VALUES + (N'X', 11, N'允许AGV下降', 550, 1, 0, 1, N'允许AGV下降', N'允许AGV下降'); +END + +IF NOT EXISTS (SELECT 1 FROM [dbo].[MES_基本变量变量类型代码] WHERE [变量类型代码] = 551) +BEGIN + INSERT INTO [dbo].[MES_基本变量变量类型代码] + ([变量类型], [TagTypeDataType], [TagName], [变量类型代码], [TagTypeChange], [MesTagTypeChange], [WebTagTypeChange], [信号点名称], [变量类型名称]) + VALUES + (N'X', 11, N'允许AGV举升', 551, 1, 0, 1, N'允许AGV举升', N'允许AGV举升'); +END +GO + +-- 2. 扩展 AGV continueTask 放行查询。 +-- apply/release 保持原有 XD_库位Moby 查询。 +-- lower/raise 从 AGV_光栅请求记录 取最新未允许或最近请求,避免改动 XD_库位Moby 与历史表列顺序。 +ALTER PROCEDURE [dbo].[AGV_允许进入离开_查询] + @opName nvarchar(50) = 'AC0901-02', + @engineID nvarchar(50) = '0', + @type nvarchar(50) = 'apply' +AS +BEGIN + SET NOCOUNT ON; + + IF (@type = 'apply') + BEGIN + SELECT [进入req] AS reqCode, [进入task] AS taskCode + FROM [dbo].[XD_库位Moby] + WHERE [库位号] = @opName + AND [AGV请求进入时间] IS NOT NULL; + END + + IF (@type = 'release') + BEGIN + SELECT [离开req] AS reqCode, [离开task] AS taskCode + FROM [dbo].[XD_库位Moby] + WHERE [库位号] = @opName + AND [AGV请求离开时间] IS NOT NULL; + END + + IF (@type = 'lower') + BEGIN + SELECT TOP 1 [reqCode], [taskCode] + FROM [dbo].[AGV_光栅请求记录] + WHERE [method] = 'lower' + AND ( + [currentPositionCode] = @opName + OR [currentPositionCode] LIKE @opName + N'[_]%' + OR [wbCode] = @opName + ) + ORDER BY ISNULL([是否允许], 0) ASC, [创建时间] DESC, [ID] DESC; + END + + IF (@type = 'raise') + BEGIN + SELECT TOP 1 [reqCode], [taskCode] + FROM [dbo].[AGV_光栅请求记录] + WHERE [method] = 'raise' + AND ( + [currentPositionCode] = @opName + OR [currentPositionCode] LIKE @opName + N'[_]%' + OR [wbCode] = @opName + ) + ORDER BY ISNULL([是否允许], 0) ASC, [创建时间] DESC, [ID] DESC; + END +END +GO diff --git a/DatabaseScripts/XD_电能表谐波数据.sql b/DatabaseScripts/XD_电能表谐波数据.sql new file mode 100644 index 0000000..8c6308a --- /dev/null +++ b/DatabaseScripts/XD_电能表谐波数据.sql @@ -0,0 +1,173 @@ +IF OBJECT_ID(N'dbo.XD_电能表谐波数据', N'U') IS NULL +BEGIN + CREATE TABLE dbo.XD_电能表谐波数据 + ( + ID int IDENTITY(1,1) NOT NULL, + 工位号 nvarchar(50) NULL, + A相电压总谐波畸变 float NULL, + B相电压总谐波畸变 float NULL, + C相电压总谐波畸变 float NULL, + 系统电压总谐波畸变 float NULL, + A相电流总谐波畸变 float NULL, + B相电流总谐波畸变 float NULL, + C相电流总谐波畸变 float NULL, + 系统电流总谐波畸变 float NULL, + A相电压奇次谐波畸变 float NULL, + B相电压奇次谐波畸变 float NULL, + C相电压奇次谐波畸变 float NULL, + A相电流奇次谐波畸变 float NULL, + B相电流奇次谐波畸变 float NULL, + C相电流奇次谐波畸变 float NULL, + A相电压偶次谐波畸变 float NULL, + B相电压偶次谐波畸变 float NULL, + C相电压偶次谐波畸变 float NULL, + A相电流偶次谐波畸变 float NULL, + B相电流偶次谐波畸变 float NULL, + C相电流偶次谐波畸变 float NULL, + 操作时间 datetime NULL CONSTRAINT DF_XD_电能表谐波数据_操作时间 DEFAULT (GETDATE()), + CONSTRAINT PK_XD_电能表谐波数据 PRIMARY KEY CLUSTERED (ID ASC) + ); +END +GO + +IF NOT EXISTS ( + SELECT 1 + FROM sys.indexes + WHERE name = N'IX_XD_电能表谐波数据_工位号_操作时间' + AND object_id = OBJECT_ID(N'dbo.XD_电能表谐波数据') +) +BEGIN + CREATE NONCLUSTERED INDEX IX_XD_电能表谐波数据_工位号_操作时间 + ON dbo.XD_电能表谐波数据 (工位号 ASC, 操作时间 DESC); +END +GO + +IF OBJECT_ID(N'dbo.XD_电能表谐波数据_增加', N'P') IS NOT NULL + DROP PROCEDURE dbo.XD_电能表谐波数据_增加; +GO + +CREATE PROCEDURE dbo.XD_电能表谐波数据_增加 + @工位号 nvarchar(50) = N'', + @A相电压总谐波畸变 float = NULL, + @B相电压总谐波畸变 float = NULL, + @C相电压总谐波畸变 float = NULL, + @系统电压总谐波畸变 float = NULL, + @A相电流总谐波畸变 float = NULL, + @B相电流总谐波畸变 float = NULL, + @C相电流总谐波畸变 float = NULL, + @系统电流总谐波畸变 float = NULL, + @A相电压奇次谐波畸变 float = NULL, + @B相电压奇次谐波畸变 float = NULL, + @C相电压奇次谐波畸变 float = NULL, + @A相电流奇次谐波畸变 float = NULL, + @B相电流奇次谐波畸变 float = NULL, + @C相电流奇次谐波畸变 float = NULL, + @A相电压偶次谐波畸变 float = NULL, + @B相电压偶次谐波畸变 float = NULL, + @C相电压偶次谐波畸变 float = NULL, + @A相电流偶次谐波畸变 float = NULL, + @B相电流偶次谐波畸变 float = NULL, + @C相电流偶次谐波畸变 float = NULL +AS +BEGIN + SET NOCOUNT ON; + + IF NULLIF(LTRIM(RTRIM(@工位号)), N'') IS NULL + RETURN; + + -- 电表返回 -1 表示无效数据;任一谐波点无效时,本次整条采集不入库。 + IF @A相电压总谐波畸变 = -1 + OR @B相电压总谐波畸变 = -1 + OR @C相电压总谐波畸变 = -1 + OR @系统电压总谐波畸变 = -1 + OR @A相电流总谐波畸变 = -1 + OR @B相电流总谐波畸变 = -1 + OR @C相电流总谐波畸变 = -1 + OR @系统电流总谐波畸变 = -1 + OR @A相电压奇次谐波畸变 = -1 + OR @B相电压奇次谐波畸变 = -1 + OR @C相电压奇次谐波畸变 = -1 + OR @A相电流奇次谐波畸变 = -1 + OR @B相电流奇次谐波畸变 = -1 + OR @C相电流奇次谐波畸变 = -1 + OR @A相电压偶次谐波畸变 = -1 + OR @B相电压偶次谐波畸变 = -1 + OR @C相电压偶次谐波畸变 = -1 + OR @A相电流偶次谐波畸变 = -1 + OR @B相电流偶次谐波畸变 = -1 + OR @C相电流偶次谐波畸变 = -1 + RETURN; + + -- 谐波畸变允许为 0;只有全部点位都为空时跳过保存。 + IF @A相电压总谐波畸变 IS NULL + AND @B相电压总谐波畸变 IS NULL + AND @C相电压总谐波畸变 IS NULL + AND @系统电压总谐波畸变 IS NULL + AND @A相电流总谐波畸变 IS NULL + AND @B相电流总谐波畸变 IS NULL + AND @C相电流总谐波畸变 IS NULL + AND @系统电流总谐波畸变 IS NULL + AND @A相电压奇次谐波畸变 IS NULL + AND @B相电压奇次谐波畸变 IS NULL + AND @C相电压奇次谐波畸变 IS NULL + AND @A相电流奇次谐波畸变 IS NULL + AND @B相电流奇次谐波畸变 IS NULL + AND @C相电流奇次谐波畸变 IS NULL + AND @A相电压偶次谐波畸变 IS NULL + AND @B相电压偶次谐波畸变 IS NULL + AND @C相电压偶次谐波畸变 IS NULL + AND @A相电流偶次谐波畸变 IS NULL + AND @B相电流偶次谐波畸变 IS NULL + AND @C相电流偶次谐波畸变 IS NULL + RETURN; + + INSERT INTO dbo.XD_电能表谐波数据 + ( + 工位号, + A相电压总谐波畸变, + B相电压总谐波畸变, + C相电压总谐波畸变, + 系统电压总谐波畸变, + A相电流总谐波畸变, + B相电流总谐波畸变, + C相电流总谐波畸变, + 系统电流总谐波畸变, + A相电压奇次谐波畸变, + B相电压奇次谐波畸变, + C相电压奇次谐波畸变, + A相电流奇次谐波畸变, + B相电流奇次谐波畸变, + C相电流奇次谐波畸变, + A相电压偶次谐波畸变, + B相电压偶次谐波畸变, + C相电压偶次谐波畸变, + A相电流偶次谐波畸变, + B相电流偶次谐波畸变, + C相电流偶次谐波畸变 + ) + VALUES + ( + @工位号, + @A相电压总谐波畸变 / 1000.0, + @B相电压总谐波畸变 / 1000.0, + @C相电压总谐波畸变 / 1000.0, + @系统电压总谐波畸变 / 1000.0, + @A相电流总谐波畸变 / 1000.0, + @B相电流总谐波畸变 / 1000.0, + @C相电流总谐波畸变 / 1000.0, + @系统电流总谐波畸变 / 1000.0, + @A相电压奇次谐波畸变 / 1000.0, + @B相电压奇次谐波畸变 / 1000.0, + @C相电压奇次谐波畸变 / 1000.0, + @A相电流奇次谐波畸变 / 1000.0, + @B相电流奇次谐波畸变 / 1000.0, + @C相电流奇次谐波畸变 / 1000.0, + @A相电压偶次谐波畸变 / 1000.0, + @B相电压偶次谐波畸变 / 1000.0, + @C相电压偶次谐波畸变 / 1000.0, + @A相电流偶次谐波畸变 / 1000.0, + @B相电流偶次谐波畸变 / 1000.0, + @C相电流偶次谐波畸变 / 1000.0 + ); +END +GO diff --git a/Interface_WebAPI/CallWebApi/03_CallWebApi.csproj b/Interface_WebAPI/CallWebApi/03_CallWebApi.csproj new file mode 100644 index 0000000..61ad5b8 --- /dev/null +++ b/Interface_WebAPI/CallWebApi/03_CallWebApi.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {727A1B50-D83A-4319-BDF6-E923F4BD41B3} + Exe + CallWebApi + CallWebApi + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/CallWebApi/App.config b/Interface_WebAPI/CallWebApi/App.config new file mode 100644 index 0000000..6043180 --- /dev/null +++ b/Interface_WebAPI/CallWebApi/App.config @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Interface_WebAPI/CallWebApi/CallWebApi.cs b/Interface_WebAPI/CallWebApi/CallWebApi.cs new file mode 100644 index 0000000..095318a --- /dev/null +++ b/Interface_WebAPI/CallWebApi/CallWebApi.cs @@ -0,0 +1,257 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace CallWebApi +{ + public class Post + { + public static string Postring(string url, Dictionary dic) + { + string result = ""; + //url = "http://172.16.22.15:8000/" + url; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Proxy = null; + + req.KeepAlive = false; + + #region 添加Post 参数 + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + public static string Postring1(string url, string token, Dictionary dic) + { + string results = ""; + //url = "http://172.16.22.15:8000/" + url; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Headers.Add("Authorization", "Bearer " + token); + + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + try + { + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + results = reader.ReadToEnd(); + } + return results; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return e.Message; + throw; + } + + } + /// + /// 西开电器专用 + /// + /// + /// + /// + /// + public static string Post_XK(string url, string token, Dictionary dic) + { + string results = ""; + //url = "http://172.16.22.15:8000/" + url; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Headers.Add("Authorization", "Bearer " + token); + + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + try + { + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + results = reader.ReadToEnd(); + } + return results; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return e.Message; + throw; + } + + } + + + public static string MyPost() + { + // var url = "http://192.168.1.224:41190/"; + var url = "http://127.0.0.1:41190/"; + var controller = "ZSaveTag"; + var action = "SelectPage"; + Dictionary dict = new Dictionary(); + dict.Add("OpName",""); + dict.Add("StartTime", "2022-06-24 00:00:00"); + dict.Add("EndTime", "2022-06-30 00:00:00"); + dict.Add("PageCurrent", "1"); + dict.Add("PageSize", "2"); + + + var reqUrl = url + "/api/" + controller + "/" + action; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(reqUrl); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Proxy = null; + + req.KeepAlive = false; + + #region 添加Post 参数 + JObject jObject = new JObject(); + jObject.Add("OpName", ""); + jObject.Add("StartTime", "2022-06-24 00:00:00"); + jObject.Add("EndTime", "2022-06-30 00:00:00"); + jObject.Add("PageCurrent", "2"); + jObject.Add("PageSize", "3"); + var jStr = jObject.ToString(); + + //StringBuilder builder = new StringBuilder(); + //int i = 0; + //foreach (var item in dict) + //{ + // if (i > 0) + // builder.Append("&"); + // builder.AppendFormat("{0}={1}", item.Key, item.Value); + // i++; + //} + //byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + byte[] data = Encoding.UTF8.GetBytes(jStr); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + string result = ""; + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + public static string MyPost(string url,string jsonStr) + { + string result = ""; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Proxy = null; + req.KeepAlive = false; + + byte[] data = Encoding.UTF8.GetBytes(jsonStr); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + Console.WriteLine(result); + + + } + catch (Exception err) + { + Console.WriteLine(" " + err.Message); + } + + return result; + } + + } +} diff --git a/Interface_WebAPI/CallWebApi/Program.cs b/Interface_WebAPI/CallWebApi/Program.cs new file mode 100644 index 0000000..aaf6a2d --- /dev/null +++ b/Interface_WebAPI/CallWebApi/Program.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CallWebApi +{ + internal class Program + { + static void Main(string[] args) + { + Post.MyPost(); + + var url = "http://localhost:41190/api/ZSaveTag/SelectPage"; + + JObject jObject = new JObject(); + jObject.Add("OpName", ""); + jObject.Add("StartTime", "2022-06-24 00:00:00"); + jObject.Add("EndTime", "2022-06-30 00:00:00"); + jObject.Add("PageCurrent", "2"); + jObject.Add("PageSize", "3"); + var jStr = jObject.ToString(); + + Post.MyPost(url, jStr); + + Console.ReadKey(); + + } + } +} diff --git a/Interface_WebAPI/CallWebApi/Properties/AssemblyInfo.cs b/Interface_WebAPI/CallWebApi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7fca5ca --- /dev/null +++ b/Interface_WebAPI/CallWebApi/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CallWebApi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CallWebApi")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("727a1b50-d83a-4319-bdf6-e923f4bd41b3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Interface_WebAPI/CallWebApi/packages.config b/Interface_WebAPI/CallWebApi/packages.config new file mode 100644 index 0000000..ce3dc38 --- /dev/null +++ b/Interface_WebAPI/CallWebApi/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Interface_WebAPI/DLL/BasicData.dll b/Interface_WebAPI/DLL/BasicData.dll new file mode 100644 index 0000000..2531c4d Binary files /dev/null and b/Interface_WebAPI/DLL/BasicData.dll differ diff --git a/Interface_WebAPI/DLL/DataLinkMesWork.dll b/Interface_WebAPI/DLL/DataLinkMesWork.dll new file mode 100644 index 0000000..57fcd25 Binary files /dev/null and b/Interface_WebAPI/DLL/DataLinkMesWork.dll differ diff --git a/Interface_WebAPI/DLL/ICSharpCode.SharpZipLib.dll b/Interface_WebAPI/DLL/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..84e8c68 Binary files /dev/null and b/Interface_WebAPI/DLL/ICSharpCode.SharpZipLib.dll differ diff --git a/Interface_WebAPI/DLL/NPOI.OOXML.dll b/Interface_WebAPI/DLL/NPOI.OOXML.dll new file mode 100644 index 0000000..031d41d Binary files /dev/null and b/Interface_WebAPI/DLL/NPOI.OOXML.dll differ diff --git a/Interface_WebAPI/DLL/NPOI.OpenXml4Net.dll b/Interface_WebAPI/DLL/NPOI.OpenXml4Net.dll new file mode 100644 index 0000000..8da4ac2 Binary files /dev/null and b/Interface_WebAPI/DLL/NPOI.OpenXml4Net.dll differ diff --git a/Interface_WebAPI/DLL/NPOI.OpenXmlFormats.dll b/Interface_WebAPI/DLL/NPOI.OpenXmlFormats.dll new file mode 100644 index 0000000..4a8f87b Binary files /dev/null and b/Interface_WebAPI/DLL/NPOI.OpenXmlFormats.dll differ diff --git a/Interface_WebAPI/DLL/NPOI.dll b/Interface_WebAPI/DLL/NPOI.dll new file mode 100644 index 0000000..1a500e9 Binary files /dev/null and b/Interface_WebAPI/DLL/NPOI.dll differ diff --git a/Interface_WebAPI/DLL/Newtonsoft.Json.dll b/Interface_WebAPI/DLL/Newtonsoft.Json.dll new file mode 100644 index 0000000..7af125a Binary files /dev/null and b/Interface_WebAPI/DLL/Newtonsoft.Json.dll differ diff --git a/Interface_WebAPI/DatabaseClient/01_DatabaseClient.csproj b/Interface_WebAPI/DatabaseClient/01_DatabaseClient.csproj new file mode 100644 index 0000000..c05ab38 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/01_DatabaseClient.csproj @@ -0,0 +1,134 @@ + + + + + Debug + AnyCPU + {C7C5E929-BE10-4ED6-94DB-B8D65E05E52F} + Exe + DatabaseClient + DatabaseClient + v4.8 + 512 + true + true + + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + LocalIntranet + + + false + + + + + ..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll + + + ..\packages\Google.Protobuf.3.19.4\lib\net45\Google.Protobuf.dll + + + ..\packages\K4os.Compression.LZ4.1.2.6\lib\net46\K4os.Compression.LZ4.dll + + + ..\packages\K4os.Compression.LZ4.Streams.1.2.6\lib\net46\K4os.Compression.LZ4.Streams.dll + + + ..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll + + + ..\packages\log4net.2.0.14\lib\net45\log4net.dll + + + ..\packages\MySql.Data.8.0.29\lib\net452\MySql.Data.dll + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + + + + ..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.116.0\lib\net46\System.Data.SQLite.dll + + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + + + + + + + + + ..\packages\MySql.Data.8.0.29\lib\net452\Ubiety.Dns.Core.dll + + + ..\packages\MySql.Data.8.0.29\lib\net452\ZstdNet.dll + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/Interface_WebAPI/DatabaseClient/App.config b/Interface_WebAPI/DatabaseClient/App.config new file mode 100644 index 0000000..fbf0811 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/Interface_WebAPI/DatabaseClient/DBClient.cs b/Interface_WebAPI/DatabaseClient/DBClient.cs new file mode 100644 index 0000000..96ee82d --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/DBClient.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseClient +{ + public abstract class DBClient + { + /// + /// 根据连接字符串连接 + /// + /// 连接字符串 + public abstract void Connect(string connString); + + /// + /// 执行sql查询语句,返回DataTable + /// + /// 查询sql字符串 + /// + public abstract DataTable ExecQuery(string sql); + + /// + /// 执行sql非查询语句,返回执行结果 + /// + /// 非查询sql字符串 + /// + public abstract int ExecNonQuery(string sql); + + /// + /// 分页,将原始表分成子表。约束为当前页数和每页记录数 + /// + /// 泛型类型 + /// 原始表 + /// 每页记录数 + /// 当前页数 + /// + public static List SplitePage(List originList,int pageSize,int currentPage) + { + List resList = new List(); + + var numAll = originList.Count; + var numPage = numAll / pageSize + 1; + + var start = (currentPage - 1) * pageSize; + var end = start + pageSize; + + for (int i = 0; i < originList.Count; i++) + { + var origin = originList[i]; + if (i >= start && i < end) + { + resList.Add(origin); + } + } + + return resList; + } + } +} diff --git a/Interface_WebAPI/DatabaseClient/DBClientFactory.cs b/Interface_WebAPI/DatabaseClient/DBClientFactory.cs new file mode 100644 index 0000000..cffba85 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/DBClientFactory.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseClient +{ + public class DBClientFactory + { + DatabaseFactory factory; + + public DBClientFactory(string dbTypeStr) + { + switch (dbTypeStr.ToLower()) + { + case "mysql": + { + factory = new MysqlDatabaseFactory(); + break; + } + case "sqlite": + { + factory = new SqliteDatabaseFactory(); + break; + } + case "mssql": + { + factory = new MssqlDatabaseFactory(); + break; + } + default: + { + factory = new MysqlDatabaseFactory(); + break; + } + } + } + + public DBClient Create() + { + return factory.Create(); + } + } +} diff --git a/Interface_WebAPI/DatabaseClient/DBClientLog4net.config b/Interface_WebAPI/DatabaseClient/DBClientLog4net.config new file mode 100644 index 0000000..2842f30 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/DBClientLog4net.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/DatabaseClient/DatabaseFactory.cs b/Interface_WebAPI/DatabaseClient/DatabaseFactory.cs new file mode 100644 index 0000000..240cf43 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/DatabaseFactory.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseClient +{ + public abstract class DatabaseFactory + { + public abstract DBClient Create(); + } + + class MysqlDatabaseFactory : DatabaseFactory + { + public override DBClient Create() + { + return new MysqlClient(); + } + } + + class SqliteDatabaseFactory : DatabaseFactory + { + public override DBClient Create() + { + return new SqliteClient(); + } + } + + class MssqlDatabaseFactory : DatabaseFactory + { + public override DBClient Create() + { + return new MssqlClient(); + } + } +} diff --git a/Interface_WebAPI/DatabaseClient/GlobalVar.cs b/Interface_WebAPI/DatabaseClient/GlobalVar.cs new file mode 100644 index 0000000..15deaac --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/GlobalVar.cs @@ -0,0 +1,9 @@ +using log4net; + +namespace DatabaseClient +{ + class GlobalVar + { + public static ILog log = LogManager.GetLogger("DBClient"); + } +} diff --git a/Interface_WebAPI/DatabaseClient/MssqlClient.cs b/Interface_WebAPI/DatabaseClient/MssqlClient.cs new file mode 100644 index 0000000..9e5b022 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/MssqlClient.cs @@ -0,0 +1,75 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +namespace DatabaseClient +{ + class MssqlClient : DBClient + { + SqlConnection conn = null; + + public MssqlClient(){} + + public override void Connect(string connString) + { + try + { + conn = new SqlConnection(connString); + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + } + + public override DataTable ExecQuery(string sql) + { + DataTable dt = null; + try + { + if (conn != null) + { + conn.Open(); + + var cmd = new SqlCommand(sql, conn); + SqlDataAdapter da = new SqlDataAdapter(cmd); + DataSet ds = new DataSet(); + da.Fill(ds); + + conn.Close(); + if (ds.Tables.Count > 0) + { + dt = ds.Tables[0]; + } + } + + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + + return dt; + } + + public override int ExecNonQuery(string sql) + { + int res = 0; + try + { + if (conn!=null) + { + var cmd = new SqlCommand(sql, conn); + conn.Open(); + res = cmd.ExecuteNonQuery(); + conn.Close(); + } + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + return res; + } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/DatabaseClient/MysqlClient.cs b/Interface_WebAPI/DatabaseClient/MysqlClient.cs new file mode 100644 index 0000000..a22e42f --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/MysqlClient.cs @@ -0,0 +1,126 @@ +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseClient +{ + public class MysqlClient : DBClient + { + MySqlConnection conn; + + public MysqlClient() { } + + public override void Connect(string connString) + { + try + { + conn = new MySqlConnection(connString); + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + } + + public override DataTable ExecQuery(string sql) + { + DataTable dt = null; + try + { + if (conn != null) + { + conn.Open(); + + MySqlCommand command = new MySqlCommand(sql, conn); + MySqlDataAdapter da = new MySqlDataAdapter(command); + DataSet ds = new DataSet(); + da.Fill(ds); + + conn.Close(); + + if (ds.Tables.Count > 0) + { + dt = ds.Tables[0]; + } + + } + + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + return dt; + } + + public override int ExecNonQuery(string sql) + { + int res = 0; + + try + { + if (conn != null) + { + conn.Open(); + + MySqlCommand command = new MySqlCommand(sql, conn); + res = command.ExecuteNonQuery(); + + conn.Close(); + } + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + + return res; + } + + public static bool ExecQueryDataTable(string sql,string ConnectStr,out DataTable dt, out string err) + { + bool success = false; + err = ""; + dt = null; + using (MySqlConnection conn = new MySqlConnection(ConnectStr)) + { + try + { + conn.Open(); + + MySqlCommand command = new MySqlCommand(sql, conn); + MySqlDataAdapter da = new MySqlDataAdapter(command); + DataSet ds = new DataSet(); + da.Fill(ds); + + if (ds.Tables.Count > 0) + { + dt = ds.Tables[0]; + } + success = true; + } + catch (Exception er) + { + err = er.Message; + } + finally + { + if (conn != null) + { + conn.Close(); + } + } + + } + + return success; + } + + + + } +} diff --git a/Interface_WebAPI/DatabaseClient/Program.cs b/Interface_WebAPI/DatabaseClient/Program.cs new file mode 100644 index 0000000..9f03a4b --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/Program.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseClient +{ + internal class Program + { + static void Main(string[] args) + { + + // TestSqlite(); + TestMysql(); + //TestMssql(); + Console.ReadKey(); + } + static void TestSqlite() + { + var sqlClient = new DBClientFactory("Sqlite").Create(); + sqlClient.Connect("Data Source=mytest.sqlite;Version=3;"); + var ds = sqlClient.ExecQuery("select * from Z_Save_Position"); + } + static void TestMysql() + { + var sqlClient = new DBClientFactory("Mysql").Create(); + sqlClient.Connect("server=192.168.1.204;port=33060;database=zkeco;username=mesuser;password=Mes147258;"); + var ds = sqlClient.ExecQuery("select * from vw_mes_userinfo;"); + } + + static void TestMssql() + { + var sqlClient = new DBClientFactory("Mssql").Create(); + + sqlClient.Connect(@"server=.\WINCC;database=MW_DataFactory_App_Add;uid=sa;pwd=126.com;Connection Reset=FALSE;Max Pool Size = 1000"); + var ds = sqlClient.ExecQuery("select * from ProjectList"); + } + } +} diff --git a/Interface_WebAPI/DatabaseClient/Properties/AssemblyInfo.cs b/Interface_WebAPI/DatabaseClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8b1127e --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Database")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Database")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c7c5e929-be10-4ed6-94db-b8d65e05e52f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "DBClientLog4net.config", Watch = true)] \ No newline at end of file diff --git a/Interface_WebAPI/DatabaseClient/SqliteClient.cs b/Interface_WebAPI/DatabaseClient/SqliteClient.cs new file mode 100644 index 0000000..051c462 --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/SqliteClient.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using System.Data.SQLite; + + + +namespace DatabaseClient +{ + class SqliteClient : DBClient + { + SQLiteConnection conn; + + public SqliteClient() { } + + public override void Connect(string connString) + { + try + { + conn = new SQLiteConnection(connString); + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + } + + public override int ExecNonQuery(string sql) + { + int res = 0; + try + { + if (conn!=null) + { + conn.Open(); + + var cmd = new SQLiteCommand(sql, conn); + res = cmd.ExecuteNonQuery(); + + conn.Close(); + } + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + return res; + } + + public override DataTable ExecQuery(string sql) + { + DataTable dt = null; + try + { + if (conn!=null) + { + conn.Open(); + + var cmd = new SQLiteCommand(sql, conn); + SQLiteDataAdapter da = new SQLiteDataAdapter(cmd); + DataSet ds = new DataSet(); + da.Fill(ds); + conn.Close(); + if (ds.Tables.Count > 0) + { + dt = ds.Tables[0]; + } + } + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + + + return dt; + } + } +} diff --git a/Interface_WebAPI/DatabaseClient/packages.config b/Interface_WebAPI/DatabaseClient/packages.config new file mode 100644 index 0000000..2a1becf --- /dev/null +++ b/Interface_WebAPI/DatabaseClient/packages.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/ExternalDataSyncSln.sln b/Interface_WebAPI/ExternalDataSyncSln.sln new file mode 100644 index 0000000..2b5d944 --- /dev/null +++ b/Interface_WebAPI/ExternalDataSyncSln.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03_CallWebApi", "CallWebApi\03_CallWebApi.csproj", "{727A1B50-D83A-4319-BDF6-E923F4BD41B3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{157C56BA-4D67-4ED0-B3D6-6D29888D81B9}" + ProjectSection(SolutionItems) = preProject + ReadMe.md = ReadMe.md + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalDataSync", "SlMesDbIterface\ExternalDataSync.csproj", "{2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01_DatabaseClient", "DatabaseClient\01_DatabaseClient.csproj", "{C7C5E929-BE10-4ED6-94DB-B8D65E05E52F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "00_MyLog4Net", "MyLog4Net\00_MyLog4Net.csproj", "{1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {727A1B50-D83A-4319-BDF6-E923F4BD41B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {727A1B50-D83A-4319-BDF6-E923F4BD41B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {727A1B50-D83A-4319-BDF6-E923F4BD41B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {727A1B50-D83A-4319-BDF6-E923F4BD41B3}.Release|Any CPU.Build.0 = Release|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Release|Any CPU.Build.0 = Release|Any CPU + {C7C5E929-BE10-4ED6-94DB-B8D65E05E52F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7C5E929-BE10-4ED6-94DB-B8D65E05E52F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7C5E929-BE10-4ED6-94DB-B8D65E05E52F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7C5E929-BE10-4ED6-94DB-B8D65E05E52F}.Release|Any CPU.Build.0 = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0AADB308-CA83-444C-BB95-7C628DA904BB} + EndGlobalSection +EndGlobal diff --git a/Interface_WebAPI/MyLog4Net/00_MyLog4Net.csproj b/Interface_WebAPI/MyLog4Net/00_MyLog4Net.csproj new file mode 100644 index 0000000..1c1c6ad --- /dev/null +++ b/Interface_WebAPI/MyLog4Net/00_MyLog4Net.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F} + Library + Properties + MyLog4Net + MyLog4Net + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\log4net.2.0.14\lib\net45\log4net.dll + + + + + + + + + + + + + + + + + + + + + Always + + + + \ No newline at end of file diff --git a/Interface_WebAPI/MyLog4Net/MyLogEventArgs.cs b/Interface_WebAPI/MyLog4Net/MyLogEventArgs.cs new file mode 100644 index 0000000..a913363 --- /dev/null +++ b/Interface_WebAPI/MyLog4Net/MyLogEventArgs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyLog4Net +{ + public class MyLogEventArgs : EventArgs + { + public string Message { get; set; } + public string Module { get; set; } + } +} diff --git a/Interface_WebAPI/MyLog4Net/MyLogHelper.cs b/Interface_WebAPI/MyLog4Net/MyLogHelper.cs new file mode 100644 index 0000000..cb446e4 --- /dev/null +++ b/Interface_WebAPI/MyLog4Net/MyLogHelper.cs @@ -0,0 +1,65 @@ +using log4net; +using System; + +namespace MyLog4Net +{ + public class MyLogHelper + { + public delegate void MyLogEventHandler(object sender, MyLogEventArgs e); + public static event MyLogEventHandler LogCommit; + + /// + /// 普通日志 + /// + /// 日志内容 + public static void Info(string module, string message) + { + ILog log = LogManager.GetLogger(module); + if (log.IsInfoEnabled) + { + log.Info(message); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + /// + /// 错误日志带异常 + /// + /// 错误日志 + public static void Error(string module, string message, Exception ex) + { + ILog log = LogManager.GetLogger(module); + if (log.IsErrorEnabled) + { + log.Error(message, ex); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + + /// + /// 错误日志不带异常 + /// + /// 错误日志 + public static void Error(string module, string message) + { + ILog log = LogManager.GetLogger(module); + if (log.IsErrorEnabled) + { + log.Error(message); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + } + +} diff --git a/Interface_WebAPI/MyLog4Net/Properties/AssemblyInfo.cs b/Interface_WebAPI/MyLog4Net/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1228254 --- /dev/null +++ b/Interface_WebAPI/MyLog4Net/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Log4Net")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Log4Net")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1dc48c83-1842-4de8-acaf-26e1e7f7c58f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] diff --git a/Interface_WebAPI/MyLog4Net/log4net.config b/Interface_WebAPI/MyLog4Net/log4net.config new file mode 100644 index 0000000..92f4d40 --- /dev/null +++ b/Interface_WebAPI/MyLog4Net/log4net.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/MyLog4Net/packages.config b/Interface_WebAPI/MyLog4Net/packages.config new file mode 100644 index 0000000..a0798f9 --- /dev/null +++ b/Interface_WebAPI/MyLog4Net/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/ExternalDataSync.ESB_base.baseResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/ExternalDataSync.ESB_base.baseResponse.datasource new file mode 100644 index 0000000..1678cd8 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/ExternalDataSync.ESB_base.baseResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_base.baseResponse, Connected Services.ESB_base.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/ExternalDataSync.ESB_base.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/ExternalDataSync.ESB_base.interfaceResponse.datasource new file mode 100644 index 0000000..24b0918 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/ExternalDataSync.ESB_base.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_base.interfaceResponse, Connected Services.ESB_base.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/Reference.cs new file mode 100644 index 0000000..9aae7fb --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/Reference.cs @@ -0,0 +1,497 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_base { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_base.UrmRsBaseInterface")] + public interface UrmRsBaseInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_base.baseResponse @base(ExternalDataSync.ESB_base.@base request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task baseAsync(ExternalDataSync.ESB_base.@base request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class rsBaseInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string alarmDateField; + + private string equipCodeField; + + private string siteField; + + private string toolCodeField; + + private string toolDownProdutionField; + + private string toolDownReasonField; + + private string toolDownResidualField; + + private string toolDownTypeField; + + private string workCellCodeField; + + private string workCenterField; + + private string tNumberField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string alarmDate { + get { + return this.alarmDateField; + } + set { + this.alarmDateField = value; + this.RaisePropertyChanged("alarmDate"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string equipCode { + get { + return this.equipCodeField; + } + set { + this.equipCodeField = value; + this.RaisePropertyChanged("equipCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string site { + get { + return this.siteField; + } + set { + this.siteField = value; + this.RaisePropertyChanged("site"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string toolCode { + get { + return this.toolCodeField; + } + set { + this.toolCodeField = value; + this.RaisePropertyChanged("toolCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string toolDownProdution { + get { + return this.toolDownProdutionField; + } + set { + this.toolDownProdutionField = value; + this.RaisePropertyChanged("toolDownProdution"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string toolDownReason { + get { + return this.toolDownReasonField; + } + set { + this.toolDownReasonField = value; + this.RaisePropertyChanged("toolDownReason"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string toolDownResidual { + get { + return this.toolDownResidualField; + } + set { + this.toolDownResidualField = value; + this.RaisePropertyChanged("toolDownResidual"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=7)] + public string toolDownType { + get { + return this.toolDownTypeField; + } + set { + this.toolDownTypeField = value; + this.RaisePropertyChanged("toolDownType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=8)] + public string workCellCode { + get { + return this.workCellCodeField; + } + set { + this.workCellCodeField = value; + this.RaisePropertyChanged("workCellCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=9)] + public string workCenter { + get { + return this.workCenterField; + } + set { + this.workCenterField = value; + this.RaisePropertyChanged("workCenter"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=10)] + public string tNumber { + get { + return this.tNumberField; + } + set { + this.tNumberField = value; + this.RaisePropertyChanged("tNumber"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="base", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class @base { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_base.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_base.rsBaseInfoTo[] arg1; + + public @base() { + } + + public @base(ExternalDataSync.ESB_base.interfaceRequestHeader arg0, ExternalDataSync.ESB_base.rsBaseInfoTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="baseResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class baseResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_base.interfaceResponse @return; + + public baseResponse() { + } + + public baseResponse(ExternalDataSync.ESB_base.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface UrmRsBaseInterfaceChannel : ExternalDataSync.ESB_base.UrmRsBaseInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class UrmRsBaseInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_base.UrmRsBaseInterface { + + public UrmRsBaseInterfaceClient() { + } + + public UrmRsBaseInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public UrmRsBaseInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public UrmRsBaseInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public UrmRsBaseInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_base.baseResponse ExternalDataSync.ESB_base.UrmRsBaseInterface.@base(ExternalDataSync.ESB_base.@base request) { + return base.Channel.@base(request); + } + + public ExternalDataSync.ESB_base.interfaceResponse @base(ExternalDataSync.ESB_base.interfaceRequestHeader arg0, ExternalDataSync.ESB_base.rsBaseInfoTo[] arg1) { + ExternalDataSync.ESB_base.@base inValue = new ExternalDataSync.ESB_base.@base(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_base.baseResponse retVal = ((ExternalDataSync.ESB_base.UrmRsBaseInterface)(this)).@base(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_base.UrmRsBaseInterface.baseAsync(ExternalDataSync.ESB_base.@base request) { + return base.Channel.baseAsync(request); + } + + public System.Threading.Tasks.Task baseAsync(ExternalDataSync.ESB_base.interfaceRequestHeader arg0, ExternalDataSync.ESB_base.rsBaseInfoTo[] arg1) { + ExternalDataSync.ESB_base.@base inValue = new ExternalDataSync.ESB_base.@base(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_base.UrmRsBaseInterface)(this)).baseAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/Reference.svcmap new file mode 100644 index 0000000..25b3409 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/UrmRsBaseInterface2.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/UrmRsBaseInterface2.wsdl new file mode 100644 index 0000000..acb39bf --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/UrmRsBaseInterface2.wsdl @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/configuration.svcinfo new file mode 100644 index 0000000..c56d4c7 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/configuration91.svcinfo new file mode 100644 index 0000000..f56e88e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + urmRsBaseInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_CutterDownInfo/ProxyServices/CutterDownInfoPS + + + + + + basicHttpBinding + + + urmRsBaseInterfaceSoapBinding + + + ESB_base.UrmRsBaseInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + UrmRsBaseInterfaceImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/urmRsBaseInterface.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/urmRsBaseInterface.wsdl new file mode 100644 index 0000000..3d02d0b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_base/urmRsBaseInterface.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ColltReInterface2.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ColltReInterface2.wsdl new file mode 100644 index 0000000..51cca5a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ColltReInterface2.wsdl @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ExternalDataSync.ESB_collt.colltResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ExternalDataSync.ESB_collt.colltResponse.datasource new file mode 100644 index 0000000..3563b3d --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ExternalDataSync.ESB_collt.colltResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_collt.colltResponse, Connected Services.ESB_collt.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ExternalDataSync.ESB_collt.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ExternalDataSync.ESB_collt.interfaceResponse.datasource new file mode 100644 index 0000000..93bf208 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/ExternalDataSync.ESB_collt.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_collt.interfaceResponse, Connected Services.ESB_collt.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/Reference.cs new file mode 100644 index 0000000..f3d6f5d --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/Reference.cs @@ -0,0 +1,515 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_collt { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_collt.ColltReInterface")] + public interface ColltReInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_collt.colltResponse collt(ExternalDataSync.ESB_collt.collt request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task colltAsync(ExternalDataSync.ESB_collt.collt request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class citemInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string actualValueField; + + private string citemCodeField; + + private string citemNameField; + + private string citemRemarkField; + + private string isOKField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string actualValue { + get { + return this.actualValueField; + } + set { + this.actualValueField = value; + this.RaisePropertyChanged("actualValue"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string citemCode { + get { + return this.citemCodeField; + } + set { + this.citemCodeField = value; + this.RaisePropertyChanged("citemCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string citemName { + get { + return this.citemNameField; + } + set { + this.citemNameField = value; + this.RaisePropertyChanged("citemName"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string citemRemark { + get { + return this.citemRemarkField; + } + set { + this.citemRemarkField = value; + this.RaisePropertyChanged("citemRemark"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string isOK { + get { + return this.isOKField; + } + set { + this.isOKField = value; + this.RaisePropertyChanged("isOK"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class colltReInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string acqTimeField; + + private citemInfoTo[] citemInfoToField; + + private string equipCodeField; + + private string siteField; + + private string workCellCodeField; + + private string workCenterField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string acqTime { + get { + return this.acqTimeField; + } + set { + this.acqTimeField = value; + this.RaisePropertyChanged("acqTime"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute("citemInfoTo", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=1)] + public citemInfoTo[] citemInfoTo { + get { + return this.citemInfoToField; + } + set { + this.citemInfoToField = value; + this.RaisePropertyChanged("citemInfoTo"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string equipCode { + get { + return this.equipCodeField; + } + set { + this.equipCodeField = value; + this.RaisePropertyChanged("equipCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string site { + get { + return this.siteField; + } + set { + this.siteField = value; + this.RaisePropertyChanged("site"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string workCellCode { + get { + return this.workCellCodeField; + } + set { + this.workCellCodeField = value; + this.RaisePropertyChanged("workCellCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string workCenter { + get { + return this.workCenterField; + } + set { + this.workCenterField = value; + this.RaisePropertyChanged("workCenter"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="collt", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class collt { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_collt.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_collt.colltReInfoTo[] arg1; + + public collt() { + } + + public collt(ExternalDataSync.ESB_collt.interfaceRequestHeader arg0, ExternalDataSync.ESB_collt.colltReInfoTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="colltResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class colltResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_collt.interfaceResponse @return; + + public colltResponse() { + } + + public colltResponse(ExternalDataSync.ESB_collt.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface ColltReInterfaceChannel : ExternalDataSync.ESB_collt.ColltReInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class ColltReInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_collt.ColltReInterface { + + public ColltReInterfaceClient() { + } + + public ColltReInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public ColltReInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public ColltReInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public ColltReInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_collt.colltResponse ExternalDataSync.ESB_collt.ColltReInterface.collt(ExternalDataSync.ESB_collt.collt request) { + return base.Channel.collt(request); + } + + public ExternalDataSync.ESB_collt.interfaceResponse collt(ExternalDataSync.ESB_collt.interfaceRequestHeader arg0, ExternalDataSync.ESB_collt.colltReInfoTo[] arg1) { + ExternalDataSync.ESB_collt.collt inValue = new ExternalDataSync.ESB_collt.collt(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_collt.colltResponse retVal = ((ExternalDataSync.ESB_collt.ColltReInterface)(this)).collt(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_collt.ColltReInterface.colltAsync(ExternalDataSync.ESB_collt.collt request) { + return base.Channel.colltAsync(request); + } + + public System.Threading.Tasks.Task colltAsync(ExternalDataSync.ESB_collt.interfaceRequestHeader arg0, ExternalDataSync.ESB_collt.colltReInfoTo[] arg1) { + ExternalDataSync.ESB_collt.collt inValue = new ExternalDataSync.ESB_collt.collt(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_collt.ColltReInterface)(this)).colltAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/Reference.svcmap new file mode 100644 index 0000000..063ba59 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/colltReInterface.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/colltReInterface.wsdl new file mode 100644 index 0000000..a112612 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/colltReInterface.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/configuration.svcinfo new file mode 100644 index 0000000..1deb5af --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/configuration91.svcinfo new file mode 100644 index 0000000..e574fda --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_collt/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + colltReInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_EquipmentParameter/ProxyServices/EquipmentParameterPS + + + + + + basicHttpBinding + + + colltReInterfaceSoapBinding + + + ESB_collt.ColltReInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + ColltReInterfaceImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/.editorconfig b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/.editorconfig new file mode 100644 index 0000000..e69de29 diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/ExternalDataSync.ESB_daq.daqResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/ExternalDataSync.ESB_daq.daqResponse.datasource new file mode 100644 index 0000000..1cf722c --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/ExternalDataSync.ESB_daq.daqResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_daq.daqResponse, Connected Services.ESB_daq.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/ExternalDataSync.ESB_daq.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/ExternalDataSync.ESB_daq.interfaceResponse.datasource new file mode 100644 index 0000000..bb7d07b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/ExternalDataSync.ESB_daq.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_daq.interfaceResponse, Connected Services.ESB_daq.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/Reference.cs new file mode 100644 index 0000000..e745675 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/Reference.cs @@ -0,0 +1,539 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_daq { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_daq.UexDaqInfoInterface")] + public interface UexDaqInfoInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_daq.daqResponse daq(ExternalDataSync.ESB_daq.daq request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task daqAsync(ExternalDataSync.ESB_daq.daq request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class uexDaqInfoExTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string containerIDField; + + private string daqDateField; + + private string daqIDField; + + private string daqTypeField; + + private string discardQtyField; + + private string effectiveQtyField; + + private string opCodeField; + + private string operateTypeField; + + private string produCodeField; + + private string siteField; + + private string stationField; + + private string unEffectiveQtyField; + + private string workCenterField; + + private string workOrderCodeField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string containerID { + get { + return this.containerIDField; + } + set { + this.containerIDField = value; + this.RaisePropertyChanged("containerID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string daqDate { + get { + return this.daqDateField; + } + set { + this.daqDateField = value; + this.RaisePropertyChanged("daqDate"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string daqID { + get { + return this.daqIDField; + } + set { + this.daqIDField = value; + this.RaisePropertyChanged("daqID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string daqType { + get { + return this.daqTypeField; + } + set { + this.daqTypeField = value; + this.RaisePropertyChanged("daqType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string discardQty { + get { + return this.discardQtyField; + } + set { + this.discardQtyField = value; + this.RaisePropertyChanged("discardQty"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string effectiveQty { + get { + return this.effectiveQtyField; + } + set { + this.effectiveQtyField = value; + this.RaisePropertyChanged("effectiveQty"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string opCode { + get { + return this.opCodeField; + } + set { + this.opCodeField = value; + this.RaisePropertyChanged("opCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=7)] + public string operateType { + get { + return this.operateTypeField; + } + set { + this.operateTypeField = value; + this.RaisePropertyChanged("operateType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=8)] + public string produCode { + get { + return this.produCodeField; + } + set { + this.produCodeField = value; + this.RaisePropertyChanged("produCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=9)] + public string site { + get { + return this.siteField; + } + set { + this.siteField = value; + this.RaisePropertyChanged("site"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=10)] + public string station { + get { + return this.stationField; + } + set { + this.stationField = value; + this.RaisePropertyChanged("station"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=11)] + public string unEffectiveQty { + get { + return this.unEffectiveQtyField; + } + set { + this.unEffectiveQtyField = value; + this.RaisePropertyChanged("unEffectiveQty"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=12)] + public string workCenter { + get { + return this.workCenterField; + } + set { + this.workCenterField = value; + this.RaisePropertyChanged("workCenter"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=13)] + public string workOrderCode { + get { + return this.workOrderCodeField; + } + set { + this.workOrderCodeField = value; + this.RaisePropertyChanged("workOrderCode"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="daq", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class daq { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_daq.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_daq.uexDaqInfoExTo[] arg1; + + public daq() { + } + + public daq(ExternalDataSync.ESB_daq.interfaceRequestHeader arg0, ExternalDataSync.ESB_daq.uexDaqInfoExTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="daqResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class daqResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_daq.interfaceResponse @return; + + public daqResponse() { + } + + public daqResponse(ExternalDataSync.ESB_daq.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface UexDaqInfoInterfaceChannel : ExternalDataSync.ESB_daq.UexDaqInfoInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class UexDaqInfoInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_daq.UexDaqInfoInterface { + + public UexDaqInfoInterfaceClient() { + } + + public UexDaqInfoInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public UexDaqInfoInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public UexDaqInfoInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public UexDaqInfoInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_daq.daqResponse ExternalDataSync.ESB_daq.UexDaqInfoInterface.daq(ExternalDataSync.ESB_daq.daq request) { + return base.Channel.daq(request); + } + + public ExternalDataSync.ESB_daq.interfaceResponse daq(ExternalDataSync.ESB_daq.interfaceRequestHeader arg0, ExternalDataSync.ESB_daq.uexDaqInfoExTo[] arg1) { + ExternalDataSync.ESB_daq.daq inValue = new ExternalDataSync.ESB_daq.daq(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_daq.daqResponse retVal = ((ExternalDataSync.ESB_daq.UexDaqInfoInterface)(this)).daq(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_daq.UexDaqInfoInterface.daqAsync(ExternalDataSync.ESB_daq.daq request) { + return base.Channel.daqAsync(request); + } + + public System.Threading.Tasks.Task daqAsync(ExternalDataSync.ESB_daq.interfaceRequestHeader arg0, ExternalDataSync.ESB_daq.uexDaqInfoExTo[] arg1) { + ExternalDataSync.ESB_daq.daq inValue = new ExternalDataSync.ESB_daq.daq(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_daq.UexDaqInfoInterface)(this)).daqAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/Reference.svcmap new file mode 100644 index 0000000..eea5ee6 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/UexDaqInfoInterface2.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/UexDaqInfoInterface2.wsdl new file mode 100644 index 0000000..73c1449 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/UexDaqInfoInterface2.wsdl @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/configuration.svcinfo new file mode 100644 index 0000000..d480da5 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/configuration91.svcinfo new file mode 100644 index 0000000..78e55eb --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + uexDaqInfoInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_PassingPointInfo/ProxyServices/PassingPointInfoPS + + + + + + basicHttpBinding + + + uexDaqInfoInterfaceSoapBinding + + + ESB_daq.UexDaqInfoInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + UexDaqInfoInterfaceImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/uexDaqInfoInterface.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/uexDaqInfoInterface.wsdl new file mode 100644 index 0000000..8c27c45 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_daq/uexDaqInfoInterface.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/ExternalDataSync.ESB_energy.energyResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/ExternalDataSync.ESB_energy.energyResponse.datasource new file mode 100644 index 0000000..a51c555 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/ExternalDataSync.ESB_energy.energyResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_energy.energyResponse, Connected Services.ESB_energy.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/ExternalDataSync.ESB_energy.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/ExternalDataSync.ESB_energy.interfaceResponse.datasource new file mode 100644 index 0000000..d4d200c --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/ExternalDataSync.ESB_energy.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_energy.interfaceResponse, Connected Services.ESB_energy.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/PctEnergyInfoInterface1.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/PctEnergyInfoInterface1.wsdl new file mode 100644 index 0000000..973cd45 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/PctEnergyInfoInterface1.wsdl @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/Reference.cs new file mode 100644 index 0000000..c62e567 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/Reference.cs @@ -0,0 +1,413 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_energy { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_energy.PctEnergyInfoInterface")] + public interface PctEnergyInfoInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_energy.energyResponse energy(ExternalDataSync.ESB_energy.energy request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task energyAsync(ExternalDataSync.ESB_energy.energy request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class pctEnergyInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string accrueNumField; + + private string energyTypeField; + + private string powerLevelField; + + private string powerLoadField; + + private string sourceCodeField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string accrueNum { + get { + return this.accrueNumField; + } + set { + this.accrueNumField = value; + this.RaisePropertyChanged("accrueNum"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string energyType { + get { + return this.energyTypeField; + } + set { + this.energyTypeField = value; + this.RaisePropertyChanged("energyType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string powerLevel { + get { + return this.powerLevelField; + } + set { + this.powerLevelField = value; + this.RaisePropertyChanged("powerLevel"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string powerLoad { + get { + return this.powerLoadField; + } + set { + this.powerLoadField = value; + this.RaisePropertyChanged("powerLoad"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string sourceCode { + get { + return this.sourceCodeField; + } + set { + this.sourceCodeField = value; + this.RaisePropertyChanged("sourceCode"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="energy", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class energy { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_energy.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_energy.pctEnergyInfoTo[] arg1; + + public energy() { + } + + public energy(ExternalDataSync.ESB_energy.interfaceRequestHeader arg0, ExternalDataSync.ESB_energy.pctEnergyInfoTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="energyResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class energyResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_energy.interfaceResponse @return; + + public energyResponse() { + } + + public energyResponse(ExternalDataSync.ESB_energy.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface PctEnergyInfoInterfaceChannel : ExternalDataSync.ESB_energy.PctEnergyInfoInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class PctEnergyInfoInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_energy.PctEnergyInfoInterface { + + public PctEnergyInfoInterfaceClient() { + } + + public PctEnergyInfoInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public PctEnergyInfoInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public PctEnergyInfoInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public PctEnergyInfoInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_energy.energyResponse ExternalDataSync.ESB_energy.PctEnergyInfoInterface.energy(ExternalDataSync.ESB_energy.energy request) { + return base.Channel.energy(request); + } + + public ExternalDataSync.ESB_energy.interfaceResponse energy(ExternalDataSync.ESB_energy.interfaceRequestHeader arg0, ExternalDataSync.ESB_energy.pctEnergyInfoTo[] arg1) { + ExternalDataSync.ESB_energy.energy inValue = new ExternalDataSync.ESB_energy.energy(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_energy.energyResponse retVal = ((ExternalDataSync.ESB_energy.PctEnergyInfoInterface)(this)).energy(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_energy.PctEnergyInfoInterface.energyAsync(ExternalDataSync.ESB_energy.energy request) { + return base.Channel.energyAsync(request); + } + + public System.Threading.Tasks.Task energyAsync(ExternalDataSync.ESB_energy.interfaceRequestHeader arg0, ExternalDataSync.ESB_energy.pctEnergyInfoTo[] arg1) { + ExternalDataSync.ESB_energy.energy inValue = new ExternalDataSync.ESB_energy.energy(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_energy.PctEnergyInfoInterface)(this)).energyAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/Reference.svcmap new file mode 100644 index 0000000..d5df003 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/configuration.svcinfo new file mode 100644 index 0000000..505dfb2 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/configuration91.svcinfo new file mode 100644 index 0000000..9fe0e55 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + pctEnergyInfoInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_EnergyInfo/ProxyServices/EnergyInfoPS + + + + + + basicHttpBinding + + + pctEnergyInfoInterfaceSoapBinding + + + ESB_energy.PctEnergyInfoInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + PctEnergyInfoImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/pctEnergyInfoInterface.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/pctEnergyInfoInterface.wsdl new file mode 100644 index 0000000..c3416bd --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_energy/pctEnergyInfoInterface.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/EquipExceInterface2.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/EquipExceInterface2.wsdl new file mode 100644 index 0000000..7f19d7d --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/EquipExceInterface2.wsdl @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/ExternalDataSync.ESB_excep.excepResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/ExternalDataSync.ESB_excep.excepResponse.datasource new file mode 100644 index 0000000..e95e165 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/ExternalDataSync.ESB_excep.excepResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_excep.excepResponse, Connected Services.ESB_excep.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/ExternalDataSync.ESB_excep.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/ExternalDataSync.ESB_excep.interfaceResponse.datasource new file mode 100644 index 0000000..343e81e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/ExternalDataSync.ESB_excep.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_excep.interfaceResponse, Connected Services.ESB_excep.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/Reference.cs new file mode 100644 index 0000000..f6c392b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/Reference.cs @@ -0,0 +1,497 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_excep { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_excep.EquipExceInterface")] + public interface EquipExceInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_excep.excepResponse excep(ExternalDataSync.ESB_excep.excep request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task excepAsync(ExternalDataSync.ESB_excep.excep request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class equipExceInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string acqTimeField; + + private string alarmContentField; + + private string alarmNumberField; + + private string equipCodeField; + + private string equipStateField; + + private string isAlarmField; + + private string opCodeField; + + private string siteField; + + private string stateValueField; + + private string workCellCodeField; + + private string workCenterField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string acqTime { + get { + return this.acqTimeField; + } + set { + this.acqTimeField = value; + this.RaisePropertyChanged("acqTime"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string alarmContent { + get { + return this.alarmContentField; + } + set { + this.alarmContentField = value; + this.RaisePropertyChanged("alarmContent"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string alarmNumber { + get { + return this.alarmNumberField; + } + set { + this.alarmNumberField = value; + this.RaisePropertyChanged("alarmNumber"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string equipCode { + get { + return this.equipCodeField; + } + set { + this.equipCodeField = value; + this.RaisePropertyChanged("equipCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string equipState { + get { + return this.equipStateField; + } + set { + this.equipStateField = value; + this.RaisePropertyChanged("equipState"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string isAlarm { + get { + return this.isAlarmField; + } + set { + this.isAlarmField = value; + this.RaisePropertyChanged("isAlarm"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string opCode { + get { + return this.opCodeField; + } + set { + this.opCodeField = value; + this.RaisePropertyChanged("opCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=7)] + public string site { + get { + return this.siteField; + } + set { + this.siteField = value; + this.RaisePropertyChanged("site"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=8)] + public string stateValue { + get { + return this.stateValueField; + } + set { + this.stateValueField = value; + this.RaisePropertyChanged("stateValue"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=9)] + public string workCellCode { + get { + return this.workCellCodeField; + } + set { + this.workCellCodeField = value; + this.RaisePropertyChanged("workCellCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=10)] + public string workCenter { + get { + return this.workCenterField; + } + set { + this.workCenterField = value; + this.RaisePropertyChanged("workCenter"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="excep", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class excep { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_excep.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_excep.equipExceInfoTo[] arg1; + + public excep() { + } + + public excep(ExternalDataSync.ESB_excep.interfaceRequestHeader arg0, ExternalDataSync.ESB_excep.equipExceInfoTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="excepResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class excepResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_excep.interfaceResponse @return; + + public excepResponse() { + } + + public excepResponse(ExternalDataSync.ESB_excep.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface EquipExceInterfaceChannel : ExternalDataSync.ESB_excep.EquipExceInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class EquipExceInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_excep.EquipExceInterface { + + public EquipExceInterfaceClient() { + } + + public EquipExceInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public EquipExceInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public EquipExceInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public EquipExceInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_excep.excepResponse ExternalDataSync.ESB_excep.EquipExceInterface.excep(ExternalDataSync.ESB_excep.excep request) { + return base.Channel.excep(request); + } + + public ExternalDataSync.ESB_excep.interfaceResponse excep(ExternalDataSync.ESB_excep.interfaceRequestHeader arg0, ExternalDataSync.ESB_excep.equipExceInfoTo[] arg1) { + ExternalDataSync.ESB_excep.excep inValue = new ExternalDataSync.ESB_excep.excep(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_excep.excepResponse retVal = ((ExternalDataSync.ESB_excep.EquipExceInterface)(this)).excep(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_excep.EquipExceInterface.excepAsync(ExternalDataSync.ESB_excep.excep request) { + return base.Channel.excepAsync(request); + } + + public System.Threading.Tasks.Task excepAsync(ExternalDataSync.ESB_excep.interfaceRequestHeader arg0, ExternalDataSync.ESB_excep.equipExceInfoTo[] arg1) { + ExternalDataSync.ESB_excep.excep inValue = new ExternalDataSync.ESB_excep.excep(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_excep.EquipExceInterface)(this)).excepAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/Reference.svcmap new file mode 100644 index 0000000..475d6f7 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/configuration.svcinfo new file mode 100644 index 0000000..c9d20dc --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/configuration91.svcinfo new file mode 100644 index 0000000..6d221fe --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + equipExceInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_EquipmentFailInfo/ProxyServices/EquipmentFailInfoPS + + + + + + basicHttpBinding + + + equipExceInterfaceSoapBinding + + + ESB_excep.EquipExceInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + EquipExceInterfaceImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/equipExceInterface1.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/equipExceInterface1.wsdl new file mode 100644 index 0000000..fa1182a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_excep/equipExceInterface1.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/EquipHistoryInterface2.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/EquipHistoryInterface2.wsdl new file mode 100644 index 0000000..8c9feaf --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/EquipHistoryInterface2.wsdl @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/ExternalDataSync.ESB_history.historyResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/ExternalDataSync.ESB_history.historyResponse.datasource new file mode 100644 index 0000000..3a638e2 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/ExternalDataSync.ESB_history.historyResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_history.historyResponse, Connected Services.ESB_history.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/ExternalDataSync.ESB_history.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/ExternalDataSync.ESB_history.interfaceResponse.datasource new file mode 100644 index 0000000..9202819 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/ExternalDataSync.ESB_history.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_history.interfaceResponse, Connected Services.ESB_history.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/Reference.cs new file mode 100644 index 0000000..9e813aa --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/Reference.cs @@ -0,0 +1,469 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_history { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_history.EquipHistoryInterface")] + public interface EquipHistoryInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_history.historyResponse history(ExternalDataSync.ESB_history.history request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task historyAsync(ExternalDataSync.ESB_history.history request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class equipHistoryInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string equipCodeField; + + private string equipStateField; + + private string opCodeField; + + private string siteField; + + private string stateStartTimeField; + + private string stateSwtichTimeField; + + private string stateValueField; + + private string workCellCodeField; + + private string workCenterField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string equipCode { + get { + return this.equipCodeField; + } + set { + this.equipCodeField = value; + this.RaisePropertyChanged("equipCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string equipState { + get { + return this.equipStateField; + } + set { + this.equipStateField = value; + this.RaisePropertyChanged("equipState"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string opCode { + get { + return this.opCodeField; + } + set { + this.opCodeField = value; + this.RaisePropertyChanged("opCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string site { + get { + return this.siteField; + } + set { + this.siteField = value; + this.RaisePropertyChanged("site"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string stateStartTime { + get { + return this.stateStartTimeField; + } + set { + this.stateStartTimeField = value; + this.RaisePropertyChanged("stateStartTime"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string stateSwtichTime { + get { + return this.stateSwtichTimeField; + } + set { + this.stateSwtichTimeField = value; + this.RaisePropertyChanged("stateSwtichTime"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string stateValue { + get { + return this.stateValueField; + } + set { + this.stateValueField = value; + this.RaisePropertyChanged("stateValue"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=7)] + public string workCellCode { + get { + return this.workCellCodeField; + } + set { + this.workCellCodeField = value; + this.RaisePropertyChanged("workCellCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=8)] + public string workCenter { + get { + return this.workCenterField; + } + set { + this.workCenterField = value; + this.RaisePropertyChanged("workCenter"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="history", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class history { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_history.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_history.equipHistoryInfoTo[] arg1; + + public history() { + } + + public history(ExternalDataSync.ESB_history.interfaceRequestHeader arg0, ExternalDataSync.ESB_history.equipHistoryInfoTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="historyResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class historyResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_history.interfaceResponse @return; + + public historyResponse() { + } + + public historyResponse(ExternalDataSync.ESB_history.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface EquipHistoryInterfaceChannel : ExternalDataSync.ESB_history.EquipHistoryInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class EquipHistoryInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_history.EquipHistoryInterface { + + public EquipHistoryInterfaceClient() { + } + + public EquipHistoryInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public EquipHistoryInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public EquipHistoryInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public EquipHistoryInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_history.historyResponse ExternalDataSync.ESB_history.EquipHistoryInterface.history(ExternalDataSync.ESB_history.history request) { + return base.Channel.history(request); + } + + public ExternalDataSync.ESB_history.interfaceResponse history(ExternalDataSync.ESB_history.interfaceRequestHeader arg0, ExternalDataSync.ESB_history.equipHistoryInfoTo[] arg1) { + ExternalDataSync.ESB_history.history inValue = new ExternalDataSync.ESB_history.history(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_history.historyResponse retVal = ((ExternalDataSync.ESB_history.EquipHistoryInterface)(this)).history(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_history.EquipHistoryInterface.historyAsync(ExternalDataSync.ESB_history.history request) { + return base.Channel.historyAsync(request); + } + + public System.Threading.Tasks.Task historyAsync(ExternalDataSync.ESB_history.interfaceRequestHeader arg0, ExternalDataSync.ESB_history.equipHistoryInfoTo[] arg1) { + ExternalDataSync.ESB_history.history inValue = new ExternalDataSync.ESB_history.history(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_history.EquipHistoryInterface)(this)).historyAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/Reference.svcmap new file mode 100644 index 0000000..791ec58 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/configuration.svcinfo new file mode 100644 index 0000000..4a9ac8e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/configuration91.svcinfo new file mode 100644 index 0000000..d24c780 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + equipHistoryInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_EquipmentStateInfo/ProxyServices/EquipmentStateInfoPS + + + + + + basicHttpBinding + + + equipHistoryInterfaceSoapBinding + + + ESB_history.EquipHistoryInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + EquipHistoryInterfaceImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/equipHistoryInterface.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/equipHistoryInterface.wsdl new file mode 100644 index 0000000..ce3f75d --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_history/equipHistoryInterface.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/ExternalDataSync.ESB_life.interfaceResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/ExternalDataSync.ESB_life.interfaceResponse.datasource new file mode 100644 index 0000000..259864c --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/ExternalDataSync.ESB_life.interfaceResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_life.interfaceResponse, Connected Services.ESB_life.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/ExternalDataSync.ESB_life.lifeResponse.datasource b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/ExternalDataSync.ESB_life.lifeResponse.datasource new file mode 100644 index 0000000..bf72632 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/ExternalDataSync.ESB_life.lifeResponse.datasource @@ -0,0 +1,10 @@ + + + + ExternalDataSync.ESB_life.lifeResponse, Connected Services.ESB_life.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/Reference.cs b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/Reference.cs new file mode 100644 index 0000000..f01b6e8 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/Reference.cs @@ -0,0 +1,567 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.ESB_life { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://zk.ws.epichust.com/", ConfigurationName="ESB_life.UrmRsBaseLifeInterface")] + public interface UrmRsBaseLifeInterface { + + // CODEGEN: 参数“return”需要其他方案信息,使用参数模式无法捕获这些信息。特定特性为“System.Xml.Serialization.XmlElementAttribute”。 + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + [return: System.ServiceModel.MessageParameterAttribute(Name="return")] + ExternalDataSync.ESB_life.lifeResponse life(ExternalDataSync.ESB_life.life request); + + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + System.Threading.Tasks.Task lifeAsync(ExternalDataSync.ESB_life.life request); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceRequestHeader : object, System.ComponentModel.INotifyPropertyChanged { + + private string interfaceIDField; + + private string messageIDField; + + private string receiverField; + + private string senderField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string receiver { + get { + return this.receiverField; + } + set { + this.receiverField = value; + this.RaisePropertyChanged("receiver"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string sender { + get { + return this.senderField; + } + set { + this.senderField = value; + this.RaisePropertyChanged("sender"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class interfaceResponse : object, System.ComponentModel.INotifyPropertyChanged { + + private string commentField; + + private string interfaceIDField; + + private string messageIDField; + + private string resultCodeField; + + private string resultMessageField; + + private string resultTypeField; + + private string transIDField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string comment { + get { + return this.commentField; + } + set { + this.commentField = value; + this.RaisePropertyChanged("comment"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string interfaceID { + get { + return this.interfaceIDField; + } + set { + this.interfaceIDField = value; + this.RaisePropertyChanged("interfaceID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string messageID { + get { + return this.messageIDField; + } + set { + this.messageIDField = value; + this.RaisePropertyChanged("messageID"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string resultCode { + get { + return this.resultCodeField; + } + set { + this.resultCodeField = value; + this.RaisePropertyChanged("resultCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string resultMessage { + get { + return this.resultMessageField; + } + set { + this.resultMessageField = value; + this.RaisePropertyChanged("resultMessage"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string resultType { + get { + return this.resultTypeField; + } + set { + this.resultTypeField = value; + this.RaisePropertyChanged("resultType"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string transID { + get { + return this.transIDField; + } + set { + this.transIDField = value; + this.RaisePropertyChanged("transID"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4161.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://zk.ws.epichust.com/")] + public partial class baseLifeInfoTo : object, System.ComponentModel.INotifyPropertyChanged { + + private string acqTimeField; + + private string dupField; + + private string equipCodeField; + + private string kpartCodeField; + + private string magField; + + private string placeField; + + private string proCodeField; + + private string siteField; + + private string toolAlarmField; + + private string toolCodeField; + + private string toolProductionField; + + private string toolResidualField; + + private string toolSetField; + + private string workCellCodeField; + + private string workCenterField; + + private string tNumberField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)] + public string acqTime { + get { + return this.acqTimeField; + } + set { + this.acqTimeField = value; + this.RaisePropertyChanged("acqTime"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)] + public string dup { + get { + return this.dupField; + } + set { + this.dupField = value; + this.RaisePropertyChanged("dup"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)] + public string equipCode { + get { + return this.equipCodeField; + } + set { + this.equipCodeField = value; + this.RaisePropertyChanged("equipCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)] + public string kpartCode { + get { + return this.kpartCodeField; + } + set { + this.kpartCodeField = value; + this.RaisePropertyChanged("kpartCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)] + public string mag { + get { + return this.magField; + } + set { + this.magField = value; + this.RaisePropertyChanged("mag"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)] + public string place { + get { + return this.placeField; + } + set { + this.placeField = value; + this.RaisePropertyChanged("place"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)] + public string proCode { + get { + return this.proCodeField; + } + set { + this.proCodeField = value; + this.RaisePropertyChanged("proCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=7)] + public string site { + get { + return this.siteField; + } + set { + this.siteField = value; + this.RaisePropertyChanged("site"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=8)] + public string toolAlarm { + get { + return this.toolAlarmField; + } + set { + this.toolAlarmField = value; + this.RaisePropertyChanged("toolAlarm"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=9)] + public string toolCode { + get { + return this.toolCodeField; + } + set { + this.toolCodeField = value; + this.RaisePropertyChanged("toolCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=10)] + public string toolProduction { + get { + return this.toolProductionField; + } + set { + this.toolProductionField = value; + this.RaisePropertyChanged("toolProduction"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=11)] + public string toolResidual { + get { + return this.toolResidualField; + } + set { + this.toolResidualField = value; + this.RaisePropertyChanged("toolResidual"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=12)] + public string toolSet { + get { + return this.toolSetField; + } + set { + this.toolSetField = value; + this.RaisePropertyChanged("toolSet"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=13)] + public string workCellCode { + get { + return this.workCellCodeField; + } + set { + this.workCellCodeField = value; + this.RaisePropertyChanged("workCellCode"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=14)] + public string workCenter { + get { + return this.workCenterField; + } + set { + this.workCenterField = value; + this.RaisePropertyChanged("workCenter"); + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=15)] + public string tNumber { + get { + return this.tNumberField; + } + set { + this.tNumberField = value; + this.RaisePropertyChanged("tNumber"); + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="life", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class life { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_life.interfaceRequestHeader arg0; + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=1)] + [System.Xml.Serialization.XmlElementAttribute("arg1", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_life.baseLifeInfoTo[] arg1; + + public life() { + } + + public life(ExternalDataSync.ESB_life.interfaceRequestHeader arg0, ExternalDataSync.ESB_life.baseLifeInfoTo[] arg1) { + this.arg0 = arg0; + this.arg1 = arg1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(WrapperName="lifeResponse", WrapperNamespace="http://zk.ws.epichust.com/", IsWrapped=true)] + public partial class lifeResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://zk.ws.epichust.com/", Order=0)] + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ExternalDataSync.ESB_life.interfaceResponse @return; + + public lifeResponse() { + } + + public lifeResponse(ExternalDataSync.ESB_life.interfaceResponse @return) { + this.@return = @return; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface UrmRsBaseLifeInterfaceChannel : ExternalDataSync.ESB_life.UrmRsBaseLifeInterface, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class UrmRsBaseLifeInterfaceClient : System.ServiceModel.ClientBase, ExternalDataSync.ESB_life.UrmRsBaseLifeInterface { + + public UrmRsBaseLifeInterfaceClient() { + } + + public UrmRsBaseLifeInterfaceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public UrmRsBaseLifeInterfaceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public UrmRsBaseLifeInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public UrmRsBaseLifeInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + ExternalDataSync.ESB_life.lifeResponse ExternalDataSync.ESB_life.UrmRsBaseLifeInterface.life(ExternalDataSync.ESB_life.life request) { + return base.Channel.life(request); + } + + public ExternalDataSync.ESB_life.interfaceResponse life(ExternalDataSync.ESB_life.interfaceRequestHeader arg0, ExternalDataSync.ESB_life.baseLifeInfoTo[] arg1) { + ExternalDataSync.ESB_life.life inValue = new ExternalDataSync.ESB_life.life(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + ExternalDataSync.ESB_life.lifeResponse retVal = ((ExternalDataSync.ESB_life.UrmRsBaseLifeInterface)(this)).life(inValue); + return retVal.@return; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task ExternalDataSync.ESB_life.UrmRsBaseLifeInterface.lifeAsync(ExternalDataSync.ESB_life.life request) { + return base.Channel.lifeAsync(request); + } + + public System.Threading.Tasks.Task lifeAsync(ExternalDataSync.ESB_life.interfaceRequestHeader arg0, ExternalDataSync.ESB_life.baseLifeInfoTo[] arg1) { + ExternalDataSync.ESB_life.life inValue = new ExternalDataSync.ESB_life.life(); + inValue.arg0 = arg0; + inValue.arg1 = arg1; + return ((ExternalDataSync.ESB_life.UrmRsBaseLifeInterface)(this)).lifeAsync(inValue); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/Reference.svcmap b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/Reference.svcmap new file mode 100644 index 0000000..c8cffda --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/UrmRsBaseLifeInterface2.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/UrmRsBaseLifeInterface2.wsdl new file mode 100644 index 0000000..30c0b81 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/UrmRsBaseLifeInterface2.wsdl @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/configuration.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/configuration.svcinfo new file mode 100644 index 0000000..c196433 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/configuration91.svcinfo b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/configuration91.svcinfo new file mode 100644 index 0000000..3c26e59 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + urmRsBaseLifeInterfaceSoapBinding + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (集合) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://10.6.201.184:8011/CDMOM/COMMON/COMMON2CDMOM_CutterStateInfo/ProxyServices/CutterStateInfoPS + + + + + + basicHttpBinding + + + urmRsBaseLifeInterfaceSoapBinding + + + ESB_life.UrmRsBaseLifeInterface + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + UrmRsBaseLifeInterfaceImplPort + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/urmRsBaseLifeInterface1.wsdl b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/urmRsBaseLifeInterface1.wsdl new file mode 100644 index 0000000..4b19020 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Connected Services/ESB_life/urmRsBaseLifeInterface1.wsdl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + OSB Service + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/ExternalDataSync.csproj b/Interface_WebAPI/SlMesDbIterface/ExternalDataSync.csproj new file mode 100644 index 0000000..812ee07 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/ExternalDataSync.csproj @@ -0,0 +1,522 @@ + + + + + Debug + AnyCPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A} + WinExe + ExternalDataSync + ExternalDataSync + v4.8 + 512 + true + true + + + + + + AnyCPU + true + full + false + bin\ExternalDataSync\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + 系统管理和监控服务.ico + + + + + ..\DLL\BasicData.dll + + + False + bin\ExternalDataSync\DataLinkMesWork.dll + + + ..\DLL\ICSharpCode.SharpZipLib.dll + + + False + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\..\MisDataFun\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll + + + ..\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll + + + ..\..\MisDataFun\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\DLL\NPOI.dll + + + ..\DLL\NPOI.OOXML.dll + + + ..\DLL\NPOI.OpenXml4Net.dll + + + ..\DLL\NPOI.OpenXmlFormats.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + ..\packages\SharpCompress.0.30.1\lib\net461\SharpCompress.dll + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + + ..\packages\System.Security.AccessControl.5.0.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll + + + + ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + ..\packages\Microsoft.AspNet.Cors.5.2.9\libet45\System.Web.Cors.dll + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.9\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.Cors.5.2.9\lib\net45\System.Web.Http.Cors.dll + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.9\lib\net45\System.Web.Http.Owin.dll + + + ..\packages\Microsoft.AspNet.WebApi.SelfHost.5.2.9\lib\net45\System.Web.Http.SelfHost.dll + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.9\lib\net45\System.Web.Http.WebHost.dll + + + + ..\packages\System.Web.Services.Description.4.10.2\lib\net461\System.Web.Services.Description.dll + + + + + + + + + + + ..\..\packages\WinSCP.6.5.3\lib\net40\WinSCPnet.dll + + + + + + + + + + + + + + + + + + + + + + + True + True + Reference.svcmap + + + True + True + Reference.svcmap + + + True + True + Reference.svcmap + + + True + True + Reference.svcmap + + + True + True + Reference.svcmap + + + True + True + Reference.svcmap + + + True + True + Reference.svcmap + + + Form + + + Form_MoveSqlTable.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form_MoveSqlTable.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + Reference.svcmap + + + Reference.svcmap + + + + + + + Reference.svcmap + + + Reference.svcmap + + + + Reference.svcmap + + + Reference.svcmap + + + + + Reference.svcmap + + + Reference.svcmap + + + + + + + Reference.svcmap + + + Reference.svcmap + + + + + Reference.svcmap + + + Reference.svcmap + + + Reference.svcmap + + + Reference.svcmap + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WCF Proxy Generator + Reference.cs + + + + + WCF Proxy Generator + Reference.cs + + + + + WCF Proxy Generator + Reference.cs + + + + + WCF Proxy Generator + Reference.cs + + + + + WCF Proxy Generator + Reference.cs + + + + + WCF Proxy Generator + Reference.cs + + + + + WCF Proxy Generator + Reference.cs + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {5c0c572b-f8f1-41de-b049-4d40ae29cd21} + 99-DataBaseAccess2 + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 13.3MIS_FuntionSaveData + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + + + + + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.Designer.cs b/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.Designer.cs new file mode 100644 index 0000000..73418af --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.Designer.cs @@ -0,0 +1,207 @@ + +namespace SlMesDbIterface +{ + partial class Form_MoveSqlTable + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form_MoveSqlTable)); + this.richTextBoxLogBox = new System.Windows.Forms.RichTextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button56 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // richTextBoxLogBox + // + this.richTextBoxLogBox.Location = new System.Drawing.Point(3, 47); + this.richTextBoxLogBox.Name = "richTextBoxLogBox"; + this.richTextBoxLogBox.Size = new System.Drawing.Size(518, 361); + this.richTextBoxLogBox.TabIndex = 2; + this.richTextBoxLogBox.Text = ""; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 22F); + this.label1.Location = new System.Drawing.Point(8, 6); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(133, 30); + this.label1.TabIndex = 3; + this.label1.Text = "数据接口"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(538, 165); + this.button1.Margin = new System.Windows.Forms.Padding(2); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(109, 34); + this.button1.TabIndex = 4; + this.button1.Text = "生产开工"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(538, 203); + this.button2.Margin = new System.Windows.Forms.Padding(2); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(109, 34); + this.button2.TabIndex = 4; + this.button2.Text = "产线报警"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(538, 243); + this.button3.Margin = new System.Windows.Forms.Padding(2); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(109, 34); + this.button3.TabIndex = 4; + this.button3.Text = "工序完工"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button56 + // + this.button56.Location = new System.Drawing.Point(538, 281); + this.button56.Margin = new System.Windows.Forms.Padding(2); + this.button56.Name = "button56"; + this.button56.Size = new System.Drawing.Size(109, 34); + this.button56.TabIndex = 4; + this.button56.Text = "任务完工与报工"; + this.button56.UseVisualStyleBackColor = true; + this.button56.Click += new System.EventHandler(this.button56_Click); + // + // button5 + // + this.button5.Location = new System.Drawing.Point(538, 47); + this.button5.Margin = new System.Windows.Forms.Padding(2); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(109, 34); + this.button5.TabIndex = 4; + this.button5.Text = "物料配送"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button4_Click); + // + // button4 + // + this.button4.Location = new System.Drawing.Point(538, 367); + this.button4.Margin = new System.Windows.Forms.Padding(2); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(109, 31); + this.button4.TabIndex = 5; + this.button4.Text = "缓存位置查询"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click_1); + // + // button6 + // + this.button6.Location = new System.Drawing.Point(538, 85); + this.button6.Margin = new System.Windows.Forms.Padding(2); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(109, 34); + this.button6.TabIndex = 4; + this.button6.Text = "器具信息查询"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button6_Click); + // + // button7 + // + this.button7.Location = new System.Drawing.Point(538, 123); + this.button7.Margin = new System.Windows.Forms.Padding(2); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(109, 34); + this.button7.TabIndex = 4; + this.button7.Text = "物料配送确认"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.button7_Click); + // + // button8 + // + this.button8.Location = new System.Drawing.Point(538, 319); + this.button8.Margin = new System.Windows.Forms.Padding(2); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(109, 34); + this.button8.TabIndex = 4; + this.button8.Text = "转序(点对点)"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.button8_Click); + // + // Form_MoveSqlTable + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(680, 409); + this.Controls.Add(this.button4); + this.Controls.Add(this.button7); + this.Controls.Add(this.button6); + this.Controls.Add(this.button5); + this.Controls.Add(this.button8); + this.Controls.Add(this.button56); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.label1); + this.Controls.Add(this.richTextBoxLogBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(2); + this.MaximizeBox = false; + this.Name = "Form_MoveSqlTable"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "20250106.1105"; + this.Load += new System.EventHandler(this.Form_MoveSqlTable_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.RichTextBox richTextBoxLogBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button56; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.cs b/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.cs new file mode 100644 index 0000000..59f4c39 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.cs @@ -0,0 +1,325 @@ +using MisDataSaveDate; +using MisDataSaveDate.MOM; +using Newtonsoft.Json; +using NPOI.SS.Formula.Functions; +using PLMTEST; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using WebApi; +using static NPOI.HSSF.Record.UnicodeString; +using static System.Configuration.ConfigurationManager; + +/// +/// +/// +namespace SlMesDbIterface +{ + public partial class Form_MoveSqlTable : Form + { + public static Action Delegate_UpdateValue = null; + public int count = 0; + //InitServer initServer = null; + + /// + /// + /// + public Form_MoveSqlTable() + { + InitializeComponent(); + } + + private void Form_MoveSqlTable_Load(object sender, EventArgs e) + { + //MyLog4Net.MyLogHelper.LogCommit += MyLogHelper_LogCommit; + //initServer = new InitServer(); + } + + private void MyLogHelper_LogCommit(object sender, MyLog4Net.MyLogEventArgs e) + { + var module = e.Module; + var message = e.Message; + + var log = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + module + " " + message + "\r\n"; + + count++; + + + if (this.InvokeRequired) + { + this.Invoke(new Action(() => + { + if (count > 100) + { + this.richTextBoxLogBox.Text = ""; + } + this.richTextBoxLogBox.AppendText(log); + // this.richTextBoxLogBox.Text += log; + richTextBoxLogBox.Focus(); + })); + } + else + { + if (count > 100) + { + this.richTextBoxLogBox.Text = ""; + } + this.richTextBoxLogBox.AppendText(log); + // this.richTextBoxLogBox.Text += log; + richTextBoxLogBox.Focus(); + } + + } + + private void Form_MoveSqlTable_FormClosing_1(object sender, FormClosingEventArgs e) + { + + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + //new TaskFactory().StartNew(delegate () + //{ + try + { + CALL_Inerface_DataHandle.CALL_Inerface_JobStart("AC2401", "SCDD-0302-250707-0410-01", "SCDD-0302-250707-0410-01"); + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Info("生产开工接口res:", err.Message); + } + //}); + } + + private void button2_Click(object sender, EventArgs e) + { + try + { + CALL_Inerface_DataHandle.CALL_Inerface_DeviceAlarm("AC0901", "90010003", "1", "测试报警信息!"); + } + + catch (Exception err) + { + MyLog4Net.MyLogHelper.Info("产线报警接口res:", err.Message); + } + } + + private void button3_Click(object sender, EventArgs e) + { + + try + { + //JobFinished productionReport = GenerateTestData_ProductionReport(); + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_ProcessJobFinish"]; + //var result = CALL_Interface_WebAPI.CALL_WebApi_JobFinished(InterfaceUrl,productionReport); + //richTextBoxLogBox.Text = result.ToString(); + CALL_Inerface_DataHandle.CALL_Inerface_JobFinished("AC2401", "SCDD-0302-250707-0410-01", "SCDD-0302-250707-0410-01"); + } + + catch (Exception err) + { + MyLog4Net.MyLogHelper.Info("工序完工接口res:", err.Message); + } + + } + + private void button4_Click(object sender, EventArgs e) + { + //new TaskFactory().StartNew(delegate () + //{ + try + { + // 1退托盘,2叫料,3送料,4转序 + CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial("AC0901-2", "2"); + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Info("物料配送接口res:", err.Message); + } + //}); + } + + private void button56_Click(object sender, EventArgs e) + { + //new TaskFactory().StartNew(delegate () + //{ + try + { + TaskFinish taskFinish = GenerateTestData_taskFinish(); + var result = CALL_Interface_WebAPI.CALL_WebApi_FinishedReport(taskFinish); + richTextBoxLogBox.Text = result.ToString(); + + } + + catch (Exception err) + { + MyLog4Net.MyLogHelper.Info("任务完工与工时汇报接口res:", err.Message); + } + //}); + } + + public static JobFinished GenerateTestData_ProductionReport() + { + return new JobFinished + { + orderID = "OrderID20250512", + taskID = "TASK202403150001", + finishedQuantity = 100.00m, + createTime = "2024-03-15 08:00:00", + endTime = "2024-03-15 17:00:00", + beat = 5.5m, + processNo = "PROC001", + lastModifiedTime = "2024-03-15 17:00:00", + operation = "操作人", + inspectionInfo = new List + { + new InspectionInfo + { + Inspectcode = "INS202403150001", + inspector = "张三", + inspectionTime = "2024-03-15 16:30:00", + qualifiedQuantity = 98.00m, + unqualifiedQuantity = 2.00m, + inspectionDetails = new List + { + new InspectionDetail + { + inspectionItemID = "ITEM001", + inspectionItemNo = "CHECK001", + inspectionItemName = "尺寸检查", + inspectionValue = "检测值", + inspectionStandardText = "标准尺寸检查", + upperLimitSymbol = "≤", + upperLimitValue = 11.0m, + lowerLimitSymbol = "≥", + lowerLimitValue = 10.0m, + standardValue = 10.5m, + inspectionResult = "检验结果" + }, + new InspectionDetail + { + inspectionItemID = "ITEM002", + inspectionItemNo = "CHECK002", + inspectionItemName = "重量检查", + inspectionValue = "检测值", + inspectionStandardText = "标准重量检查", + upperLimitSymbol = "≤", + upperLimitValue = 550.0m, + lowerLimitSymbol = "≥", + lowerLimitValue = 450.0m, + standardValue = 500.0m, + inspectionResult = "检验结果" + } + } + } + }, + materialInfo = new List + { + new MaterialInfo + { + consumedMaterialNo = "MAT001", + qty = 1.0m, + qualifiedqty = 1.0m, + unqualifiedqty = 0.0m, + inspectionTool = "游标卡尺", + batchNo = "BATCH202403150001", + serialNo = "序列号" + }, + new MaterialInfo + { + consumedMaterialNo = "MAT002", + qty = 1.0m, + qualifiedqty = 1.0m, + unqualifiedqty = 0.0m, + inspectionTool = "电子秤", + batchNo = "BATCH202403150002", + serialNo = "序列号" + } + }, + workinghours = new List + { + new Workinghours + { + employee = "员工1", + quantity = 1.0m, + workingHours = 1.0m, + }, + new Workinghours + { + employee = "员工2", + quantity = 1.0m, + workingHours = 1.0m, + } + } + }; + } + + public static TaskFinish GenerateTestData_taskFinish() + { + return new TaskFinish + { + orderID = "ORD202403150002", + taskID = "TASK202403150003", + employee = "王五", + quantity = 120, + workingHours = 9 + }; + } + + private void button4_Click_1(object sender, EventArgs e) + { + new TaskFactory().StartNew(delegate () + { + try + { + MaterialPosition materialPosition = new MaterialPosition + { + requestId = "请求ID", + process = "工序" + }; + //var result = CALL_Interface_WebAPI.CALL_WebApi_CallMaterial(materialSend); + //richTextBoxLogBox.Text = result.ToString(); + } + + catch (Exception err) + { + MyLog4Net.MyLogHelper.Info("缓存位置查询接口res:", err.Message); + } + }); + } + + private void button6_Click(object sender, EventArgs e) + { + CALL_Inerface_DataHandle.CALL_Inerface_DeviceInfoQuery("AC0901-2", "Y1030121000595"); + } + + private void button7_Click(object sender, EventArgs e) + { + CALL_Inerface_DataHandle.CALL_Inerface_MaterialConfirm("AC0901-02", "YX126GISSGW002"); + } + + private void button8_Click(object sender, EventArgs e) + { + CALL_Inerface_DataHandle.CALL_Inerface_MaterialTransfer("ACHC01", "ACHC02", "211"); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.resx b/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.resx new file mode 100644 index 0000000..aedf36b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Form_MoveSqlTable.resx @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 47 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnVsKAKFdDgChXQ4CoV0OBaFdDgWhXQ4FoVwNBaBc + DAWgXAwFoFwMBaBcDAWhXA0FoV0OBaFdDgWhXQ4FoV0OAqFdDgChXQ4AAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACdWwoAoV0OAKFdDk6hXQ6voV0OrqFd + Dq6hXA2uoFwMrqBcDK6gXAyuoFwMrqFcDa6hXQ6uoV0OrqFdDq+hXQ5IoV0OAKFdDgAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ1bCwCiXQ4AoV0OLaFd + DmWhXQ11o2EU7MKYZv/OrYX/zayD/82sg//OrYX/xZxs/6RjF+yhXA11oV0OZKFdDimhXQ4AoV0OAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAChXQ4AoVwOAKFdDgChXQ4AoV0OAKFdDgChXQ4AoV0OAKFd + DgChXQ4AoV0OAJ9YBhSlZBnZ3Mar//Hs4v/w6t//8Orf//Hr4v/gzrb/p2ge2Z1VAhShXQ4AoV0OAKFd + DgChXQ4AoV0OAKFdDgChXQ4AoV0OAKFdDgCiXhAAoVwNAKFdDgChXQ4AoV0OD6FdDiqhXQ4uoV0OLaFd + Di2hXQ4toV0OLaFdDi2hXQ4soFwMQ6RjF+LStI//49K8/+LQuv/i0Lr/49K8/9W6mP+mZhvioFsLQ6Fd + DiyhXQ4toV0OLaFdDi2hXQ4toV0OLaFdDi6hXQ4poV0ODaFdDgCiXQ8AoV0OAKFdDiehXQ60oV0OzqFd + DsmhXQ7KoV0OyqFdDsqhXQ7KoV0OyqFdDsmhXQ7MoV4P3KdoH9+pbCXfqWwk36lsJN+pbCTfqGkg36Fe + ENyhXQ7MoV0OyaFdDsqhXQ7KoV0OyqFdDsqhXQ7KoV0OyaFdDs6hXQ6woV0OI6FdDgChXQ0AoV0Oj6Fd + DqyhXQ4ooF0OIaBdDiGgXQ4hoF0OIaBdDiGgXQ4hoF0OIaBdDiGgXA4gnVgGIJxWBCCdVgQgnVYEIJxW + BCCdVwYgoFwNIKBdDiGgXQ4hoF0OIaBdDiGgXQ4hoF0OIaBdDiGgXQ4hoV0OKqFdDrKhXQ6JolwOAKFd + DgShXQ6woV0ObqFdDgCgXQ4AoF0OAKBdDgCgXQ4AoF0OAKBdDgCgXQ4AoF0OAKBdDgCgXQ4AoF0OAKBd + DgCgXQ4AoV0OAKFdDgCgXQ4AoF0OAKBdDgCgXQ4AoF0OAKBdDgCgXQ4AoF0OAKBdDgChXQ4AoV0Ob6Fd + DqeiXQ0DoV0OBaFdDrChXQ5toV0OAKFdDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoV4NAKBd + DgCdXw4AoV0OAKFdDg+hXQ5WoV0OIKFdDgChXQ4An10OAAAAAAAAAAAAAAAAAAAAAAAAAAAAoV0OAKFd + DgChXQ5toV0Op6NdDAOhXQ4FoV0OsKFdDm2hXQ4AoV0OAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKJb + CwChXQ4AoV0OAKFdDgChXQ4moV0OqKFdDuOhXQ6toV0OFKFdDgChXQ4AAAAAAAAAAAAAAAAAAAAAAAAA + AAChXQ4AoV0OAKFdDm2hXQ6no10MA6FdDgWhXQ6woV0ObaFdDgChXQ4AoV0OAKFdDgCfWwwAAAAAAAAA + AAChXg4AoV0OAKFdDgCgXg0BoV0OTaFdDsuhXQ6eoV0ONKFdDrKhXQ6VoV0OCKFdDgAAAAAAAAAAAAAA + AAAAAAAAAAAAAKFdDgChXQ4AoV0ObaFdDqejXQwDoV0OBaFdDrChXQ5toV8TAaFdDimhXA4HoV0OAKFc + DQChXg8AoV0OAKBdDwChXQ4AoV0ODqFdDn2hXQ7VoV0OcaFdDgmhXQ4AoV0OKqFdDnajXAkMg3lpAFCo + /wBQqP8AUKn/AFCp/wAAAAAAoV0OAKFdDgChXQ5toV0Op6NdDAOhXQ4FoV0OsKFdDmyhXQ4VoV0Ot6Fd + DpShXQ4boV0OAKFdDgChXQ4AoV0OAKFdDiihXQ6soV0OxqFdDkOfXA8AoV0OAKFdDwCiXAsAdomUAEO0 + /wNQqP4HUKj/B1Co/wVQqf8AUKr/AAAAAAChXQ4AoV0OAKFdDm2hXQ6no10MA6FdDgWhXQ6woV0ObaFd + DgChXQ4woV0OraFdDsKhXQ5GoVwRAKBgDQGhXQ5QoV0OzaFdDqKhXQ4goV0OALJOAABPqv8AUKn/AFKn + +gBPqv8OUKn/kU+p/7lPqf+4UKn/pFCp/x5Qqf8AUKn/AFCp/wCiXAsAoV0ObaFdDqejXQwDoV0OBaFd + DrChXQ5toV0OAKFdDgChXQ4NoV0OdKFdDtChXQ6BoV0OhKFdDtihXQ5zoV0OCqFdDgBok7kAUKn/AFCp + /wtQqf8zUKn/BE2n/xlWrP/Xjcf//47H//9XrP/zTqj/N1Co/wBQqf8wUKn/FIZ2XgChXQ5uoV0OqaNd + DAOhXQ4FoV0OsKFdDm2hXQ4AoV0OAKFdDgChXQ8AoV0OPKFdDrmhXQ7FoV0ORaJcDQChXQ4AdIeUAFCp + /wBPqf8NT6n/j1Gp/+pPqP92TKf/OVit/9i+3v/1vt//+lqu//BNp/9STqj/XFCp/+RPqf+pQrb/FaNb + B1ihXQ6Lo10MAqFdDgWhXQ6woV0ObaFdDgChXQ4AoV0OAKFdDQChXQ4AoV0OEKFdDhWhXQ4AoV0OAKFd + DgBQqf8AUKn/D0+p/5ZuuP/0lcv/+V2v//NUq//gdrz/8cXi//nG4v/8eLz/+VWs/+Zbrv/sksn/93G5 + //xQqf+wZJbDJalUAA2hXA0AoV0OBaFdDrChXQ5toV0OAKFdDgB9TQkAoV0NAKFdDgChXQ4AoV0OAKZc + DQCiXQ4AfhIAAFCp/wBPqf8vUan/4ZfM/+vQ6P/8sdn/+6zW//nI5P/70Of//9Dn///I5P/+rdb//rDY + //vQ6P/8m87/+FKq//NPqf9LYZnLAKJbCAChXQ4FoV0OsKFdDm2hXQ4AoV0OAKFdDgChXQ4AAAAAAAAA + AAAAAAAAAAAAAFCp/wBQqf8AUKn/AFCo/wBPqP9aXK//47LZ//TS6P//0ej//9Dn///I4///x+P//8/n + ///R6P//0uj//7Xa//tfsP/yT6j/dlCq/wNQqf8AUKn/AKFdDgWhXQ6woV0ObaFdDgChXQ4BoV0OAKFd + DgAAAAAAAAAAAAAAAAAAAAAAUKn/AFCp/wBQqf8XTqj/N0un/0xXrP/astn/9tHo///L5f//mMz//3C5 + //9vuP//jsf//8fj///R6P//tdr//Vmt/+5Lpv9eTaf/NlCp/x5Qqf8AoV0OBaFdDrChXQ5roV0OT6Fd + DmmhXQ4AoV0OAKFdDgChXQ4AoV0OAJ9cDABQqf8AUKn/AFCp/35Yrf/tYLH/6YDB/+7L5f/70ej//6HR + //9ptf//pNL//6vV//9vuP//ksn//9Dn///N5v/+iMT/+mOy//Fcr//zUKn/nlCp/wOhXQ4FoV0OsKFd + DmmhXQ58oV0Ow6FdDkWhXQ4OoV0OMqFdDh2hXQ4An1wMAFCp/wBQqf8ATaj/jYfE//PH4//1y+X/+s/n + ///O5///fr///5DI///S6f//0+n//6LR//9wuf//yeT//9Dn///M5v/+yOT//JTK//9Pqf+vT6n/BaFd + DgShXQ6voV0ObqFdDjyhXQ67oV0OraFdDiGhXQ5+oV0OSaFdDgChXQ4AoV0PAGCa0ABOqP+Oeb3//qjU + //+63f/9z+f//8/n//+Fw///gcH//8zl///P5///kcn//3W7///L5f//0Of//7rd//am0//wf8D//U+p + /7FPqf8FoV0OAKFdDn+hXQ6/oV0OSKFdDkWhXQ5IoV0OPaFdDkShXQ5AoV0OO6FdDjuhXQ42uUYACE+p + /19Rqv/HUan/zmy3//PE4v/80ej//7Ta//9otf//eLz//32///9ls///p9T//9Ho///I5P/7cLn/8k+o + /8tQqf+/UKn/dlCp/wGhXQ4AoV0OF6FdDpKhXQ7HoV0OxqFdDsahXQ7HoV0OxqFdDsehXQ7HoV0OyKFd + DrahXAwiAP//AU6o/wpOqP8pUqr/16fT//nR6P//z+f//7jc//+PyP//i8b//7DY///O5///0ej//7HY + //hVq//pTqj/P0+q/wZQqv8EUKn/AKFdDgChXQ4AoV0OA6FdDhSiXQ0Xol0NFqJdDRaiXQ0Wol0NFqJd + DRaiXQ0XoV0NFaBdDgRenNYAUKn/Dk+p/5VvuP/wv9//+dDn///P5//+0uj//9Ho///Q6P//0uj//9Dn + //7Q5//+w+H/+nW7//NQqf+1UKn/HlCp/wBQqf8AoF0PAKFdDgChXQ4AoV0OAKJdDQCiXQ0Aol0NAKJd + DQCiXQ0Aol0NAKJdDQChXQ0AoV0OAFCp/wBPqf8vUan/45PK//jJ5P/8kcn//IbD//6x2P/7zeb//s7n + //+12//5iMT/+o3H//nI5P/7nc//91Oq//FPqf9LUKn/AFCp/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUKn/AFCp/wJPqP9bXK//5nK6//9Sqv/aTKf/ql6w + /+y93v/2xOH//Ga0//ZMp/+xUan/xnC5//tesP/uT6j/b1Cp/wZQqf8AUKn/AAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQqf8AUKn/AEmk/wBOqP9UTqj/tk+p + /z5Mp/8bV63/07bb//S+3//8XrD/70yn/zhPqP8jTqj/p06o/2ZTq/8CUKn/AFCp/wBQqP8AAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCq/wBQqf8AUKn/AEmq + /wBQqf8KUKn/AE+o/xlSqv/Ub7j//XO6//5Vq//tT6j/NFCp/wBQqf8HUKn/AVCp/wBQqf8AUKz/AAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCx + /wBQqf8AUKn/AFCp/wBQqf8AUKn/BVCp/0lMp/9hS6f/YU+p/1NQqf8NUKn/AFCp/wBQqf8AUKn/AFCo + /wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCp/wBQqf8AUKn/AFCp/wBQqf8AUKn/AFCp/wBQqf8AAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA/gAAf/4AAH/+AAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAH8APgB+AD4ADA + A+AAAAAgAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAeAAAAHgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAA//gAAP/4AAD/+AAB//wAA///wD8= + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/AGV_InterAction.cs b/Interface_WebAPI/SlMesDbIterface/MOM/AGV_InterAction.cs new file mode 100644 index 0000000..8c98553 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/AGV_InterAction.cs @@ -0,0 +1,27 @@ +using System; + using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class AGV_InterAction + { +//"{ +//""LocationCode"": ""位置编号"", +//""TaskCode"": ""配送任务号"", +//""deliveryType"": ""配送类型"", +//""ReqCMD"": ""请求标识"" +//}" + + [JsonProperty("LocationCode")] + public string LocationCode { get; set; } // 位置编号 + + [JsonProperty("TaskCode")] + public string TaskCode { get; set; } // 配送任务号 + + [JsonProperty("deliveryType")] + public string DeliveryType { get; set; } // 配送类型 + + [JsonProperty("ReqCMD")] + public string ReqCMD { get; set; } // 请求标识 + + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/AlarmClosed.cs b/Interface_WebAPI/SlMesDbIterface/MOM/AlarmClosed.cs new file mode 100644 index 0000000..6e6a299 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/AlarmClosed.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +//using System.Text.Json.Serialization; // 用于 System.Text.Json +using Newtonsoft.Json; // 如果使用 Newtonsoft.Json 则取消注释 +namespace MisDataSaveDate.MOM +{ + public class AlarmClosed + { + [JsonProperty("taskID")] + // [JsonProperty("taskID")] // Newtonsoft.Json 用法 + public string alarmTaskId { get; set; } // 报警任务ID + + [JsonProperty("handleInfo")] + public List HandleInfos { get; set; } // 处理信息列表 + } + + public class AlarmHandleInfo + { + [JsonProperty("userId")] + public string UserId { get; set; } // 处理用户ID + + [JsonProperty("userCode")] + public string UserCode { get; set; } // 处理用户编号 + + [JsonProperty("userName")] + public string UserName { get; set; } // 处理用户名称 + + [JsonProperty("startTime")] + public string StartTime { get; set; } // 处理开始时间 + + [JsonProperty("endTime")] + public string EndTime { get; set; } // 处理完成时间(可空) + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/ApiResponse.cs b/Interface_WebAPI/SlMesDbIterface/MOM/ApiResponse.cs new file mode 100644 index 0000000..fddbfba --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/ApiResponse.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class ApiResponse + { + [JsonProperty("code")] + public int Code { get; set; } + + [JsonProperty("message")] + public string Message { get; set; } + + [JsonProperty("data")] + public List Data { get; set; } + } + + public class Response_Data + { + [JsonProperty("code")] + public int Code { get; set; } + + [JsonProperty("message")] + public string Message { get; set; } + + [JsonProperty("dataid")] + public string DataId { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/Employee.cs b/Interface_WebAPI/SlMesDbIterface/MOM/Employee.cs new file mode 100644 index 0000000..57d6c3f --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/Employee.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +//using System.Text.Json.Serialization; // For System.Text.Json +using Newtonsoft.Json; // Uncomment if using Newtonsoft.Json +namespace MisDataSaveDate.MOM +{ + public class EmployeeInfoSave + { + [JsonProperty("data")] + public List Data { get; set; } + } + + public class EmployeeInfo + { + [JsonProperty("personID")] + // [JsonProperty("empID")] // For Newtonsoft.Json + public string PersonId { get; set; } // 人员ID + + [JsonProperty("personCode")] + public string PersonCode { get; set; } // 人员编号 + + [JsonProperty("personName")] + public string PersonName { get; set; } // 人员名称 + + [JsonProperty("orgID")] + public string OrgId { get; set; } // 所属组织 + + [JsonProperty("phoneNumber")] + public string PhoneNumber { get; set; } // 手机号 + + [JsonProperty("createTime")] + public string CreateTime { get; set; } // 创建时间 + + [JsonProperty("lastModifyTime")] + public string LastModifyTime { get; set; } // 最后修改时间 + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/InspectionPlan.cs b/Interface_WebAPI/SlMesDbIterface/MOM/InspectionPlan.cs new file mode 100644 index 0000000..da1b302 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/InspectionPlan.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class InspectionPlan + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("usecompecode")] + public string CompileUnitCode { get; set; } + + [JsonProperty("usecompename")] + public string CompileUnitName { get; set; } + + [JsonProperty("checktypecode")] + public string CheckTypeCode { get; set; } + + [JsonProperty("checktypename")] + public string CheckTypeName { get; set; } + + [JsonProperty("cycleplan")] + public string IsCyclePlan { get; set; } + + [JsonProperty("checkcycle")] + public string CheckCycle { get; set; } + + [JsonProperty("cycleunit")] + public string CycleUnit { get; set; } + + [JsonProperty("nextchecktime")] + public string NextCheckTime { get; set; } + + [JsonProperty("planstatus")] + public string PlanStatus { get; set; } + + [JsonProperty("whetherinspect")] + public string WhetherInspect { get; set; } + + [JsonProperty("taskvalidityperiod")] + public string TaskValidityPeriod { get; set; } + + [JsonProperty("validityunit")] + public string ValidityUnit { get; set; } + + [JsonProperty("daysahead")] + public string DaysAhead { get; set; } + + [JsonProperty("aheadunit")] + public string AheadUnit { get; set; } + + [JsonProperty("checkobjects")] + public List CheckObjects { get; set; } + } + + public class CheckObject + { + [JsonProperty("checkobjectsid")] + public string CheckObjectId { get; set; } + + [JsonProperty("amcode")] + public string AssetCode { get; set; } + + [JsonProperty("amname")] + public string AssetName { get; set; } + + [JsonProperty("poscode")] + public string PositionCode { get; set; } + + [JsonProperty("posname")] + public string PositionName { get; set; } + + [JsonProperty("plancheckercode")] + public string PlanCheckerCode { get; set; } + + [JsonProperty("plancheckername")] + public string PlanCheckerName { get; set; } + + [JsonProperty("detail")] + public List Details { get; set; } + } + + public class CheckDetail + { + [JsonProperty("detailid")] + public string DetailId { get; set; } + + [JsonProperty("checkpart")] + public string CheckPart { get; set; } + + [JsonProperty("checkitem")] + public string CheckItem { get; set; } + + [JsonProperty("checkcontent")] + public string CheckContent { get; set; } + + [JsonProperty("checkmethodcode")] + public string CheckMethodCode { get; set; } + + [JsonProperty("checkmethodname")] + public string CheckMethodName { get; set; } + + [JsonProperty("standardclaim")] + public string StandardClaim { get; set; } + + [JsonProperty("resulttype")] + public string ResultType { get; set; } + + [JsonProperty("resultoptionsids")] + public string ResultOptionsIds { get; set; } + + [JsonProperty("resultoptions")] + public string ResultOptions { get; set; } + + [JsonProperty("Abnmeasurescode")] + public string AbnormalMeasuresCode { get; set; } + + [JsonProperty("abnmeasuresname")] + public string AbnormalMeasuresName { get; set; } + + [JsonProperty("checkstatusenumcode")] + public string CheckStatusEnumCode { get; set; } + + [JsonProperty("checkstatusenumname")] + public string CheckStatusEnumName { get; set; } + + [JsonProperty("isphotographed")] + public string IsPhotographed { get; set; } + + [JsonProperty("plancheckercode")] + public string PlanCheckerCode { get; set; } + + [JsonProperty("plancheckername")] + public string PlanCheckerName { get; set; } + + [JsonProperty("lastchecktime")] + public string LastCheckTime { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/LineSideStock.cs b/Interface_WebAPI/SlMesDbIterface/MOM/LineSideStock.cs new file mode 100644 index 0000000..6079b14 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/LineSideStock.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class LineSideStock + { + [JsonProperty("requestId")] + public string RequestId { get; set; } + + [JsonProperty("process")] + public string Process { get; set; } + } + + public class Res_LineSideStock + { + [JsonProperty("code")] + public int Code { get; set; } + + [JsonProperty("message")] + public string Message { get; set; } + + [JsonProperty("data")] + public List Data { get; set; } + } + + public class LSSData + { + [JsonProperty("processNo")] + public string ProcessNo { get; set; } + + [JsonProperty("locationNo")] + public string LocationNo { get; set; } + + [JsonProperty("emptySlots")] + public string EmptySlots { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/MOM_Order.cs b/Interface_WebAPI/SlMesDbIterface/MOM/MOM_Order.cs new file mode 100644 index 0000000..a6c8ac0 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/MOM_Order.cs @@ -0,0 +1,290 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + public class DispatchOrder + { + /// + /// 派工单ID + /// + public string orderID { get; set; } + + /// + /// 派工单号 + /// + public string orderNo { get; set; } + + /// + /// 物料ID + /// + public string materialId { get; set; } + + /// + /// 物料编号 + /// + public string materialCode { get; set; } + + /// + /// 物料名称 + /// + public string materialName { get; set; } + + /// + /// 物料规格 + /// + public string materialSpec { get; set; } + + /// + /// 物料型号 + /// + public string materialModel { get; set; } + /// + /// 工程号 + /// + public string projectCode { get; set; } + /// + /// 工程名称 + /// + public string projectName { get; set; } + /// + /// 断路器产线根据此判断是不是同一工艺路线 + /// + public string routingId { get; set; } + /// + /// 数量 + /// + public string qty { get; set; } + /// + /// 计划投产时间 + /// + public string planStartTime { get; set; } + + /// + /// 派工任务列表 + /// + public List dispatchTask { get; set; } + } + + public class DispatchTask + { + /// + /// 任务ID + /// + public string taskId { get; set; } + + /// + /// 任务号 + /// + public string taskNo { get; set; } + + /// + /// 工单工序ID + /// + public string workOrderProcessId { get; set; } + + /// + /// 工单号 + /// + public string workOrderNo { get; set; } + + /// + /// 工作中心ID + /// + public string workCenterId { get; set; } + + /// + /// 工作中心编号 + /// + public string workCenterCode { get; set; } + + /// + /// 工作中心名称 + /// + public string workCenterName { get; set; } + + /// + /// 工序ID + /// + public string processId { get; set; } + + /// + /// 工序编号 + /// + public string processCode { get; set; } + + /// + /// 工序名称 + /// + public string processName { get; set; } + + /// + /// 物料ID + /// + public string materialId { get; set; } + + /// + /// 物料编号 + /// + public string materialCode { get; set; } + + /// + /// 物料名称 + /// + public string materialName { get; set; } + + /// + /// 物料型号 + /// + public string materialModel { get; set; } + + /// + /// 计划投产时间 + /// + public string planStartTime { get; set; } + + /// + /// 计划产出时间 + /// + public string planEndTime { get; set; } + + /// + /// 派工数量 + /// + public string dispatchQty { get; set; } + + /// + /// 任务状态 + /// + public string taskStatus { get; set; } + + /// + /// 创建时间 + /// + public string createdAt { get; set; } + + /// + /// 修改时间 + /// + public string modifiedAt { get; set; } + + /// + /// 配送信息列表 + /// + public List deliveryInfo { get; set; } + } + + public class DeliveryInfo + { + /// + /// 配送计划ID + /// + public string deliveryInfoid { get; set; } + /// + /// 工单备料ID + /// + public string momid { get; set; } + /// + /// 备料号 + /// + public string preparationNo { get; set; } + + /// + /// 物料ID + /// + public string materialId { get; set; } + + /// + /// 物料编号 + /// + public string materialCode { get; set; } + + /// + /// 物料名称 + /// + public string materialName { get; set; } + + /// + /// 物料规格 + /// + public string materialSpec { get; set; } + + /// + /// 物料型号 + /// + public string materialModel { get; set; } + + /// + /// 物料描述 + /// + public string materialDesc { get; set; } + + /// + /// 工序ID + /// + public string processId { get; set; } + + /// + /// 工序编号 + /// + public string processCode { get; set; } + + /// + /// 工序名称 + /// + public string processName { get; set; } + + /// + /// 工作中心ID + /// + public string workCenterId { get; set; } + + /// + /// 工作中心编号 + /// + public string workCenterCode { get; set; } + + /// + /// 工作中心名称 + /// + public string workCenterName { get; set; } + + /// + /// 所需数量 + /// + public string requiredQty { get; set; } + + /// + /// 计划时间 + /// + public string planTime { get; set; } + + /// + /// 批次号 + /// + public string batchNo { get; set; } + + /// + /// 序列号 + /// + public string serialNo { get; set; } + + /// + /// 配送位置ID + /// + public string deliveryPosId { get; set; } + + /// + /// 配送位置编号 + /// + public string deliveryPosCode { get; set; } + + /// + /// 配送位置名称 + /// + public string deliveryPosName { get; set; } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/MOM_Process.cs b/Interface_WebAPI/SlMesDbIterface/MOM/MOM_Process.cs new file mode 100644 index 0000000..8fbe85a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/MOM_Process.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + + /// + /// 工艺方案类 + /// + public class ProcessScheme + { + /// + /// 工艺方案ID,数据唯一标识 + /// + public string id { get; set; } + + /// + /// 工艺方案编号 + /// + public string code { get; set; } + + /// + /// 工艺方案编号 + /// + public string name { get; set; } + + /// + /// 订单号(生产订单或生产工单的编号) + /// + public string orderNo { get; set; } + + /// + /// 产品ID + /// + public string productId { get; set; } + + /// + /// 产品编号 + /// + public string productCode { get; set; } + + /// + /// 产品名称 + /// + public string productName { get; set; } + + /// + /// 产品规格(非必填) + /// + public string productSpec { get; set; } + + /// + /// 产品型号(非必填) + /// + public string model { get; set; } + + /// + /// 创建时间,格式为yyyy-MM-dd HH:mm:ss + /// + public string createdTime { get; set; } + + /// + /// 最后修改时间,格式为yyyy-MM-dd HH:mm:ss + /// + public string lastModifiedTime { get; set; } + + /// + /// 工序信息 + /// + public List processInfo { get; set; } + + public List routingInfo { get; set; } + } + + /// + /// 工序信息类 + /// + public class ProcessInfo + { + /// + /// 顺序号 + /// + public string sequenceNo { get; set; } + + /// + /// 工序ID + /// + public string processId { get; set; } + + /// + /// 工序编号 + /// + public string processCode { get; set; } + + /// + /// 工序名称 + /// + public string processName { get; set; } + + /// + /// 文档信息(文档路径) + /// + public string docInfo { get; set; } + /// + /// 文档名称 + /// + public string filename { get; set; } + /// + /// 工序信息id + /// + public string processInfoid { get; set; } + } + public class RoutingInfo + { + /// + /// 工艺路线信息ID + /// + public string routingid { get; set; } + + /// + /// 工艺路线编号 + /// + public string routingcode { get; set; } + + /// + /// 工序ID + /// + public string processId { get; set; } + + /// + /// 工序号 + /// + public string processCode { get; set; } + + /// + /// 工序名称 + /// + public string processName { get; set; } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/MaterialData.cs b/Interface_WebAPI/SlMesDbIterface/MOM/MaterialData.cs new file mode 100644 index 0000000..13dd0fd --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/MaterialData.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class MaterialInfoSave + { + [JsonProperty("data")] + public List Data { get; set; } + } + + public class Material + { + [JsonProperty("materialID")] + public string MaterialID { get; set; } + + [JsonProperty("materialCode")] + public string MaterialCode { get; set; } + + [JsonProperty("materialName")] + public string MaterialName { get; set; } + + [JsonProperty("unitOfMeasure")] + public string UnitOfMeasure { get; set; } + + [JsonProperty("materialCategory")] + public string MaterialCategory { get; set; } + + [JsonProperty("materialSpec")] + public string MaterialSpec { get; set; } + + [JsonProperty("materialModel")] + public string MaterialModel { get; set; } + + [JsonProperty("materialDescription")] + public string MaterialDescription { get; set; } + + [JsonProperty("createTime")] + public string CreateTime { get; set; } + + [JsonProperty("lastModifyTime")] + public string LastModifyTime { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/OneCheckData.cs b/Interface_WebAPI/SlMesDbIterface/MOM/OneCheckData.cs new file mode 100644 index 0000000..4f867d3 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/OneCheckData.cs @@ -0,0 +1,241 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ExternalDataSync.MOM +{ + public class OnlineCheckData + { + /// + /// MsgId + /// + public string MsgId { get; set; } = ""; + /// + /// OpCode + /// + public string OpCode { get; set; } = ""; + /// + /// ProductionCode + /// + public string ProductionCode { get; set; } = ""; + /// + /// CheckTime + /// + public string ScanTime { get; set; } = ""; + + /// + /// EndTime + /// + public string EndTime { get; set; } = ""; + + /// + /// CheckPerson + /// + public string CheckPerson { get; set; } = ""; + + /// + /// Powerused + /// + public string Powerused { get; set; } = ""; + + + /// + /// QualityMark + /// + public int QualityMark { get; set; } = 1; + + public List CheckData { get; set; } = new List(); + } + + public class OnlineCheckData_CheckData + { + /// + /// CheckCode + /// + public string CheckCode { get; set; } = ""; + /// + /// CheckName + /// + public string CheckName { get; set; } = ""; + /// + /// ProductionCode + /// + public string Unit { get; set; } + /// + /// StandardValue + /// + public string StandardValue { get; set; } = ""; + /// + /// MinValue + /// + public string MinValue { get; set; } = ""; + /// + /// MaxValue + /// + public string MaxValue { get; set; } = ""; + /// + /// CheckValue + /// + public string CheckValue { get; set; } = ""; + /// + /// QualityMark + /// + public int QualityMark { get; set; } = 1; + } + + /// + /// 测试数据上传接口响应类 + /// + public class OnlineCheckDataResponse + { + /// + /// 响应码 200正常、500失败 + /// + public string Code { get; set; } = ""; + + /// + /// 响应消息,出错时返回接口调用失败原因 + /// + public string Message { get; set; } = ""; + + /// + /// 请求编号,响应结果带回请求编号 + /// + public string MsgId { get; set; } = ""; + + /// + /// 携带数据,JSON格式字符串数据 + /// + public string Data { get; set; } = ""; + } + public class PrintTaskData + { + /// string msg = $"MARK|{printTemplete}|{productCode},{printDate}"; + + /// + /// printTemplete + /// + public string printTemplete { get; set; } = ""; + /// + /// productCode + /// + public string productCode { get; set; } = ""; + /// + /// printDate + /// + public string printDate { get; set; } = ""; + + } + + /// + /// 设备状态数据上传 + /// + public class OnlineStatusData + { + /// + /// 消息ID + /// + public string MsgId { get; set; } = ""; + + /// + /// 设备编码 + /// + public string DeviceCode { get; set; } = ""; + + /// + /// 数据类型: Status-设备状态, Use-使用情况 + /// + public string DataType { get; set; } = ""; + + /// + /// 状态数据列表 + /// + public List CheckData { get; set; } = new List(); + } + + /// + /// 设备状态数据明细 + /// + public class OnlineStatusData_CheckData + { + /// + /// 状态代码 + /// + public string StatuCode { get; set; } = ""; + + /// + /// 状态名称 + /// + public string StatuName { get; set; } = ""; + + /// + /// 状态值 + /// + public string StatuValue { get; set; } = ""; + } + + /// + /// 获取位置待测试产品信息 - 请求类 + /// + public class GetWaitCheckProductDataRequest + { + /// + /// 请求编号 GUID + /// + public string MsgId { get; set; } = ""; + + /// + /// 位置号 AC1104-1, AC1104-2等 + /// + public string OpCode { get; set; } = ""; + } + + /// + /// 获取位置待测试产品信息 - 响应类 + /// + public class GetWaitCheckProductDataResponse + { + /// + /// 响应码 200正常、500失败 + /// + public string Code { get; set; } = ""; + + /// + /// 响应消息,出错时返回接口调用失败原因 + /// + public string Message { get; set; } = ""; + + /// + /// 请求编号,响应结果带回请求编号 + /// + public string MsgId { get; set; } = ""; + + /// + /// 响应数据 + /// + public GetWaitCheckProductDataResult Data { get; set; } = new GetWaitCheckProductDataResult(); + } + + /// + /// 获取位置待测试产品信息 - 响应数据 + /// + public class GetWaitCheckProductDataResult + { + /// + /// 产品编号,唯一产品编码,若无待测产品则空 + /// + public string ProductionCode { get; set; } = ""; + + /// + /// 产品型号,待测产品型号 + /// + public string ProductModel { get; set; } = ""; + + /// + /// 产品型号代码,机型对应数字类型编号 + /// + public int ProductModelCode { get; set; } = 0; + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/OrganizationData.cs b/Interface_WebAPI/SlMesDbIterface/MOM/OrganizationData.cs new file mode 100644 index 0000000..15a368e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/OrganizationData.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + + public class OrganizationData + { + [JsonProperty("data")] + public List Data { get; set; } + } + + public class Organization + { + [JsonProperty("orgID")] + public string OrgID { get; set; } + + [JsonProperty("orgCode")] + public string OrgCode { get; set; } + + [JsonProperty("orgName")] + public string OrgName { get; set; } + + [JsonProperty("classification")] + public string Classification { get; set; } + + [JsonProperty("level")] + public string LevelNo { get; set; } + + [JsonProperty("detail")] + public string Detail { get; set; } + + [JsonProperty("createTime")] + public string CreateTime { get; set; } + + [JsonProperty("lastModifyTime")] + public string LastModifyTime { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/ProductionOrder.cs b/Interface_WebAPI/SlMesDbIterface/MOM/ProductionOrder.cs new file mode 100644 index 0000000..72ea489 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/ProductionOrder.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class ProductionOrder + { + [JsonProperty("orderID")] + public string OrderID { get; set; } + + [JsonProperty("orderNo")] + public string OrderNo { get; set; } + + [JsonProperty("materialId")] + public string MaterialId { get; set; } + + [JsonProperty("materialCode")] + public string MaterialCode { get; set; } + + [JsonProperty("materialName")] + public string MaterialName { get; set; } + + [JsonProperty("materialSpec")] + public string MaterialSpec { get; set; } + + [JsonProperty("materialModel")] + public string MaterialModel { get; set; } + + [JsonProperty("orderType")] + public string OrderType { get; set; } + + [JsonProperty("clr")] + public string Clr { get; set; } + + [JsonProperty("planproddate")] + public string PlanProdDate { get; set; } + + [JsonProperty("planprodqty")] + public string PlanProdQty { get; set; } + + [JsonProperty("planoutputdate")] + public string PlanOutputDate { get; set; } + + [JsonProperty("planoutputqty")] + public string PlanOutputQty { get; set; } + + [JsonProperty("projectno")] + public string ProjectNo { get; set; } + + [JsonProperty("projectname")] + public string ProjectName { get; set; } + + [JsonProperty("planid")] + public string PlanId { get; set; } + + [JsonProperty("processplan")] + public List ProcessPlans { get; set; } + } + + public class ProcessPlan + { + [JsonProperty("rountingid")] + public string RoutingId { get; set; } + + [JsonProperty("processplanId")] + public string ProcessPlanId { get; set; } + + [JsonProperty("processplanNo")] + public string ProcessPlanNo { get; set; } + + [JsonProperty("workOrderProcessId")] + public string WorkOrderProcessId { get; set; } + + [JsonProperty("workOrderNo")] + public string WorkOrderNo { get; set; } + + [JsonProperty("workCenterId")] + public string WorkCenterId { get; set; } + + [JsonProperty("workCenterCode")] + public string WorkCenterCode { get; set; } + + [JsonProperty("workCenterName")] + public string WorkCenterName { get; set; } + + [JsonProperty("processId")] + public string ProcessId { get; set; } + + [JsonProperty("processCode")] + public string ProcessCode { get; set; } + + [JsonProperty("processName")] + public string ProcessName { get; set; } + + [JsonProperty("materialId")] + public string MaterialId { get; set; } + + [JsonProperty("materialCode")] + public string MaterialCode { get; set; } + + [JsonProperty("materialName")] + public string MaterialName { get; set; } + + [JsonProperty("materialModel")] + public string MaterialModel { get; set; } + + [JsonProperty("planStartTime")] + public string PlanStartTime { get; set; } + + [JsonProperty("planEndTime")] + public string PlanEndTime { get; set; } + + [JsonProperty("qty")] + public decimal Qty { get; set; } + + [JsonProperty("outqty")] + public decimal OutQty { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("createdAt")] + public string CreatedAt { get; set; } + + [JsonProperty("modifiedAt")] + public string ModifiedAt { get; set; } + + [JsonProperty("deliveryInfo")] + public List DeliveryInfo { get; set; } + } + + public class DeliveryMaterialInfo + { + [JsonProperty("deliveryInfoid")] + public string DeliveryInfoId { get; set; } + + [JsonProperty("preparationNo")] + public string PreparationNo { get; set; } + + [JsonProperty("materialId")] + public string MaterialId { get; set; } + + [JsonProperty("materialCode")] + public string MaterialCode { get; set; } + + [JsonProperty("materialName")] + public string MaterialName { get; set; } + + [JsonProperty("materialSpec")] + public string MaterialSpec { get; set; } + + [JsonProperty("materialModel")] + public string MaterialModel { get; set; } + + [JsonProperty("materialDesc")] + public string MaterialDesc { get; set; } + + [JsonProperty("processId")] + public string ProcessId { get; set; } + + [JsonProperty("processCode")] + public string ProcessCode { get; set; } + + [JsonProperty("processName")] + public string ProcessName { get; set; } + + [JsonProperty("workCenterId")] + public string WorkCenterId { get; set; } + + [JsonProperty("workCenterCode")] + public string WorkCenterCode { get; set; } + + [JsonProperty("workCenterName")] + public string WorkCenterName { get; set; } + + [JsonProperty("requiredQty")] + public decimal RequiredQty { get; set; } + + [JsonProperty("planTime")] + public string PlanTime { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/QTStandardInfo.cs b/Interface_WebAPI/SlMesDbIterface/MOM/QTStandardInfo.cs new file mode 100644 index 0000000..64fa1cd --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/QTStandardInfo.cs @@ -0,0 +1,268 @@ +using Newtonsoft.Json; +using NPOI.OpenXml4Net.OPC; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +namespace MisDataSaveDate.MOM +{ + public class QTStandardInfo + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("name_chs")] + public string NameChs { get; set; } + + [JsonProperty("createdate")] + public string CreateDate { get; set; } + + [JsonProperty("lastmodifiedtime")] + public string LastModifiedTime { get; set; } + + [JsonProperty("materialid")] + public MaterialID Material { get; set; } + + [JsonProperty("note")] + public string Note { get; set; } + + [JsonProperty("procedureid")] + public ProcedureInfo Procedure { get; set; } + + [JsonProperty("standardsortid")] + public StandardSortInfo StandardSort { get; set; } + + [JsonProperty("standardstate")] + public string StandardState { get; set; } + + [JsonProperty("standardtypeid")] + public StandardTypeInfo StandardType { get; set; } + + [JsonProperty("meqmstandarditemsource")] + public List StandardItemList { get; set; } + + [JsonProperty("meqmstandardvaluesource")] + public List StandardValueList { get; set; } + } + + public class MaterialidInfo + { + [JsonProperty("materialid")] + public string MaterialId { get; set; } + + [JsonProperty("materialid_code")] + public string MaterialCode { get; set; } + + [JsonProperty("materialid_name_chs")] + public string MaterialName { get; set; } + } + + public class ProcedureInfo + { + [JsonProperty("procedureid")] + public string ProcedureId { get; set; } + + [JsonProperty("procedureid_name_chs")] + public string ProcedureName { get; set; } + + [JsonProperty("procedureid_ppbzgx_gxbh")] + public string ProcedureCode { get; set; } + } + + public class StandardSortInfo + { + [JsonProperty("standardsortid")] + public string StandardSortId { get; set; } + + [JsonProperty("standardsortid_code")] + public string StandardSortCode { get; set; } + + [JsonProperty("standardsortid_name_chs")] + public string StandardSortName { get; set; } + + [JsonProperty("standardsortid_sortpath")] + public string StandardSortPath { get; set; } + } + + public class StandardTypeInfo + { + [JsonProperty("standardtypeid")] + public string StandardTypeId { get; set; } + + [JsonProperty("standardtypeid_code")] + public string StandardTypeCode { get; set; } + + [JsonProperty("standardtypeid_iseffective")] + public string IsEffective { get; set; } + + [JsonProperty("standardtypeid_issystem")] + public string IsSystem { get; set; } + + [JsonProperty("standardtypeid_name_chs")] + public string StandardTypeName { get; set; } + } + + public class StandardItemSource + { + [JsonProperty("id")] + public string itemId { get; set; } + + [JsonProperty("standardid")] + public RelatedStandard Standard { get; set; } + + [JsonProperty("createtime")] + public DateTime CreateTime { get; set; } + + [JsonProperty("inspecclassification")] + public string InspectionClassification { get; set; } + + [JsonProperty("inspecclassificationname")] + public string InspectionClassificationName { get; set; } + + [JsonProperty("note")] + public string Note { get; set; } + + [JsonProperty("targetauxdescribe")] + public string TargetAuxDescribe { get; set; } + + [JsonProperty("targetdescribe")] + public string TargetDescribe { get; set; } + + [JsonProperty("targetgroupid")] + public TargetGroup TargetGroup { get; set; } + + [JsonProperty("targetid")] + public TargetInfo Target { get; set; } + + [JsonProperty("targetno")] + public string TargetNo { get; set; } + } + + public class RelatedStandard + { + [JsonProperty("standardid")] + public string StandardId { get; set; } + + [JsonProperty("standardid_code")] + public string StandardCode { get; set; } + + [JsonProperty("standardid_name_chs")] + public string StandardName { get; set; } + } + + public class TargetGroup + { + [JsonProperty("targetgroupid")] + public string TargetGroupId { get; set; } + + [JsonProperty("targetgroupid_code")] + public string TargetGroupCode { get; set; } + + [JsonProperty("targetgroupid_name_chs")] + public string TargetGroupName { get; set; } + } + + public class TargetInfo + { + [JsonProperty("targetid")] + public string TargetId { get; set; } + + [JsonProperty("targetid_code")] + public string TargetCode { get; set; } + + [JsonProperty("targetid_name_chs")] + public string TargetName { get; set; } + + [JsonProperty("targetid_note")] + public string TargetNote { get; set; } + + [JsonProperty("targetid_targetgroupid")] + public string TargetGroupId { get; set; } + + [JsonProperty("targetid_targettype")] + public string TargetType { get; set; } + } + + public class StandardValueInfo + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("inspectionresults")] + public InspectionResult InspectionResults { get; set; } + + [JsonProperty("inspectionresultsname")] + public string InspectionResultsName { get; set; } + + [JsonProperty("itemvaluetype")] + public string ItemValueType { get; set; } + + [JsonProperty("lowercharacter")] + public string LowerCharacter { get; set; } + + [JsonProperty("lowerdiffvalue")] + public decimal? LowerDiffValue { get; set; } + + [JsonProperty("lowervalue")] + public decimal? LowerValue { get; set; } + + [JsonProperty("note")] + public string Note { get; set; } + + [JsonProperty("standardid")] + public string StandardId { get; set; } + + [JsonProperty("standarditemid")] + public string StandardItemId { get; set; } + + [JsonProperty("standardstrvalue")] + public string StandardStrValue { get; set; } + + [JsonProperty("standardvalue")] + public string StandardValue { get; set; } + + [JsonProperty("targetvalueid")] + public TargetValue TargetValue { get; set; } + + [JsonProperty("uppercharacter")] + public string UpperCharacter { get; set; } + + [JsonProperty("upperdiffvalue")] + public string UpperDiffValue { get; set; } + + [JsonProperty("uppervalue")] + public string UpperValue { get; set; } + + [JsonProperty("valueno")] + public string ValueNo { get; set; } + } + + public class InspectionResult + { + [JsonProperty("inspectionresults")] + public string InspectionResults { get; set; } + + [JsonProperty("inspectionresults_code")] + public string InspectionResultsCode { get; set; } + + [JsonProperty("inspectionresults_enable")] + public string InspectionResultsEnable { get; set; } + + [JsonProperty("inspectionresults_name")] + public string InspectionResultsName { get; set; } + } + + public class TargetValue + { + [JsonProperty("targetvalueid")] + public string TargetValueId { get; set; } + + [JsonProperty("targetvalueid_code")] + public string TargetValueCode { get; set; } + + [JsonProperty("targetvalueid_name")] + public string TargetValueName { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/QTTemplateInfo.cs b/Interface_WebAPI/SlMesDbIterface/MOM/QTTemplateInfo.cs new file mode 100644 index 0000000..4f51d6c --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/QTTemplateInfo.cs @@ -0,0 +1,287 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +namespace MisDataSaveDate.MOM +{ + public class QTTemplateInfo + { + [JsonProperty("note")] + public string Note { get; set; } + + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("productionworkcenter")] + public ProdWorkCenter ProductionWorkCenter { get; set; } + + [JsonProperty("classidentifier2")] + public string ClassIdentifier2 { get; set; } + + [JsonProperty("classidentifier1")] + public string ClassIdentifier1 { get; set; } + + [JsonProperty("filedata")] + public string FileData { get; set; } + + [JsonProperty("classidentifier4")] + public string ClassIdentifier4 { get; set; } + + [JsonProperty("classidentifier3")] + public string ClassIdentifier3 { get; set; } + + [JsonProperty("classidentifier6")] + public string ClassIdentifier6 { get; set; } + + [JsonProperty("materialid")] + public MaterialID Material { get; set; } + + [JsonProperty("type")] + public Type Type { get; set; } + + [JsonProperty("classidentifier5")] + public string ClassIdentifier5 { get; set; } + + [JsonProperty("procedureid")] + public ProcedureID Process { get; set; } + + [JsonProperty("classidentifier8")] + public string ClassIdentifier8 { get; set; } + + [JsonProperty("classidentifier7")] + public string ClassIdentifier7 { get; set; } + + [JsonProperty("lastmodifieduserid")] + public string LastModifiedUserId { get; set; } + + [JsonProperty("materialtype")] + public MaterialType MaterialType { get; set; } + + [JsonProperty("createuserid")] + public string CreateUserId { get; set; } + + [JsonProperty("lastmodifieduser")] + public string LastModifiedUser { get; set; } + + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("state")] + public string State { get; set; } + + [JsonProperty("lastmodifiedtime")] + public string LastModifiedTime { get; set; } + + [JsonProperty("createtime")] + public string CreateTime { get; set; } + + [JsonProperty("xm_inspectfile")] + public List XmInspectFile { get; set; } + + [JsonProperty("qualityorg")] + public QualityOrg QualityOrg { get; set; } + + [JsonProperty("createuser")] + public string CreateUser { get; set; } + + [JsonProperty("recordtemplateitems")] + public List RecordTemplateItems { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("productionorg")] + public ProductionOrg ProductionOrg { get; set; } + } + public class ProdWorkCenter + { + [JsonProperty("productionworkcenter_ppsczx_zxbh")] + public string ProductionWorkCenterPpsczxZxbh { get; set; } + + [JsonProperty("productionworkcenter")] + public string ProductionWorkCenter { get; set; } + + [JsonProperty("productionworkcenter_name_chs")] + public string ProductionWorkCenterNameChs { get; set; } + } + + public class MaterialID + { + [JsonProperty("materialid_code")] + public string MaterialIdCode { get; set; } + + [JsonProperty("materialid")] + public string MaterialId { get; set; } + + [JsonProperty("materialid_name_chs")] + public string MaterialIdNameChs { get; set; } + } + + public class Type + { + [JsonProperty("type_name")] + public string TypeName { get; set; } + + [JsonProperty("type")] + public string TypeID { get; set; } + + [JsonProperty("type_code")] + public string TypeCode { get; set; } + } + + public class ProcedureID + { + [JsonProperty("procedureid_ppbzgx_gxbh")] + public string ProcedureIdPpbzgxGxbh { get; set; } + + [JsonProperty("procedureid_name_chs")] + public string ProcedureIdNameChs { get; set; } + + [JsonProperty("procedureid")] + public string ProcedureId { get; set; } + } + + public class MaterialType + { + [JsonProperty("materialtype_code")] + public string MaterialTypeCode { get; set; } + + [JsonProperty("materialtype")] + public string MaterialTypeValue { get; set; } + + [JsonProperty("materialtype_name_chs")] + public string MaterialTypeNameChs { get; set; } + } + + public class QualityOrg + { + [JsonProperty("qualityorg_ppzzzl_zzbh")] + public string QualityOrgPpzzzlZzbh { get; set; } + + [JsonProperty("qualityorg")] + public string QualityOrgValue { get; set; } + + [JsonProperty("qualityorg_name_chs")] + public string QualityOrgNameChs { get; set; } + } + + public class ProductionOrg + { + [JsonProperty("productionorg_name_chs")] + public string ProductionOrgNameChs { get; set; } + + [JsonProperty("productionorg_ppzzsc_zzbh")] + public string ProductionOrgPpzzscZzbh { get; set; } + + [JsonProperty("productionorg")] + public string ProductionOrgValue { get; set; } + } + + public class DefaultResultValue + { + [JsonProperty("defaultresultvalue_code")] + public string DefaultResultValueCode { get; set; } + + [JsonProperty("defaultresultvalue_name")] + public string DefaultResultValueName { get; set; } + + [JsonProperty("defaultresultvalue")] + public string defaultResultValue { get; set; } + } + + public class InspectionItemId + { + [JsonProperty("inspectionitemid_code")] + public string InspectionItemIdCode { get; set; } + + [JsonProperty("inspectionitemid_name_chs")] + public string InspectionItemIdNameChs { get; set; } + + [JsonProperty("inspectionitemid")] + public string inspectionItemId { get; set; } + } + + public class RecordTemplateItem + { + [JsonProperty("inspectkey")] + public string InspectKey { get; set; } + + [JsonProperty("note")] + public string Note { get; set; } + + [JsonProperty("uploadattachments")] + public string UploadAttachments { get; set; } + + [JsonProperty("mutualinspect")] + public string MutualInspect { get; set; } + + [JsonProperty("importance")] + public string Importance { get; set; } + + [JsonProperty("defaultvalue")] + public string DefaultValue { get; set; } + + [JsonProperty("templateid")] + public string TemplateId { get; set; } + + [JsonProperty("defaultresultvalue")] + public DefaultResultValue DefaultResult { get; set; } + + [JsonProperty("requirementdesc")] + public string RequirementDesc { get; set; } + + [JsonProperty("specialinspect")] + public string SpecialInspect { get; set; } + + [JsonProperty("autoadject")] + public string AutoAdject { get; set; } + + [JsonProperty("selfinspect")] + public string SelfInspect { get; set; } + + [JsonProperty("inspectionitemstype")] + public string InspectionItemsType { get; set; } + + [JsonProperty("requiredtext")] + public string RequiredText { get; set; } + + [JsonProperty("firstinspect")] + public string FirstInspect { get; set; } + + [JsonProperty("inspectionitemname")] + public string InspectionItemName { get; set; } + + [JsonProperty("linenum")] + public string LineNum { get; set; } + + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("inspectionitemid")] + public InspectionItemId InspectionItem { get; set; } + } + + public class XmInspectFile + { + [JsonProperty("fileuser")] + public string FileUser { get; set; } + + [JsonProperty("filename")] + public string FileName { get; set; } + + [JsonProperty("filesize")] + public string FileSize { get; set; } + + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("fileext")] + public string FileExt { get; set; } + + [JsonProperty("templateid")] + public string TemplateId { get; set; } + + [JsonProperty("fileid")] + public string FileId { get; set; } + } + +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/ShiftSchedule.cs b/Interface_WebAPI/SlMesDbIterface/MOM/ShiftSchedule.cs new file mode 100644 index 0000000..c03a4b9 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/ShiftSchedule.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class ShiftSchedule + { + [JsonProperty("empID")] + public string EmployeeID { get; set; } + + [JsonProperty("empCode")] + public string EmployeeCode { get; set; } + + [JsonProperty("empName")] + public string EmployeeName { get; set; } + + [JsonProperty("startDate")] + public string StartDate { get; set; } + + [JsonProperty("endDate")] + public string EndDate { get; set; } + + [JsonProperty("prodOrg")] + public string ProductionOrg { get; set; } + + [JsonProperty("prodCenter")] + public string ProductionCenter { get; set; } + + [JsonProperty("workProc")] + public string WorkProcess { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/UnitData.cs b/Interface_WebAPI/SlMesDbIterface/MOM/UnitData.cs new file mode 100644 index 0000000..755b3fb --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/UnitData.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + public class UnitData + { + [JsonProperty("data")] + public List Data { get; set; } + } + + public class Unit + { + [JsonProperty("unitID")] + public string UnitID { get; set; } + + [JsonProperty("unitCode")] + public string UnitCode { get; set; } + + [JsonProperty("unitName")] + public string UnitName { get; set; } + + [JsonProperty("createTime")] + public string CreateTime { get; set; } + + [JsonProperty("lastModifyTime")] + public string LastModifyTime { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/WorkCenterData.cs b/Interface_WebAPI/SlMesDbIterface/MOM/WorkCenterData.cs new file mode 100644 index 0000000..3f8f8dd --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/WorkCenterData.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +namespace MisDataSaveDate.MOM +{ + + public class WorkCenterData + { + [JsonProperty("data")] + public List Data { get; set; } + } + + public class WorkCenter + { + [JsonProperty("workCenterID")] + public string WorkCenterID { get; set; } + + [JsonProperty("workCenterCode")] + public string WorkCenterCode { get; set; } + + [JsonProperty("workCenterName")] + public string WorkCenterName { get; set; } + + [JsonProperty("orgID")] + public string OrgID { get; set; } + + [JsonProperty("classification")] + public string Classification { get; set; } + + [JsonProperty("level")] + public string LevelNo { get; set; } + + [JsonProperty("detail")] + public string Detail { get; set; } + + [JsonProperty("createTime")] + public string CreateTime { get; set; } + + [JsonProperty("lastModifyTime")] + public string LastModifyTime { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM/msgResHeader.cs b/Interface_WebAPI/SlMesDbIterface/MOM/msgResHeader.cs new file mode 100644 index 0000000..03f27c7 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM/msgResHeader.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate +{ + public class MsgResHeader + { + /// + /// 返回结果 + /// + public int code + { + get; + set; + } + /// + /// 返回消息 + /// + public string message + { + get; + set; + } + /// + /// 返回结果集 + /// + public T Data { + get; + set; + } + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceAlarm.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceAlarm.cs new file mode 100644 index 0000000..8716ce3 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceAlarm.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 设备异常报警数据上传 + /// + + public class DeviceAlarm + { + /// + /// 派工单ID + /// + public string orderID { get; set; } + + /// + /// 派工任务ID + /// + public string taskID { get; set; } + + /// + /// 报警唯一标识 + /// + public string id { get; set; } + /// + /// 异常工序 + /// + public string processNo { get; set; } + + /// + /// 报警代码 + /// + public string alarmCode { get; set; } + + /// + /// 报文/设备状态信息 + /// + public string deviceInfo { get; set; } + + /// + /// 异常类型 + /// + public string exceptionType { get; set; } + + /// + /// 异常信息 + /// + public string exceptionInfo { get; set; } + + /// + /// 异常发送人 + /// + public string sender { get; set; } + + /// + /// 异常位置 + /// + public string location { get; set; } + + /// + /// 异常生产中心 + /// + public string productionCenter { get; set; } + + /// + /// 创建时间 + /// + public string createTime { get; set; } + + /// + /// 最后修改时间 + /// + public string lastModifiedTime { get; set; } + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceInfo.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceInfo.cs new file mode 100644 index 0000000..4821a14 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceInfo.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 缓存位置查询 + /// + + public class DeviceInfo + { + /// + /// 请求编号 + /// + public string id { get; set; } = ""; + /// + /// 请求方标识 + /// + public string callcode { get; set; } = ""; + /// + /// 工位号 + /// + public string containerNo { get; set; } = ""; + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceInfoResponse.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceInfoResponse.cs new file mode 100644 index 0000000..0d4c473 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceInfoResponse.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; + +namespace MisDataSaveDate.MOM +{ + /// + /// 器具信息查询响应实体 + /// + public class DeviceInfoResponse + { + public int code { get; set; } + public string message { get; set; } + public DeviceInfoData data { get; set; } + } + + /// + /// 器具信息数据 + /// + public class DeviceInfoData + { + public List businessdata { get; set; } + } + + /// + /// 业务数据 + /// + public class BusinessData + { + /// + /// 批次号 + /// + public string batchno { get; set; } + + /// + /// 数量 + /// + public string qty { get; set; } + + /// + /// 物料编号 + /// + public string sku { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceStatus.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceStatus.cs new file mode 100644 index 0000000..cb25693 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/DeviceStatus.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 缓存位置查询 + /// + + public class DeviceStatus + { + /// + /// 请求编号 + /// + public string MsgId { get; set; } = ""; + /// + /// 请求方标识 + /// + public string MsgSource { get; set; } = ""; + /// + /// 工位号 + /// + public string OPNo { get; set; } = ""; + /// + /// 当前状态 + /// + public int StatusCode { get; set; } = 0; + /// + /// 采集时间 + /// + public string StatusTime { get; set; } = ""; + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/JobFinished.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/JobFinished.cs new file mode 100644 index 0000000..d40ad80 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/JobFinished.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace MisDataSaveDate.MOM +{ + /// + /// 开工 + /// + + public class JobFinished + { + /// + /// 派工单ID + /// + public string orderID { get; set; } + /// + /// 派工任务ID + /// + public string taskID { get; set; } + /// + /// 工序ID + /// + public decimal finishedQuantity { get; set; } + + /// + /// 操作时间 + /// + public string createTime { get; set; } + + /// + /// 操作人 + /// + public string endTime { get; set; } + + /// + /// 创建时间 + /// + public decimal beat { get; set; } + public string processNo { get; set; } + public string lastModifiedTime { get; set; } + public List inspectionInfo { get; set; } + public List materialInfo { get; set; } + public List workinghours { get; set; } + /// + /// 操作:0取消开工,1开工 + /// + public string operation { get; set; } + + } + public class InspectionInfo + { + public string Inspectcode { get; set; } + public string inspector { get; set; } + public string inspectionTime { get; set; } + public decimal qualifiedQuantity { get; set; } + public decimal unqualifiedQuantity { get; set; } + public string templetecode { get; set; } + public List inspectionDetails { get; set; } + } + public class InspectionDetail + { + public string inspectionItemID { get; set; } + public string inspectionItemNo { get; set; } + public string inspectionItemName { get; set; } + public string inspectionValue { get; set; } + public string inspectionStandardText { get; set; } + public string upperLimitSymbol { get; set; } + public decimal upperLimitValue { get; set; } + public string lowerLimitSymbol { get; set; } + public decimal lowerLimitValue { get; set; } + public decimal standardValue { get; set; } + public string inspectionResult { get; set; } + + } + public class MaterialInfo + { + public string consumedMaterialNo { get; set; } + public string type { get; set; } + public decimal qty { get; set; } + public decimal qualifiedqty { get; set; } + public decimal unqualifiedqty { get; set; } + public string inspectionTool { get; set; } + public string batchNo { get; set; } + public string serialNo { get; set; } + + } + public class Workinghours + { + public string employee { get; set; } + public decimal quantity { get; set; } + public decimal workingHours { get; set; } + public string operation { get; set; } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/JobStart.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/JobStart.cs new file mode 100644 index 0000000..ea5129a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/JobStart.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using Newtonsoft.Json; + +namespace MisDataSaveDate.MOM +{ + /// + /// 开工 + /// + + public class JobStart + { + /// + /// 派工单ID + /// + public string orderID { get; set; } + /// + /// 派工任务ID + /// + public string taskID { get; set; } + /// + /// 工序ID + /// + public string processId { get; set; } + + /// + /// 操作时间 + /// + public string operationTime { get; set; } + + /// + /// 操作人 + /// + [JsonProperty("operator")] + public string operatorName { get; set; } + + /// + /// 创建时间 + /// + public string createTime { get; set; } + + /// + /// 最后修改时间 + /// + public string lastModifiedTime { get; set; } + /// + /// 操作:0取消开工,1开工 + /// + public string operation { get; set; } + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialConfirm.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialConfirm.cs new file mode 100644 index 0000000..3b75a53 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialConfirm.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 缓存位置查询 + /// + + public class MaterialConfirm + { + /// + /// 请求编号 + /// + public string tackcode { get; set; } = ""; + /// + /// 请求方标识 + /// + public string orderID { get; set; } = ""; + /// + /// 工位号 + /// + public string taskID { get; set; } = ""; + public string processId { get; set; } = ""; + public string containerNo { get; set; } = ""; + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialPosition.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialPosition.cs new file mode 100644 index 0000000..c76d66f --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialPosition.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 缓存位置查询 + /// + + public class MaterialPosition + { + /// + /// 请求ID + /// + public string requestId { get; set; } + + /// + /// 工序 + /// + public string process { get; set; } + + } + public class MaterialPositionInfo + { + /// + /// 工序编号 + /// + public string processNo { get; set; } + + /// + /// 位置编号 + /// + public string locationNo { get; set; } + /// + /// 空位置数量编号 + /// + public string emptySlots { get; set; } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialSend.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialSend.cs new file mode 100644 index 0000000..4d5319b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialSend.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 物料配送 + /// + + public class MaterialSend + { + /// + /// 叫料任务号 + /// + public string code { get; set; } + + /// + /// 派工单ID + /// + public string orderID { get; set; } + + /// + /// 派工任务ID + /// + public string taskID { get; set; } + + /// + /// 顺序号 + /// + public string sequenceNo { get; set; } + + /// + /// 配送类型 + /// + public string deliveryType { get; set; } + + /// + /// 工序 + /// + public string processStep { get; set; } + + /// + /// 起始位置 + /// + public string startLocation { get; set; } + + /// + /// 终止位置 + /// + public string endLocation { get; set; } + + /// + /// 配送物料 + /// + public string material { get; set; } + + /// + /// 配送数量 + /// + public int quantity { get; set; } + + /// + /// 托盘号 + /// + public string trayNumber { get; set; } + + /// + /// 产线 + /// + public string prodline { get; set; } + + /// + /// 工位 + /// + public string workstation { get; set; } + + /// + /// 车间 + /// + public string workshop { get; set; } + + /// + /// 企业 + /// + public string customerid { get; set; } + + /// + /// 创建人 + /// + public string creator { get; set; } + + /// + /// 创建时间 + /// + public string createTime { get; set; } + + /// + /// 最后修改时间 + /// + public string lastModifiedTime { get; set; } + + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialTransfer.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialTransfer.cs new file mode 100644 index 0000000..22cfb5c --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/MaterialTransfer.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 物料转序 + /// + public class MaterialTransfer + { + /// + /// 请求编号,每个请求都要一个唯一编号,同一个请求重复提交,使用同一编号 + /// + public string reqCode { get; set; } + + /// + /// 请求时间截 格式: "yyyy-MM-dd HH:mm:ss" + /// + public string reqTime { get; set; } + + /// + /// 令牌号, 由系统颁发 + /// + public string tokenCode { get; set; } + + /// + /// 客户端编号,如PDA,HCWMS等 + /// + public string clientCode { get; set; } + + /// + /// 任务模板编号 + /// + public string taskType { get; set; } + + /// + /// 1:搬运容器,2;搬运货架,默认:2 + /// + public string moveTaskType { get; set; } + + /// + /// 载具类型:0-空;1-满,搬运货架起点不是地码,搬运容器起点不是仓位时必填 + /// 0:空料架;1:满料架 + /// + public string vehicleStatus { get; set; } + + /// + /// 位置列表(默认第一个位置是起点,第二个位置是终点) + /// + public List positionCodeList { get; set; } + + /// + /// 派工任务id + /// + public string dataid { get; set; } + } + + /// + /// 位置信息 + /// + public class PositionInfo + { + /// + /// 00-地码(位置);05-仓位;04-区域 + /// 00:工位;04:区域 + /// + public string type { get; set; } + + /// + /// 根据type填值,具体的点位 + /// + public string positionCode { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/SpotCheckResult.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/SpotCheckResult.cs new file mode 100644 index 0000000..5b4f735 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/SpotCheckResult.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json; +public class SpotCheckResult +{ + [JsonProperty("id")] + public string Id { get; set; } // 点检记录id + + [JsonProperty("code")] + public string Code { get; set; } // 点检记录编号 + + [JsonProperty("checkplanid")] + public string CheckPlanId { get; set; } // 点检计划ID + + [JsonProperty("createusercode")] + public string CreateUserCode { get; set; } // 点检记录编制人编号 + + [JsonProperty("createusername")] + public string CreateUserName { get; set; } // 点检记录编制人名称 + + [JsonProperty("createtime")] + public DateTime CreateTime { get; set; } // 点检时间 + + [JsonProperty("resultData")] + public List ResultData { get; set; } // 点检明细列表 +} + +public class CheckResultDetail +{ + [JsonProperty("resultid")] + public string ResultId { get; set; } // 点检明细id + + [JsonProperty("checkplandetailid")] + public string CheckPlanDetailId { get; set; } // 点检计划详细信息ID + + [JsonProperty("abnormal")] + public string Abnormal { get; set; } // 是否异常(假设为布尔值) + + [JsonProperty("checkvalue")] + public string CheckValue { get; set; } // 点检值 + + [JsonProperty("checkresult")] + public string CheckResult { get; set; } // 点检结果 + + [JsonProperty("checkercode")] + public string CheckerCode { get; set; } // 点检人 + + [JsonProperty("checkername")] + public string CheckerName { get; set; } // 点检人名称 + + [JsonProperty("checktime")] + public string CheckTime { get; set; } // 实际点检时间 + + [JsonProperty("processresult")] + public string ProcessResult { get; set; } // 处理结果 + + [JsonProperty("processmethod")] + public string ProcessMethod { get; set; } // 处理方式 + + [JsonProperty("filebefore")] + public string FileBefore { get; set; } // 改善前附件 + + [JsonProperty("fileafter")] + public string FileAfter { get; set; } // 改善后附件 + + [JsonProperty("exdescribe")] + public string ExDescribe { get; set; } // 异常描述 + + [JsonProperty("nohandlereason")] + public string NoHandleReason { get; set; } // 不处理原因 +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MOM_Upload/taskFinish.cs b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/taskFinish.cs new file mode 100644 index 0000000..8d28321 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MOM_Upload/taskFinish.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.MOM +{ + /// + /// 任务完工与工时汇报 + /// + + public class TaskFinish + { + /// + /// 派工单ID + /// + public string orderID { get; set; } + + /// + /// 派工任务ID + /// + public string taskID { get; set; } + + /// + /// 员工 + /// + public string employee { get; set; } + + /// + /// 数量 + /// + public int quantity { get; set; } + + /// + /// 工时 + /// + public int workingHours { get; set; } + } + + +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/ApiTools.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/ApiTools.cs new file mode 100644 index 0000000..a51e14d --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/ApiTools.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http; +using System.Net.Http; +using System.Text.RegularExpressions; + +namespace WebApi +{ + public enum ResponseCode + { + Fail = 00000, + Success = 00200, + } + + public class ApiTools + { + private string msgModel = "{{\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}"; + public ApiTools() + { + } + public HttpResponseMessage MsgFormat(ResponseCode code, string explanation, string result) + { + string r = @"^(\-|\+)?\d+(\.\d+)?$"; + string json = string.Empty; + if (Regex.IsMatch(result, r) || result.ToLower() == "true" || result.ToLower() == "false" || result == "[]" || result.Contains('{')) + { + json = string.Format(msgModel, (int)code, explanation, result); + } + else + { + if (result.Contains('"')) + { + json = string.Format(msgModel, (int)code, explanation, result); + } + else + { + json = string.Format(msgModel, (int)code, explanation, "\"" + result + "\""); + } + } + return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }; + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/CallWebApi.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/CallWebApi.cs new file mode 100644 index 0000000..6af3a4f --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/CallWebApi.cs @@ -0,0 +1,355 @@ +using ExternalDataSync; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace WebApi +{ + public class Post + { + public static string Postring(string url, Dictionary dic) + { + string result = ""; + //url = "http://172.16.22.15:8000/" + url; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Proxy = null; + + req.KeepAlive = false; + + #region 添加Post 参数 + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + public static string Post_XK(string url, string content) + { + + var WebapiPostHeader_Tenant = ConfigurationManager.AppSettings["WebapiPostHeader_Tenant"]; + var WebapiPostHeader_Language = ConfigurationManager.AppSettings["WebapiPostHeader_Language"]; + var WebapiPostHeader_Authorization = ConfigurationManager.AppSettings["WebapiPostHeader_Authorization"]; + var WebapiPostHeader_Systemcode = ConfigurationManager.AppSettings["WebapiPostHeader_Systemcode"]; + + ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; + + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + + req.Headers.Add("X-ECC-Current-Tenant", WebapiPostHeader_Tenant); + req.Headers.Add("Accept-Language", WebapiPostHeader_Language); + req.Headers.Add("Authorization", WebapiPostHeader_Authorization); + //req.Headers.Add("Connect-Type", "application/json"); + req.Headers.Add("Systemcode", WebapiPostHeader_Systemcode); + + req.Accept = "*/*"; + req.Method = "POST"; + req.ContentType = "application/json"; + req.Timeout = 10000; + + try + { + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + } + catch (Exception ex) + { + return JsonConvert.SerializeObject(new { code = 500, message = ex.Message, data = new object() }); + } + + + try + { + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + using (Stream stream = resp.GetResponseStream()) + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + catch (WebException ex) + { + if (ex.Response != null) + { + using (Stream stream = ex.Response.GetResponseStream()) + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + else + { + result = JsonConvert.SerializeObject(new { code = 500, message = ex.Message, data = new object() }); + } + } + catch (Exception ex) + { + + result = JsonConvert.SerializeObject(new { code = 500, message = ex.Message, data = new object() }); + } + + return result; + } + + public static string Post_Auto(string url, string content) + { + ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; + + string result = ""; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Headers.Add("Connect-Type", "application/json"); + req.Accept = "*/*"; + req.Method = "POST"; + req.ContentType = "application/json"; + req.Timeout = 10000; + + // 写入请求数据 + if (!string.IsNullOrEmpty(content)) + { + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + } + } + else + { + req.ContentLength = 0; + } + + // 获取响应 + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + using (Stream stream = resp.GetResponseStream()) + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + catch (WebException ex) + { + if (ex.Response != null) + { + using (Stream stream = ex.Response.GetResponseStream()) + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + else + { + // 返回标准格式的错误信息 + result = JsonConvert.SerializeObject(new { code = 500, message = ex.Message }); + } + } + catch (Exception ex) + { + // 返回标准格式的错误信息 + result = JsonConvert.SerializeObject(new { code = 500, message = ex.Message }); + } + + return result; + } + + public static JObject Post_WebAPI(string WebAPI_Url, string m_msg) + { + try + { + return JsonConvert.DeserializeObject(WebApi.Post.Post_Auto(WebAPI_Url, m_msg)); + } + catch (Exception ex) + { + return new JObject { { "code", 500 }, { "Message", ex.Message }, { "data", new JObject() } }; + } + } + + public static string Postring1(string url, string token, Dictionary dic) + { + string results = ""; + //url = "http://172.16.22.15:8000/" + url; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Headers.Add("Authorization", "Bearer " + token); + + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + try + { + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + results = reader.ReadToEnd(); + } + return results; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return e.Message; + throw; + } + + } + + + public static string MyPost() + { + // var url = "http://192.168.1.224:41190/"; + var url = "http://127.0.0.1:41190/"; + var controller = "ZSaveTag"; + var action = "SelectPage"; + Dictionary dict = new Dictionary(); + dict.Add("OpName",""); + dict.Add("StartTime", "2022-06-24 00:00:00"); + dict.Add("EndTime", "2022-06-30 00:00:00"); + dict.Add("PageCurrent", "1"); + dict.Add("PageSize", "2"); + + + var reqUrl = url + "/api/" + controller + "/" + action; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(reqUrl); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Proxy = null; + + req.KeepAlive = false; + + #region 添加Post 参数 + JObject jObject = new JObject(); + jObject.Add("OpName", ""); + jObject.Add("StartTime", "2022-06-24 00:00:00"); + jObject.Add("EndTime", "2022-06-30 00:00:00"); + jObject.Add("PageCurrent", "2"); + jObject.Add("PageSize", "3"); + var jStr = jObject.ToString(); + + //StringBuilder builder = new StringBuilder(); + //int i = 0; + //foreach (var item in dict) + //{ + // if (i > 0) + // builder.Append("&"); + // builder.AppendFormat("{0}={1}", item.Key, item.Value); + // i++; + //} + //byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + byte[] data = Encoding.UTF8.GetBytes(jStr); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + string result = ""; + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + public static string MyPost(string url,string jsonStr) + { + string result = ""; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Proxy = null; + req.KeepAlive = false; + + byte[] data = Encoding.UTF8.GetBytes(jsonStr); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + Console.WriteLine(result); + + + } + catch (Exception err) + { + Console.WriteLine(" " + err.Message); + } + + return result; + } + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/DeviceTools.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/DeviceTools.cs new file mode 100644 index 0000000..895833a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/DeviceTools.cs @@ -0,0 +1,313 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TECSharpFunction; + +namespace SlMesDbIterface +{ + public class DeviceTools + { + public static void GetToolExcel(string FtpServer, string FtpUser,string FtpPassWord, string FtpFileList) + { + FTPHelper ftpClient = new FTPHelper(FtpServer, @"", FtpUser, FtpPassWord); + //ListType=1代表获取文件列表,ListType=2代表获取文件夹列表,ListType=3代表获取文件和文件夹列表。 + //Detail=true时获文件或文件夹详细信息,Detail=false时只获取文件或文件夹名称。 + //Keyword是只需list名称包含Keyword的文件或文件夹,若要list所有文件或文件夹,则该参数为空。若ListType=3,则该参数无效。 + + int ListType = 1; + bool Detail = false; + string Keyword = ""; + + var fileList = ftpClient.GetFileDirctoryList(ListType, Detail, Keyword); + + foreach (string itemFileName in fileList) + { + string tableName = itemFileName.Substring(0, itemFileName.LastIndexOf(".")); + if (FtpFileList.Contains(itemFileName)) + { + ftpClient.Download(itemFileName, itemFileName, null); + ExcelToDataTable(itemFileName, tableName); + } + else + { + } + } + } + + private static void ExcelToDataTable(string excelPath, string tableName) + { + ////判断是否包含当前日期的记录 + //int excelSheetindex = 0; + //var dt = NPOITest.ExeclHelper.ExcelToDataTable(excelPath, excelSheetindex, true); + //switch (tableName) + //{ + // case "刀具柜-库存明细": + // { + // string str1 = "delete from[刀具柜-库存明细] where[导入日期] = '" + DateTime.Now.ToShortDateString() + "'"; + // DataLinkMesWork.SQLCommon.ExecuteSql(str1, Program.ConnectionString_MES, out string errorMessage1); + // var dt_DB = GetToolDetail(dt); + // SqlBulkCopyByDatatable(Program.ConnectionString_MES, tableName, dt_DB); + // } + // break; + // case "刀具领用记录": + // { + // string str2 = "delete from[刀具领用记录] where[导入日期] = '" + DateTime.Now.ToShortDateString() + "'"; + // DataLinkMesWork.SQLCommon.ExecuteSql(str2, Program.ConnectionString_MES, out string errorMessage2); + // var dt_DB = GetToolRecoder(dt); + // SqlBulkCopyByDatatable(Program.ConnectionString_MES, tableName, dt_DB); + // } + // break; + //} + } + + + /// + /// 刀具领用记录 + /// + private static DataTable GetToolRecoder(DataTable dtData) + { + //刀具领用记录.xls + + DataTable dt = new DataTable(); + dt.Columns.Add("物料名称", typeof(System.String)); + dt.Columns.Add("物料编号", typeof(System.String)); + dt.Columns.Add("物料型号", typeof(System.String)); + dt.Columns.Add("供应商", typeof(System.String));//品牌(供应商) + dt.Columns.Add("领取来源", typeof(System.String)); + dt.Columns.Add("领取数量", typeof(System.Int32)); + dt.Columns.Add("实领数量", typeof(System.Int32)); + dt.Columns.Add("领取单位", typeof(System.String)); + dt.Columns.Add("包装数量", typeof(System.Int32)); + dt.Columns.Add("包装单位", typeof(System.String)); + dt.Columns.Add("领用类型", typeof(System.String)); + dt.Columns.Add("单价", typeof(System.Double));//单价(元) + dt.Columns.Add("金额", typeof(System.Double)); + dt.Columns.Add("部门", typeof(System.String)); + dt.Columns.Add("领用人员", typeof(System.String)); + dt.Columns.Add("已归还数量", typeof(System.Int32)); + dt.Columns.Add("是否归还", typeof(System.String)); + dt.Columns.Add("领用时间", typeof(System.DateTime)); + DataRow dr = dt.NewRow(); + for (int i = 0; i < dtData.Rows.Count; i++) + { + dr = dt.NewRow(); + var 物料名称 = dtData.Rows[i][0].ToString(); + if (物料名称 == "合计") + { + continue; + } + dr["物料名称"] = 物料名称; + dr["物料编号"] = dtData.Rows[i][1].ToString(); + dr["物料型号"] = dtData.Rows[i][2].ToString(); + dr["供应商"] = dtData.Rows[i][3].ToString(); + dr["领取来源"] = dtData.Rows[i][4].ToString(); + try + { + dr["领取数量"] = Convert.ToInt32(dtData.Rows[i][5]); + } + catch + { + dr["领取数量"] = 0; + } + try + { + dr["实领数量"] = Convert.ToInt32(dtData.Rows[i][6]); + } + catch + { + dr["实领数量"] = 0; + } + dr["领取单位"] = dtData.Rows[i][7].ToString(); + try + { + dr["包装数量"] = Convert.ToInt32(dtData.Rows[i][8]); + } + catch + { + dr["包装数量"] = 0; + } + + + dr["包装单位"] = dtData.Rows[i][9].ToString(); + dr["领用类型"] = dtData.Rows[i][10].ToString(); + try + { + dr["单价"] = Convert.ToDouble(dtData.Rows[i][11]); + } + catch + { + dr["单价"] = 0; + } + try + { + dr["金额"] = Convert.ToDouble(dtData.Rows[i][12]); + } + catch + { + dr["金额"] = 0; + } + dr["部门"] = dtData.Rows[i][13].ToString(); + dr["领用人员"] = dtData.Rows[i][14].ToString(); + + + try + { + dr["已归还数量"] = Convert.ToInt32(dtData.Rows[i][15]); + } + catch + { + dr["已归还数量"] = 0; + } + dr["是否归还"] = dtData.Rows[i][16].ToString(); + try + { + dr["领用时间"] = Convert.ToDateTime(dtData.Rows[i][17]); + // dr["领用时间"] = dtData.Rows[i][17].ToString(); + } + catch + { + dr["领用时间"] = DBNull.Value; + } + + dt.Rows.Add(dr); + } + + + return dt; + + } + /// + /// 刀具柜-库存明细 + /// + private static DataTable GetToolDetail(DataTable dtData) + { + //刀具柜 - 库存明细.xls + + DataTable dt = new DataTable(); + dt.Columns.Add("刀具柜名称", typeof(System.String)); + dt.Columns.Add("行号", typeof(System.Int32)); + dt.Columns.Add("列号", typeof(System.Int32)); + dt.Columns.Add("物料名称", typeof(System.String)); + dt.Columns.Add("物料编号", typeof(System.String)); + dt.Columns.Add("物料型号", typeof(System.String)); + dt.Columns.Add("当前数量", typeof(System.Double)); + dt.Columns.Add("包装单位", typeof(System.String)); + dt.Columns.Add("单价", typeof(System.Double)); + dt.Columns.Add("金额", typeof(System.Double)); + dt.Columns.Add("最大存储", typeof(System.Int32)); + dt.Columns.Add("警告阀值", typeof(System.Int32)); + dt.Columns.Add("最后上架时间", typeof(System.DateTime)); + DataRow dr = dt.NewRow(); + for (int i = 0; i < dtData.Rows.Count; i++) + { + dr = dt.NewRow(); + dr["刀具柜名称"] = dtData.Rows[i]["刀具柜名称"].ToString(); + try + { + dr["行号"] = Convert.ToInt32(dtData.Rows[i]["行号"]); + } + catch + { + dr["行号"] = 0; + } + try + { + dr["列号"] = Convert.ToInt32(dtData.Rows[i]["列号"]); + } + catch + { + dr["列号"] = 0; + } + dr["物料名称"] = dtData.Rows[i]["物料名称"].ToString(); + dr["物料编号"] = dtData.Rows[i]["物料编号"].ToString(); + dr["物料型号"] = dtData.Rows[i]["物料型号"].ToString(); + try + { + dr["当前数量"] = Convert.ToDouble(dtData.Rows[i]["当前数量"]); + } + catch + { + dr["当前数量"] = 0; + } + dr["包装单位"] = dtData.Rows[i]["包装单位"].ToString(); + try + { + dr["单价"] = Convert.ToDouble(dtData.Rows[i]["单价"]); + } + catch + { + dr["单价"] = 0; + } + try + { + dr["金额"] = Convert.ToDouble(dtData.Rows[i]["金额"]); + } + catch + { + dr["金额"] = 0; + } + try + { + dr["最大存储"] = Convert.ToDouble(dtData.Rows[i]["最大存储"]); + } + catch + { + dr["最大存储"] = 0; + } + try + { + dr["警告阀值"] = Convert.ToDouble(dtData.Rows[i]["警告阀值"]); + } + catch + { + dr["警告阀值"] = 0; + } + try + { + dr["最后上架时间"] = Convert.ToDateTime(dtData.Rows[i]["最后上架时间"]); + } + catch + { + dr["警告阀值"] = DBNull.Value; + } + dt.Rows.Add(dr); + } + + + return dt; + + } + + static void SqlBulkCopyByDatatable(string connectionString, string TableName, DataTable dt) + { + using (SqlConnection conn = new SqlConnection(connectionString)) + { + using (SqlBulkCopy sqlbulkcopy = + new SqlBulkCopy(connectionString, SqlBulkCopyOptions.UseInternalTransaction)) + { + try + { + sqlbulkcopy.DestinationTableName = "[" + TableName + "]"; + dt.TableName = TableName; + for (int i = 0; i < dt.Columns.Count; i++) + { + sqlbulkcopy.ColumnMappings.Add(dt.Columns[i].ColumnName.Trim(), "[" + dt.Columns[i].ColumnName + "]"); + } + sqlbulkcopy.WriteToServer(dt); + } + catch (System.Exception ex) + { + //throw ex; + } + } + } + } + + + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/FTPHelper.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/FTPHelper.cs new file mode 100644 index 0000000..df8e7d0 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/FTPHelper.cs @@ -0,0 +1,332 @@ +using System; +using System.IO; +using System.Net; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace TECSharpFunction +{ + /// + /// FTP操作 + /// + public class FTPHelper + { + #region FTPConfig + string ftpURI; + string ftpUserID; + string ftpServerIP; + string ftpPassword; + string ftpRemotePath; + #endregion + + /// + /// 连接FTP服务器 + /// + /// FTP连接地址 + /// 指定FTP连接成功后的当前目录, 如果不指定即默认为根目录 + /// 用户名 + /// 密码 + public FTPHelper(string FtpServerIP, string FtpRemotePath, string FtpUserID, string FtpPassword) + { + ftpServerIP = FtpServerIP; + ftpRemotePath = FtpRemotePath; + ftpUserID = FtpUserID; + ftpPassword = FtpPassword; + ftpURI = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/"; + } + + public bool CheckFtp() + { + try + { + FtpWebRequest ftprequest = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI)); + // ftp用户名和密码 + ftprequest.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + ftprequest.Method = WebRequestMethods.Ftp.ListDirectory; + ftprequest.Timeout = 3000; + FtpWebResponse ftpResponse = (FtpWebResponse)ftprequest.GetResponse(); + + ftpResponse.Close(); + return true; + } + catch (Exception ex) + { + return false; + } + } + // 参数localfile为要上传的本地文件,ftpfile为上传到FTP的文件名称,ProgressBar为显示上传进度的滚动条,适用于WinForm。若应用于控制台程序,只要重写该函数,将参数ProgressBar去掉即可,同时将函数实现里所有涉及ProgressBar的地方都删掉。 + //———————————————— + //版权声明:本文为CSDN博主「只会搬运的小菜鸟」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 + //原文链接:https://blog.csdn.net/u011465910/article/details/126563124 + public void Upload(string localfile, string ftpfile, System.Windows.Forms.ProgressBar pb) + { + FileInfo fileInf = new FileInfo(localfile); + FtpWebRequest reqFTP; + reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI + ftpfile)); + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + reqFTP.Method = WebRequestMethods.Ftp.UploadFile; + reqFTP.KeepAlive = false; + reqFTP.UseBinary = true; + reqFTP.ContentLength = fileInf.Length; + if (pb != null) + { + pb.Maximum = Convert.ToInt32(reqFTP.ContentLength / 2048); + pb.Maximum = pb.Maximum + 1; + pb.Minimum = 0; + pb.Value = 0; + } + int buffLength = 2048; + byte[] buff = new byte[buffLength]; + int contentLen; + FileStream fs = fileInf.OpenRead(); + try + { + Stream strm = reqFTP.GetRequestStream(); + contentLen = fs.Read(buff, 0, buffLength); + while (contentLen != 0) + { + strm.Write(buff, 0, contentLen); + if (pb != null) + { + if (pb.Value != pb.Maximum) + pb.Value = pb.Value + 1; + } + contentLen = fs.Read(buff, 0, buffLength); + System.Windows.Forms.Application.DoEvents(); + } + if (pb != null) + pb.Value = pb.Maximum; + System.Windows.Forms.Application.DoEvents(); + strm.Close(); + fs.Close(); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + //参数localfilename为将下载到本地的文件名称,ftpfilename为要下载的FTP上文件名称, + // ProcessBar为用于显示下载进度的进度条。该函数用于WinForm,若用于控制台,只要重写该函数,删除所有涉及ProcessBar的代码即可。 + public void Download(string localfilename, string ftpfileName, System.Windows.Forms.ProgressBar pb) + { + long fileSize = GetFileSize(ftpfileName); + if (fileSize > 0) + { + if (pb != null) + { + pb.Maximum = Convert.ToInt32(fileSize / 2048); + pb.Maximum = pb.Maximum + 1; + pb.Minimum = 0; + pb.Value = 0; + } + try + { + FileStream outputStream = new FileStream(localfilename, FileMode.Create); + FtpWebRequest reqFTP; + reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI + ftpfileName)); + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; + reqFTP.UseBinary = true; + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + Stream ftpStream = response.GetResponseStream(); + int bufferSize = 2048; + + int readCount; + byte[] buffer = new byte[bufferSize]; + readCount = ftpStream.Read(buffer, 0, bufferSize); + while (readCount > 0) + { + outputStream.Write(buffer, 0, readCount); + if (pb != null) + { + if (pb.Value != pb.Maximum) + pb.Value = pb.Value + 1; + } + readCount = ftpStream.Read(buffer, 0, bufferSize); + System.Windows.Forms.Application.DoEvents(); + } + if (pb != null) + pb.Value = pb.Maximum; + System.Windows.Forms.Application.DoEvents(); + ftpStream.Close(); + outputStream.Close(); + response.Close(); + } + catch (Exception ex) + { + File.Delete(localfilename); + //throw new Exception(ex.Message); + } + } + } + + public void Delete(string fileName) + { + try + { + FtpWebRequest reqFTP; + reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI + fileName)); + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + reqFTP.Method = WebRequestMethods.Ftp.DeleteFile; + reqFTP.KeepAlive = false; + string result = String.Empty; + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + long size = response.ContentLength; + Stream datastream = response.GetResponseStream(); + StreamReader sr = new StreamReader(datastream); + result = sr.ReadToEnd(); + sr.Close(); + datastream.Close(); + response.Close(); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + //ListType=1代表获取文件列表,ListType=2代表获取文件夹列表,ListType=3代表获取文件和文件夹列表。 + //Detail=true时获文件或文件夹详细信息,Detail=false时只获取文件或文件夹名称。 + //Keyword是只需list名称包含Keyword的文件或文件夹,若要list所有文件或文件夹,则该参数为空。若ListType=3,则该参数无效。 + //———————————————— + //版权声明:本文为CSDN博主「只会搬运的小菜鸟」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 + public List GetFileDirctoryList(int ListType, bool Detail, string Keyword) + { + List strs = new List(); + try + { + FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI)); + // ftp用户名和密码 + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + if (Detail) + reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails; + else + reqFTP.Method = WebRequestMethods.Ftp.ListDirectory; + WebResponse response = reqFTP.GetResponse(); + + + StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名 + string line = reader.ReadLine(); + while (line != null) + { + if (ListType == 1) + { + if (line.Contains(".")) + { + if (Keyword.Trim() == "*.*" || Keyword.Trim() == "") + { + strs.Add(line); + } + else if (line.IndexOf(Keyword.Trim()) > -1) + { + strs.Add(line); + } + } + } + else if (ListType == 2) + { + if (!line.Contains(".")) + { + if (Keyword.Trim() == "*" || Keyword.Trim() == "") + { + strs.Add(line); + } + else if (line.IndexOf(Keyword.Trim()) > -1) + { + strs.Add(line); + } + } + } + else if (ListType == 3) + { + strs.Add(line); + } + line = reader.ReadLine(); + } + reader.Close(); + response.Close(); + return strs; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + + + + } + + public void MakeDir(string dirName) + { + FtpWebRequest reqFTP; + try + { + reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI + dirName)); + reqFTP.Method = WebRequestMethods.Ftp.MakeDirectory; + reqFTP.UseBinary = true; + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + Stream ftpStream = response.GetResponseStream(); + ftpStream.Close(); + response.Close(); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + + public long GetFileSize(string ftpfileName) + { + long fileSize = 0; + try + { + FtpWebRequest reqFTP; + reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI + ftpfileName)); + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + reqFTP.Method = WebRequestMethods.Ftp.GetFileSize; + reqFTP.UseBinary = true; + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + Stream ftpStream = response.GetResponseStream(); + fileSize = response.ContentLength; + ftpStream.Close(); + response.Close(); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + return fileSize; + } + + + + public void ReName(string currentFilename, string newFilename) + { + FtpWebRequest reqFTP; + try + { + reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURI + currentFilename)); + reqFTP.Method = WebRequestMethods.Ftp.Rename; + reqFTP.RenameTo = newFilename; + reqFTP.UseBinary = true; + reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + Stream ftpStream = response.GetResponseStream(); + ftpStream.Close(); + response.Close(); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + + public void MovieFile(string currentFilename, string newDirectory) + { + ReName(currentFilename, newDirectory); + } + + + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/GetVal.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/GetVal.cs new file mode 100644 index 0000000..6043381 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/GetVal.cs @@ -0,0 +1,69 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RecData +{ + public class GetVal + { + + public static string JObject_Value(JObject jObj,string name) + { + var objVal = "NULL"; + if (jObj[name] != null) + { + objVal = jObj[name].ToString(); + } + return objVal; + } + public static string JObject_Value_Int(JObject jObj, string name) + { + var objVal = "-1"; + if (jObj[name] != null) + { + objVal = jObj[name].ToString(); + } + return objVal; + } + public static string JToken_Value(JToken jToken, string name) + { + var objVal = "NULL"; + var jTokenStr = jToken.ToString(); + if (!jTokenStr.Contains(name)) + { + return objVal; + } + + if (jToken[name] != null) + { + objVal = jToken[name].ToString(); + } + return objVal; + + } + public static string JToken_Value_Int(JToken jToken, string name) + { + var objVal = "-1"; + if (jToken[name] != null) + { + objVal = jToken[name].ToString(); + } + return objVal; + + } + public static JArray JObject_JArray(JObject jObj, string name) + { + var jArray = new JArray(); + if (jObj[name] != null) + { + jArray = (JArray)jObj[name]; + } + return jArray; + } + + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/HttpCli.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/HttpCli.cs new file mode 100644 index 0000000..cefdfd7 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/HttpCli.cs @@ -0,0 +1,349 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace PLMTEST +{ + public class HttpCli + { + + + /// + /// 指定Url地址使用Get 方式获取全部字符串 + /// + /// 请求链接地址 + /// + public static string Get(string url) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + try + { + //获取内容 + using (StreamReader reader = new StreamReader(stream)) + { + result = reader.ReadToEnd(); + } + } + finally + { + stream.Close(); + } + return result; + } + + public static void GetFile(string url,string path) + { + WebRequest request = WebRequest.Create(url); + WebResponse response = request.GetResponse(); + if (response.ContentType.ToLower().Length > 0) + { + using (Stream reader = response.GetResponseStream()) + { + using (FileStream writer = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) + { + byte[] buffer = new byte[1024]; + int c = 0; + while ((c = reader.Read(buffer, 0, buffer.Length)) > 0) + { + writer.Write(buffer, 0, c); + } + } + } + //HttpContext + } + } + + public static byte[] GetFile_Bytes(string url) + { + byte[] bytesAll = null; + WebRequest request = WebRequest.Create(url); + WebResponse response = request.GetResponse(); + if (response.ContentType.ToLower().Length > 0) + { + using (Stream reader = response.GetResponseStream()) + { + MemoryStream ms = new MemoryStream(); + byte[] buffer = new byte[1024]; + while (true) + { + int sz = reader.Read(buffer, 0, 1024); + if (sz == 0) break; + ms.Write(buffer, 0, sz); + } + bytesAll = ms.ToArray(); + } + } + + //如是图片 + //System.Drawing.Image img = System.Drawing.Image.FromStream(ms); + + return bytesAll; + + } + + + + + + + + public void FGHJ() + { + + // Create a 'WebRequest' object with the specified url. + WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com"); + + // Send the 'WebRequest' and wait for response. + WebResponse myWebResponse = myWebRequest.GetResponse(); + + // Obtain a 'Stream' object associated with the response object. + Stream ReceiveStream = myWebResponse.GetResponseStream(); + + Encoding encode = System.Text.Encoding.GetEncoding("utf-8"); + + // Pipe the stream to a higher level stream reader with the required encoding format. + StreamReader readStream = new StreamReader(ReceiveStream, encode); + Console.WriteLine("\nResponse stream received"); + Char[] read = new Char[256]; + + // Read 256 charcters at a time. + int count = readStream.Read(read, 0, 256); + Console.WriteLine("HTML...\r\n"); + + while (count > 0) + { + // Dump the 256 characters on a string and display the string onto the console. + String str = new String(read, 0, count); + Console.Write(str); + count = readStream.Read(read, 0, 256); + } + + Console.WriteLine(""); + // Release the resources of stream object. + readStream.Close(); + + // Release the resources of response object. + myWebResponse.Close(); + + } + + /// + /// 发送Get请求 + /// + /// 地址 + /// 请求参数定义 + /// + public static string Get(string url, Dictionary dic) + { + string result = ""; + StringBuilder builder = new StringBuilder(); + builder.Append(url); + if (dic.Count > 0) + { + builder.Append("?"); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + } + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString()); + //添加参数 + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + try + { + //获取内容 + using (StreamReader reader = new StreamReader(stream)) + { + result = reader.ReadToEnd(); + } + } + finally + { + stream.Close(); + } + return result; + } + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// + public static string Post(string url) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// + public static string Post(string url, Dictionary dic) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + #region 添加Post 参数 + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// Post提交数据内容(utf-8编码的) + /// + public static string Post(string url, string content) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + + #region 添加Post 参数 + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + + /// + /// Http下载文件 + /// + /// 下载地址 + /// 存放完整路径(含文件名) + /// 每次多的大小 + /// 下载操作是否成功 + + public static bool DownLoadFiles(string uri, string filefullpath, int size = 1000000) + { + try + { + if (File.Exists(filefullpath)) + { + try + { + File.Delete(filefullpath); + } + catch (Exception ex) + { + return false; + } + } + + string fileDirectory = System.IO.Path.GetDirectoryName(filefullpath); + + if (!Directory.Exists(fileDirectory)) + { + Directory.CreateDirectory(fileDirectory); + } + + FileStream fs = new FileStream(filefullpath, FileMode.Create); + + byte[] buffer = new byte[size]; + + HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); + + request.Timeout = 100000; + + request.AddRange((int)fs.Length); + + Stream ns = request.GetResponse().GetResponseStream(); + + long contentLength = request.GetResponse().ContentLength; + + int length = ns.Read(buffer, 0, buffer.Length); + + while (length > 0) + { + fs.Write(buffer,0 , length); + buffer = new byte[size]; + length = ns.Read(buffer, 0, buffer.Length); + } + + fs.Close(); + + return true; + } + catch (Exception ex) + { + return false; + } + + } + + + + + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/InitServer.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/InitServer.cs new file mode 100644 index 0000000..a2870f2 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/InitServer.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Text; +using System.Web.Http; +using System.Web.Http.Cors; +using System.Web.Http.SelfHost; + +namespace WebApi +{ + /// + /// + /// + public class InitServer + { + /// + /// + /// + HttpSelfHostConfiguration config = null; + /// + /// + /// + HttpSelfHostServer server = null; + /// + /// + /// + /// + public InitServer(int port) + { + config = new HttpSelfHostConfiguration($"http://0.0.0.0:{port}"); + config.EnableCors(new EnableCorsAttribute("*", "*", "*")); + config.MapHttpAttributeRoutes(); + config.MaxReceivedMessageSize = 1024 * 1024 * 10; + //config.Routes.MapHttpRoute( + // name: "DefaultApi", + // routeTemplate: "api/{controller}/{id}", + // defaults: new { id = RouteParameter.Optional } + //); + + // 自定义路由匹配到action + config.Routes.MapHttpRoute( + name: "API Default", + routeTemplate: "api/{controller}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + + server = new HttpSelfHostServer(config); + + server.OpenAsync().Wait(); + + } + /// + /// + /// + /// + public void Init(int port) + { + + + } + public void Close() + { + server.CloseAsync(); + } + /// + /// + /// + public class JsonContentNegotiator : IContentNegotiator + { + /// + /// + /// + private readonly JsonMediaTypeFormatter _jsonFormatter; + /// + /// + /// + /// + public JsonContentNegotiator(JsonMediaTypeFormatter formatter) + { + _jsonFormatter = formatter; + } + /// + /// + /// + /// + /// + /// + /// + public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable formatters) + { + var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json")); + return result; + } + + public static string Postring1(string url, string token, Dictionary dic) + { + string results = ""; + //url = "http://172.16.22.15:8000/" + url; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Headers.Add("Authorization", "Bearer " + token); + + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + try + { + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + results = reader.ReadToEnd(); + } + return results; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return e.Message; + throw; + } + + } + + + + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/LocalNetworkFileHelper.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/LocalNetworkFileHelper.cs new file mode 100644 index 0000000..7460b81 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/LocalNetworkFileHelper.cs @@ -0,0 +1,329 @@ +using ICSharpCode.SharpZipLib.Zip; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using System.Web.UI.WebControls; + +namespace ExternalDataSync.MessageHanlder +{ + public class LocalNetworkFileHelper + { + [DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Auto)] + public extern static bool PathFileExists(string path); + /// + /// 连接远程共享文件夹 + /// + /// 远程共享文件夹的路径 + /// 用户名 + /// 密码 + public static bool connectState(string path, string userName, string passWord, out string Sharefile_Error) + { + Sharefile_Error = ""; + bool Flag = false; + Process proc = new Process(); + try + { + proc.StartInfo.FileName = "cmd.exe"; + proc.StartInfo.UseShellExecute = false; + proc.StartInfo.RedirectStandardInput = true; + proc.StartInfo.RedirectStandardOutput = true; + proc.StartInfo.RedirectStandardError = true; + proc.StartInfo.CreateNoWindow = true; + proc.Start(); + string dosLine = "net use " + path + " " + passWord + " /user:" + userName; + proc.StandardInput.WriteLine(dosLine); + proc.StandardInput.WriteLine("exit"); + while (!proc.HasExited) + { + proc.WaitForExit(1000); + } + string errormsg = proc.StandardError.ReadToEnd(); + proc.StandardError.Close(); + if (string.IsNullOrEmpty(errormsg)) + { + Flag = true; + } + else + { + Sharefile_Error = errormsg; + } + } + catch (Exception ex) + { + Sharefile_Error = ex.Message; + } + finally + { + proc.Close(); + proc.Dispose(); + } + return Flag; + } + + /// + /// 从远程服务器下载文件到本地 + /// + /// 远程服务器路径(共享文件夹路径) + /// 下载到本地后的文件路径 + /// 下载到本地文件名称,包含扩展名:ABC.text + public static bool TransportRemoteToLocal(string SourceFile, string LocalFile, string LocalFileName, out string Sharefile_Error, out byte[] fileContent) + { + fileContent = null; + Sharefile_Error = ""; + bool rel = false; + try + { + + if (Directory.Exists(LocalFile)) + { + Directory.Delete(LocalFile, true); + } + Directory.CreateDirectory(LocalFile); + //从远程服务器下载到本地的文件 + if (LocalFile.EndsWith(@"\")) + { + LocalFile = LocalFile + LocalFileName; + } + else + { + LocalFile = LocalFile + "\\" + LocalFileName; + } + //远程服务器文件 此处假定远程服务器共享文件夹下确实包含本文件,否则程序报错 + FileStream inFileStream = new FileStream(SourceFile, FileMode.Open); + FileStream outFileStream = new FileStream(LocalFile, FileMode.OpenOrCreate); + byte[] buf = new byte[inFileStream.Length]; + int byteCount; + while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0) + { + outFileStream.Write(buf, 0, byteCount); + fileContent = new byte[buf.Length]; + Array.Copy(buf, fileContent, buf.Length); + } + inFileStream.Flush(); + inFileStream.Close(); + outFileStream.Flush(); + outFileStream.Close(); + rel = true; + } + catch (Exception ex) + { + Sharefile_Error = ex.Message; + } + return rel; + } + + /// + /// 从远程服务器下载文件到本地 + /// + /// 远程服务器路径(共享文件夹路径) + /// 下载到本地后的文件路径 + public static bool TransportRemoteToLocal(string SourceFilePath, string LocalFilePath, out string Sharefile_Error) + { + Sharefile_Error = ""; + bool rel = false; + try + { + if (!Directory.Exists(SourceFilePath)) + { + Sharefile_Error = "共享文件路径不存在!" + SourceFilePath; + return false; + } + if (!Directory.Exists(LocalFilePath)) + { + Directory.CreateDirectory(LocalFilePath); + } + IEnumerable files = System.IO.Directory.EnumerateFileSystemEntries(SourceFilePath); + if (files != null && files.Count() > 0) + { + foreach (var item in files) + { + string desPath = System.IO.Path.Combine(LocalFilePath, System.IO.Path.GetFileName(item)); + //如果是文件 + var fileExist = System.IO.File.Exists(item); + if (fileExist) + { + //复制文件到指定目录下 + System.IO.File.Copy(item, desPath, true); + continue; + } + //如果是文件夹 + TransportRemoteToLocal(item, desPath, out string aaa); + } + } + rel = true; + } + catch (Exception ex) + { + Sharefile_Error = ex.Message; + } + return rel; + } + public static class DirectoryExtension + { + public static bool IsShareAccessible(string path) + { + + return true; + + //Ping ping = new Ping(); + //var response = ping.Send(path, 4); + + + //string errorMessage; + //var timeStart = DateTime.Now; + //using (var process = new Process { + // StartInfo = { + // FileName = "cmd.exe", + // UseShellExecute = false, + // RedirectStandardInput = true, + // RedirectStandardOutput = true, + // CreateNoWindow = true, + // RedirectStandardError = true + // } + //}) + //{ + // process.Start(); + // process.StandardInput.AutoFlush = true; + // process.StandardInput.WriteLine(@"net use " + path); + // process.StandardInput.WriteLine("exit"); + // errorMessage = process.StandardError.ReadToEnd(); + // process.WaitForExit(); + // if (string.IsNullOrEmpty(errorMessage)) + // { + // return true; + // } + // else + // { + // return false; + // } + //} + } + + public static bool FtpFolderExists(string folderPath, string username, string password) + { + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(folderPath); + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.ListDirectory; + + try + { + using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) + { + return true; // 如果成功获取响应,则文件夹存在 + } + } + catch (WebException ex) + { + return false; // 文件夹不存在 + } + } + + } + /// + /// 从远程服务器下载文件到本地 + /// + /// 远程服务器路径(共享文件夹路径) + /// 下载到本地后的文件路径 + /// 下载到本地文件名称,包含扩展名:ABC.text + public static bool TransportRemoteToLocalZip(string SourceFile, string LocalFile, string LocalFileName, string zipedFolder, out string Sharefile_Error) + { + Sharefile_Error = ""; + bool rel = false; + try + { + //远程服务器文件 此处假定远程服务器共享文件夹下确实包含本文件,否则程序报错 + FileStream inFileStream = new FileStream(SourceFile, FileMode.Open); + if (Directory.Exists(LocalFile)) + { + Directory.Delete(LocalFile, true); + } + Directory.CreateDirectory(LocalFile); + //从远程服务器下载到本地的文件 + if (LocalFile.EndsWith(@"\")) + { + LocalFile = LocalFile + LocalFileName; + } + else + { + LocalFile = LocalFile + "\\" + LocalFileName; + } + + FileStream outFileStream = new FileStream(LocalFile, FileMode.OpenOrCreate); + byte[] buf = new byte[inFileStream.Length]; + int byteCount; + while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0) + { + outFileStream.Write(buf, 0, byteCount); + } + inFileStream.Flush(); + inFileStream.Close(); + outFileStream.Flush(); + outFileStream.Close(); + + ZipHelper.UnZip(LocalFile, zipedFolder); + rel = true; + } + catch (Exception ex) + { + Sharefile_Error = ex.Message; + } + return rel; + } + + /// + /// 将本地文件上传到远程服务器共享目录 + /// + /// 本地文件的绝对路径,包含扩展名 + /// 远程服务器共享文件路径,不包含文件扩展名 + /// 上传到远程服务器后的文件扩展名 + public static bool TransportLocalToRemote(string SourceFile, string RemoteFile, string RemoteFileName, out string Sharefile_Error) //src + { + Sharefile_Error = ""; + //string SourceFile, string LocalFile, string LocalFileName + bool rel = false; + try + { + FileStream inFileStream = new FileStream(SourceFile, FileMode.Open); //此处假定本地文件存在,不然程序会报错 + if (!Directory.Exists(RemoteFile)) //判断上传到的远程服务器路径是否存在 + { + Directory.CreateDirectory(RemoteFile); + } + //上传到远程服务器共享文件夹后文件的绝对路径 + if (!RemoteFile.EndsWith(@"\")) + { + RemoteFile = RemoteFile + RemoteFileName; + } + else + { + RemoteFile = RemoteFile + "\\" + RemoteFileName; + } + FileStream outFileStream = new FileStream(RemoteFile, FileMode.OpenOrCreate); + byte[] buf = new byte[inFileStream.Length]; + int byteCount; + while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0) + { + outFileStream.Write(buf, 0, byteCount); + } + inFileStream.Flush(); + inFileStream.Close(); + outFileStream.Flush(); + outFileStream.Close(); + rel = true; + } + catch (Exception ex) + { + Sharefile_Error = ex.Message; + } + return rel; + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/Re.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/Re.cs new file mode 100644 index 0000000..001c77e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/Re.cs @@ -0,0 +1,173 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using RecData; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PLMTEST +{ + public class Re + { + + + public static DataTable Analysis_DataObject(string jsonStr) + { + /* +{ +"list": [ +{ + "errcode": 0, + "errmsg": null, + "objId": "01_18AC913FCA4A4DA99BDF01A99C232219", + "objNo": "0100045006", + "fname": null, + "suffix": null, + "hasAffine": null, + "name": "油泵轴油封", + "fsize": null, + "fsizeStr": "未知", + "type": "D", + "tablename": "MPART", + "smemo": null, + "ctimestr": "2017-07-11 16:03", + "mtimestr": "2020-12-21 15:36", + "creator": "5914洪杰", + "modifier": "11458戚亚克", + "ver": "1", + "stimestr": null, + "etimestr": null, + "extra": null,//这里加了俩字段:PTYPE(小类)、DTYPE(大类) + "searchText": null +} +], +"errcode": 0, +"errmsg": null, +"total": 1 +} + */ + + DataTable dt = new DataTable(); + dt.Columns.Add("errcode"); + dt.Columns.Add("errmsg"); + dt.Columns.Add("objId"); + dt.Columns.Add("objNo"); + dt.Columns.Add("fname"); + dt.Columns.Add("suffix"); + dt.Columns.Add("hasAffine"); + dt.Columns.Add("name"); + dt.Columns.Add("fsize"); + dt.Columns.Add("fsizeStr"); + dt.Columns.Add("type"); + dt.Columns.Add("tablename"); + dt.Columns.Add("smemo"); + dt.Columns.Add("ctimestr"); + dt.Columns.Add("mtimestr"); + dt.Columns.Add("creator"); + dt.Columns.Add("modifier"); + dt.Columns.Add("ver"); + dt.Columns.Add("stimestr"); + dt.Columns.Add("etimestr"); + dt.Columns.Add("extra"); + dt.Columns.Add("PTYPE"); + dt.Columns.Add("DTYPE"); + dt.Columns.Add("searchText"); + + + + var json = JsonConvert.DeserializeObject(jsonStr); + var errcode = json["errcode"].ToString(); + var errmsg = json["errmsg"].ToString(); + // var total = json["total"].ToString(); + if (errcode != "0") + { + dt = new DataTable(); + dt.Columns.Add("errcode"); + dt.Columns.Add("errmsg"); + // dt.Columns.Add("total"); + var dr = dt.NewRow(); + dr["errcode"] = errcode; + dr["errmsg"] = errmsg; + //dr["total"] = total; + dt.Rows.Add(dr); + return dt; + } + var array = json["list"]; + foreach (var a in array) + { + var _errcode = a["errcode"].ToString(); + var _errmsg = a["errmsg"].ToString(); + var objId = a["objId"].ToString(); + var objNo = a["objNo"].ToString(); + var fname = a["fname"].ToString(); + var suffix = a["suffix"].ToString(); + var hasAffine = a["hasAffine"].ToString(); + var name = a["name"].ToString(); + var fsize = a["fsize"].ToString(); + var fsizeStr = a["fsizeStr"].ToString(); + var type = a["type"].ToString(); + var tablename = a["tablename"].ToString(); + var smemo = a["smemo"].ToString(); + var ctimestr = a["ctimestr"].ToString(); + var mtimestr = a["mtimestr"].ToString(); + var creator = a["creator"].ToString(); + var modifier = a["modifier"].ToString(); + var ver = a["ver"].ToString(); + var stimestr = a["stimestr"].ToString(); + var etimestr = a["etimestr"].ToString(); + var extra_O = a["extra"]; + var extra = "-1"; + if (a["extra"] != null) + { + extra = a["extra"].ToString(); + } + var PTYPE = GetVal.JToken_Value(extra_O, "PTYPE"); + var DTYPE = GetVal.JToken_Value(extra_O, "DTYPE"); + + var searchText = a["searchText"].ToString(); + + var dr = dt.NewRow(); + dr["errcode"] = _errcode; + dr["errmsg"] = _errmsg; + dr["objId"] = objId; + dr["objNo"] = objNo; + dr["fname"] = fname; + dr["suffix"] = suffix; + dr["hasAffine"] = hasAffine; + dr["name"] = name; + dr["fsize"] = fsize; + dr["fsizeStr"] = fsizeStr; + dr["type"] = type; + dr["tablename"] = tablename; + dr["smemo"] = smemo; + + dr["ctimestr"] = ctimestr; + dr["mtimestr"] = mtimestr; + dr["creator"] = creator; + dr["modifier"] = modifier; + dr["ver"] = ver; + + dr["stimestr"] = stimestr; + dr["etimestr"] = etimestr; + dr["extra"] = extra; + dr["PTYPE"] = PTYPE; + dr["DTYPE"] = DTYPE; + dr["searchText"] = searchText; + + dt.Rows.Add(dr); + } + + return dt; + } + + + + + + + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/MessageHanlder/ZipHelper.cs b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/ZipHelper.cs new file mode 100644 index 0000000..3ffd69a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/MessageHanlder/ZipHelper.cs @@ -0,0 +1,245 @@ +using ICSharpCode.SharpZipLib.Zip; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ExternalDataSync.MessageHanlder +{ + /// + /// 适用于ZIP压缩 + /// + public class ZipHelper + { + #region 压缩 + /// + /// 压缩文件夹 + /// + /// 要压缩的文件夹路径 + /// 压缩前的Stream,方法执行后变为压缩完成后的文件 + /// 密码 + /// 是否成功 + public static bool ZipDirectoryToStream(string folderToZip, Stream Stream, string password = null) + { + return ZipDirectoryToZipStream(folderToZip, Stream, password) != null; + } + + /// + /// 压缩文件夹 + /// + /// 要压缩的文件夹路径 + /// 压缩前的Stream,方法执行后变为压缩完成后的文件 + /// 密码 + /// 是否压缩成功返回ZipOutputStream,否则返回null + public static ZipOutputStream ZipDirectoryToZipStream(string folderToZip, Stream Stream, string password = null) + { + if (!Directory.Exists(folderToZip)) + { + return null; + } + ZipOutputStream zipStream = new ZipOutputStream(Stream); + zipStream.SetLevel(6); + if (!string.IsNullOrEmpty(password)) + { + zipStream.Password = password; + } + if (ZipDirectory(folderToZip, zipStream, "")) + { + zipStream.Finish(); + return zipStream; + } + GC.Collect(1); + return null; + } + + /// + /// 递归压缩文件夹的内部方法 + /// + /// 要压缩的文件夹路径 + /// 压缩输出流 + /// 此文件夹的上级文件夹 + /// 是否成功 + private static bool ZipDirectory(string folderToZip, ZipOutputStream zipStream, string parentFolderName) + { + var crc = new ICSharpCode.SharpZipLib.Checksum.Crc32(); + + //这段是创建空文件夹,注释掉可以去掉空文件夹(因为在写入文件的时候也会创建文件夹) + //if (!string.IsNullOrEmpty(parentFolderName)) + //{ + // ent = new ZipEntry(parentFolderName + "/"); + // zipStream.PutNextEntry(ent); + // zipStream.Flush(); + //} + + var files = Directory.GetFiles(folderToZip); + foreach (string file in files) + { + byte[] buffer = File.ReadAllBytes(file); + var ent = new ZipEntry(parentFolderName + "/" + Path.GetFileName(file)); + //ent.DateTime = File.GetLastWriteTime(file);//设置文件最后修改时间 + ent.DateTime = DateTime.Now; + ent.Size = buffer.Length; + + crc.Reset(); + crc.Update(buffer); + + ent.Crc = crc.Value; + zipStream.PutNextEntry(ent); + zipStream.Write(buffer, 0, buffer.Length); + } + + var folders = Directory.GetDirectories(folderToZip); + foreach (var folder in folders) + { + var _parentFolderName = parentFolderName + "\\" + folder.Substring(folder.LastIndexOf('\\') + 1); + if (!ZipDirectory(folder, zipStream, _parentFolderName)) + { + return false; + } + } + return true; + } + + /// + /// 压缩文件夹 + /// + /// 要压缩的文件夹路径 + /// 压缩文件完整路径 + /// 密码 + /// 是否成功 + public static bool ZipDirectory(string folderToZip, string zipedFile, string password = null) + { + var zipStream = ZipDirectoryToZipStream(folderToZip, new FileStream(zipedFile, FileMode.Create, FileAccess.Write), password); + if (zipStream == null) + { + return false; + } + zipStream.Close(); + return true; + } + + /// + /// 压缩文件 + /// + /// 要压缩的文件全名 + /// 压缩后的文件名 + /// 密码 + /// 是否成功 + public static bool ZipFile(string fileToZip, string zipedFile, string password = null) + { + if (!File.Exists(fileToZip)) + { + return false; + } + var fs = File.OpenRead(fileToZip); + byte[] buffer = new byte[fs.Length]; + fs.Read(buffer, 0, buffer.Length); + fs.Close(); + + fs = File.Create(zipedFile); + var ent = new ZipEntry(Path.GetFileName(fileToZip)); + using (var zipStream = new ZipOutputStream(fs)) + { + if (!string.IsNullOrEmpty(password)) + { + zipStream.Password = password; + } + zipStream.PutNextEntry(ent); + zipStream.SetLevel(6); + zipStream.Write(buffer, 0, buffer.Length); + } + + if (fs != null) + { + fs.Close(); + fs.Dispose(); + } + + GC.Collect(1); + + return true; + } + + /// + /// 压缩文件或文件夹 + /// + /// 要压缩的路径 + /// 压缩后的文件名 + /// 密码 + /// 是否成功 + public static bool Zip(string fileToZip, string zipedFile, string password = null) + { + if (Directory.Exists(fileToZip)) + { + return ZipDirectory(fileToZip, zipedFile, password); + } + else if (File.Exists(fileToZip)) + { + return ZipFile(fileToZip, zipedFile, password); + } + return false; + } + #endregion + + #region 解压 + /// + /// 解压功能(解压压缩文件到指定目录) + /// + /// 待解压的文件 + /// 指定解压目标目录 + /// 密码 + /// 是否成功 + public static bool UnZip(string fileToUnZip, string zipedFolder, string password = null) + { + if (!System.IO.File.Exists(fileToUnZip)) + { + return false; + } + + if (!Directory.Exists(zipedFolder)) + { + Directory.CreateDirectory(zipedFolder); + } + + if (!zipedFolder.EndsWith("\\")) + { + zipedFolder += "\\"; + } + ZipEntry ent = null; + using (var zipStream = new ZipInputStream(System.IO.File.OpenRead(fileToUnZip))) + { + if (!string.IsNullOrEmpty(password)) + { + zipStream.Password = password; + } + while ((ent = zipStream.GetNextEntry()) != null) + { + if (ent.IsDirectory) + { + continue; + } + if (string.IsNullOrEmpty(ent.Name)) + { + continue; + } + string fileName = zipedFolder + ent.Name.Replace('/', '\\'); + var index = ent.Name.LastIndexOf('/'); + if (index != -1) + { + string path = zipedFolder + ent.Name.Substring(0, index).Replace('/', '\\'); + System.IO.Directory.CreateDirectory(path); + } + var bytes = new byte[ent.Size]; + zipStream.Read(bytes, 0, bytes.Length); + System.IO.File.WriteAllBytes(fileName, bytes); + } + } + GC.Collect(1); + return true; + } + #endregion + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/Program.cs b/Interface_WebAPI/SlMesDbIterface/Program.cs new file mode 100644 index 0000000..cfaaa8e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SlMesDbIterface +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + bool bCanRun = false; + System.Threading.Mutex mutex = new System.Threading.Mutex(true, "InterfaceUpLoad508SMALL_AGV", out bCanRun); + if (!bCanRun) + { + MessageBox.Show("508小AGV接口数据上传 程序 正在运行!不可重复启动!"); + return; + } + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form_MoveSqlTable()); + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Properties/AssemblyInfo.cs b/Interface_WebAPI/SlMesDbIterface/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fb7c2d0 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SlMesDbIterface")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SlMesDbIterface")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("2f33d79d-1dff-4cda-b357-fcd5221cab9a")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Interface_WebAPI/SlMesDbIterface/Properties/Resources.Designer.cs b/Interface_WebAPI/SlMesDbIterface/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c36b797 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Properties/Resources.Designer.cs @@ -0,0 +1,163 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExternalDataSync.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 任务监控和查询 { + get { + object obj = ResourceManager.GetObject("任务监控和查询", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 关闭系统 { + get { + object obj = ResourceManager.GetObject("关闭系统", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 动态数据查询 { + get { + object obj = ResourceManager.GetObject("动态数据查询", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 按键分割线 { + get { + object obj = ResourceManager.GetObject("按键分割线", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 按键分割线浅 { + get { + object obj = ResourceManager.GetObject("按键分割线浅", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 断开连接 { + get { + object obj = ResourceManager.GetObject("断开连接", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 日志 { + get { + object obj = ResourceManager.GetObject("日志", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 清除 { + get { + object obj = ResourceManager.GetObject("清除", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 连接 { + get { + object obj = ResourceManager.GetObject("连接", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 重新加载数据 { + get { + object obj = ResourceManager.GetObject("重新加载数据", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Properties/Resources.resx b/Interface_WebAPI/SlMesDbIterface/Properties/Resources.resx new file mode 100644 index 0000000..e08dc5a --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Properties/Resources.resx @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\icon\任务监控和查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\关闭系统.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\动态数据查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\按键分割线.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\按键分割线浅.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\断开连接.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\日志.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\清除.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\连接.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\重新加载数据.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/Properties/Settings.Designer.cs b/Interface_WebAPI/SlMesDbIterface/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5f6e85b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace ExternalDataSync.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/Properties/Settings.settings b/Interface_WebAPI/SlMesDbIterface/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Interface_WebAPI/SlMesDbIterface/SQLHelper/DataAccess.cs b/Interface_WebAPI/SlMesDbIterface/SQLHelper/DataAccess.cs new file mode 100644 index 0000000..daa7472 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/SQLHelper/DataAccess.cs @@ -0,0 +1,606 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataLinkMesWork2 +{ + public class DataAccess2 + { + public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"]; + public static bool ExecuteNonQuery(string sql, string connectionString, out string errorMessage) + { + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + //ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + + } + public static bool ExecuteDataset(string sql, string connectionString, out DataSet ds, out string errorMessage) + { + errorMessage = ""; + bool result = true; + errorMessage = ""; + ds = new DataSet(); + + /// SQLSERVER + /// SQLiteDB + try + { + //bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + //ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + catch (Exception err) + { + + } + + return result; + + + } + /// + /// 增 删 改 + /// + /// + /// + /// + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out string errorMessage) + { + string connectionString = ConnectionString_MES; + errorMessage=""; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlCommand cmd = new SqlCommand(procedureName, conn)) + { + cmd.CommandTimeout = 0; + cmd.CommandType = CommandType.StoredProcedure; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + cmd.Parameters.Add(sqlParameters[i]); + } + } + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + if (conn.State == ConnectionState.Open) + conn.Close(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters,out DataTable dt, out string errorMessage) + { + string connectionString = ConnectionString_MES; + errorMessage=""; + bool result = false; + errorMessage = ""; + //ds = new DataSet(); + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage) + { + string connectionString = ConnectionString_MES; + errorMessage = ""; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteDataset(string sql, out DataSet ds) + { + string errorMessage; + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteDataTable(string sql, out DataTable dt) + { + //public static bool ExecuteDataTable(string sql, string connectionString, out DataTable dt, out string errorMessage) + string errorMessage; + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static DataTable ExecuteSQL(string sql, ref SqlParameter[] sqlParameters, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + DataTable dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter(sql, conn)) + { + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + dsCommand.Fill(dt); + } + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteSelectMesWork\r\n" + sql + "\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return dt; + } + + public static bool ExecuteSQL(string sql, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用) + /// + /// 存储过程名称 + /// 存储过程参数数组 + /// 增加数据的数据表 + /// + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, DataTable dt, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + // if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.InsertCommand = new SqlCommand(procedureName, conn); + dsCommand.InsertCommand.CommandType = CommandType.StoredProcedure; + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]); + } + if (dt == null) return false; + dt.AcceptChanges(); + for (int i = 0; i < dt.Rows.Count; i++) + { + dt.Rows[i].SetAdded(); + } + dsCommand.Update(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用) + /// + /// + /// + /// + public static bool ExecuteStoredProcedure(string procedureName, out DataTable dt, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// + /// + /// + /// + /// + /// + public static bool ExecuteSQL(string sql, ref SqlParameter[] sqlParameters, DataTable dt, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + + + try + { + // if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.InsertCommand = new SqlCommand(sql, conn); + + for (int i = 0; i < sqlParameters.Length; i++) + { + sqlParameters[i].IsNullable = true; + dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]); + } + if (dt == null) return false; + dt.AcceptChanges(); + for (int i = 0; i < dt.Rows.Count; i++) + { + dt.Rows[i].SetAdded(); + } + dsCommand.Update(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + //ApplicationConfig.ConnectionStringPIS_NEW_Value = "0"; + //TestConnection(); + //errorMessage = e.ToString(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteSQL\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteNonQuery_newID(string sql, out long newID) + { + sql += ";select @@identity"; + string connectionString; + connectionString = ConnectionString_MES; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + conn.Open(); + newID = Convert.ToInt64(cmd.ExecuteScalar()); + } + return true; + } + catch (Exception e) + { + newID = 0; + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\n ExecuteNonQuery_newID\r\n�洢���̣�\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + return false; + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + } + + public static bool ExecuteOutNum(string sql, out int count) + { + string connectionString; + connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + count = 0; + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + count = Convert.ToInt32(cmd.ExecuteScalar().ToString()); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + } + + +} diff --git a/Interface_WebAPI/SlMesDbIterface/SQLHelper/JsonHelper.cs b/Interface_WebAPI/SlMesDbIterface/SQLHelper/JsonHelper.cs new file mode 100644 index 0000000..0e6aa68 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/SQLHelper/JsonHelper.cs @@ -0,0 +1,333 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Data; +using System.Runtime.Serialization.Json; +using System.Web.Script.Serialization; + +public class JsonHelper +{ + #region 序列化和反序列化 + // 序列化 + public static string JsonSerializer(T t) + { + // 使用 DataContractJsonSerializer 将 T 对象序列化为内存流。 + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T)); + MemoryStream ms = new MemoryStream(); + // 使用 WriteObject 方法将 JSON 数据写入到流中。 + jsonSerializer.WriteObject(ms, t); + // 流转字符串 + string jsonString = Encoding.UTF8.GetString(ms.ToArray()); + ms.Close(); + //替换Json的Date字符串 + string p = @"\\/Date\((\d+)\+\d+\)\\/"; + MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString); + Regex reg = new Regex(p); + jsonString = reg.Replace(jsonString, matchEvaluator); + return jsonString; + } + public static T JsonDeserialize(string jsonString) + { + //将"yyyy-MM-dd HH:mm:ss"格式的字符串转为"\/Date(1294499956278+0800)\/"格式 + string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}"; + MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate); + Regex reg = new Regex(p); + jsonString = reg.Replace(jsonString, matchEvaluator); + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T)); + // 字符串转流 + MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)); + // 通过使用 DataContractJsonSerializer 的 ReadObject 方法,将 JSON 编码数据反序列化为T + T obj = (T)jsonSerializer.ReadObject(ms); + return obj; + } + public static string ConvertJsonDateToDateString(Match match) + { + string result = string.Empty; + DateTime dateTime = new DateTime(1970, 1, 1); + dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value)); + dateTime = dateTime.ToLocalTime(); + result = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); + return result; + } + private static string ConvertDateStringToJsonDate(Match m) + { + string result = string.Empty; + DateTime dt = DateTime.Parse(m.Groups[0].Value); + dt = dt.ToUniversalTime(); + TimeSpan ts = dt - DateTime.Parse("1970-01-01"); + result = string.Format("\\/Date({0}+0800)\\/", ts.TotalMilliseconds); + return result; + } + #endregion + + // 对象转换为Json + public static string ObjectToJson(object obj) + { + JavaScriptSerializer js = new JavaScriptSerializer(); + js.MaxJsonLength = Int32.MaxValue; // 定义JavaScriptSerializer接受字符串的最大长度 hdk 20180524 + try + { + return js.Serialize(obj); + } + catch (Exception exception) + { + + throw new Exception(exception.Message); + } + } + // 数据表转化为集合 + public static List> DataTableToList(DataTable dt) + { + List> list = new List>(); + foreach (DataRow dataRow in dt.Rows) + { + Dictionary dic = new Dictionary(); + + + foreach (DataColumn dc in dt.Columns) + { + if (dataRow[dc.ColumnName].GetType() == typeof(DateTime)) + { + string str = Convert.ToDateTime(dataRow[dc.ColumnName]).ToString("yyyy-MM-dd HH:mm:ss"); + dic.Add(dc.ColumnName, str); + } + else if + (dataRow[dc.ColumnName].GetType() == typeof(byte[])) + { + string str = Convert.ToBase64String((byte[])dataRow[dc.ColumnName]); + dic.Add(dc.ColumnName, str); + } + else + { + dic.Add(dc.ColumnName, dataRow[dc.ColumnName]); + } + + //Type type1 = dt.Rows[0]["产品图片"].GetType(); + //Type type2 = typeof(byte[]); + + } + list.Add(dic); + } + return list; + } + /// + /// 表转换为Json + /// + /// + /// + public static string DataTableToJson(DataTable dt) + { + return ObjectToJson(DataTableToList(dt)); + } + /// + /// 将DataTable中的数据转换成JSON格式 + /// + /// 数据源DataTable + /// 是否输出数据总条数 + /// JSON中显示的数据总条数 + /// + public static string CreateJsonParameters(DataTable dt, bool displayCount, int totalcount) + { + StringBuilder JsonString = new StringBuilder(); + //Exception Handling + + if (dt != null) + { + JsonString.Append("{ "); + JsonString.Append("\"rows\":[ "); + for (int i = 0; i < dt.Rows.Count; i++) + { + JsonString.Append("{ "); + for (int j = 0; j < dt.Columns.Count; j++) + { + if (j < dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower() + ","); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString() + ","); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + } + } + else if (j == dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower()); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString()); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + } + } + } + /*end Of String*/ + if (i == dt.Rows.Count - 1) + { + JsonString.Append("} "); + } + else + { + JsonString.Append("}, "); + } + } + JsonString.Append("]"); + + if (displayCount) + { + JsonString.Append(","); + + JsonString.Append("\"total\":"); + JsonString.Append(totalcount); + } + + JsonString.Append("}"); + return JsonString.ToString().Replace("\n", ""); + } + else + { + return null; + } + } + public static string CreateJsonParameters(DataTable dt) + { + StringBuilder JsonString = new StringBuilder(); + //Exception Handling + + if (dt != null) + { + JsonString.Append("{ "); + JsonString.Append("\"rows\":[ "); + for (int i = 0; i < dt.Rows.Count; i++) + { + JsonString.Append("{ "); + for (int j = 0; j < dt.Columns.Count; j++) + { + if (j < dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower() + ","); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString() + ","); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + } + } + else if (j == dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower()); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString()); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + } + } + } + /*end Of String*/ + if (i == dt.Rows.Count - 1) + { + JsonString.Append("} "); + } + else + { + JsonString.Append("}, "); + } + } + JsonString.Append("]"); + + JsonString.Append("}"); + return JsonString.ToString().Replace("\n", ""); + } + else + { + return null; + } + } + StringBuilder result = new StringBuilder(); + StringBuilder sb = new StringBuilder(); + /// + /// 根据DataTable生成EasyUI Tree Json树结构 + /// + /// 数据源 + /// ID列 + /// Text列 + /// 节点Url + /// 关系字段 + /// 父ID + public string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId) + { + result.Append(sb.ToString()); + sb.Clear(); + if (tabel.Rows.Count > 0) + { + sb.Append("["); + string filer = string.Format("{0}='{1}'", rela, pId); + DataRow[] rows = tabel.Select(filer); + if (rows.Length > 0) + { + foreach (DataRow row in rows) + { + sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\",\"state\":\"open\""); + if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0) + { + sb.Append(",\"children\":"); + GetTreeJsonByTable(tabel, idCol, txtCol, url, rela, row[idCol]); + result.Append(sb.ToString()); + sb.Clear(); + } + result.Append(sb.ToString()); + sb.Clear(); + sb.Append("},"); + } + sb = sb.Remove(sb.Length - 1, 1); + } + sb.Append("]"); + result.Append(sb.ToString()); + sb.Clear(); + } + return result.ToString(); + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/AGV_BusinessLogic.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/AGV_BusinessLogic.cs new file mode 100644 index 0000000..d314ecd --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/AGV_BusinessLogic.cs @@ -0,0 +1,428 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Configuration; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using ExternalDataSync; +using MesServerWork; +using MisDataSaveDate; +using System.Net.Http; +using System.Web.Http; +using MisDataSaveDate.MOM; +using System.Data.SqlClient; +using static MisDataSaveDate.Helper.ApiLogHelper; +using MisDataSaveDate.Helper; +using WebApi; +using System.Security.Policy; +using System.Data; +using MisDataFunDll; +using System.Reflection.Emit; + +namespace MisDataSaveDate +{ + /// + /// AGV业务处理类 + /// + public class AGV_BusinessLogic + { + static string agvBaseUrl = ConfigurationManager.AppSettings["AGV_BaseUrl"]; + + /// + /// 处理AGV进入请求业务逻辑 + /// + /// 接口URL + /// AGV请求数据 + /// 处理结果 + public static string ProcessAGVEnterRequest(string url, [FromBody] JObject jobj) + { + var result = new AGV_Response(); + result.code = "0"; + result.message = ""; + result.reqCode = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = "1"; + result.message = "参数格式不正确!"; + result.reqCode = ""; + string retString1 = JsonConvert.SerializeObject(result); + SaveMesLog("AGV进入请求", "参数格式不正确!", MesLogType.ERROR); + MyLog4Net.MyLogHelper.Info("AGV请求进入接口res:", retString1); + return retString1; + } + + string str = jobj.ToString(); + //存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + // 解析AGV请求内容 + AGV_EnterRequest enterRequest = JsonConvert.DeserializeObject(str); + + // 必填字段校验 + if (string.IsNullOrWhiteSpace(enterRequest.reqCode)) + { + throw new Exception("请求编号(reqCode)不能为空"); + } + + if (string.IsNullOrWhiteSpace(enterRequest.reqTime)) + { + throw new Exception("请求时间戳(reqTime)不能为空"); + } + + if (string.IsNullOrWhiteSpace(enterRequest.currentPositionCode)) + { + throw new Exception("当前位置编号(currentPositionCode)不能为空"); + } + + if (string.IsNullOrWhiteSpace(enterRequest.method)) + { + throw new Exception("方法名(method)不能为空"); + } + + if (string.IsNullOrWhiteSpace(enterRequest.robotCode)) + { + throw new Exception("AGV编号(robotCode)不能为空"); + } + + if (string.IsNullOrWhiteSpace(enterRequest.taskCode)) + { + throw new Exception("任务编号(taskCode)不能为空"); + } + + string method = enterRequest.method.Trim().ToLower(); + if (method != "apply" && method != "release" && method != "lower" && method != "raise") + { + throw new Exception($"不支持的method:{enterRequest.method}"); + } + + //enterRequest.currentPositionCode = RemoveTrailingZero(enterRequest.currentPositionCode); + + // 调用存储过程保存AGV请求数据 + var param = new SqlParameter[] { + new SqlParameter("@reqCode", enterRequest.reqCode ?? ""), + new SqlParameter("@reqTime", enterRequest.reqTime ?? ""), + new SqlParameter("@cooX", enterRequest.cooX ?? ""), + new SqlParameter("@cooY", enterRequest.cooY ?? ""), + new SqlParameter("@currentPositionCode", enterRequest.currentPositionCode ?? ""), + new SqlParameter("@data", ""),// enterRequest.data ?? + new SqlParameter("@mapCode", enterRequest.mapCode ?? ""), + new SqlParameter("@mapDataCode", enterRequest.mapDataCode ?? ""), + new SqlParameter("@stgBinCode", enterRequest.stgBinCode ?? ""), + new SqlParameter("@method", method), + new SqlParameter("@podCode", enterRequest.podCode ?? ""), + new SqlParameter("@podDir", enterRequest.podDir ?? ""), + new SqlParameter("@materialLot", enterRequest.materialLot ?? ""), + new SqlParameter("@robotCode", enterRequest.robotCode ?? ""), + new SqlParameter("@taskCode", enterRequest.taskCode ?? ""), + new SqlParameter("@wbCode", enterRequest.wbCode ?? ""), + new SqlParameter("@ctnrCode", enterRequest.ctnrCode ?? ""), + new SqlParameter("@ctnrType", enterRequest.ctnrType ?? ""), + new SqlParameter("@roadWayCode", enterRequest.roadWayCode ?? ""), + new SqlParameter("@seq", enterRequest.seq ?? ""), + new SqlParameter("@eqpCode", enterRequest.eqpCode ?? "") + }; + + // 这里定义AGV返回的位置 - 从currentPositionCode获取并去掉尾部_1后缀 + string OpCode = ""; + try + { + // 从请求的currentPositionCode字段获取位置码 + string currentPositionCode = enterRequest.currentPositionCode?.ToString() ?? ""; + if (!string.IsNullOrEmpty(currentPositionCode)) + { + // 去掉尾部的_1后缀,保留前面的库位号 + int lastUnderscoreIndex = currentPositionCode.LastIndexOf('_'); + if (lastUnderscoreIndex > 0) + { + OpCode = currentPositionCode.Substring(0, lastUnderscoreIndex); + } + else + { + // 如果没有下划线,直接使用原值 + OpCode = currentPositionCode; + } + } + + // 如果从currentPositionCode获取不到,使用wbCode作为备用 + if (string.IsNullOrEmpty(OpCode)) + { + OpCode = enterRequest.wbCode?.ToString() ?? ""; + } + } + catch (Exception ex) + { + // 解析失败时使用wbCode作为备用 + OpCode = enterRequest.wbCode?.ToString() ?? ""; + SaveMesLog("AGV进入请求", $"解析currentPositionCode失败,使用wbCode作为备用:{ex.Message}", MesLogType.WARNING); + } + + // 跟新Moby表 AGV进入离开、下降举升状态 + MisDataFun.Location_MIS_MOBY_Insert(OpCode, method, "1"); + + // 执行存储过程 + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("AGV_光栅请求记录_增加", ref param, out errorMessage); + + switch (method) + { + case "apply": + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "inReq", enterRequest.reqCode); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "inTask", enterRequest.taskCode); + MisDataFun.Rrunning_AGV_Arrive(OpCode); // 磨合AGV到达 + MIS_BASE.WritePLC(301, OpCode, true); // 请求进入 + SaveMesLog(OpCode, $"AGV请求进入成功:工位{OpCode}", MesLogType.INFO); + break; + case "release": // 离开在收到后反馈回去 发给PLC + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "outReq", enterRequest.reqCode); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "outTask", enterRequest.taskCode); + MisDataFun.Rrunning_AGV_Leave(OpCode); // 磨合AGV离开 + // 读取一下上一个请求进入的工件编号~~~ 然后传过去 找对应的 + //bool agvOutResult = PassAgvInOut(OpCode, "", "release"); // 通知AGV可以离开 + //if (!agvOutResult) + //{ + // errorMessage = $"AGV离开通知失败:工位{OpCode}"; + // SaveMesLog("AGV进入请求", errorMessage, "error"); + //} + SaveMesLog(OpCode, $"AGV离开通知成功:工位{OpCode}", MesLogType.INFO); + MIS_BASE.WritePLC(301, OpCode, false); // 请求进入 + // AGV已离开 - 通知PLC + MIS_BASE.WritePLC(303, OpCode, true); + MIS_BASE.WritePLC(302, OpCode, false); // 托盘到位 器具放置完毕 请求扫描器具码 + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "AllowAGVLeave", "1"); + break; + case "lower": + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "lowerReq", enterRequest.reqCode); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "lowerTask", enterRequest.taskCode); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "当前状态", "AGV请求下降"); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "备注", $"lowerReq={enterRequest.reqCode};lowerTask={enterRequest.taskCode}"); + MIS_BASE.WritePLC(500, OpCode, true); // AGV请求下降 + SaveMesLog(OpCode, $"AGV请求下降成功:工位{OpCode}", MesLogType.INFO); + break; + case "raise": + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "raiseReq", enterRequest.reqCode); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "raiseTask", enterRequest.taskCode); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "当前状态", "AGV请求举升"); + MisDataFun.Location_MIS_MOBY_Insert(OpCode, "备注", $"raiseReq={enterRequest.reqCode};raiseTask={enterRequest.taskCode}"); + MIS_BASE.WritePLC(501, OpCode, true); // AGV请求举升 + SaveMesLog(OpCode, $"AGV请求举升成功:工位{OpCode}", MesLogType.INFO); + break; + default: + break; + } + + + if (!string.IsNullOrEmpty(errorMessage)) + { + result.code = "500"; + result.message = "AGV请求处理失败"; + result.reqCode = enterRequest.reqCode; + SaveMesLog("AGV进入请求", errorMessage, MesLogType.ERROR); + } + else + { + result.code = "0"; + result.message = ""; + result.reqCode = enterRequest.reqCode; + } + } + catch (Exception err) + { + // 记录错误日志 + SaveMesLog("AGV进入请求", err.Message, MesLogType.ERROR); + + result.code = "1"; + result.message = err.Message; + + // 尝试从请求中获取reqCode + try + { + AGV_EnterRequest tempRequest = JsonConvert.DeserializeObject(str); + result.reqCode = tempRequest?.reqCode ?? ""; + } + catch + { + result.reqCode = ""; + } + } + + string retString = JsonConvert.SerializeObject(result); + // 存储响应日志 + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("AGV请求进入接口res:", retString); + return retString; + } + + public static string RemoveTrailingZero(string input) + { + if (input != null && input.Contains("-0") && input.Length >= 3) + { + int dashIndex = input.LastIndexOf("-0"); + if (dashIndex > 0 && dashIndex == input.Length - 3) // 确保是最后的-0x格式 + { + return input.Remove(dashIndex + 1, 1); // 去掉"-0"中的0 + } + } + return input; + } + + /// + /// 发送AGV任务继续执行请求(允许进入、离开、下降或举升) + /// + /// 工位号 + /// 工件编号 + /// 任务类型 + /// 操作是否成功 + public static bool PassAgvInOut(string opName, string engineID, string type) + { + try + { + // 其实没有用 engineID 这玩意正常本工位获取不到 + + // 调用存储过程获取AGV任务数据 + var param = new SqlParameter[] { + new SqlParameter("@opName", opName), + new SqlParameter("@engineID", engineID), + new SqlParameter("@type", type) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("AGV_允许进入离开_查询", ref param, out DataTable dtResult, out string errMessage); + + if (dtResult == null || dtResult.Rows.Count == 0) + { + SaveMesLog(opName, $"获取AGV任务数据失败:工位号={opName}, 工件编号={engineID}, 任务类型={type}, 错误信息={errMessage}", MesLogType.ERROR); + return false; + } + + // 从数据库获取请求编号和任务号 + string reqCode = dtResult.Rows[0]["reqCode"].ToString(); + string taskCode = dtResult.Rows[0]["taskCode"].ToString(); + + // 构造AGV反馈请求对象 + AGV_FeedbackRequest agvFeedbackRequest = new AGV_FeedbackRequest() + { + reqCode = reqCode, + taskCode = taskCode + }; + + // 获取AGV接口地址并发送请求 + string interfaceUrl = agvBaseUrl.TrimEnd('/') + "/rcms/services/rest/hikRpcService/continueTask"; + string jsonStr = JsonConvert.SerializeObject(agvFeedbackRequest); + + //存储请求日志 + SaveLog_Interface_Request(interfaceUrl, 1, jsonStr, out int AID); + + string resultStr = ""; + try + { + resultStr = Post.Post_Auto(interfaceUrl, jsonStr); + } + catch (Exception httpEx) + { + SaveMesLog(opName, $"AGV接口HTTP请求异常:工位号={opName}, 工件编号={engineID}, 任务类型={type}, 异常信息={httpEx.Message}", MesLogType.ERROR); + // 存储响应日志 + SaveLog_Interface_Response($"HTTP请求异常:{httpEx.Message}", AID); + return false; + } + + // 存储响应日志 + SaveLog_Interface_Response(resultStr, AID); + + // 解析响应结果 + if (string.IsNullOrWhiteSpace(resultStr)) + { + SaveMesLog(opName, "AGV接口返回空响应", MesLogType.ERROR); + return false; + } + + // 检查是否为Post.Post_Auto返回的错误格式 + try + { + JObject tempResult = JsonConvert.DeserializeObject(resultStr); + if (tempResult != null && tempResult["code"] != null && tempResult["code"].ToString() == "500") + { + string errorMsg = tempResult["message"]?.ToString() ?? "HTTP请求异常"; + SaveMesLog(opName, $"AGV接口HTTP异常:工位号={opName}, 工件编号={engineID}, 任务类型={type}, 错误信息={errorMsg}", MesLogType.ERROR); + return false; + } + } + catch + { + // 如果不是标准JSON格式,继续后续处理 + } + + AGV_Response result = JsonConvert.DeserializeObject(resultStr); + if (result == null) + { + SaveMesLog(opName, "AGV接口返回数据格式错误", MesLogType.ERROR); + return false; + } + + // 检查AGV返回码 + string code = result.code?.ToString(); + if (code != "0") + { + string message = result.message?.ToString() ?? "未知错误"; + SaveMesLog(opName, $"允许AGV光栅请求失败:工位号={opName}, 工件编号={engineID}, 任务类型={type}, code={code}, message={message}", MesLogType.ERROR); + return false; + } + + // 请求成功后调用存储过程更新送料状态 + var updateParam = new SqlParameter[] { + new SqlParameter("@opName", opName), + new SqlParameter("@engineID", engineID), + new SqlParameter("@reqCode", reqCode), + new SqlParameter("@taskCode", taskCode) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("AGV_光栅请求记录_允许", ref updateParam, out string updateErrMessage); + + if (!string.IsNullOrEmpty(updateErrMessage)) + { + SaveMesLog(opName, $"允许AGV光栅请求失败:工位号={opName}, 工件编号={engineID}, 任务类型={type}, 异常信息={updateErrMessage}", MesLogType.ERROR); + return false; + } + + + // 根据任务类型进行后续操作 + if (type == "apply") + { + // AGV已进入 + MisDataFun.Location_MIS_MOBY_Insert(opName, "AllowAGVEnter", "1"); + } + else if (type == "release") + { + // AGV已离开 - 通知PLC + MIS_BASE.WritePLC(301, opName, false); // 请求进入 + MIS_BASE.WritePLC(303, opName, true); + MisDataFun.Location_MIS_MOBY_Insert(opName, "AllowAGVLeave", "1"); + } + else if (type == "lower") + { + // AGV允许下降 + MIS_BASE.WritePLC(500, opName, false); // AGV请求下降 + MisDataFun.Location_MIS_MOBY_Insert(opName, "AllowAGVLower", "1"); + MisDataFun.Location_MIS_MOBY_Insert(opName, "当前状态", "允许AGV下降"); + } + else if (type == "raise") + { + // AGV允许举升 + MIS_BASE.WritePLC(501, opName, false); // AGV请求举升 + MisDataFun.Location_MIS_MOBY_Insert(opName, "AllowAGVRaise", "1"); + MisDataFun.Location_MIS_MOBY_Insert(opName, "当前状态", "允许AGV举升"); + } + + SaveMesLog(opName, $"允许AGV光栅请求成功:工件编号={engineID}, 请求编号={reqCode}, 任务号={taskCode}, 工位号={opName}, 任务类型={type}", MesLogType.INFO); + return true; + } + catch (Exception ex) + { + SaveMesLog(opName, $"允许AGV光栅请求失败:工位号={opName}, 工件编号={engineID}, 任务类型={type}, 异常信息={ex.Message}", MesLogType.ERROR); + return false; + } + } + } +} + diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/AGV_Models.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/AGV_Models.cs new file mode 100644 index 0000000..6ee9939 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/AGV_Models.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace MisDataSaveDate +{ + /// + /// AGV进入请求实体类 + /// + public class AGV_EnterRequest + { + /// + /// 请求编号,每个请求都要一个唯一编号,同一个请求重复提交,使用同一编号 + /// + public string reqCode { get; set; } + + /// + /// 请求时间戳,格式: "yyyy-MM-dd HH:mm:ss" + /// + public string reqTime { get; set; } + + /// + /// 地码 X 坐标(mm):任务完成时有值 + /// + public string cooX { get; set; } + + /// + /// 地码 Y 坐标(mm):任务完成时有值 + /// + public string cooY { get; set; } + + /// + /// 当前位置编号 + /// + public string currentPositionCode { get; set; } + + /// + /// 自定义字段,不超过2000个字符 + /// + public object data { get; set; } + + /// + /// 地图编号 + /// + public string mapCode { get; set; } + + /// + /// 地码编号:任务完成时有值 + /// + public string mapDataCode { get; set; } + + /// + /// 仓位编号:叉车与CTU任务时有值 + /// + public string stgBinCode { get; set; } + + /// + /// 方法名, apply: 申请进入;release:申请离开 + /// + public string method { get; set; } + + /// + /// 货架编号:背货架时有值 + /// + public string podCode { get; set; } + + /// + /// "180","0","90","-90" 分别对应地图的"左","右","上","下":任务完成时有值 + /// + public string podDir { get; set; } + + /// + /// 物料编号 + /// + public string materialLot { get; set; } + + /// + /// AGV编号(同 agvCode) + /// + public string robotCode { get; set; } + + /// + /// 当前任务单号 + /// + public string taskCode { get; set; } + + /// + /// 工作位,与RCS-2000端配置的位置名称一致。任务完成时有值,与生成任务单接口中的wbCode一致 + /// + public string wbCode { get; set; } + + /// + /// 容器编号 + /// + public string ctnrCode { get; set; } + + /// + /// 容器类型 + /// + public string ctnrType { get; set; } + + /// + /// 巷道编号 + /// + public string roadWayCode { get; set; } + + /// + /// 巷道内顺序号,巷道尾是0,到巷道头依次递增1 + /// + public string seq { get; set; } + + /// + /// 设备编号,如梳齿式工作站、输送线等,一般使用于CTU场景。系统根据仓位定位到关联的设备编号 + /// + public string eqpCode { get; set; } + } + + /// + /// AGV请求反馈实体类 + /// + public class AGV_FeedbackRequest + { + /// + /// 请求编号 + /// + public string reqCode { get; set; } + + /// + /// 任务单号 + /// + public string taskCode { get; set; } + } + + /// + /// AGV接口通用响应类 + /// + public class AGV_Response + { + /// + /// 返回码 "0"表示成功 + /// + public string code { get; set; } + + /// + /// 返回消息 + /// + public string message { get; set; } + + /// + /// 请求编号 + /// + public string reqCode { get; set; } + + public AGV_Response() + { + code = "0"; + message = "成功"; + reqCode = ""; + } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/ZZAGV_BusinessLogic.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/ZZAGV_BusinessLogic.cs new file mode 100644 index 0000000..498b08d --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/ZZAGV_BusinessLogic.cs @@ -0,0 +1,200 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Configuration; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using MisDataSaveDate; +using System.Web.Http; +using static MisDataSaveDate.Helper.ApiLogHelper; +using MisDataSaveDate.Helper; + +namespace MisDataSaveDate +{ + /// + /// 西开 AGV 业务处理类 + /// 处理 AGV -> MES 的接收请求 + /// + public class ZZAGV_BusinessLogic + { + /// + /// 处理状态更新请求(到达/离开) + /// + /// 接口URL + /// 请求数据 + /// 处理结果 JSON 字符串 + public static string ProcessStatusUpdate(string url, [FromBody] JObject jobj) + { + var result = ZZAGV_Response.Success(); + string str = jobj?.ToString() ?? ""; + + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + if (jobj == null) + { + throw new Exception("请求参数不能为空"); + } + + ZZAGV_StatusUpdateRequest request = JsonConvert.DeserializeObject(str); + + // 参数校验 + if (string.IsNullOrWhiteSpace(request.position)) + { + throw new Exception("工位编号(position)不能为空"); + } + + string typeDesc = request.type == 1 ? "到达" : (request.type == 2 ? "离开" : "未知"); + SaveMesLog("ZZAGV_StatusUpdate", $"AGV状态更新:工位={request.position}, 类型={typeDesc}, AGV={request.agvid}, 物料={request.materialCode}", MesLogType.INFO); + + // TODO: 后续业务逻辑在此添加 + + } + catch (Exception ex) + { + result = ZZAGV_Response.Fail(1, ex.Message); + SaveMesLog("ZZAGV_StatusUpdate", $"处理异常:{ex.Message}", MesLogType.ERROR); + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + return retString; + } + + /// + /// 处理动作完成请求(举升/下降) + /// + /// 接口URL + /// 请求数据 + /// 处理结果 JSON 字符串 + public static string ProcessActionComplete(string url, [FromBody] JObject jobj) + { + var result = ZZAGV_Response.Success(); + string str = jobj?.ToString() ?? ""; + + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + if (jobj == null) + { + throw new Exception("请求参数不能为空"); + } + + ZZAGV_ActionCompleteRequest request = JsonConvert.DeserializeObject(str); + + // 参数校验 + if (string.IsNullOrWhiteSpace(request.position)) + { + throw new Exception("工位编号(position)不能为空"); + } + + string typeDesc = request.type == 1 ? "举升完成" : (request.type == 2 ? "下降完成" : "未知"); + SaveMesLog("ZZAGV_ActionComplete", $"AGV动作完成:工位={request.position}, 类型={typeDesc}", MesLogType.INFO); + + // TODO: 后续业务逻辑在此添加 + + } + catch (Exception ex) + { + result = ZZAGV_Response.Fail(1, ex.Message); + SaveMesLog("ZZAGV_ActionComplete", $"处理异常:{ex.Message}", MesLogType.ERROR); + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + return retString; + } + + /// + /// 处理故障/报警推送请求 + /// + /// 接口URL + /// 请求数据 + /// 处理结果 JSON 字符串 + public static string ProcessAlarmPush(string url, [FromBody] JObject jobj) + { + var result = ZZAGV_Response.Success(); + string str = jobj?.ToString() ?? ""; + + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + if (jobj == null) + { + throw new Exception("请求参数不能为空"); + } + + ZZAGV_AlarmPushRequest request = JsonConvert.DeserializeObject(str); + + string typeDesc = request.type == 1 ? "AGV故障" : (request.type == 2 ? "区域故障" : "未知"); + SaveMesLog("ZZAGV_AlarmPush", $"AGV故障推送:类型={typeDesc}, AGV={request.agvNo}, 故障码={request.errorCode}, 信息={request.errorMsg}", MesLogType.WARNING); + + // TODO: 后续业务逻辑在此添加 + + } + catch (Exception ex) + { + result = ZZAGV_Response.Fail(1, ex.Message); + SaveMesLog("ZZAGV_AlarmPush", $"处理异常:{ex.Message}", MesLogType.ERROR); + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + return retString; + } + + /// + /// 处理任务执行结果请求 + /// + /// 接口URL + /// 请求数据 + /// 处理结果 JSON 字符串 + public static string ProcessTaskResult(string url, [FromBody] JObject jobj) + { + var result = ZZAGV_Response.Success(); + string str = jobj?.ToString() ?? ""; + + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + if (jobj == null) + { + throw new Exception("请求参数不能为空"); + } + + ZZAGV_TaskResultRequest request = JsonConvert.DeserializeObject(str); + + // 参数校验 + if (string.IsNullOrWhiteSpace(request.requestTaskId)) + { + throw new Exception("任务ID(requestTaskId)不能为空"); + } + + string statusDesc = request.status == "success" ? "成功" : "失败"; + SaveMesLog("ZZAGV_TaskResult", $"AGV任务结果:任务ID={request.requestTaskId}, 状态={statusDesc}, AGV={request.agvNo}, 消息={request.message}", MesLogType.INFO); + + // TODO: 后续业务逻辑在此添加 + + } + catch (Exception ex) + { + result = ZZAGV_Response.Fail(1, ex.Message); + SaveMesLog("ZZAGV_TaskResult", $"处理异常:{ex.Message}", MesLogType.ERROR); + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + return retString; + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/ZZAGV_Models.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/ZZAGV_Models.cs new file mode 100644 index 0000000..347e37f --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/AGV/ZZAGV_Models.cs @@ -0,0 +1,221 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate +{ + #region AGV -> MES 接收请求模型 + + /// + /// 状态更新请求(到达/离开) + /// AGV 到达或离开工位时通知 MES + /// + public class ZZAGV_StatusUpdateRequest + { + /// + /// 工位编号 + /// + public string position { get; set; } + + /// + /// 类型:1-到达,2-离开 + /// + public int type { get; set; } + + /// + /// 物料编码/产品编码 + /// + public string materialCode { get; set; } + + /// + /// AGV车号 + /// + public string agvid { get; set; } + } + + /// + /// 动作完成请求(举升/下降) + /// AGV 完成托盘举升或下降动作后通知 MES + /// + public class ZZAGV_ActionCompleteRequest + { + /// + /// 工位编号 + /// + public string position { get; set; } + + /// + /// 类型:1-举升完成,2-下降完成 + /// + public int type { get; set; } + } + + /// + /// 故障/报警推送请求 + /// AGV 上报故障或区域故障 + /// + public class ZZAGV_AlarmPushRequest + { + /// + /// AGV车号 + /// + public string agvNo { get; set; } + + /// + /// 故障代码 + /// + public string errorCode { get; set; } + + /// + /// 故障信息 + /// + public string errorMsg { get; set; } + + /// + /// 故障类型:1-AGV故障,2-区域故障 + /// + public int type { get; set; } + } + + /// + /// 任务执行结果请求 + /// AGV 告知 MES 任务是否执行成功 + /// + public class ZZAGV_TaskResultRequest + { + /// + /// 任务唯一ID(与下发任务时的 requestTaskId 对应) + /// + public string requestTaskId { get; set; } + + /// + /// 执行状态:success-成功,fail-失败 + /// + public string status { get; set; } + + /// + /// AGV车号 + /// + public string agvNo { get; set; } + + /// + /// 失败原因(成功时为空) + /// + public string message { get; set; } + } + + #endregion + + #region MES -> AGV 发送请求模型 + + /// + /// 下发任务请求 + /// MES 给 AGV 下发搬运任务 + /// + public class ZZAGV_AddTaskRequest + { + /// + /// 任务唯一ID(由 MES 生成) + /// + public string requestTaskId { get; set; } + + /// + /// 抬货点/取货位置 + /// + public string startPosition { get; set; } + + /// + /// 卸货点/目标位置 + /// + public string endPosition { get; set; } + + /// + /// 产品编码/物料编码 + /// + public string materialCode { get; set; } + } + + /// + /// 放行请求 + /// MES 告知 AGV 可以离开当前位置 + /// + public class ZZAGV_AllowLeaveRequest + { + /// + /// 请求ID + /// + public string requestId { get; set; } + + /// + /// 当前位置编号 + /// + public string position { get; set; } + + /// + /// 放行标志(固定为1) + /// + public int allowLeave { get; set; } = 1; + } + + #endregion + + #region 通用响应模型 + + /// + /// 西开 AGV 接口通用响应 + /// + public class ZZAGV_Response + { + /// + /// 返回码:0-成功,其他-失败 + /// + public int code { get; set; } + + /// + /// 返回描述信息 + /// + public string desc { get; set; } + + /// + /// 是否成功 + /// + public bool success { get; set; } + + public ZZAGV_Response() + { + code = 0; + desc = "成功"; + success = true; + } + + /// + /// 设置成功响应 + /// + public static ZZAGV_Response Success(string desc = "成功") + { + return new ZZAGV_Response + { + code = 0, + desc = desc, + success = true + }; + } + + /// + /// 设置失败响应 + /// + public static ZZAGV_Response Fail(int code, string desc) + { + return new ZZAGV_Response + { + code = code, + desc = desc, + success = false + }; + } + } + + #endregion +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/AGVController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/AGVController.cs new file mode 100644 index 0000000..e2c2be2 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/AGVController.cs @@ -0,0 +1,44 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; +using System.Threading; +using System.Net; +using System.Net.Http.Headers; +using System.IO; +using MisDataSaveDate; + +namespace MisDataSaveDate +{ + /// + /// AGV接口控制器 + /// + public class AGVController : ApiController + { + readonly string headUrl = "agv/"; + + /// + /// AGV请求进入离开、下降举升接口(接收方) + /// 接收AGV的进入、离开、下降、举升请求并存储到数据库 + /// + /// AGV请求数据 + /// 处理结果 + [HttpPost] + [Route("agv/agvReqInOut")] + public HttpResponseMessage agvReqInOut([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AGV_BusinessLogic.ProcessAGVEnterRequest(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CheckDataController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CheckDataController.cs new file mode 100644 index 0000000..46e68b2 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CheckDataController.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using System.Net.Http; +using System.Web.Http; +using ExternalDataSync.MOM; + +namespace ExternalDataSync.WebAPI.Controller +{ + public class CheckDataController : ApiController + { + private readonly string headUrl = "TestPlatform/"; + + [HttpPost] + [Route("TestPlatform/OnlineCheckData")] + public HttpResponseMessage OnlineCheckData([FromBody] JObject jobj) + { + var result = Other.OnlineCheckData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("TestPlatform/OnlineStatusData")] + public HttpResponseMessage OnlineStatusData([FromBody] JObject jobj) + { + var result = Other.OnlineStatusData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("TestPlatform/OnlineDewPointResultData")] + public HttpResponseMessage OnlineDewPointResultData([FromBody] JObject jobj) + { + var result = DewPointDataHandler.OnlineDewPointResultData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("TestPlatform/OnlineDewPointTechnologyData")] + public HttpResponseMessage OnlineDewPointTechnologyData([FromBody] JObject jobj) + { + var result = DewPointDataHandler.OnlineDewPointTechnologyData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("TestPlatform/OnlineDewPointUseData")] + public HttpResponseMessage OnlineDewPointUseData([FromBody] JObject jobj) + { + var result = DewPointDataHandler.OnlineDewPointUseData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("TestPlatform/OnlineDewPointStatusData")] + public HttpResponseMessage OnlineDewPointStatusData([FromBody] JObject jobj) + { + var result = DewPointDataHandler.OnlineDewPointStatusData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + /// + /// 获取位置待测试产品信息 + /// + [HttpPost] + [Route("TestPlatform/GetWaitCheckProductData")] + public HttpResponseMessage GetWaitCheckProductData([FromBody] JObject jobj) + { + var result = Other.GetWaitCheckProductData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj); + return new HttpResponseMessage + { + Content = new StringContent(result, Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CheckImageController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CheckImageController.cs new file mode 100644 index 0000000..1a4be08 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CheckImageController.cs @@ -0,0 +1,270 @@ +using System; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.RegularExpressions; +using System.Web.Http; +using DataLinkMesWork2; + +namespace WebApi +{ + [RoutePrefix("api/checkimage")] + public class CheckImageController : ApiController + { + private readonly string _defaultRoot = @"D:\\XDCheckImages"; + + public class ImageUploadRequest + { + public string ProductCode { get; set; } + public string Remark { get; set; } + public string ImageBase64 { get; set; } + public string FileExt { get; set; } + } + + public class ImageDownloadRequest + { + public string Path { get; set; } + } + + private string GetRootPath() + { + string root = null; + try + { + root = ConfigurationManager.AppSettings["XD_CheckImageRootPath"]; + } + catch + { + } + + if (string.IsNullOrWhiteSpace(root)) + { + root = _defaultRoot; + } + + return root; + } + + private string SanitizeForPath(string input) + { + if (string.IsNullOrEmpty(input)) return string.Empty; + char[] invalid = Path.GetInvalidFileNameChars(); + var value = input.Trim(); + foreach (var c in invalid) + { + value = value.Replace(c.ToString(), string.Empty); + } + value = value.Replace("/", string.Empty).Replace("\\", string.Empty); + return value; + } + + private string GetExtensionFromRequest(ImageUploadRequest request) + { + string ext = ".jpg"; + if (request == null) return ext; + + if (!string.IsNullOrWhiteSpace(request.FileExt)) + { + ext = request.FileExt.Trim(); + if (!ext.StartsWith(".")) + { + ext = "." + ext; + } + return ext; + } + + if (!string.IsNullOrWhiteSpace(request.ImageBase64) && + request.ImageBase64.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) + { + try + { + var match = Regex.Match(request.ImageBase64, "^data:(?[^;]+);base64,", RegexOptions.IgnoreCase); + if (match.Success) + { + var mime = match.Groups["mime"].Value.ToLowerInvariant(); + if (mime == "image/png") return ".png"; + if (mime == "image/gif") return ".gif"; + if (mime == "image/bmp") return ".bmp"; + if (mime == "image/webp") return ".webp"; + if (mime == "image/tiff" || mime == "image/tif") return ".tif"; + if (mime == "image/jpeg" || mime == "image/jpg") return ".jpg"; + } + } + catch + { + } + } + + return ext; + } + + private string GetContentType(string fileName) + { + var extension = Path.GetExtension(fileName).ToLowerInvariant(); + if (extension == ".bmp") return "image/bmp"; + if (extension == ".jpg" || extension == ".jpeg") return "image/jpeg"; + if (extension == ".png") return "image/png"; + if (extension == ".gif") return "image/gif"; + if (extension == ".tiff" || extension == ".tif") return "image/tiff"; + if (extension == ".webp") return "image/webp"; + return "application/octet-stream"; + } + + private bool IsPathSafe(string fullPath) + { + try + { + var basePath = Path.GetFullPath(GetRootPath()); + var requestedPath = Path.GetFullPath(fullPath); + return requestedPath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase); + } + catch + { + return false; + } + } + + [HttpPost] + [Route("upload")] + public IHttpActionResult Upload([FromBody] ImageUploadRequest request) + { + try + { + if (request == null || + string.IsNullOrWhiteSpace(request.ProductCode) || + string.IsNullOrWhiteSpace(request.Remark) || + string.IsNullOrWhiteSpace(request.ImageBase64)) + { + return Ok(new { success = false, message = "产品编号、备注和图片不能为空" }); + } + + string productCode = SanitizeForPath(request.ProductCode); + string remark = SanitizeForPath(request.Remark); + if (string.IsNullOrEmpty(productCode)) + { + return Ok(new { success = false, message = "产品编号无效" }); + } + + string ext = GetExtensionFromRequest(request); + string base64 = request.ImageBase64.Trim(); + int commaIndex = base64.IndexOf(','); + if (base64.StartsWith("data:", StringComparison.OrdinalIgnoreCase) && commaIndex > 0) + { + base64 = base64.Substring(commaIndex + 1); + } + + byte[] bytes; + try + { + bytes = Convert.FromBase64String(base64); + } + catch + { + return Ok(new { success = false, message = "图片数据格式错误" }); + } + + var now = DateTime.Now; + string datePart = now.ToString("yyyyMMdd"); + string timePart = now.ToString("HHmmss"); + + string fileName = string.Format("{0}-{1}-{2}{3}", timePart, productCode, remark, ext); + string relativePath = string.Format("/{0}/{1}", datePart, fileName); + + string root = GetRootPath(); + string directory = Path.Combine(root, datePart); + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + string fullPath = Path.Combine(directory, fileName); + + if (!IsPathSafe(fullPath)) + { + return Ok(new { success = false, message = "目标路径不安全" }); + } + + File.WriteAllBytes(fullPath, bytes); + + string errorMessage; + var sqlParameters = new SqlParameter[4]; + sqlParameters[0] = new SqlParameter("@产品编号", SqlDbType.NVarChar, 500) { Value = (object)request.ProductCode ?? DBNull.Value }; + sqlParameters[1] = new SqlParameter("@备注", SqlDbType.NVarChar, 500) { Value = (object)request.Remark ?? DBNull.Value }; + sqlParameters[2] = new SqlParameter("@图片路径", SqlDbType.NVarChar, 500) { Value = (object)relativePath ?? DBNull.Value }; + sqlParameters[3] = new SqlParameter("@图片名称", SqlDbType.NVarChar, 500) { Value = (object)fileName ?? DBNull.Value }; + + bool dbOk = DataAccess2.ExecuteStoredProcedure("XD_检测图片上传_增加", ref sqlParameters, out errorMessage); + if (!dbOk) + { + return Ok(new { success = false, message = "图片已保存,但写入数据库失败:" + errorMessage }); + } + + return Ok(new + { + success = true, + message = "上传成功", + data = new + { + 产品编号 = request.ProductCode, + 备注 = request.Remark, + 图片路径 = relativePath, + 图片名称 = fileName + } + }); + } + catch (Exception ex) + { + return Ok(new { success = false, message = "服务器错误:" + ex.Message }); + } + } + + [HttpPost] + [Route("download")] + public IHttpActionResult Download([FromBody] ImageDownloadRequest request) + { + try + { + if (request == null || string.IsNullOrWhiteSpace(request.Path)) + { + return Ok(new { success = false, message = "文件路径不能为空" }); + } + + string root = GetRootPath(); + string relative = request.Path.Replace("\\", "/").Trim(); + if (relative.StartsWith("/")) + { + relative = relative.Substring(1); + } + string fullPath = Path.Combine(root, relative.Replace('/', Path.DirectorySeparatorChar)); + + if (!IsPathSafe(fullPath) || !File.Exists(fullPath)) + { + return Ok(new { success = false, message = "文件不存在" }); + } + + var fileInfo = new FileInfo(fullPath); + var contentType = GetContentType(fileInfo.Name); + + var response = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StreamContent(new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read)) + }; + response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline") + { + FileName = fileInfo.Name + }; + + return ResponseMessage(response); + } + catch (Exception ex) + { + return Ok(new { success = false, message = "下载文件失败:" + ex.Message }); + } + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CraftFileController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CraftFileController.cs new file mode 100644 index 0000000..bc955b3 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/CraftFileController.cs @@ -0,0 +1,458 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using System.Net.Http.Headers; +using WinSCP; + +namespace WebApi +{ + [RoutePrefix("api/craftfile")] + public class CraftFileController : ApiController + { + // 本地缓存根目录 + private readonly string _cacheRoot = @"D:\\CraftFilesCache"; + + private readonly string _sftpHost = "10.107.69.5"; + private readonly string _sftpUser = "root"; + private readonly string _sftpPassword = "XKYXmes@123!"; + + public class FileRequestDto + { + // 远程(SFTP)相对路径或绝对路径:如 /root/PLM-MES/.../xxx.pdf + public string RelativePath { get; set; } = ""; + } + + [HttpPost] + [Route("browse")] + public IHttpActionResult Browse([FromBody] FileRequestDto request) + { + try + { + if (request == null || string.IsNullOrWhiteSpace(request.RelativePath)) + return Ok(new { success = false, message = "路径不能为空" }); + + EnsureCacheRoot(); + + var remotePath = NormalizeRemotePath(request.RelativePath); + var localPath = ToLocalPath(remotePath); + + var isFile = Path.HasExtension(remotePath); + + if (isFile) + { + // 确保本地存在 + if (!System.IO.File.Exists(localPath)) + { + var ok = DownloadFileFromSftp(remotePath, localPath, out string err); + if (!ok) return Ok(new { success = false, message = $"下载失败: {err}" }); + } + return GetFilePreviewLocal(localPath, remotePath); + } + else + { + // 目录:优先读取本地,没有则读取远程目录结构 + if (Directory.Exists(localPath)) + { + return GetDirectoryContentsLocal(localPath, remotePath); + } + else + { + return GetDirectoryContentsRemote(remotePath); + } + } + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"服务器错误: {ex.Message}" }); + } + } + + [HttpPost] + [Route("download")] + public IHttpActionResult Download([FromBody] FileRequestDto request) + { + try + { + if (request == null || string.IsNullOrWhiteSpace(request.RelativePath)) + return Ok(new { success = false, message = "文件路径不能为空" }); + + EnsureCacheRoot(); + + var remotePath = NormalizeRemotePath(request.RelativePath); + var localPath = ToLocalPath(remotePath); + + if (!Path.HasExtension(remotePath)) + return Ok(new { success = false, message = "请传入文件路径" }); + + if (!System.IO.File.Exists(localPath)) + { + var ok = DownloadFileFromSftp(remotePath, localPath, out string err); + if (!ok) return Ok(new { success = false, message = $"下载失败: {err}" }); + } + + var fileInfo = new FileInfo(localPath); + var contentType = GetContentType(fileInfo.Name); + var response = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StreamContent(new FileStream(localPath, FileMode.Open, FileAccess.Read, FileShare.Read)) + }; + response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); + response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") + { + FileName = fileInfo.Name + }; + return ResponseMessage(response); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"下载文件失败: {ex.Message}" }); + } + } + + // 新增:浏览器直接预览文件(支持PDF等),支持Range分块 + [HttpGet] + [Route("preview")] + public HttpResponseMessage Preview([FromUri] string path) + { + try + { + if (string.IsNullOrWhiteSpace(path)) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, new { success = false, message = "文件路径不能为空" }); + } + + EnsureCacheRoot(); + var remotePath = NormalizeRemotePath(path); + var localPath = ToLocalPath(remotePath); + + if (!Path.HasExtension(remotePath)) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, new { success = false, message = "请传入文件路径" }); + } + + if (!System.IO.File.Exists(localPath)) + { + var ok = DownloadFileFromSftp(remotePath, localPath, out string err); + if (!ok) + { + return Request.CreateResponse(HttpStatusCode.InternalServerError, new { success = false, message = $"下载失败: {err}" }); + } + } + + var fileInfo = new FileInfo(localPath); + var contentType = GetContentType(fileInfo.Name); + var totalLength = fileInfo.Length; + + var response = new HttpResponseMessage(); + var range = Request.Headers.Range; + + var stream = new FileStream(localPath, FileMode.Open, FileAccess.Read, FileShare.Read); + if (range != null && range.Ranges.Count > 0 && totalLength > 0) + { + // 处理 Range 请求 + var from = range.Ranges.First().From ?? 0; + var to = range.Ranges.First().To ?? (totalLength - 1); + if (to >= totalLength) to = totalLength - 1; + var length = to - from + 1; + stream.Seek(from, SeekOrigin.Begin); + + response.StatusCode = HttpStatusCode.PartialContent; + response.Content = new StreamContent(stream); + response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + response.Content.Headers.ContentLength = length; + response.Content.Headers.ContentRange = new ContentRangeHeaderValue(from, to, totalLength); + response.Headers.AcceptRanges.Add("bytes"); + } + else + { + // 全量流式 + response.StatusCode = HttpStatusCode.OK; + response.Content = new StreamContent(stream); + response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + response.Content.Headers.ContentLength = totalLength; + response.Headers.AcceptRanges.Add("bytes"); + } + + // inline 以支持浏览器内嵌预览 + response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline") + { + FileName = fileInfo.Name + }; + + // CORS 允许跨域及暴露必要头 + if (!response.Headers.Contains("Access-Control-Allow-Origin")) + response.Headers.Add("Access-Control-Allow-Origin", "*"); + if (!response.Headers.Contains("Access-Control-Expose-Headers")) + response.Headers.Add("Access-Control-Expose-Headers", "Accept-Ranges, Content-Range, Content-Length, Content-Type, Content-Disposition"); + + return response; + } + catch (Exception ex) + { + return Request.CreateResponse(HttpStatusCode.InternalServerError, new { success = false, message = $"预览失败: {ex.Message}" }); + } + } + + private IHttpActionResult GetFilePreviewLocal(string localPath, string remotePath) + { + try + { + var fileInfo = new FileInfo(localPath); + var extension = fileInfo.Extension.ToLowerInvariant(); + var previewable = IsPreviewableFile(extension); + var contentType = GetContentType(fileInfo.Name); + + bool tooLarge = fileInfo.Length > 500 * 1024 * 1024; // 500MB限制 + string base64String = null; + string dataUrl = null; + bool canPreview = previewable && !tooLarge; + if (canPreview) + { + var fileBytes = System.IO.File.ReadAllBytes(localPath); + base64String = Convert.ToBase64String(fileBytes); + dataUrl = $"data:{contentType};base64,{base64String}"; + } + + var result = new + { + success = true, + type = "file", + path = remotePath, + name = fileInfo.Name, + size = fileInfo.Length, + extension = fileInfo.Extension, + contentType = contentType, + isPreviewable = canPreview, + base64Data = base64String, + dataUrl = dataUrl, + created = fileInfo.CreationTime, + modified = fileInfo.LastWriteTime, + message = tooLarge ? "文件过大,无法预览,可下载" : null + }; + return Ok(result); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"获取文件预览失败: {ex.Message}" }); + } + } + + private IHttpActionResult GetDirectoryContentsLocal(string localPath, string remotePath) + { + try + { + var items = new List(); + var directories = Directory.GetDirectories(localPath); + foreach (var dir in directories) + { + var dirInfo = new DirectoryInfo(dir); + var subPath = CombineRemotePath(remotePath, dirInfo.Name); + items.Add(new + { + name = dirInfo.Name, + type = "directory", + path = subPath, + created = dirInfo.CreationTime, + modified = dirInfo.LastWriteTime, + isPreviewable = false + }); + } + var files = Directory.GetFiles(localPath); + foreach (var file in files) + { + var fileInfo = new FileInfo(file); + var filePath = CombineRemotePath(remotePath, fileInfo.Name); + var extension = fileInfo.Extension.ToLowerInvariant(); + items.Add(new + { + name = fileInfo.Name, + type = "file", + path = filePath, + size = fileInfo.Length, + extension = fileInfo.Extension, + created = fileInfo.CreationTime, + modified = fileInfo.LastWriteTime, + isPreviewable = IsPreviewableFile(extension), + contentType = GetContentType(fileInfo.Name) + }); + } + var result = new + { + success = true, + type = "directory", + path = remotePath, + items = items.OrderBy(x => ((dynamic)x).type == "directory" ? 0 : 1) + .ThenBy(x => ((dynamic)x).name) + .ToList() + }; + return Ok(result); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"读取目录失败: {ex.Message}" }); + } + } + + private IHttpActionResult GetDirectoryContentsRemote(string remotePath) + { + try + { + using (var session = OpenSftp()) + { + var dir = session.ListDirectory(remotePath); + var items = new List(); + + foreach (var subdir in dir.Files.Where(e => e.IsDirectory && e.Name != "." && e.Name != "..")) + { + var subPath = CombineRemotePath(remotePath, subdir.Name); + items.Add(new + { + name = subdir.Name, + type = "directory", + path = subPath, + created = subdir.LastWriteTime, + modified = subdir.LastWriteTime, + isPreviewable = false + }); + } + + foreach (var file in dir.Files.Where(e => !e.IsDirectory)) + { + var filePath = CombineRemotePath(remotePath, file.Name); + var extension = Path.GetExtension(file.Name).ToLowerInvariant(); + items.Add(new + { + name = file.Name, + type = "file", + path = filePath, + size = file.Length, + extension = Path.GetExtension(file.Name), + created = file.LastWriteTime, + modified = file.LastWriteTime, + isPreviewable = IsPreviewableFile(extension), + contentType = GetContentType(file.Name) + }); + } + + var result = new + { + success = true, + type = "directory", + path = remotePath, + items = items.OrderBy(x => ((dynamic)x).type == "directory" ? 0 : 1) + .ThenBy(x => ((dynamic)x).name) + .ToList() + }; + return Ok(result); + } + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"读取远程目录失败: {ex.Message}" }); + } + } + + private bool DownloadFileFromSftp(string remotePath, string localPath, out string error) + { + error = null; + try + { + var localDir = Path.GetDirectoryName(localPath); + if (!Directory.Exists(localDir)) Directory.CreateDirectory(localDir); + + using (var session = OpenSftp()) + { + var result = session.GetFiles(remotePath, localPath, false); + result.Check(); + } + return true; + } + catch (Exception ex) + { + error = ex.Message; + return false; + } + } + + private Session OpenSftp() + { + var options = new SessionOptions + { + Protocol = Protocol.Sftp, + HostName = _sftpHost, + UserName = _sftpUser, + Password = _sftpPassword, + SshHostKeyPolicy = SshHostKeyPolicy.GiveUpSecurityAndAcceptAny + }; + var session = new Session(); + session.Open(options); + return session; + } + + private void EnsureCacheRoot() + { + if (!Directory.Exists(_cacheRoot)) Directory.CreateDirectory(_cacheRoot); + } + + private string NormalizeRemotePath(string p) + { + if (string.IsNullOrWhiteSpace(p)) return "/"; + var s = p.Trim(); + // 统一使用正斜杠 + s = s.Replace('\\', '/'); + return s; + } + + private string ToLocalPath(string remotePath) + { + // 去掉开头的 '/' + var relative = remotePath.Trim().TrimStart('/'); + var localRelative = relative.Replace('/', Path.DirectorySeparatorChar); + return Path.Combine(_cacheRoot, localRelative); + } + + private string CombineRemotePath(string basePath, string name) + { + if (string.IsNullOrEmpty(basePath) || basePath == "/") return $"/{name}"; + if (basePath.EndsWith("/")) return basePath + name; + return basePath + "/" + name; + } + + private bool IsPreviewableFile(string extension) + { + var previewableExtensions = new[] + { + ".bmp", ".jpg", ".jpeg", ".png", ".gif", ".tiff", ".tif", ".webp", + ".txt", ".json", ".xml", ".csv", ".log", ".md", ".pdf" + }; + return previewableExtensions.Contains(extension); + } + + private string GetContentType(string fileName) + { + var extension = Path.GetExtension(fileName).ToLowerInvariant(); + if (extension == ".bmp") return "image/bmp"; + if (extension == ".jpg" || extension == ".jpeg") return "image/jpeg"; + if (extension == ".png") return "image/png"; + if (extension == ".gif") return "image/gif"; + if (extension == ".tiff" || extension == ".tif") return "image/tiff"; + if (extension == ".webp") return "image/webp"; + if (extension == ".pdf") return "application/pdf"; + if (extension == ".txt") return "text/plain"; + if (extension == ".json") return "application/json"; + if (extension == ".xml") return "application/xml"; + if (extension == ".csv") return "text/csv"; + if (extension == ".md") return "text/markdown"; + if (extension == ".log") return "text/plain"; + if (extension == ".zip") return "application/zip"; + if (extension == ".rar") return "application/x-rar-compressed"; + return "application/octet-stream"; + } + } +} + + diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/IFileController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/IFileController.cs new file mode 100644 index 0000000..6ca5aa5 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/IFileController.cs @@ -0,0 +1,277 @@ +using System.Net.Http; +using System.Net; +using System.Web.Http; +using Newtonsoft.Json.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; + +/////http://127.0.0.1:9981/api/file/browse + +/// +/// +/// +namespace WebApi +{ + /// + /// + /// + [RoutePrefix("api/file")] + public class IFileController : ApiController + { + // 基础路径配置 + private readonly string _basePath = @"D:\CameraImg"; + + /// + /// 请求DTO + /// + public class FileRequestDto + { + public string RelativePath { get; set; } = ""; + } + + /// + /// 浏览文件或文件夹,前端传相对路径,返回文件夹内容或文件流(图片等可预览) + /// + [HttpPost] + [Route("browse")] + public IHttpActionResult BrowsePath([FromBody] FileRequestDto request) + { + try + { + if (request == null) + request = new FileRequestDto(); + + if (string.IsNullOrEmpty(request.RelativePath) || request.RelativePath == "/") + { + request.RelativePath = ""; + } + + string fullPath = Path.Combine(_basePath, request.RelativePath.Replace('/', Path.DirectorySeparatorChar)); + + if (!IsPathSafe(fullPath)) + { + return Ok(new { success = false, message = "无效的路径" }); + } + + if (!Directory.Exists(fullPath) && !System.IO.File.Exists(fullPath)) + { + return Ok(new { success = false, message = "路径不存在" }); + } + + if (System.IO.File.Exists(fullPath)) + { + return GetFilePreview(fullPath, request.RelativePath); + } + + if (Directory.Exists(fullPath)) + { + return GetDirectoryContents(fullPath, request.RelativePath); + } + + return Ok(new { success = false, message = "路径不存在" }); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"服务器错误: {ex.Message}" }); + } + } + + /// + /// 获取文件预览数据(图片/文本base64,前端可直接预览) + /// + private IHttpActionResult GetFilePreview(string fullPath, string relativePath) + { + try + { + var fileInfo = new FileInfo(fullPath); + var extension = fileInfo.Extension.ToLowerInvariant(); + var previewable = IsPreviewableFile(extension); + var contentType = GetContentType(fileInfo.Name); + + bool tooLarge = fileInfo.Length > 10 * 1024 * 1024; // 10MB限制 + string base64String = null; + string dataUrl = null; + bool canPreview = previewable && !tooLarge; + if (canPreview) + { + var fileBytes = System.IO.File.ReadAllBytes(fullPath); + base64String = Convert.ToBase64String(fileBytes); + dataUrl = $"data:{contentType};base64,{base64String}"; + } + + var result = new + { + success = true, + type = "file", + path = relativePath, + name = fileInfo.Name, + size = fileInfo.Length, + extension = fileInfo.Extension, + contentType = contentType, + isPreviewable = canPreview, + base64Data = base64String, + dataUrl = dataUrl, + created = fileInfo.CreationTime, + modified = fileInfo.LastWriteTime, + message = tooLarge ? "文件过大,无法预览,可下载" : null + }; + return Ok(result); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"获取文件预览失败: {ex.Message}" }); + } + } + + /// + /// 判断文件是否可预览 + /// + private bool IsPreviewableFile(string extension) + { + var previewableExtensions = new[] + { + ".bmp", ".jpg", ".jpeg", ".png", ".gif", ".tiff", ".tif", ".webp", + ".txt", ".json", ".xml", ".csv", ".log", ".md" + }; + return previewableExtensions.Contains(extension); + } + + /// + /// 安全检查:确保路径在基础目录内,防止路径遍历攻击 + /// + private bool IsPathSafe(string fullPath) + { + try + { + var basePath = Path.GetFullPath(_basePath); + var requestedPath = Path.GetFullPath(fullPath); + return requestedPath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase); + } + catch + { + return false; + } + } + + /// + /// 根据文件扩展名获取MIME类型(兼容C# 7.3) + /// + private string GetContentType(string fileName) + { + var extension = Path.GetExtension(fileName).ToLowerInvariant(); + if (extension == ".bmp") return "image/bmp"; + if (extension == ".jpg" || extension == ".jpeg") return "image/jpeg"; + if (extension == ".png") return "image/png"; + if (extension == ".gif") return "image/gif"; + if (extension == ".tiff" || extension == ".tif") return "image/tiff"; + if (extension == ".webp") return "image/webp"; + if (extension == ".pdf") return "application/pdf"; + if (extension == ".txt") return "text/plain"; + if (extension == ".json") return "application/json"; + if (extension == ".xml") return "application/xml"; + if (extension == ".csv") return "text/csv"; + if (extension == ".md") return "text/markdown"; + if (extension == ".log") return "text/plain"; + if (extension == ".zip") return "application/zip"; + if (extension == ".rar") return "application/x-rar-compressed"; + return "application/octet-stream"; + } + + private IHttpActionResult GetDirectoryContents(string fullPath, string relativePath) + { + try + { + var items = new List(); + var directories = Directory.GetDirectories(fullPath); + foreach (var dir in directories) + { + var dirInfo = new DirectoryInfo(dir); + var subPath = string.IsNullOrEmpty(relativePath) + ? dirInfo.Name + : $"{relativePath}/{dirInfo.Name}"; + items.Add(new + { + name = dirInfo.Name, + type = "directory", + path = subPath, + created = dirInfo.CreationTime, + modified = dirInfo.LastWriteTime, + isPreviewable = false + }); + } + var files = Directory.GetFiles(fullPath); + foreach (var file in files) + { + var fileInfo = new FileInfo(file); + var filePath = string.IsNullOrEmpty(relativePath) + ? fileInfo.Name + : $"{relativePath}/{fileInfo.Name}"; + var extension = fileInfo.Extension.ToLowerInvariant(); + items.Add(new + { + name = fileInfo.Name, + type = "file", + path = filePath, + size = fileInfo.Length, + extension = fileInfo.Extension, + created = fileInfo.CreationTime, + modified = fileInfo.LastWriteTime, + isPreviewable = IsPreviewableFile(extension), + contentType = GetContentType(fileInfo.Name) + }); + } + var result = new + { + success = true, + type = "directory", + path = relativePath, + items = items.OrderBy(x => ((dynamic)x).type == "directory" ? 0 : 1) + .ThenBy(x => ((dynamic)x).name) + .ToList() + }; + return Ok(result); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"读取目录失败: {ex.Message}" }); + } + } + + [HttpPost] + [Route("download")] + public IHttpActionResult DownloadFile([FromBody] FileRequestDto request) + { + try + { + if (request == null || string.IsNullOrEmpty(request.RelativePath)) + return Ok(new { success = false, message = "文件路径不能为空" }); + + string fullPath = Path.Combine(_basePath, request.RelativePath.Replace('/', Path.DirectorySeparatorChar)); + if (!IsPathSafe(fullPath) || !System.IO.File.Exists(fullPath)) + return Ok(new { success = false, message = "文件不存在" }); + + var fileInfo = new FileInfo(fullPath); + var contentType = GetContentType(fileInfo.Name); + + var response = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StreamContent(new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read)) + }; + response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); + response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") + { + FileName = fileInfo.Name + }; + return ResponseMessage(response); + } + catch (Exception ex) + { + return Ok(new { success = false, message = $"下载文件失败: {ex.Message}" }); + } + } + } +} + diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/MomController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/MomController.cs new file mode 100644 index 0000000..e41f2e2 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/MomController.cs @@ -0,0 +1,252 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; +using System.Threading; +using PLMTEST; +using System.Net; +using System.Net.Http.Headers; +using System.IO; +using MisDataSaveDate; + + +/////http://127.0.0.1:9981/api/IOrder/InsertOrder + + + +/// +/// +/// +namespace WebApi +{ + /// + /// + /// + public class MomController : ApiController + { + readonly string headUrl = "/"; + + /// + /// 工艺信息接口 + /// + /// + /// + [HttpPost] + [Route("ProcessInfo")] + public HttpResponseMessage ProcessInfo([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.ProcessInfo(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 生产任务接口 + /// + /// + /// + [HttpPost] + [Route("DispatchOrder")] + public HttpResponseMessage DispatchOrder([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.DispatchOrder(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 生产工单接口 + /// + /// + /// + [HttpPost] + [Route("ProductionOrder")] + public HttpResponseMessage ProductionOrder([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.ProductionOrder(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 员工信息下发接口 + /// + /// + /// + [HttpPost] + [Route("EmployeeSave")] + public HttpResponseMessage EmployeeSave([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_Employee(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 生产组织信息下发 + /// + /// + /// + [HttpPost] + [Route("OrgInfoSave")] + public HttpResponseMessage OrgInfoSave([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_OrgInfo(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 工作中心信息下发 + /// + /// + /// + [HttpPost] + [Route("WorkCenterSave")] + public HttpResponseMessage WorkCenterSave([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_WorkCenterSave(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 物料信息下发 + /// + /// + /// + [HttpPost] + [Route("MaterialSave")] + public HttpResponseMessage MaterialSave([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_MaterialSave(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 计量单位下发 + /// + /// + /// + [HttpPost] + [Route("UnitInfoSave")] + public HttpResponseMessage UnitInfoSave([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_UnitInfoSave(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 员工排班信息下发 + /// + /// + /// + [HttpPost] + [Route("ShiftScheduleSave")] + public HttpResponseMessage ShiftScheduleSave([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_ShiftScheduleSave(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 报警关闭 + /// + /// + /// + [HttpPost] + [Route("AlarmClosed")] + public HttpResponseMessage AlarmClosed([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.MES_To_AMS_AlarmClosed(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// AGV送料交互接口 + /// + /// + /// + [HttpPost] + [Route("AGV_To_AMS_InterAction")] + public HttpResponseMessage AGV_To_AMS_InterAction([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.AGV_To_AMS_Interaction(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 缓存位置查询 + /// + /// + /// + [HttpPost] + [Route("LineSideStock")] + public HttpResponseMessage LineSideStock([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.AGV_To_AMS_LineSideStock(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 点检计划下发 + /// + /// + /// + [HttpPost] + [Route("InspectionPlan")] + public HttpResponseMessage InspectionPlan([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.InspectionPlan(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + [HttpPost] + [Route("QTTemplateInfo")] + public HttpResponseMessage QTTemplateInfo([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.QTItemTemplateInfo(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + [HttpPost] + [Route("QTStandardInfo")] + public HttpResponseMessage QTStandardInfo([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.QTStandardInfo(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + /// + /// 删除派工订单接口 + /// + /// + /// + [HttpPost] + [Route("DeleteDispatchOrder")] + public HttpResponseMessage DeleteDispatchOrder([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(AnalysisMomMsg.DeleteDispatchOrder(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/WEBController.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/WEBController.cs new file mode 100644 index 0000000..ba93382 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Controller/WEBController.cs @@ -0,0 +1,134 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; +using System.Threading; +using System.Net; +using System.Net.Http.Headers; +using System.IO; +using MisDataSaveDate; +using WebApi; + +namespace MisDataSaveDate +{ + /// + /// AGV接口控制器 + /// + public class WebController : ApiController + { + readonly string headUrl = "/"; + + /// + /// AGV请求进入接口(接收方) + /// 接收AGV的进入请求并存储到数据库 + /// + /// AGV请求数据 + /// 处理结果 + [HttpPost] + [Route("web/WEB_Request")] + public HttpResponseMessage WEB_Request([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(WEB_BusinessLogic.WEB_Request(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + /// + /// AGV请求进入接口(接收方) + /// 接收AGV的进入请求并存储到数据库 + /// + /// AGV请求数据 + /// 处理结果 + [HttpPost] + [Route("web/WEB_SpotCheckResultUpload")] + public HttpResponseMessage WEB_SpotCheckResultUpload([FromBody] SpotCheckResult request) + { + var result = new MsgResHeader + { + code = 200, + message = "", + Data = null + }; + + try + { + if (request == null) + { + throw new Exception("请求体不能为空"); + } + + var response = CALL_Inerface_DataHandle.CALL_Inerface_SpotCheckResultUpload(request); + int.TryParse(response["code"]?.ToString() ?? "500", out int remoteCode); + result.code = remoteCode; + result.message = response["message"]?.ToString() ?? ""; + result.Data = response["data"]; + } + catch (Exception ex) + { + result.code = 500; + result.message = ex.Message; + } + + return new HttpResponseMessage + { + Content = new StringContent(JsonConvert.SerializeObject(result), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + /// + /// 磨合转序接口 + /// 调用AGV转序接口,成功后执行转序存储过程 + /// + /// 转序请求数据 + /// 处理结果 + [HttpPost] + [Route("web/WEB_RunningInTransfer")] + public HttpResponseMessage WEB_RunningInTransfer([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(WEB_BusinessLogic.WEB_RunningInTransfer(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + /// + /// 批量读取PLC点位值接口 + /// 前端传递TagTypeCodeID数组和工位号,返回对应点位的值 + /// + /// 请求数据,包含OpName和TagTypeCodeIDs数组 + /// 返回对应TagTypeCodeID的值列表 + [HttpPost] + [Route("web/WEB_ReadPLCValues")] + public HttpResponseMessage WEB_ReadPLCValues([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(WEB_BusinessLogic.WEB_ReadPLCValues(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + /// + /// 写入PLC接口 + /// 前端传递TagTypeCodeID、工位号和值,写入到PLC + /// + /// 请求数据,包含TagTypeCodeID、OpName和TagValue + /// 写入结果 + [HttpPost] + [Route("web/WEB_WritePLC")] + public HttpResponseMessage WEB_WritePLC([FromBody] JObject jobj) + { + return new HttpResponseMessage + { + Content = new StringContent(WEB_BusinessLogic.WEB_WritePLC(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/Analysis508Msg.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/Analysis508Msg.cs new file mode 100644 index 0000000..b28c081 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/Analysis508Msg.cs @@ -0,0 +1,1962 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Net.Mail; +using PLMTEST; +using MisDataSaveDate.MOM; +using Newtonsoft.Json.Linq; +using System.Web.Http; +using DataLinkMesWork; +using System.Configuration; +using ExternalDataSync; +using NPOI.SS.Formula.Functions; +using static System.Windows.Forms.AxHost; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using System.Net.NetworkInformation; +using NPOI.XSSF.Streaming.Values; +using MesServerWork; +using static MisDataSaveDate.Helper.ApiLogHelper; + +namespace MisDataSaveDate +{ + public class AnalysisMomMsg + { + /// + /// UUID生成 + /// + /// + public static string UuidUtil() + { + string result = Guid.NewGuid().ToString(); + + return result; + } + + /// + /// 员工信息保存 + /// + /// + /// + public static string MES_To_AMS_AlarmClosed(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("员工信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + AlarmClosed alarmclosed = JsonConvert.DeserializeObject(str); + if (string.IsNullOrWhiteSpace(alarmclosed.alarmTaskId)) + { + throw new Exception("参数taskID值不正确!"); + } + if (alarmclosed.HandleInfos == null || alarmclosed.HandleInfos.Count <= 0) + { + throw new Exception("参数handleInfo值不正确!"); + } + List alarmHandleInfos = alarmclosed.HandleInfos; + foreach (var alrmitem in alarmHandleInfos) + { + var param = new SqlParameter[] { + new SqlParameter("@报警任务ID",alarmclosed.alarmTaskId), + new SqlParameter("@处理人ID",alrmitem.UserId), + new SqlParameter("@处理人编号",alrmitem.UserCode), + new SqlParameter("@处理人名称",alrmitem.UserName), + new SqlParameter("@处理开始时间",alrmitem.StartTime), + new SqlParameter("@处理完成时间",alrmitem.EndTime) + }; + //DataAccess.ExecuteStoredProcedure("报警工位记录表_处理",ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("报警工位记录表_处理", ref param, out errorMessage); + } + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString); + return retString; + } + /// + /// 员工信息保存 + /// + /// + /// + public static string MES_To_AMS_Employee(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + result.Data = new List(); + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("员工信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + EmployeeInfoSave employeeScheme = JsonConvert.DeserializeObject(str); + if (employeeScheme?.Data == null || employeeScheme.Data.Count == 0) + { + throw new Exception("数据列表为空!"); + } + + foreach (var employee in employeeScheme.Data) + { + var responseData = new Response_Data(); + try + { + if (string.IsNullOrWhiteSpace(employee.PersonId)) + { + throw new Exception("参数personID值不正确!"); + } + if (string.IsNullOrWhiteSpace(employee.PersonCode)) + { + throw new Exception("参数personCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(employee.PersonName)) + { + throw new Exception("参数personName值不正确!"); + } + if (string.IsNullOrWhiteSpace(employee.OrgId)) + { + throw new Exception("参数orgID值不正确!"); + } + if (string.IsNullOrWhiteSpace(employee.PhoneNumber)) + { + throw new Exception("参数phoneNumber值不正确!"); + } + if (string.IsNullOrWhiteSpace(employee.CreateTime)) + { + throw new Exception("参数createTime值不正确!"); + } + if (string.IsNullOrWhiteSpace(employee.LastModifyTime)) + { + throw new Exception("参数lastModifyTime值不正确!"); + } + + var param = new SqlParameter[] { + new SqlParameter("@人员ID", employee.PersonId), + new SqlParameter("@人员编号", employee.PersonCode), + new SqlParameter("@人员名称", employee.PersonName), + new SqlParameter("@所属组织", employee.OrgId), + new SqlParameter("@手机号", employee.PhoneNumber), + new SqlParameter("@创建时间", employee.CreateTime), + new SqlParameter("@最后修改时间", employee.LastModifyTime) + }; + + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_人员名单_新增或更新", ref param, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + responseData.Code = 200; + responseData.Message = ""; + responseData.DataId = employee.PersonId; + } + catch (Exception ex) + { + responseData.Code = 500; + responseData.Message = ex.Message; + responseData.DataId = employee.PersonId; + } + result.Data.Add(responseData); + } + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("员工信息保存res:", retString); + return retString; + } + /// + /// 组织信息保存 + /// + /// + /// + public static string MES_To_AMS_OrgInfo(string url, [FromBody] JObject jobj) + { + + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + result.Data = null; + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("生产组织信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + OrganizationData OrgScheme = JsonConvert.DeserializeObject(str); + List OrgInfoList = OrgScheme.Data; + if (OrgScheme.Data == null || OrgScheme.Data.Count <= 0) + { + throw new Exception("参数Data值不正确!"); + } + List resDataList = new List(); + foreach (var orgitem in OrgInfoList) + { + if (string.IsNullOrEmpty(orgitem.OrgID)) + { + errorMessage = "参数orgID值不正确!"; + } + else if (string.IsNullOrEmpty(orgitem.OrgCode)) + { + errorMessage = "参数orgCode值不正确!"; + } + else if (string.IsNullOrEmpty(orgitem.OrgName)) + { + errorMessage = "参数orgName值不正确!"; + } + else if (string.IsNullOrEmpty(orgitem.Classification)) + { + errorMessage = "参数classification值不正确!"; + } + else if (string.IsNullOrEmpty(orgitem.LevelNo)) + { + errorMessage = "参数level值不正确!"; + } + else if (string.IsNullOrEmpty(orgitem.Detail)) + { + errorMessage = "参数detail值不正确!"; + } + else if (string.IsNullOrEmpty(orgitem.CreateTime)) + { + errorMessage = "参数createTime值不正确!"; + } + else + { + var param = new SqlParameter[] + { + new SqlParameter("@OrgID",orgitem.OrgID), + new SqlParameter("@OrgCode",orgitem.OrgCode), + new SqlParameter("@OrgName",orgitem.OrgName), + new SqlParameter("@Classification",orgitem.Classification), + new SqlParameter("@LevelNo",orgitem.LevelNo), + new SqlParameter("@Detail",orgitem.Detail), + new SqlParameter("@CreateTime",orgitem.CreateTime), + new SqlParameter("@LastModifyTime",VHandle(orgitem.LastModifyTime)) + }; + //DataAccess.ExecuteStoredProcedure("MOM_生产组织_新增或更新", ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产组织_新增或更新", ref param, out errorMessage); + } + Response_Data resData = new Response_Data(); + resData.Message = errorMessage; + resData.Code = errorMessage == "" ? 200 : 500; + resData.DataId = ""; + resDataList.Add(resData); + } + result.Data = resDataList; + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("生产组织信息保存res:", retString); + return retString; + } + /// + /// 工作中心保存 + /// + /// + /// + public static string MES_To_AMS_WorkCenterSave(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("工作中心信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + WorkCenterData Scheme = JsonConvert.DeserializeObject(str); + List workCenterList = Scheme.Data; + if (Scheme.Data == null || Scheme.Data.Count <= 0) + { + throw new Exception("参数Data值不正确!"); + } + List resDataList = new List(); + foreach (var dataitem in workCenterList) + { + if (string.IsNullOrEmpty(dataitem.WorkCenterID)) + { + errorMessage = "参数workCenterID值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.WorkCenterCode)) + { + errorMessage = "参数workCenterCode值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.WorkCenterName)) + { + errorMessage = "参数workCenterName值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.OrgID)) + { + errorMessage = "参数orgID值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.Classification)) + { + errorMessage = "参数classification值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.LevelNo)) + { + errorMessage = "参数level值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.Detail)) + { + errorMessage = "参数detail值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.CreateTime)) + { + errorMessage = "参数createTime值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.LastModifyTime)) + { + errorMessage = "参数lastModifyTime值不正确!"; + } + else + { + var param = new SqlParameter[] + { + new SqlParameter("@workCenterID",dataitem.WorkCenterID), + new SqlParameter("@workCenterCode",dataitem.WorkCenterCode), + new SqlParameter("@workCenterName",dataitem.WorkCenterName), + new SqlParameter("@orgID",dataitem.OrgID), + new SqlParameter("@classification",dataitem.Classification), + new SqlParameter("@LevelNo",dataitem.LevelNo), + new SqlParameter("@Detail",dataitem.Detail), + new SqlParameter("@CreateTime",dataitem.CreateTime), + new SqlParameter("@LastModifyTime",dataitem.LastModifyTime) + }; + //DataAccess.ExecuteStoredProcedure("MOM_工作中心_新增或更新", ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工作中心_新增或更新", ref param, out errorMessage); + } + Response_Data resData = new Response_Data(); + resData.Message = errorMessage; + resData.Code = errorMessage == "" ? 200 : 500; + resData.DataId = ""; + resDataList.Add(resData); + } + result.Data = resDataList; + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("工作中心信息保存res:", retString); + return retString; + } + /// + /// 物料信息保存 + /// + /// + /// + public static string MES_To_AMS_MaterialSave(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("物料信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + MaterialInfoSave Scheme = JsonConvert.DeserializeObject(str); + List materialList = Scheme.Data; + if (Scheme.Data == null || Scheme.Data.Count <= 0) + { + throw new Exception("参数Data值不正确!"); + } + List resDataList = new List(); + foreach (var dataitem in materialList) + { + if (string.IsNullOrEmpty(dataitem.MaterialID)) + { + errorMessage = "参数materialID值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.MaterialCode)) + { + errorMessage = "参数materialCode值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.MaterialName)) + { + errorMessage = "参数materialName值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.CreateTime)) + { + errorMessage = "参数createTime值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.LastModifyTime)) + { + errorMessage = "参数lastModifyTime值不正确!"; + } + else + { + var param = new SqlParameter[] + { + new SqlParameter("@materialID",dataitem.MaterialID), + new SqlParameter("@materialCode",dataitem.MaterialCode), + new SqlParameter("@materialName",dataitem.MaterialName), + new SqlParameter("@unitOfMeasure",VHandle(dataitem.UnitOfMeasure)), + new SqlParameter("@materialCategory",VHandle(dataitem.MaterialCategory)), + new SqlParameter("@materialSpec",VHandle(dataitem.MaterialSpec)), + new SqlParameter("@materialModel",VHandle(dataitem.MaterialModel)), + new SqlParameter("@materialDescription",VHandle(dataitem.MaterialDescription)), + new SqlParameter("@CreateTime",dataitem.CreateTime), + new SqlParameter("@LastModifyTime",dataitem.LastModifyTime) + }; + //DataAccess.ExecuteStoredProcedure("MOM_物料信息_新增或更新", ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_物料信息_新增或更新", ref param, out errorMessage); + } + Response_Data resData = new Response_Data(); + resData.Message = errorMessage; + resData.Code = errorMessage == "" ? 200 : 500; + resData.DataId = dataitem.MaterialID; + resDataList.Add(resData); + } + result.Data = resDataList; + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("物料信息保存res:", retString); + return retString; + } + /// + /// 计量单位信息保存 + /// + /// + /// + public static string MES_To_AMS_UnitInfoSave(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("计量单位信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + UnitData Scheme = JsonConvert.DeserializeObject(str); + List materialList = Scheme.Data; + if (Scheme.Data == null || Scheme.Data.Count <= 0) + { + throw new Exception("参数Data值不正确!"); + } + List resDataList = new List(); + foreach (var dataitem in materialList) + { + if (string.IsNullOrEmpty(dataitem.UnitID)) + { + errorMessage = "参数unitID值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.UnitCode)) + { + errorMessage = "参数unitCode值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.UnitName)) + { + errorMessage = "参数unitName值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.CreateTime)) + { + errorMessage = "参数createTime值不正确!"; + } + else if (string.IsNullOrEmpty(dataitem.LastModifyTime)) + { + errorMessage = "参数lastModifyTime值不正确!"; + } + else + { + var param = new SqlParameter[] + { + new SqlParameter("@unitID",dataitem.UnitID), + new SqlParameter("@unitCode",dataitem.UnitCode), + new SqlParameter("@unitName",dataitem.UnitName), + new SqlParameter("@CreateTime",dataitem.CreateTime), + new SqlParameter("@LastModifyTime",dataitem.LastModifyTime) + }; + //DataAccess.ExecuteStoredProcedure("MOM_计量单位_新增或更新", ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_计量单位_新增或更新", ref param, out errorMessage); + } + Response_Data resData = new Response_Data(); + resData.Message = errorMessage; + resData.Code = errorMessage == "" ? 200 : 500; + resData.DataId = ""; + resDataList.Add(resData); + } + result.Data = resDataList; + + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("计量单位信息保存res:", retString); + return retString; + } + /// + /// 员工排班信息 + /// + /// + /// + public static string MES_To_AMS_ShiftScheduleSave(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("员工排班信息保存res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + ShiftSchedule Scheme = JsonConvert.DeserializeObject(str); + if (string.IsNullOrWhiteSpace(Scheme.EmployeeID)) + { + throw new Exception("参数EmployeeID值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.EmployeeCode)) + { + throw new Exception("参数EmployeeCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.EmployeeName)) + { + throw new Exception("参数EmployeeName值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.StartDate)) + { + throw new Exception("参数StartDate值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.EndDate)) + { + throw new Exception("参数EndDate值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.ProductionOrg)) + { + throw new Exception("参数prodOrg值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.ProductionCenter)) + { + throw new Exception("参数prodCenter值不正确!"); + } + if (string.IsNullOrWhiteSpace(Scheme.WorkProcess)) + { + throw new Exception("参数workProc值不正确!"); + } + var param = new SqlParameter[] + { + new SqlParameter("@empID",Scheme.EmployeeID), + new SqlParameter("@empCode",Scheme.EmployeeCode), + new SqlParameter("@empName",Scheme.EmployeeName), + new SqlParameter("@startDate",Scheme.StartDate), + new SqlParameter("@endDate",Scheme.EndDate), + new SqlParameter("@prodOrg",Scheme.ProductionOrg), + new SqlParameter("@prodCenter",Scheme.ProductionCenter), + new SqlParameter("@workProc",Scheme.WorkProcess) + }; + //DataAccess.ExecuteStoredProcedure("MOM_员工排班信息_新增或更新",ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_员工排班信息_新增或更新", ref param, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("员工排班信息保存res:", retString); + return retString; + } + /// + /// AGV与产线AMS交互接口 + /// + /// + /// + public static string AGV_To_AMS_Interaction(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + AGV_InterAction interAction = JsonConvert.DeserializeObject(str); + + if (string.IsNullOrWhiteSpace(interAction.LocationCode)) + { + throw new Exception("参数LocationCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(interAction.TaskCode)) + { + throw new Exception("参数TaskCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(interAction.DeliveryType)) + { + throw new Exception("参数deliveryType值不正确!"); + } + if (string.IsNullOrWhiteSpace(interAction.ReqCMD)) + { + throw new Exception("参数ReqCMD值不正确!"); + } + + switch (interAction.LocationCode) + { + case "AGV_To_AMS_RequestEnter": + //向PLC发送请求进入信号 + //MIS_BASE.WritePLC(); + break; + case "AGV_To_AMS_PlaceCompleted": + //向PLC发送器具放置完毕信号 + + break; + case "AGV_To_AMS_ExitGrating": + //向PLC发送 + break; + default: + break; + } + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString); + return retString; + } + /// + /// 工艺信息接口 + /// + /// + /// + public static string ProcessInfo(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + ProcessScheme processScheme = JsonConvert.DeserializeObject(str); + + if (string.IsNullOrWhiteSpace(processScheme.id)) + { + throw new Exception("参数id值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.code)) + { + throw new Exception("参数code值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.orderNo)) + { + throw new Exception("参数orderNo值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.productId)) + { + throw new Exception("参数productId值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.productCode)) + { + throw new Exception("参数productCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.productName)) + { + throw new Exception("参数productName值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.createdTime)) + { + throw new Exception("参数createdTime值不正确!"); + } + if (string.IsNullOrWhiteSpace(processScheme.lastModifiedTime)) + { + throw new Exception("参数lastModifiedTime值不正确!"); + } + //if (processScheme.processInfo == null || processScheme.processInfo.Count <= 0) + //{ + // throw new Exception("参数processInfo值不正确!"); + //} + if (processScheme.routingInfo == null || processScheme.routingInfo.Count <= 0) + { + throw new Exception("参数routingInfo值不正确!"); + } + var param = new SqlParameter[] { + new SqlParameter("@id",processScheme.id), + new SqlParameter("@code",processScheme.code), + new SqlParameter("@name",VHandle(processScheme.name)), + new SqlParameter("@orderNo",processScheme.orderNo), + new SqlParameter("@productId",processScheme.productId), + new SqlParameter("@productCode",processScheme.productCode), + new SqlParameter("@productName",processScheme.productName), + new SqlParameter("@productSpec",VHandle(processScheme.productSpec)), + new SqlParameter("@model",VHandle(processScheme.model)), + new SqlParameter("@createdTime",processScheme.createdTime), + new SqlParameter("@lastModifiedTime",processScheme.lastModifiedTime), + + }; + //DataAccess.ExecuteStoredProcedure("MOM_工艺信息_新增", ref param); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工艺信息_新增", ref param, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List processInfoList = processScheme.processInfo; + + for (int i = 0; i < processInfoList.Count; i++) + { + MisDataSaveDate.MOM.ProcessInfo processInfo = processInfoList[i]; + if (string.IsNullOrWhiteSpace(processInfo.processInfoid)) + { + throw new Exception("参数processInfoid值不正确!"); + } + if (string.IsNullOrWhiteSpace(processInfo.sequenceNo)) + { + throw new Exception("参数sequenceNo值不正确!"); + } + if (string.IsNullOrWhiteSpace(processInfo.processId)) + { + throw new Exception("参数processId值不正确!"); + } + if (string.IsNullOrWhiteSpace(processInfo.processCode)) + { + throw new Exception("参数processCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(processInfo.processName)) + { + throw new Exception("参数processName值不正确!"); + } + // 文件文档路径非必填,允许为空 + var param2 = new SqlParameter[] { + new SqlParameter("@ProcessSchemeId",processScheme.id), + new SqlParameter("@processInfoid",processInfo.processInfoid), + new SqlParameter("@sequenceNo",processInfo.sequenceNo), + new SqlParameter("@processId",processInfo.processId), + new SqlParameter("@processCode",processInfo.processCode), + new SqlParameter("@processName",processInfo.processName), + new SqlParameter("@docInfo", VHandle(processInfo.docInfo)), + new SqlParameter("@filename", VHandle(processInfo.filename)) + }; + //DataAccess.ExecuteStoredProcedure("MOM_工艺信息_工序信息_新增", ref param2); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工艺信息_工序信息_新增", ref param2, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + + List routingInfoList = processScheme.routingInfo; + + for (int i = 0; i < routingInfoList.Count; i++) + { + MisDataSaveDate.MOM.RoutingInfo routingInfo = routingInfoList[i]; + if (string.IsNullOrWhiteSpace(routingInfo.routingid)) + { + throw new Exception("参数routingid值不正确!"); + } + if (string.IsNullOrWhiteSpace(routingInfo.routingcode)) + { + throw new Exception("参数routingcode值不正确!"); + } + if (string.IsNullOrWhiteSpace(routingInfo.processId)) + { + throw new Exception("参数processId值不正确!"); + } + if (string.IsNullOrWhiteSpace(routingInfo.processCode)) + { + throw new Exception("参数processCode值不正确!"); + } + if (string.IsNullOrWhiteSpace(routingInfo.processName)) + { + throw new Exception("参数processName值不正确!"); + } + var param3 = new SqlParameter[] { + new SqlParameter("@ProcessSchemeId",processScheme.id), + new SqlParameter("@routingid",routingInfo.routingid), + new SqlParameter("@routingcode",routingInfo.routingcode), + new SqlParameter("@processId",routingInfo.processId), + new SqlParameter("@processCode",routingInfo.processCode), + new SqlParameter("@processName",routingInfo.processName) + }; + //DataAccess.ExecuteStoredProcedure("MOM_工艺信息_工艺路线_新增", ref param3); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工艺信息_工艺路线_新增", ref param3, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString); + return retString; + } + /// + /// 计划下发 + /// + /// + /// + public static string DispatchOrder(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("生产任务接口res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + DispatchOrder dispatchOrder = JsonConvert.DeserializeObject(str); + + if (!ValidateProperty(dispatchOrder.orderID, "orderID", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(dispatchOrder.orderNo, "orderNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(dispatchOrder.materialId, "materialId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(dispatchOrder.materialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(dispatchOrder.materialName, "materialName", out errorMessage)) throw new Exception(errorMessage); + //if (!ValidateProperty(dispatchOrder.planStartTime, "planStartTime", out errorMessage)) throw new Exception(errorMessage); + + var qty = dispatchOrder.qty == null ? 1 : Convert.ToInt32(double.Parse(dispatchOrder.qty)); + var planStartDate = string.IsNullOrEmpty(dispatchOrder.planStartTime) ? DateTime.Now.ToString("yyyy-MM-dd") : DateTime.Parse(dispatchOrder.planStartTime).ToString("yyyy-MM-dd"); + + var param = new SqlParameter[] { + new SqlParameter("@orderID",dispatchOrder.orderID), + new SqlParameter("@orderNo",dispatchOrder.orderNo), + new SqlParameter("@materialId",dispatchOrder.materialId), + new SqlParameter("@materialCode",dispatchOrder.materialCode), + new SqlParameter("@materialName",dispatchOrder.materialName), + new SqlParameter("@materialSpec",VHandle(dispatchOrder.materialSpec)), + new SqlParameter("@materialModel",VHandle(dispatchOrder.materialModel )), + new SqlParameter("@projectCode",VHandle(dispatchOrder.projectCode)), + new SqlParameter("@projectName",VHandle(dispatchOrder.projectName)), + new SqlParameter("@routingId",VHandle(dispatchOrder.routingId)), + new SqlParameter("@qty",qty), + new SqlParameter("@planStartTime",planStartDate), + }; + //新增生产任务、执行计划(根据计划数量拆分流水号及各工序Moby) + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_新增", ref param, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List processInfoList = dispatchOrder.dispatchTask; + + for (int i = 0; i < processInfoList.Count; i++) + { + DispatchTask processInfo = processInfoList[i]; + if (!ValidateProperty(processInfo.taskId, "taskId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.taskNo, "taskNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.workOrderProcessId, "workOrderProcessId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.workOrderNo, "workOrderNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.workCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.workCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.workCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.processId, "processId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.processCode, "processCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.processName, "processName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.materialId, "materialId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.materialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.materialName, "materialName", out errorMessage)) throw new Exception(errorMessage); + //if (!ValidateProperty(processInfo.materialModel, "materialModel", out errorMessage))throw new Exception(errorMessage); + //if (!ValidateProperty(processInfo.planStartTime, "planStartTime", out errorMessage))throw new Exception(errorMessage); + //if (!ValidateProperty(processInfo.planEndTime, "planEndTime", out errorMessage))throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.dispatchQty, "dispatchQty", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.taskStatus, "taskStatus", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.createdAt, "createdAt", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.modifiedAt, "modifiedAt", out errorMessage)) throw new Exception(errorMessage); + + var param2 = new SqlParameter[] { + new SqlParameter("@orderID", dispatchOrder.orderID), + new SqlParameter("@orderNo", dispatchOrder.orderNo), + new SqlParameter("@taskId", processInfo.taskId), + new SqlParameter("@taskNo", processInfo.taskNo), + new SqlParameter("@workOrderProcessId", processInfo.workOrderProcessId), + new SqlParameter("@workOrderNo", processInfo.workOrderNo), + new SqlParameter("@workCenterId", processInfo.workCenterId), + new SqlParameter("@workCenterCode", processInfo.workCenterCode), + new SqlParameter("@workCenterName", processInfo.workCenterName), + new SqlParameter("@processId", processInfo.processId), + new SqlParameter("@processCode", processInfo.processCode), + new SqlParameter("@processName", processInfo.processName), + new SqlParameter("@materialId", processInfo.materialId), + new SqlParameter("@materialCode", processInfo.materialCode), + new SqlParameter("@materialName", processInfo.materialName), + new SqlParameter("@materialModel", VHandle(processInfo.materialModel)), + new SqlParameter("@planStartTime", VHandle(processInfo.planStartTime)), + new SqlParameter("@planEndTime", VHandle(processInfo.planEndTime)), + new SqlParameter("@dispatchQty",Convert.ToInt32(double.Parse(processInfo.dispatchQty))), + new SqlParameter("@taskStatus", processInfo.taskStatus), + new SqlParameter("@createdAt", processInfo.createdAt), + new SqlParameter("@modifiedAt", processInfo.modifiedAt), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_新增", ref param2, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List deliveryInfoList = processInfo.deliveryInfo; + + for (int j = 0; j < deliveryInfoList.Count; j++) + { + DeliveryInfo deliveryInfo = deliveryInfoList[j]; + if (!ValidateProperty(deliveryInfo.deliveryInfoid, "deliveryInfoid", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.momid, "momid", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.preparationNo, "preparationNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.materialId, "materialId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.materialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.materialName, "materialName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.processId, "processId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.processCode, "processCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.processName, "processName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.workCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.workCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.workCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.requiredQty, "requiredQty", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.planTime, "planTime", out errorMessage)) throw new Exception(errorMessage); + + var param3 = new SqlParameter[] { + new SqlParameter("@orderID", dispatchOrder.orderID), + new SqlParameter("@orderNo", dispatchOrder.orderNo), + new SqlParameter("@taskId", processInfo.taskId), + new SqlParameter("@taskNo", processInfo.taskNo), + new SqlParameter("@deliveryInfoid", deliveryInfo.deliveryInfoid), + new SqlParameter("@momid", deliveryInfo.momid), + new SqlParameter("@preparationNo", deliveryInfo.preparationNo), + new SqlParameter("@materialId", deliveryInfo.materialId), + new SqlParameter("@materialCode", deliveryInfo.materialCode), + new SqlParameter("@materialName", deliveryInfo.materialName), + new SqlParameter("@materialSpec", VHandle(deliveryInfo.materialSpec)), + new SqlParameter("@materialModel", VHandle(deliveryInfo.materialModel)), + new SqlParameter("@materialDesc", VHandle(deliveryInfo.materialDesc)), + new SqlParameter("@processId", deliveryInfo.processId), + new SqlParameter("@processCode", deliveryInfo.processCode), + new SqlParameter("@processName", deliveryInfo.processName), + new SqlParameter("@workCenterId", deliveryInfo.workCenterId), + new SqlParameter("@workCenterCode", deliveryInfo.workCenterCode), + new SqlParameter("@workCenterName", deliveryInfo.workCenterName), + new SqlParameter("@requiredQty", Convert.ToInt32(double.Parse(deliveryInfo.requiredQty))), + new SqlParameter("@planTime", deliveryInfo.planTime), + new SqlParameter("@batchNo", VHandle(deliveryInfo.batchNo)), + new SqlParameter("@serialNo", VHandle(deliveryInfo.serialNo)), + new SqlParameter("@deliveryPosId", VHandle(deliveryInfo.deliveryPosId)), + new SqlParameter("@deliveryPosCode", VHandle(deliveryInfo.deliveryPosCode)), + new SqlParameter("@deliveryPosName", VHandle(deliveryInfo.deliveryPosName)), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_配送信息_新增", ref param3, out errorMessage); + + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + } + //将订单数据转移到MES + var param4 = new SqlParameter[] { + new SqlParameter("@orderID", dispatchOrder.orderID), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_平移到MES", ref param4, out errorMessage); + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("生产任务接口res:", retString); + return retString; + } + /// + /// 生产工单接口 + /// + /// + /// + /// + public static string ProductionOrder(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("生产工单接口res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + ProductionOrder productionOrder = JsonConvert.DeserializeObject(str); + + if (!ValidateProperty(productionOrder.OrderID, "orderID", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(productionOrder.OrderNo, "orderNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(productionOrder.MaterialId, "materialId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(productionOrder.MaterialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(productionOrder.MaterialName, "materialName", out errorMessage)) throw new Exception(errorMessage); + + var param = new SqlParameter[] { + new SqlParameter("@OrderID",productionOrder.OrderID), + new SqlParameter("@OrderNo",productionOrder.OrderNo), + new SqlParameter("@MaterialId",productionOrder.MaterialId), + new SqlParameter("@MaterialCode",productionOrder.MaterialCode), + new SqlParameter("@MaterialName",productionOrder.MaterialName), + new SqlParameter("@MaterialSpec",VHandle( productionOrder.MaterialSpec)), + new SqlParameter("@MaterialModel",VHandle(productionOrder.MaterialModel)), + new SqlParameter("@OrderType",VHandle(productionOrder.OrderType)), + new SqlParameter("@Clr",VHandle(productionOrder.Clr)), + new SqlParameter("@PlanProdDate",VHandle(productionOrder.PlanProdDate)), + new SqlParameter("@PlanProdQty",VHandle(productionOrder.PlanProdQty)), + new SqlParameter("@PlanOutputDate",VHandle(productionOrder.PlanOutputDate)), + new SqlParameter("@PlanOutputQty",VHandle(productionOrder.PlanOutputQty)), + new SqlParameter("@ProjectNo",VHandle(productionOrder.ProjectNo)), + new SqlParameter("@ProjectName",VHandle(productionOrder.ProjectName)), + new SqlParameter("@PlanId",VHandle(productionOrder.PlanId)) + }; + //新增生产任务、执行计划(根据计划数量拆分流水号及各工序Moby) + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_新增", ref param, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List processInfoList = productionOrder.ProcessPlans; + + for (int i = 0; i < processInfoList.Count; i++) + { + ProcessPlan processInfo = processInfoList[i]; + + if (!ValidateProperty(processInfo.RoutingId, "rountingid", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.ProcessPlanId, "processplanid", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.ProcessPlanNo, "processplanNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.WorkOrderProcessId, "workOrderProcessId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.WorkOrderNo, "workOrderNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.WorkCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.WorkCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.WorkCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.ProcessId, "processId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.ProcessCode, "processCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.ProcessName, "processName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.MaterialId, "materialId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.MaterialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(processInfo.MaterialName, "materialName", out errorMessage)) throw new Exception(errorMessage); + + var param2 = new SqlParameter[] { + new SqlParameter("@OrderID", productionOrder.OrderID), + new SqlParameter("@ProcessPlanId", processInfo.ProcessPlanId), + new SqlParameter("@RoutingId", processInfo.RoutingId), + new SqlParameter("@ProcessPlanNo", processInfo.ProcessPlanNo), + new SqlParameter("@WorkOrderProcessId", processInfo.WorkOrderProcessId), + new SqlParameter("@WorkOrderNo", processInfo.WorkOrderNo), + new SqlParameter("@WorkCenterId", processInfo.WorkCenterId), + new SqlParameter("@WorkCenterCode", processInfo.WorkCenterCode), + new SqlParameter("@WorkCenterName", processInfo.WorkCenterName), + new SqlParameter("@ProcessId", processInfo.ProcessId), + new SqlParameter("@ProcessCode", processInfo.ProcessCode), + new SqlParameter("@ProcessName", processInfo.ProcessName), + new SqlParameter("@MaterialId", processInfo.MaterialId), + new SqlParameter("@MaterialCode", processInfo.MaterialCode), + new SqlParameter("@MaterialName", processInfo.MaterialName), + new SqlParameter("@MaterialModel",VHandle(processInfo.MaterialModel)), + new SqlParameter("@PlanStartTime", VHandle(processInfo.PlanStartTime)), + new SqlParameter("@PlanEndTime", VHandle(processInfo.PlanEndTime)), + new SqlParameter("@Qty", processInfo.Qty), + new SqlParameter("@OutQty", processInfo.OutQty), + new SqlParameter("@Status", VHandle(processInfo.Status)), + new SqlParameter("@CreatedAt", VHandle(processInfo.CreatedAt)), + new SqlParameter("@ModifiedAt", VHandle(processInfo.ModifiedAt)) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_工单工序_新增", ref param2, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List deliveryInfoList = processInfo.DeliveryInfo; + + for (int j = 0; j < deliveryInfoList.Count; j++) + { + DeliveryMaterialInfo deliveryInfo = deliveryInfoList[j]; + if (!ValidateProperty(deliveryInfo.DeliveryInfoId, "deliveryInfoid", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.PreparationNo, "preparationNo", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.MaterialId, "materialId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.MaterialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.MaterialName, "materialName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.ProcessId, "processId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.ProcessCode, "processCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.ProcessName, "processName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.WorkCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.WorkCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.WorkCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.RequiredQty, "requiredQty", out errorMessage)) throw new Exception(errorMessage); + if (!ValidateProperty(deliveryInfo.PlanTime, "planTime", out errorMessage)) throw new Exception(errorMessage); + + var param3 = new SqlParameter[] { + new SqlParameter("@OrderId", productionOrder.OrderID), + new SqlParameter("@ProcessPlanId", processInfo.ProcessPlanId), + new SqlParameter("@DeliveryInfoId", deliveryInfo.DeliveryInfoId), + new SqlParameter("@PreparationNo", deliveryInfo.PreparationNo), + new SqlParameter("@MaterialId", deliveryInfo.MaterialId), + new SqlParameter("@MaterialCode", deliveryInfo.MaterialCode), + new SqlParameter("@MaterialName", deliveryInfo.MaterialName), + new SqlParameter("@MaterialSpec",VHandle(deliveryInfo.MaterialSpec)), + new SqlParameter("@MaterialModel", VHandle(deliveryInfo.MaterialModel)), + new SqlParameter("@MaterialDesc", VHandle(deliveryInfo.MaterialDesc)), + new SqlParameter("@ProcessId", deliveryInfo.ProcessId), + new SqlParameter("@ProcessCode", deliveryInfo.ProcessCode), + new SqlParameter("@ProcessName", deliveryInfo.ProcessName), + new SqlParameter("@WorkCenterId", deliveryInfo.WorkCenterId), + new SqlParameter("@WorkCenterCode", deliveryInfo.WorkCenterCode), + new SqlParameter("@WorkCenterName", deliveryInfo.WorkCenterName), + new SqlParameter("@RequiredQty", deliveryInfo.RequiredQty), + new SqlParameter("@PlanTime", deliveryInfo.PlanTime) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_工单工序_工单备料_新增", ref param3, out errorMessage); + + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + } + //将订单数据转移到MES + //var param4 = new SqlParameter[] { + // new SqlParameter("@orderID", productionOrder.orderID), + // }; + //DataAccess.ExecuteStoredProcedure("MOM_生产任务_平移到MES", ConnectionString, ref param4, out errorMessage); + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString); + return retString; + } + /// + /// 缓存位置查询 + /// + /// + /// + /// + public static string AGV_To_AMS_LineSideStock(string url, [FromBody] JObject jobj) + { + + var result = new Res_LineSideStock(); + result.Code = 200; + result.Message = ""; + result.Data = null; + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("缓存位置查询res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + LineSideStock LSSScheme = JsonConvert.DeserializeObject(str); + if (string.IsNullOrEmpty(LSSScheme.RequestId)) + { + throw new Exception("参数requestId值不正确!"); + } + if (string.IsNullOrEmpty(LSSScheme.Process)) + { + throw new Exception("参数process值不正确!"); + } + var param = new SqlParameter[] + { + new SqlParameter("@Process",LSSScheme.Process) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_缓存位置_查询", ref param, out DataTable dt_lss, out errorMessage); + ////////////////////List lssData = new List(); + ////////////////////foreach (DataRow dr in dt_lss.Rows) + ////////////////////{ + //////////////////// LSSData lssData = new LSSData(); + //////////////////// lssData.ProcessNo = LSSScheme.Process; + //////////////////// lssData.LocationNo = dr["工位号"].ToString(); + + ////////////////////} + ////////////////////lssData.ProcessNo = LSSScheme.Process; + ////////////////////lssData.LocationNo = errorMessage; + ////////////////////lssData. + ////////////////////result.Data = responseDatas; + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("缓存位置查询res:", retString); + return retString; + } + /// + /// 点检计划 + /// + /// + /// + /// + public static string InspectionPlan(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + result.Data = new List(); + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("点检计划res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + InspectionPlan Scheme = JsonConvert.DeserializeObject(str); + + if (string.IsNullOrWhiteSpace(Scheme.Id)) + { + throw new Exception("参数id值不正确!"); + } + else if (string.IsNullOrWhiteSpace(Scheme.Code)) + { + throw new Exception("参数code值不正确!"); + } + else if (string.IsNullOrWhiteSpace(Scheme.Name)) + { + throw new Exception("参数name值不正确!"); + } + + var param = new SqlParameter[] { + new SqlParameter("@点检计划ID",Scheme.Id), + new SqlParameter("@点检编号",Scheme.Code), + new SqlParameter("@点检名称",Scheme.Name), + new SqlParameter("@编制单位编码",VHandle(Scheme.CompileUnitCode)), + new SqlParameter("@编制单位名称",VHandle(Scheme.CompileUnitName)), + new SqlParameter("@点检类别编号",VHandle(Scheme.CheckTypeCode)), + new SqlParameter("@点检类别名称",VHandle(Scheme.CheckTypeName)), + new SqlParameter("@是否周期计划",VHandle(Scheme.IsCyclePlan)), + new SqlParameter("@点检周期",VHandle(Scheme.CheckCycle)), + new SqlParameter("@周期单位",VHandle(Scheme.CycleUnit)), + new SqlParameter("@下次点检时间",VHandle(Scheme.NextCheckTime)), + new SqlParameter("@计划状态",VHandle(Scheme.PlanStatus)), + new SqlParameter("@巡检",VHandle(Scheme.WhetherInspect)), + new SqlParameter("@任务有效期",VHandle(Scheme.TaskValidityPeriod)), + new SqlParameter("@有效期单位",VHandle(Scheme.ValidityUnit)), + new SqlParameter("@提前生成",VHandle(Scheme.DaysAhead)), + new SqlParameter("@提前单位",VHandle(Scheme.AheadUnit)) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_点检计划_新增", ref param, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List checkObjectList = Scheme.CheckObjects; + + for (int i = 0; i < checkObjectList.Count; i++) + { + MisDataSaveDate.MOM.CheckObject checkObject = checkObjectList[i]; + if (string.IsNullOrWhiteSpace(checkObject.CheckObjectId)) + { + throw new Exception("参数checkobjectsid值不正确!"); + } + + var param2 = new SqlParameter[] { + new SqlParameter("@点检计划ID",Scheme.Id), + new SqlParameter("@点检对象ID",checkObject.CheckObjectId), + new SqlParameter("@资产编号",VHandle(checkObject.AssetCode)), + new SqlParameter("@资产名称",VHandle(checkObject.AssetName)), + new SqlParameter("@资产位置",VHandle(checkObject.PositionCode)), + new SqlParameter("@资产位置名称",VHandle(checkObject.PositionName)), + new SqlParameter("@计划点检人编号",VHandle(checkObject.PlanCheckerCode)), + new SqlParameter("@计划点检人名称",VHandle(checkObject.PlanCheckerName)) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_点检计划_点检对象_新增", ref param2, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + List checkDetailList = checkObject.Details; + + for (int j = 0; j < checkDetailList.Count; j++) + { + MisDataSaveDate.MOM.CheckDetail checkDetail = checkDetailList[j]; + if (string.IsNullOrWhiteSpace(checkDetail.DetailId)) + { + throw new Exception("参数detailid值不正确!"); + } + if (string.IsNullOrWhiteSpace(checkDetail.CheckItem)) + { + throw new Exception("参数checkitem值不正确!"); + } + if (string.IsNullOrWhiteSpace(checkDetail.CheckContent)) + { + throw new Exception("参数checkcontent值不正确!"); + } + if (string.IsNullOrWhiteSpace(checkDetail.CheckMethodName)) + { + throw new Exception("参数checkmethodname值不正确!"); + } + + var param3 = new SqlParameter[] { + new SqlParameter("@点检计划ID",Scheme.Id), + new SqlParameter("@点检对象ID",checkObject.CheckObjectId), + new SqlParameter("@详细信息ID",checkDetail.DetailId), + new SqlParameter("@点检部位",VHandle(checkDetail.CheckPart)), + new SqlParameter("@点检项目",checkDetail.CheckItem), + new SqlParameter("@点检内容",checkDetail.CheckContent), + new SqlParameter("@点检方法编号",VHandle(checkDetail.CheckMethodCode)), + new SqlParameter("@点检方法名称",checkDetail.CheckMethodName), + new SqlParameter("@标准要求",VHandle(checkDetail.StandardClaim)), + new SqlParameter("@结果类型",VHandle(checkDetail.ResultType)), + new SqlParameter("@结果选项ID",VHandle(checkDetail.ResultOptionsIds)), + new SqlParameter("@结果选项",VHandle(checkDetail.ResultOptions)), + new SqlParameter("@异常对策编号",VHandle(checkDetail.AbnormalMeasuresCode)), + new SqlParameter("@异常对策名称",VHandle(checkDetail.AbnormalMeasuresName)), + new SqlParameter("@点检状态编号",VHandle(checkDetail.CheckStatusEnumCode)), + new SqlParameter("@点检状态名称",VHandle(checkDetail.CheckStatusEnumName)), + new SqlParameter("@必须拍照",VHandle(checkDetail.IsPhotographed)), + new SqlParameter("@计划点检人编号",VHandle(checkDetail.PlanCheckerCode)), + new SqlParameter("@计划点检人名称",VHandle(checkDetail.PlanCheckerName)), + new SqlParameter("@最后点检时间",VHandle(checkDetail.LastCheckTime)) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_点检计划_点检对象_详细信息_新增", ref param3, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + + } + + // 仅在 data 中返回一条顶层ID结果 + var headerRes = new Response_Data(); + headerRes.Code = string.IsNullOrEmpty(errorMessage) ? 200 : 500; + headerRes.Message = errorMessage; + headerRes.DataId = Scheme.Id; + result.Data.Add(headerRes); + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("点检计划res:", retString); + return retString; + } + /// + /// 检验模板信息接收接口 + /// + /// + /// + /// + public static string QTItemTemplateInfo(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + result.Data = new List(); + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + QTTemplateInfo Scheme = JsonConvert.DeserializeObject(str); + + if (string.IsNullOrWhiteSpace(Scheme.Id)) + { + throw new Exception("参数id值不正确!"); + } + else if (string.IsNullOrWhiteSpace(Scheme.Code)) + { + throw new Exception("参数code值不正确!"); + } + else if (string.IsNullOrWhiteSpace(Scheme.Name)) + { + throw new Exception("参数name值不正确!"); + } + else if (string.IsNullOrWhiteSpace(Scheme.State)) + { + throw new Exception("参数name值不正确!"); + } + else if (Scheme.Type == null) + { + throw new Exception("参数type值不正确!"); + } + + var param = new SqlParameter[] { + new SqlParameter("@Id",Scheme.Id), + new SqlParameter("@Code",Scheme.Code), + new SqlParameter("@Name",Scheme.Name), + new SqlParameter("@Note",VHandle(Scheme.Note)), + new SqlParameter("@ClassIdentifier1",VHandle(Scheme.ClassIdentifier1)), + new SqlParameter("@ClassIdentifier2",VHandle(Scheme.ClassIdentifier2)), + new SqlParameter("@ClassIdentifier3",VHandle(Scheme.ClassIdentifier3)), + new SqlParameter("@ClassIdentifier4",VHandle(Scheme.ClassIdentifier4)), + new SqlParameter("@ClassIdentifier5",VHandle(Scheme.ClassIdentifier5)), + new SqlParameter("@ClassIdentifier6",VHandle(Scheme.ClassIdentifier6)), + new SqlParameter("@ClassIdentifier7",VHandle(Scheme.ClassIdentifier7)), + new SqlParameter("@ClassIdentifier8",VHandle(Scheme.ClassIdentifier8)), + new SqlParameter("@FileData",VHandle(Scheme.FileData)), + new SqlParameter("@State",Scheme.State), + new SqlParameter("@CreateUserId",VHandle(Scheme.CreateUserId)), + new SqlParameter("@CreateUser",VHandle(Scheme.CreateUser)), + new SqlParameter("@CreateTime",VHandle(Scheme.CreateTime)), + new SqlParameter("@LastModifiedUserId",VHandle(Scheme.LastModifiedUserId)), + new SqlParameter("@LastModifiedUser",VHandle(Scheme.LastModifiedUser)), + new SqlParameter("@LastModifiedTime",VHandle(Scheme.LastModifiedTime)), + new SqlParameter("@ProductionWorkCenterId",VHandle(Scheme.ProductionWorkCenter.ProductionWorkCenter)), + new SqlParameter("@ProductionWorkCenterCode",VHandle(Scheme.ProductionWorkCenter.ProductionWorkCenterPpsczxZxbh)), + new SqlParameter("@ProductionWorkCenterName",VHandle(Scheme.ProductionWorkCenter.ProductionWorkCenterNameChs)), + new SqlParameter("@MaterialId",VHandle(Scheme.Material.MaterialId)), + new SqlParameter("@MaterialCode",VHandle(Scheme.Material.MaterialIdCode)), + new SqlParameter("@MaterialName",VHandle(Scheme.Material.MaterialIdNameChs)), + new SqlParameter("@TypeId",VHandle(Scheme.Type.TypeID)), + new SqlParameter("@TypeCode",VHandle(Scheme.Type.TypeCode)), + new SqlParameter("@TypeName",VHandle(Scheme.Type.TypeName)), + new SqlParameter("@ProcedureId",VHandle(Scheme.Process.ProcedureId)), + new SqlParameter("@ProcedureCode",VHandle(Scheme.Process.ProcedureIdPpbzgxGxbh)), + new SqlParameter("@ProcedureName",VHandle(Scheme.Process.ProcedureIdNameChs)), + new SqlParameter("@MaterialTypeId",VHandle(Scheme.MaterialType.MaterialTypeValue)), + new SqlParameter("@MaterialTypeCode",VHandle(Scheme.MaterialType.MaterialTypeCode)), + new SqlParameter("@MaterialTypeName",VHandle(Scheme.MaterialType.MaterialTypeNameChs)), + new SqlParameter("@QualityOrgId",VHandle(Scheme.QualityOrg.QualityOrgValue)), + new SqlParameter("@QualityOrgCode",VHandle(Scheme.QualityOrg.QualityOrgPpzzzlZzbh)), + new SqlParameter("@QualityOrgName",VHandle(Scheme.QualityOrg.QualityOrgNameChs)), + new SqlParameter("@ProductionOrgId",VHandle(Scheme.ProductionOrg.ProductionOrgValue)), + new SqlParameter("@ProductionOrgCode",VHandle(Scheme.ProductionOrg.ProductionOrgPpzzscZzbh)), + new SqlParameter("@ProductionOrgName",VHandle(Scheme.ProductionOrg.ProductionOrgNameChs)) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验模板_新增", ref param, out errorMessage); + + List checkItemList = Scheme.RecordTemplateItems; + for (int i = 0; i < checkItemList.Count; i++) + { + MisDataSaveDate.MOM.RecordTemplateItem checkItem = checkItemList[i]; + if (string.IsNullOrWhiteSpace(checkItem.Id)) + { + throw new Exception("参数recordtemplateitems.id值不正确!"); + } + var param2 = new SqlParameter[] { + new SqlParameter("@Id",checkItem.Id), + new SqlParameter("@TemplateId",Scheme.Id), + new SqlParameter("@LineNum",VHandle(checkItem.LineNum)), + new SqlParameter("@InspectionItemName",VHandle(checkItem.InspectionItemName)), + new SqlParameter("@InspectionItemsType",VHandle(checkItem.InspectionItemsType)), + new SqlParameter("@RequirementDesc",VHandle(checkItem.RequirementDesc)), + new SqlParameter("@DefaultValue",VHandle(checkItem.DefaultValue)), + new SqlParameter("@Note",VHandle(checkItem.Note)), + new SqlParameter("@UploadAttachments",VHandle(checkItem.UploadAttachments)), + new SqlParameter("@InspectKey",VHandle(checkItem.InspectKey)), + new SqlParameter("@MutualInspect",VHandle(checkItem.MutualInspect)), + new SqlParameter("@SpecialInspect",VHandle(checkItem.SpecialInspect)), + new SqlParameter("@SelfInspect",VHandle(checkItem.SelfInspect)), + new SqlParameter("@FirstInspect",VHandle(checkItem.FirstInspect)), + new SqlParameter("@Importance",VHandle(checkItem.Importance)), + new SqlParameter("@RequiredText",VHandle(checkItem.RequiredText)), + new SqlParameter("@AutoAdject",VHandle(checkItem.AutoAdject)), + new SqlParameter("@InspectionItemId",VHandle(checkItem.InspectionItem.inspectionItemId)), + new SqlParameter("@InspectionItemCode",VHandle(checkItem.InspectionItem.InspectionItemIdCode)), + new SqlParameter("@InspectionItemNameChs",VHandle(checkItem.InspectionItem.InspectionItemIdNameChs)), + new SqlParameter("@DefaultResultValueId",VHandle(checkItem.DefaultResult.defaultResultValue)), + new SqlParameter("@DefaultResultValueCode",VHandle(checkItem.DefaultResult.DefaultResultValueCode)), + new SqlParameter("@DefaultResultValueName",VHandle(checkItem.DefaultResult.DefaultResultValueName)), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验模板_检验项目_新增", ref param2, out errorMessage); + + List xmInspectFileList = Scheme.XmInspectFile; + for (int j = 0; j < xmInspectFileList.Count; j++) + { + MisDataSaveDate.MOM.XmInspectFile xmInspectFile = xmInspectFileList[j]; + if (string.IsNullOrWhiteSpace(xmInspectFile.Id)) + { + throw new Exception("参数xm_inspectfile.id值不正确!"); + } + var param3 = new SqlParameter[] { + new SqlParameter("@Id",xmInspectFile.Id), + new SqlParameter("@TemplateId",Scheme.Id), + new SqlParameter("@FileId",VHandle(xmInspectFile.FileId)), + new SqlParameter("@FileName",VHandle(xmInspectFile.FileName)), + new SqlParameter("@FileExt",VHandle(xmInspectFile.FileExt)), + new SqlParameter("@FileSize",VHandle(xmInspectFile.FileSize)), + new SqlParameter("@FileUser",VHandle(xmInspectFile.FileUser)), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验模板_附件表_新增", ref param3, out errorMessage); + } + + } + // 仅在 data 中返回一条顶层ID结果 + var headerRes = new Response_Data(); + headerRes.Code = string.IsNullOrEmpty(errorMessage) ? 200 : 500; + headerRes.Message = errorMessage; + headerRes.DataId = Scheme.Id; + result.Data.Add(headerRes); + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString); + return retString; + } + /// + /// 删除派工订单接口 + /// + /// + /// + /// + public static string DeleteDispatchOrder(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + string errorMessage = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("删除派工订单res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析参数 + var reqData = JsonConvert.DeserializeObject(str); + + string orderID = reqData.orderID?.ToString() ?? ""; + string orderNo = reqData.orderNo?.ToString() ?? ""; + + // 参数验证 + if (string.IsNullOrWhiteSpace(orderID)) + { + throw new Exception("参数orderID值不正确!"); + } + if (string.IsNullOrWhiteSpace(orderNo)) + { + throw new Exception("参数orderNo值不正确!"); + } + + // 检查data数组是否存在 + if (reqData.data == null) + { + throw new Exception("参数data值不正确!"); + } + + // 验证data数组中的参数 + var dataArray = reqData.data; + foreach (var dataItem in dataArray) + { + string taskid = dataItem.taskid?.ToString() ?? ""; + string moid = dataItem.moid?.ToString() ?? ""; + + if (string.IsNullOrWhiteSpace(taskid)) + { + throw new Exception("参数taskid值不正确!"); + } + if (string.IsNullOrWhiteSpace(moid)) + { + throw new Exception("参数moid值不正确!"); + } + } + + // 调用存储过程删除订单(只调用一次) + var param = new SqlParameter[] { + new SqlParameter("@派工单ID", orderID), + new SqlParameter("@派工单号", orderNo) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_删除", ref param, out errorMessage); + + if (!string.IsNullOrEmpty(errorMessage)) + { + throw new Exception(errorMessage); + } + + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("删除派工订单res:", retString); + return retString; + } + /// + /// + /// + /// + /// + /// + public static string QTStandardInfo(string url, [FromBody] JObject jobj) + { + var result = new ApiResponse(); + result.Code = 200; + result.Message = ""; + result.Data = new List(); + string errorMessage = ""; + + if (jobj == null) + { + result.Code = 500; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString1); + return retString1; + } + string str = jobj.ToString(); + //存储日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + try + { + // 解析订单内容,存储数据库,根据实际业务来写 + QTStandardInfo Scheme = JsonConvert.DeserializeObject(str); + + if (string.IsNullOrWhiteSpace(Scheme.Id)) + { + throw new Exception("参数id值不正确!"); + } + var param = new SqlParameter[] { + new SqlParameter("@id",VHandle(Scheme.Id)), + new SqlParameter("@code",VHandle(Scheme.Code)), + new SqlParameter("@name_chs",VHandle(Scheme.NameChs.ToString())), + new SqlParameter("@createdate",VHandle(Scheme.CreateDate.ToString())), + new SqlParameter("@lastmodifiedtime",VHandle(Scheme.LastModifiedTime.ToString())), + new SqlParameter("@note",VHandle(Scheme.Note)), + new SqlParameter("@standardstate",VHandle(Scheme.StandardState)), + new SqlParameter("@materialid",VHandle(Scheme.Material.MaterialId)), + new SqlParameter("@materialid_code",VHandle(Scheme.Material.MaterialIdCode)), + new SqlParameter("@materialid_name_chs",VHandle(Scheme.Material.MaterialIdNameChs)), + new SqlParameter("@procedureid",VHandle(Scheme.Procedure.ProcedureId)), + new SqlParameter("@procedureid_name_chs",VHandle(Scheme.Procedure.ProcedureName)), + new SqlParameter("@procedureid_ppbzgx_gxbh",VHandle(Scheme.Procedure.ProcedureCode)), + new SqlParameter("@standardsortid",VHandle(Scheme.StandardSort.StandardSortId)), + new SqlParameter("@standardsortid_code",VHandle(Scheme.StandardSort.StandardSortCode)), + new SqlParameter("@standardsortid_name_chs",VHandle(Scheme.StandardSort.StandardSortName)), + new SqlParameter("@standardsortid_sortpath",VHandle(Scheme.StandardSort.StandardSortPath)), + new SqlParameter("@standardtypeid",VHandle(Scheme.StandardType.StandardTypeId)), + new SqlParameter("@standardtypeid_code",VHandle(Scheme.StandardType.StandardTypeCode)), + new SqlParameter("@standardtypeid_iseffective",VHandle(Scheme.StandardType.IsEffective)), + new SqlParameter("@standardtypeid_issystem",VHandle(Scheme.StandardType.IsSystem)), + new SqlParameter("@standardtypeid_name_chs",VHandle(Scheme.StandardType.StandardTypeName)), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_新增", ref param, out errorMessage); + + List standardItemList = Scheme.StandardItemList; + for (int i = 0; i < standardItemList.Count; i++) + { + MisDataSaveDate.MOM.StandardItemSource standardItem = standardItemList[i]; + if (string.IsNullOrWhiteSpace(standardItem.itemId)) + { + throw new Exception("参数meqmstandarditemsource.id值不正确!"); + } + var param2 = new SqlParameter[] { + new SqlParameter("@id",VHandle(standardItem.itemId)), + new SqlParameter("@standard_id",VHandle(Scheme.Id)), + new SqlParameter("@standard_code",VHandle(Scheme.Code)), + new SqlParameter("@standard_name_chs",VHandle(Scheme.NameChs)), + new SqlParameter("@createtime",VHandle(standardItem.CreateTime.ToString())), + new SqlParameter("@inspecclassification",VHandle(standardItem.InspectionClassification)), + new SqlParameter("@inspecclassificationname",VHandle(standardItem.InspectionClassificationName)), + new SqlParameter("@note",VHandle(standardItem.Note)), + new SqlParameter("@targetauxdescribe",VHandle(standardItem.TargetAuxDescribe)), + new SqlParameter("@targetdescribe",VHandle(standardItem.TargetDescribe)), + new SqlParameter("@targetno",VHandle(standardItem.TargetNo)), + new SqlParameter("@targetgroup_id",VHandle(standardItem.TargetGroup.TargetGroupId)), + new SqlParameter("@targetgroup_code",VHandle(standardItem.TargetGroup.TargetGroupCode)), + new SqlParameter("@targetgroup_name_chs",VHandle(standardItem.TargetGroup.TargetGroupName)), + new SqlParameter("@target_id",VHandle(standardItem.Target.TargetId)), + new SqlParameter("@target_code",VHandle(standardItem.Target.TargetCode)), + new SqlParameter("@target_name_chs",VHandle(standardItem.Target.TargetName)), + new SqlParameter("@target_note",VHandle(standardItem.Target.TargetNote)), + new SqlParameter("@target_targetgroupid",VHandle(standardItem.Target.TargetGroupId)), + new SqlParameter("@target_targettype",VHandle(standardItem.Target.TargetType)), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_标准项目_新增", ref param2, out errorMessage); + } + List standardValueList = Scheme.StandardValueList; + for (int j = 0; j < standardValueList.Count; j++) + { + MisDataSaveDate.MOM.StandardValueInfo standardValue = standardValueList[j]; + if (string.IsNullOrWhiteSpace(standardValue.Id)) + { + throw new Exception("参数meqmstandardvaluesource.id值不正确!"); + } + var param3 = new SqlParameter[] { + new SqlParameter("@id",VHandle(standardValue.Id)), + new SqlParameter("@standard_id",VHandle(Scheme.Id)), + new SqlParameter("@itemid",VHandle(standardValue.StandardItemId)), + new SqlParameter("@inspectionresultsname",VHandle(standardValue.InspectionResultsName)), + new SqlParameter("@itemvaluetype",VHandle(standardValue.ItemValueType)), + new SqlParameter("@lowercharacter",VHandle(standardValue.LowerCharacter)), + new SqlParameter("@lowerdiffvalue",VHandle(standardValue.LowerDiffValue.ToString())), + new SqlParameter("@lowervalue",VHandle(standardValue.LowerValue.ToString())), + new SqlParameter("@note",VHandle(standardValue.Note)), + new SqlParameter("@standardstrvalue",VHandle(standardValue.StandardStrValue)), + new SqlParameter("@standardvalue",VHandle(standardValue.StandardValue.ToString())), + new SqlParameter("@uppercharacter",VHandle(standardValue.UpperCharacter)), + new SqlParameter("@upperdiffvalue",VHandle(standardValue.UpperDiffValue.ToString())), + new SqlParameter("@uppervalue",VHandle(standardValue.UpperValue.ToString())), + new SqlParameter("@valueno",VHandle(standardValue.ValueNo)), + new SqlParameter("@inspectionresults",VHandle(standardValue.InspectionResults.InspectionResults)), + new SqlParameter("@inspectionresults_code",VHandle(standardValue.InspectionResults.InspectionResultsCode)), + new SqlParameter("@inspectionresults_enable",VHandle(standardValue.InspectionResults.InspectionResultsEnable)), + new SqlParameter("@inspectionresults_name",VHandle(standardValue.InspectionResults.InspectionResultsName)), + new SqlParameter("@targetvalueid_id",VHandle(standardValue.TargetValue.TargetValueId)), + new SqlParameter("@targetvalueid_code",VHandle(standardValue.TargetValue.TargetValueCode)), + new SqlParameter("@targetvalueid_name",VHandle(standardValue.TargetValue.TargetValueName)), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_标准值表_新增", ref param3, out errorMessage); + } + + var param4 = new SqlParameter[] { + new SqlParameter("@检验标准ID",Scheme.Id), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_综合表_新增", ref param4, out errorMessage); + // 仅在 data 中返回一条顶层ID结果 + var headerRes = new Response_Data(); + headerRes.Code = string.IsNullOrEmpty(errorMessage) ? 200 : 500; + headerRes.Message = errorMessage; + headerRes.DataId = Scheme.Id; + result.Data.Add(headerRes); + + } + catch (Exception err) + { + result.Code = 500; + result.Message = err.Message; + } + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString); + return retString; + } + + + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/CALL_Inerface_DataHandle.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/CALL_Inerface_DataHandle.cs new file mode 100644 index 0000000..114b74b --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/CALL_Inerface_DataHandle.cs @@ -0,0 +1,919 @@ +using DataLinkMesWork; +using MesServerWork; +using MisDataFunDll; +using MisDataSaveDate.MOM; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using NPOI.HSSF.Record.Chart; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Security.Policy; +using System.Text; +using System.Threading.Tasks; +using static MisDataSaveDate.Helper.ApiLogHelper; +using MisDataSaveDate.Helper; + + +namespace WebApi +{ + public class CALL_Inerface_DataHandle + { + /// + /// 开工(工序) + /// + /// + /// + /// + public static void CALL_Inerface_JobStart(string OpName, string EngineID, string OrderForm) + { + DataTable IsSendDT = MisDataFun.IOT_ReqData_UpLoad_IsSend(OpName, OrderForm, "完工"); + if (IsSendDT.Rows[0]["result"].ToString() != "1") + { + SaveMesLog("工序完工", IsSendDT.Rows[0]["msg"].ToString(), MesLogType.ERROR); + return; + } + + //查询工单ID、任务ID、工序ID + var param = new SqlParameter[] { + new SqlParameter("@订单号",OrderForm), + new SqlParameter("@工序号",OpName), + new SqlParameter("@工件编号",EngineID) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_JobStart", ref param, out DataTable dt, out string errorMessage); + + if (dt.Rows.Count > 0) + { + JobStart ReqEntity = new JobStart + { + //orderID = dt.Rows[0]["订单ID"].ToString(), + taskID = dt.Rows[0]["任务ID"].ToString(), + processId = dt.Rows[0]["工序ID"].ToString(), + operationTime = DateTime.Now.ToString(), + createTime = DateTime.Now.ToString(), + lastModifiedTime = DateTime.Now.ToString(), + operation = "1" //0取消,1开工 + }; + string lineType = ConfigurationManager.AppSettings["WebapiPostHeader_Systemcode"]; + if (lineType == "MES_ZHDQ_126GLKG") ReqEntity.operatorName = "AC09MES"; + if (lineType == "MES_ZHDQ_126DLQ") ReqEntity.operatorName = "AC06MES"; + if (lineType == "MES_ZHDQ_126ZZ") ReqEntity.operatorName = "AC11MES"; + if (OpName == "AC2401") ReqEntity.operatorName = "AC24MES"; + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_ProcessJobStart"]; + + var result = CALL_Interface_WebAPI.CALL_WebApi_JobStart(InterfaceUrl, ReqEntity); + //保存日志 + SaveLog_Interface_Request("CALL_WebApi_JobStart", 1, JsonConvert.SerializeObject(ReqEntity), out int AID); + SaveLog_Interface_Response(result.ToString(), AID); + + //当上报失败时,保存上报内容至缓存表 + bool reqIsOk = true; + if (result["code"].ToString() != "200") + { + MisDataFun.CallWebApi_FactoryMes_NGRecordSave("CALL_WebApi_JobStart", AID, InterfaceUrl, JsonConvert.SerializeObject(ReqEntity), result.ToString()); + // 设置报工状态 + reqIsOk = false; + SaveMesLog(OpName, $"工序开工上报失败:订单号={OrderForm}, 工件编号={EngineID}, 返回码={result["code"]}, 消息={result["message"]}", MesLogType.ERROR); + } + else + { + SaveMesLog(OpName, $"工序开工上报成功:订单号={OrderForm}, 工件编号={EngineID}", MesLogType.INFO); + } + // 保存报工状态 + MisDataFun.IOT_Data_UpLode_Res_Save(OpName, OrderForm, EngineID, "开工", reqIsOk, result.ToString()); + } + else + { + SaveLog_Interface_Request("CallWebApi_FactoryMes_JobStart", 1, $"查询记录数为0:订单号={OrderForm},工序号={OpName},产品流水号={EngineID}", out int AID); + SaveMesLog(OpName, $"工序开工查询记录数为0:订单号={OrderForm}, 工件编号={EngineID}", MesLogType.WARNING); + } + } + /// + /// 完工 + /// + /// + /// + /// + public static void CALL_Inerface_JobFinished(string OpName, string EngineID, string OrderForm) + { + DataTable IsSendDT = MisDataFun.IOT_ReqData_UpLoad_IsSend(OpName, OrderForm, "完工"); + if (IsSendDT.Rows[0]["result"].ToString() != "1") + { + SaveMesLog("工序完工", IsSendDT.Rows[0]["msg"].ToString(), MesLogType.ERROR); + return; + } + + //查询工单ID、任务ID、工序ID + var param = new SqlParameter[] { + new SqlParameter("@订单号",OrderForm), + new SqlParameter("@工序号",OpName), + new SqlParameter("@工件编号",EngineID) + }; + //DataAccess.ExecuteStoredProcedure("CallWebApi_FactoryMes_JobFinished", ref param, out DataSet ds); + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_JobFinished", ref param, out DataSet ds, out string errorMessage); + //a.[订单ID],[任务ID],[工序ID],[工序名称],1 as 完工数量,@开工时间 as 开工时间,@结束时间 as 结束时间,@节拍 as 节拍,@操作时间 as 最后修改时间 + if (ds.Tables[0].Rows.Count > 0) + { + //1、工单信息 + DataRow orderRow = ds.Tables[0].Rows[0]; + JobFinished ReqEntity = new JobFinished + { + //orderID = orderRow["订单ID"].ToString(), + taskID = orderRow["任务ID"].ToString(), + processNo = orderRow["工序编号"].ToString(), + beat = decimal.Parse(orderRow["节拍"].ToString()), + finishedQuantity = 1.0M,//完工数量 + createTime = orderRow["开工时间"].ToString(), + endTime = orderRow["结束时间"].ToString(), + lastModifiedTime = DateTime.Now.ToString(), + }; + //2、检验信息,根据质量数据和检验模板生成 + if (ds.Tables[1].Rows.Count > 0) + { + var qualityOK = ds.Tables[1].Rows[0]["是否合格"].ToString(); + var OKCount = qualityOK == "1" ? 1.0M : 0.0M; + var NGCount = qualityOK == "1" ? 0.0M : 1.0M; + + List inspInfoList = new List(); + InspectionInfo inspInfo = new InspectionInfo(); + string lineType = ConfigurationManager.AppSettings["WebapiPostHeader_Systemcode"]; + if (lineType == "MES_ZHDQ_126GLKG") inspInfo.inspector = "AC09MES"; + if (lineType == "MES_ZHDQ_126DLQ") inspInfo.inspector = "AC06MES"; + if (lineType == "MES_ZHDQ_126ZZ") inspInfo.inspector = "AC11MES"; + if (OpName == "AC2401") inspInfo.inspector = "AC24MES"; + inspInfo.qualifiedQuantity = OKCount; + inspInfo.unqualifiedQuantity = NGCount; + inspInfo.inspectionTime = DateTime.Now.ToString(); + + List inspectionDetails = new List(); + foreach (DataRow inspRow in ds.Tables[1].Rows) + { + InspectionDetail inspectionDetail = new InspectionDetail(); + var qualityOKStr = ""; + string TagValue = inspRow["TagValue"].ToString(); + if (inspRow["检测结果"].ToString() == "1") qualityOKStr = "合格"; + else qualityOKStr = inspRow["检测结果"].ToString() == "0" ? "未测量" : "不合格"; + + // 合格项目 使用 合格不合格 + if (inspRow["测量单位"]?.ToString() == "OK/NG") + { + switch (TagValue?.ToString()) + { + case ("1"): + TagValue = "合格"; + break; + case ("2"): + TagValue = "不合格"; + break; + case ("0"): + TagValue = "未测量"; + break; + default: + TagValue = "未知"; + break; + } + } + //inspectionDetail.inspectionItemName = inspRow["质检项目名称"].ToString(); + inspectionDetail.inspectionItemName = inspRow["质检项目名称"].ToString(); + inspectionDetail.inspectionValue = TagValue; + inspectionDetail.inspectionResult = qualityOKStr; + inspectionDetail.upperLimitValue = Convert.ToDecimal(inspRow["上限值"]); + inspectionDetail.lowerLimitValue = Convert.ToDecimal(inspRow["下限值"]); + inspectionDetail.standardValue = Convert.ToDecimal(inspRow["理论值"]); + inspectionDetail.upperLimitSymbol = inspRow["测量单位"].ToString(); + inspectionDetail.lowerLimitSymbol = inspRow["测量单位"].ToString(); + inspInfo.templetecode = inspRow["模板编号"].ToString(); + inspectionDetail.inspectionItemID = inspRow["检验项目ID"].ToString(); + inspectionDetail.inspectionItemNo = inspRow["检验项目编号"].ToString(); + inspectionDetails.Add(inspectionDetail); + } + inspInfo.inspectionDetails = inspectionDetails; + inspInfoList.Add(inspInfo); + ReqEntity.inspectionInfo = inspInfoList; + } + + List materialInfoList = new List(); + + //3、消耗物料信息 + if (ds.Tables[2].Rows.Count > 0) + { + foreach (DataRow MRow in ds.Tables[2].Rows) + { + MaterialInfo materialInfo = new MaterialInfo(); + materialInfo.consumedMaterialNo = MRow["物料编号"].ToString(); + materialInfo.type = "0"; + materialInfo.qty = decimal.Parse(MRow["数量"].ToString()); + materialInfo.batchNo = MRow["批次号"].ToString(); + materialInfoList.Add(materialInfo); + } + } + + // 最后再记录一条产出 + MaterialInfo materialInfo2 = new MaterialInfo(); + materialInfo2.consumedMaterialNo = orderRow["产品编号"].ToString(); + materialInfo2.serialNo = EngineID; + materialInfo2.type = "1"; + materialInfo2.qty = 1; + materialInfo2.batchNo = ""; + materialInfoList.Add(materialInfo2); + ReqEntity.materialInfo = materialInfoList; + + //4、工时信息 + List workinghoursList = new List(); + Workinghours workinghours = new Workinghours(); + workinghours.workingHours = Math.Round(ReqEntity.beat / 3600, 2);//将秒换算成小时 + workinghours.quantity = 1.0M; + workinghours.operation = "1";//默认1完工 0 取消完工 1 完工 + workinghoursList.Add(workinghours); + ReqEntity.workinghours = workinghoursList; + + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_ProcessJobFinish"]; + var result = CALL_Interface_WebAPI.CALL_WebApi_JobFinished(InterfaceUrl, ReqEntity); + SaveLog_Interface_Request("CALL_WebApi_JobFinish", 1, JsonConvert.SerializeObject(ReqEntity), out int AID); + SaveLog_Interface_Response(result.ToString(), AID); + bool reqIsOk = true; + //当上报失败时,保存上报内容至缓存表 + if (result["code"].ToString() != "200") + { + MisDataFun.CallWebApi_FactoryMes_NGRecordSave("CALL_WebApi_JobFinished", AID, InterfaceUrl, JsonConvert.SerializeObject(ReqEntity), result.ToString()); + // 设置报工状态 + reqIsOk = false; + SaveMesLog(OpName, $"工序完工上报失败:订单号={OrderForm}, 工件编号={EngineID}, 返回码={result["code"]}, 消息={result["message"]}", MesLogType.ERROR); + } + else + { + SaveMesLog(OpName, $"工序完工上报成功:订单号={OrderForm}, 工件编号={EngineID}", MesLogType.INFO); + } + // 保存报工状态 + MisDataFun.IOT_Data_UpLode_Res_Save(OpName, OrderForm, EngineID, "完工", reqIsOk, result.ToString()); + } + else + { + SaveLog_Interface_Request("CallWebApi_FactoryMes_JobFinish", 1, $"查询记录数为0:订单号={OrderForm},工序号={OpName},产品流水号={EngineID}", out int AID); + SaveMesLog(OpName, $"工序完工查询记录数为0:订单号={OrderForm}, 工件编号={EngineID}", MesLogType.WARNING); + } + } + /// + /// 产线报警信息上报 + /// + /// + /// + /// + /// + public static void CALL_Inerface_DeviceAlarm(string OpName, string TagID, string alarmtype, string alarmContext) + { + MIS_BASE.Read_EngineGetOver_PLC(OpName, out bool isWorking); + if (!isWorking) return; // 没有产品 则不上传数据 + + //查询工单ID、任务ID、工序ID + var param = new SqlParameter[] { + new SqlParameter("@工序号",OpName) + }; + string orderID = ""; + string taskID = ""; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_DeviceAlarm", ref param, out DataTable dt, out string errMessage); + if (dt.Rows.Count > 0) + { + orderID = dt.Rows[0]["订单ID"].ToString(); + taskID = dt.Rows[0]["任务ID"].ToString(); + } + // 非工厂下发的订单产品,不上传报警 + if (string.IsNullOrEmpty(orderID) || string.IsNullOrEmpty(taskID)) return; + + DeviceAlarm ReqEntity = new DeviceAlarm + { + id = Guid.NewGuid().ToString(), + orderID = orderID, + taskID = taskID, + processNo = OpName, + alarmCode = TagID, + deviceInfo = alarmContext, + exceptionInfo = alarmContext, + exceptionType = alarmtype, + createTime = DateTime.Now.ToString(), + lastModifiedTime = DateTime.Now.ToString() + }; + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_AlarmInfoUpload"]; + var result = CALL_Interface_WebAPI.CALL_WebApi_DeviceAlarm(InterfaceUrl, ReqEntity); + + SaveLog_Interface_Request("CALL_WebApi_DeviceAlarm", 1, JsonConvert.SerializeObject(ReqEntity), out int AID); + SaveLog_Interface_Response(result.ToString(), AID); + //当上报失败时,保存上报内容至缓存表 + if (result["code"].ToString() != "200") + { + MisDataFun.CallWebApi_FactoryMes_NGRecordSave("CALL_WebApi_DeviceAlarm", AID, InterfaceUrl, JsonConvert.SerializeObject(ReqEntity), result.ToString()); + SaveMesLog(OpName, $"设备报警上报失败:报警代码={TagID}, 报警内容={alarmContext}, 返回码={result["code"]}, 消息={result["message"]}", MesLogType.ERROR); + } + else + { + SaveMesLog(OpName, $"设备报警上报成功:报警代码={TagID}, 报警类型={alarmtype}", MesLogType.INFO); + } + + } + /// + /// 叫料、退料、退空、转序、下空、上空、点对点 + /// + /// + /// 1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + /// + /// 叫料、退料、退空、转序、下空、上空、点对点 + /// + /// + /// 1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + public static bool CALL_Inerface_CallMaterial(string PositionCode, string deliveryType) + { + // 配送类型映射:1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + Dictionary deliveryTypeMap = new Dictionary + { + { "1", "退托盘" }, + { "2", "叫料" }, + { "3", "送料" }, + { "4", "转序" }, + { "5", "下空" }, + { "6", "上空" }, + { "7", "点对点" } + }; + string deliveryTypeName = deliveryTypeMap.ContainsKey(deliveryType) ? deliveryTypeMap[deliveryType] : "未知"; + + //查询工单ID、任务ID、工序ID + var param = new SqlParameter[] { + new SqlParameter("@位置号",PositionCode), + new SqlParameter("@叫料类型",deliveryType) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_CallMaterial", ref param, out DataTable dt, out string errMessage); + if (dt.Rows.Count > 0) + { + string containerNo = ""; + if (deliveryType == "1") + { + // 获取器具号(318) + containerNo = MIS_BASE.ReadPLC(318, PositionCode).ToString(); + } + + var callMaterialCode = Guid.NewGuid().ToString(); + MaterialSend ReqEntity = new MaterialSend + { + code = callMaterialCode, + orderID = dt.Rows[0]["派工单ID"].ToString(), + taskID = dt.Rows[0]["taskId"].ToString(), + sequenceNo = dt.Rows[0]["顺序号"].ToString(), + deliveryType = deliveryType, + processStep = dt.Rows[0]["工序号"].ToString(), + startLocation = (deliveryType == "1" || deliveryType == "3" || deliveryType == "4" || deliveryType == "5" || deliveryType == "7") ? PositionCode : "", + endLocation = (deliveryType == "2" || deliveryType == "6") ? PositionCode : "", + material = dt.Rows[0]["物料号"].ToString(), + quantity = Convert.ToInt32(dt.Rows[0]["数量"]), + trayNumber = containerNo, //dt.Rows[0]["托盘号"].ToString(), + prodline = "", // 产线 + workstation = "", + workshop = "", + customerid = "", + creator = "Auto", + createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + lastModifiedTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_CallMaterial"]; + SaveLog_Interface_Request("CallWebApiUrl_CallMaterial", 1, JsonConvert.SerializeObject(ReqEntity), out int AID); + var result = CALL_Interface_WebAPI.CALL_WebApi_CallMaterial(InterfaceUrl, ReqEntity); + SaveLog_Interface_Response(result.ToString(), AID); + //当上报失败时,保存上报内容至缓存表 + if (result["code"].ToString() != "200") + { + var param1 = new SqlParameter[] { + new SqlParameter("@接口名称","CallWebApiUrl_CallMaterial"), + new SqlParameter("@接口地址",InterfaceUrl), + new SqlParameter("@请求内容",JsonConvert.SerializeObject(ReqEntity)), + new SqlParameter("@响应内容",result.ToString()) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_NGRecordSave", ref param1, out string errMessage1); + SaveMesLog(PositionCode, $"叫料上报失败:配送类型={deliveryType}({deliveryTypeName}), 起始位置={ReqEntity.startLocation}, 终点位置={ReqEntity.endLocation}, 物料号={ReqEntity.material}, 叫料任务号={callMaterialCode}, 返回码={result["code"]}, 消息={result["message"]}", MesLogType.ERROR); + return false; + } + else + { + SaveMesLog(PositionCode, $"叫料上报成功:配送类型={deliveryType}({deliveryTypeName}), 起始位置={ReqEntity.startLocation}, 终点位置={ReqEntity.endLocation}, 物料号={ReqEntity.material}, 叫料任务号={callMaterialCode}", MesLogType.INFO); + } + MisDataFun.Location_MIS_MOBY_Insert(PositionCode, "器具号", ReqEntity.trayNumber); + MisDataFun.Location_MIS_MOBY_Insert(PositionCode, "叫料任务号", callMaterialCode); + MisDataFun.Location_MIS_MOBY_Insert(PositionCode, "派工单ID", dt.Rows[0]["派工单ID"].ToString()); + MisDataFun.Location_MIS_MOBY_Insert(PositionCode, "派工任务ID", dt.Rows[0]["taskId"].ToString()); + MisDataFun.Location_MIS_MOBY_Insert(PositionCode, "订单号", dt.Rows[0]["订单号"].ToString()); + + var param2 = new SqlParameter[] { + new SqlParameter("@叫料任务号",ReqEntity.code), + new SqlParameter("@派工单ID",ReqEntity.orderID), + new SqlParameter("@派工任务ID",ReqEntity.taskID), + new SqlParameter("@顺序号",ReqEntity.sequenceNo), + new SqlParameter("@配送类型",ReqEntity.deliveryType), + new SqlParameter("@工序",ReqEntity.processStep), + new SqlParameter("@起始位置编号",ReqEntity.startLocation), + new SqlParameter("@终点位置编号",ReqEntity.endLocation), + new SqlParameter("@配送物料编码",ReqEntity.material), + new SqlParameter("@配送数量",ReqEntity.quantity), + new SqlParameter("@器具号",ReqEntity.trayNumber), + new SqlParameter("@创建人编号",ReqEntity.creator), + new SqlParameter("@创建时间",ReqEntity.createTime), + new SqlParameter("@最后修改时间",ReqEntity.lastModifiedTime), + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_叫料记录_增加", ref param2, out string errMessage2); + } + else + { + SaveLog_Interface_Request("CallWebApi_FactoryMes_DeviceAlarm", 1, $"查询记录数为0:工序号={PositionCode}", out int AID); + SaveMesLog(PositionCode, $"叫料查询记录数为0:配送类型={deliveryType}({deliveryTypeName})", MesLogType.WARNING); + return false; + } + return true; + } + + /// + /// 物料配送确认 + /// + /// 位置号 + /// 器具号 + public static bool CALL_Inerface_MaterialConfirm(string PositionCode, string containerNo) + { + try + { + // 调用存储过程获取叫料任务号和派工任务ID + var param = new SqlParameter[] { + new SqlParameter("@位置号", PositionCode), + new SqlParameter("@器具号", containerNo) + }; + + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_叫料记录_到料确认", ref param, out DataTable dtResult, out string errMessage); + + if (dtResult == null || dtResult.Rows.Count == 0) + { + SaveLog_Interface_Request("CallWebApiUrl_MaterialInfoConfirm", 0, + $"获取叫料记录失败:位置号={PositionCode}, 器具号={containerNo}, 错误信息={errMessage}", out int errorAID); + SaveMesLog(PositionCode, $"物料配送确认-获取叫料记录失败:器具号={containerNo}, 错误={errMessage}", MesLogType.ERROR); + return false; + } + + // 获取存储过程返回的数据 + string tackcode = dtResult.Rows[0]["叫料任务号"].ToString(); + string taskID = dtResult.Rows[0]["派工任务ID"].ToString(); + + MaterialConfirm materialConfirm = new MaterialConfirm + { + tackcode = tackcode, // 从存储过程获取的配送任务号 + orderID = "", // 派工单ID + taskID = taskID, // 从存储过程获取的派工任务ID + processId = PositionCode, // 工序ID + containerNo = containerNo // 器具号 + }; + + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_MaterialInfoConfirm"]; + var result = CALL_Interface_WebAPI.CALL_WebApi_MaterialConfirm(InterfaceUrl, materialConfirm); + SaveLog_Interface_Request("CallWebApiUrl_MaterialInfoConfirm", 1, JsonConvert.SerializeObject(materialConfirm), out int AID); + SaveLog_Interface_Response(result.ToString(), AID); + + //当上报失败时,保存上报内容至缓存表 + if (result["code"].ToString() != "200") + { + var param1 = new SqlParameter[] { + new SqlParameter("@接口名称","CallWebApiUrl_MaterialInfoConfirm"), + new SqlParameter("@接口地址",InterfaceUrl), + new SqlParameter("@请求内容",JsonConvert.SerializeObject(materialConfirm)), + new SqlParameter("@响应内容",result.ToString()) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_NGRecordSave", ref param1, out string errMessage1); + SaveMesLog(PositionCode, $"物料配送确认上报失败:器具号={containerNo}, 叫料任务号={tackcode}, 返回码={result["code"]}, 消息={result["message"]}", MesLogType.ERROR); + return false; + } + SaveMesLog(PositionCode, $"物料配送确认上报成功:器具号={containerNo}, 叫料任务号={tackcode}", MesLogType.INFO); + return true; + } + catch (Exception ex) + { + SaveLog_Interface_Request("CallWebApiUrl_MaterialInfoConfirm", 0, + $"物料配送确认异常:{ex.Message}", out int exceptionAID); + SaveMesLog("MOM", $"物料配送确认异常:位置号={PositionCode}, 器具号={containerNo}, 异常={ex.Message}", MesLogType.ERROR); + return false; + } + } + + + /// + /// 器具信息查询 + /// + /// 位置号 + /// 托盘号 + /// 器具信息查询结果 + public static DeviceInfoResponse CALL_Inerface_DeviceInfoQuery(string PositionCode, string containerNo) + { + // 通过位置号查询任务号 + var param = new SqlParameter[] { + new SqlParameter("@位置号",PositionCode) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_叫料记录_器具查询", ref param, out DataTable dt, out string errMessage); + + if (dt.Rows.Count > 0) + { + string taskId = dt.Rows[0]["任务号"].ToString(); + + DeviceInfo deviceInfo = new DeviceInfo + { + id = taskId, // 使用查询出的任务号 + callcode = "", + containerNo = containerNo + }; + + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_DeviceInfoQuery"]; + SaveLog_Interface_Request("CallWebApiUrl_DeviceInfoQuery", 1, JsonConvert.SerializeObject(deviceInfo), out int AID); + var result = CALL_Interface_WebAPI.CALL_WebApi_DeviceInfoQuery(InterfaceUrl, deviceInfo); + SaveLog_Interface_Response(result.ToString(), AID); + + // 解析返回结果 + DeviceInfoResponse response = JsonConvert.DeserializeObject(result.ToString()); + + //当上报失败时,保存上报内容至缓存表 + if (result["code"].ToString() != "200") + { + var param1 = new SqlParameter[] { + new SqlParameter("@接口名称","CallWebApiUrl_DeviceInfoQuery"), + new SqlParameter("@接口地址",InterfaceUrl), + new SqlParameter("@请求内容",JsonConvert.SerializeObject(deviceInfo)), + new SqlParameter("@响应内容",result.ToString()) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_NGRecordSave", ref param1, out string errMessage1); + SaveMesLog(PositionCode, $"器具信息查询失败:位置号={PositionCode}, 器具号={containerNo}, 任务号={taskId}, 返回码={result["code"]}, 消息={result["message"]}", MesLogType.ERROR); + } + else + { + SaveMesLog(PositionCode, $"器具信息查询成功:位置号={PositionCode}, 器具号={containerNo}, 任务号={taskId}", MesLogType.INFO); + } + + return response; + } + else + { + SaveLog_Interface_Request("CALL_Inerface_DeviceInfoQuery", 1, $"查询记录数为0:位置号={PositionCode}", out int AID); + + // 返回空结果 + return new DeviceInfoResponse + { + code = 404, + message = $"查询记录数为0:位置号={PositionCode}", + data = null + }; + } + } + + /// + /// 物料转序 + /// + /// 起始位置编号 + /// 终点位置编号 + /// 任务模板编号 + /// 派工任务id + /// 搬运类型:1:搬运容器,2:搬运货架 + /// 载具类型:0-空;1-满 + /// 返回调用结果 JObject,包含 code 和 message + public static JObject CALL_Inerface_MaterialTransfer(string startPositionCode, string endPositionCode, string taskType = "211", string dataid = "", string moveTaskType = "2", string vehicleStatus = "1") + { + JObject response = new JObject(); + try + { + // 构建位置列表 + List positionList = new List + { + new PositionInfo + { + type = "00", // 工位 + positionCode = startPositionCode + }, + new PositionInfo + { + type = "00", // 工位 + positionCode = endPositionCode + } + }; + + MaterialTransfer ReqEntity = new MaterialTransfer + { + reqCode = Guid.NewGuid().ToString(), + reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + clientCode = "126GIS", + taskType = taskType, + moveTaskType = moveTaskType, + vehicleStatus = vehicleStatus, + positionCodeList = positionList, + dataid = dataid + }; + + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_MaterialTransfer"]; + SaveLog_Interface_Request("CALL_WebApi_MaterialTransfer", 1, JsonConvert.SerializeObject(ReqEntity), out int AID); + var result = CALL_Interface_WebAPI.CALL_WebApi_MaterialTransfer(InterfaceUrl, ReqEntity); + SaveLog_Interface_Response(result.ToString(), AID); + + //当上报失败时,保存上报内容至缓存表 + if (result["code"].ToString() != "200") + { + var param1 = new SqlParameter[] { + new SqlParameter("@接口名称","CALL_WebApi_MaterialTransfer"), + new SqlParameter("@接口地址",InterfaceUrl), + new SqlParameter("@请求内容",JsonConvert.SerializeObject(ReqEntity)), + new SqlParameter("@响应内容",result.ToString()) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("CallWebApi_FactoryMes_NGRecordSave", ref param1, out string errMessage1); + + string errorMsg = result["message"]?.ToString() ?? "未知错误"; + SaveMesLog("MOM", $"物料转序上报失败:起点={startPositionCode}终点={endPositionCode}, 返回码={result["code"]}, 消息={errorMsg}", MesLogType.ERROR); + + response["code"] = result["code"]; + response["message"] = errorMsg; + } + else + { + SaveMesLog("MOM", $"物料转序上报成功:起点={startPositionCode}终点={endPositionCode}", MesLogType.INFO); + response["code"] = 200; + response["message"] = "AGV调度成功"; + } + } + catch (Exception ex) + { + SaveLog_Interface_Request("CALL_WebApi_MaterialTransfer", 0, + $"物料转序异常:{ex.Message}", out int exceptionAID); + SaveMesLog("MOM", $"物料转序异常:起点={startPositionCode}终点={endPositionCode}, 异常={ex.Message}", MesLogType.ERROR); + + response["code"] = 500; + response["message"] = $"物料转序异常:{ex.Message}"; + } + return response; + } + + /// + /// 点检结果上传 + /// + /// 点检结果实体 + /// 工厂MES响应 + public static JObject CALL_Inerface_SpotCheckResultUpload(SpotCheckResult reqEntity) + { + try + { + if (reqEntity == null) + { + SaveMesLog("MOM", "点检结果上传失败:点检结果不能为空", MesLogType.ERROR); + throw new ArgumentNullException(nameof(reqEntity), "点检结果不能为空"); + } + + if (reqEntity.ResultData == null || reqEntity.ResultData.Count == 0) + { + SaveMesLog("MOM", "点检结果上传失败:点检结果缺少明细数据", MesLogType.ERROR); + throw new Exception("点检结果缺少明细数据"); + } + + string interfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_SpotCheckRecordCreate"]; + if (string.IsNullOrWhiteSpace(interfaceUrl)) + { + SaveMesLog("MOM", "点检结果上传失败:未配置 CallWebApiUrl_SpotCheckRecordCreate", MesLogType.ERROR); + throw new Exception("未配置 CallWebApiUrl_SpotCheckRecordCreate"); + } + + string requestName = "CALL_WebApi_SpotCheckRecordCreate"; + string requestBody = JsonConvert.SerializeObject(reqEntity); + SaveLog_Interface_Request(requestName, 1, requestBody, out int AID); + + var result = CALL_Interface_WebAPI.CALL_WebApi_SpotCheckRecord(interfaceUrl, reqEntity); + SaveLog_Interface_Response(result.ToString(), AID); + + var codeToken = result["code"]; + if (codeToken == null || codeToken.ToString() != "200") + { + MisDataFun.CallWebApi_FactoryMes_NGRecordSave(requestName, AID, interfaceUrl, requestBody, result.ToString()); + + string errorMsg = result["message"]?.ToString() ?? "未知错误"; + string code = codeToken?.ToString() ?? "null"; + SaveMesLog("MOM", $"点检结果上报失败:返回码={code}, 消息={errorMsg}", MesLogType.ERROR); + } + else + { + SaveMesLog("MOM", "点检结果上报成功", MesLogType.INFO); + } + + return result; + } + catch (Exception ex) + { + SaveMesLog("MOM", $"点检结果上传异常:{ex.Message}", MesLogType.ERROR); + throw; + } + } + + //#region 西开 AGV 发送方法 (MES -> AGV) + + ///// + ///// 下发任务给 AGV + ///// MES 调用 AGV 接口,下发搬运任务 + ///// + ///// 任务唯一ID(由调用方生成,如 Guid) + ///// 抬货点/取货位置 + ///// 卸货点/目标位置 + ///// 产品编码/物料编码 + ///// AGV 响应结果 + //public static JObject CALL_ZZAGV_AddTask(string requestTaskId, string startPosition, string endPosition, string materialCode) + //{ + // JObject response = new JObject(); + // try + // { + // // 参数校验 + // if (string.IsNullOrWhiteSpace(requestTaskId)) + // { + // requestTaskId = Guid.NewGuid().ToString(); + // } + + // if (string.IsNullOrWhiteSpace(startPosition)) + // { + // throw new ArgumentException("抬货点(startPosition)不能为空"); + // } + + // if (string.IsNullOrWhiteSpace(endPosition)) + // { + // throw new ArgumentException("卸货点(endPosition)不能为空"); + // } + + // // 构建请求实体 + // var reqEntity = new MisDataSaveDate.ZZAGV_AddTaskRequest + // { + // requestTaskId = requestTaskId, + // startPosition = startPosition, + // endPosition = endPosition, + // materialCode = materialCode ?? "" + // }; + + // // 获取 AGV 接口地址 + // string baseUrl = ConfigurationManager.AppSettings["ZZAGV_BaseUrl"]; + // if (string.IsNullOrWhiteSpace(baseUrl)) + // { + // throw new Exception("未配置 ZZAGV_BaseUrl"); + // } + // string interfaceUrl = baseUrl.TrimEnd('/') + "/api/mes/AddTaskFromMes"; + + // string jsonStr = JsonConvert.SerializeObject(reqEntity); + // SaveLog_Interface_Request("CALL_ZZAGV_AddTask", 1, jsonStr, out int AID); + + // // 发送 HTTP 请求 + // string resultStr = ""; + // try + // { + // resultStr = WebApi.Post.Post_Auto(interfaceUrl, jsonStr); + // } + // catch (Exception httpEx) + // { + // SaveMesLog("ZZAGV", $"下发任务HTTP请求异常:起点={startPosition}, 终点={endPosition}, 异常={httpEx.Message}", MesLogType.ERROR); + // SaveLog_Interface_Response($"HTTP请求异常:{httpEx.Message}", AID); + // response["code"] = 500; + // response["desc"] = $"HTTP请求异常:{httpEx.Message}"; + // response["success"] = false; + // return response; + // } + + // SaveLog_Interface_Response(resultStr, AID); + + // // 解析响应 + // if (string.IsNullOrWhiteSpace(resultStr)) + // { + // SaveMesLog("ZZAGV", "下发任务失败:AGV返回空响应", MesLogType.ERROR); + // response["code"] = 500; + // response["desc"] = "AGV返回空响应"; + // response["success"] = false; + // return response; + // } + + // response = JObject.Parse(resultStr); + + // // 检查返回码 + // string code = response["code"]?.ToString(); + // if (code != "0") + // { + // string desc = response["desc"]?.ToString() ?? "未知错误"; + // SaveMesLog("ZZAGV", $"下发任务失败:任务ID={requestTaskId}, 起点={startPosition}, 终点={endPosition}, 返回码={code}, 消息={desc}", MesLogType.ERROR); + + // // 保存失败记录 + // MisDataFun.CallWebApi_FactoryMes_NGRecordSave("CALL_ZZAGV_AddTask", AID, interfaceUrl, jsonStr, resultStr); + // } + // else + // { + // SaveMesLog("ZZAGV", $"下发任务成功:任务ID={requestTaskId}, 起点={startPosition}, 终点={endPosition}", MesLogType.INFO); + // } + // } + // catch (Exception ex) + // { + // SaveMesLog("ZZAGV", $"下发任务异常:{ex.Message}", MesLogType.ERROR); + // response["code"] = 500; + // response["desc"] = $"异常:{ex.Message}"; + // response["success"] = false; + // } + + // return response; + //} + + ///// + ///// 放行 AGV + ///// MES 调用 AGV 接口,告知 AGV 可以离开当前位置 + ///// + ///// 请求ID + ///// 当前位置编号 + ///// AGV 响应结果 + //public static JObject CALL_ZZAGV_AllowLeave(string requestId, string position) + //{ + // JObject response = new JObject(); + // try + // { + // // 参数校验 + // if (string.IsNullOrWhiteSpace(requestId)) + // { + // requestId = Guid.NewGuid().ToString(); + // } + + // if (string.IsNullOrWhiteSpace(position)) + // { + // throw new ArgumentException("位置编号(position)不能为空"); + // } + + // // 构建请求实体 + // var reqEntity = new MisDataSaveDate.ZZAGV_AllowLeaveRequest + // { + // requestId = requestId, + // position = position, + // allowLeave = 1 + // }; + + // // 获取 AGV 接口地址 + // string baseUrl = ConfigurationManager.AppSettings["ZZAGV_BaseUrl"]; + // if (string.IsNullOrWhiteSpace(baseUrl)) + // { + // throw new Exception("未配置 ZZAGV_BaseUrl"); + // } + // string interfaceUrl = baseUrl.TrimEnd('/') + "/api/mes/AllowLeave"; + + // string jsonStr = JsonConvert.SerializeObject(reqEntity); + // SaveLog_Interface_Request("CALL_ZZAGV_AllowLeave", 1, jsonStr, out int AID); + + // // 发送 HTTP 请求 + // string resultStr = ""; + // try + // { + // resultStr = WebApi.Post.Post_Auto(interfaceUrl, jsonStr); + // } + // catch (Exception httpEx) + // { + // SaveMesLog("ZZAGV", $"放行AGV HTTP请求异常:位置={position}, 异常={httpEx.Message}", MesLogType.ERROR); + // SaveLog_Interface_Response($"HTTP请求异常:{httpEx.Message}", AID); + // response["code"] = 500; + // response["desc"] = $"HTTP请求异常:{httpEx.Message}"; + // response["success"] = false; + // return response; + // } + + // SaveLog_Interface_Response(resultStr, AID); + + // // 解析响应 + // if (string.IsNullOrWhiteSpace(resultStr)) + // { + // SaveMesLog("ZZAGV", "放行AGV失败:AGV返回空响应", MesLogType.ERROR); + // response["code"] = 500; + // response["desc"] = "AGV返回空响应"; + // response["success"] = false; + // return response; + // } + + // response = JObject.Parse(resultStr); + + // // 检查返回码 + // string code = response["code"]?.ToString(); + // if (code != "0") + // { + // string desc = response["desc"]?.ToString() ?? "未知错误"; + // SaveMesLog("ZZAGV", $"放行AGV失败:请求ID={requestId}, 位置={position}, 返回码={code}, 消息={desc}", MesLogType.ERROR); + + // // 保存失败记录 + // MisDataFun.CallWebApi_FactoryMes_NGRecordSave("CALL_ZZAGV_AllowLeave", AID, interfaceUrl, jsonStr, resultStr); + // } + // else + // { + // SaveMesLog("ZZAGV", $"放行AGV成功:请求ID={requestId}, 位置={position}", MesLogType.INFO); + // } + // } + // catch (Exception ex) + // { + // SaveMesLog("ZZAGV", $"放行AGV异常:{ex.Message}", MesLogType.ERROR); + // response["code"] = 500; + // response["desc"] = $"异常:{ex.Message}"; + // response["success"] = false; + // } + + // return response; + //} + + //#endregion + } +} + diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/CALL_Interface_WebAPI.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/CALL_Interface_WebAPI.cs new file mode 100644 index 0000000..5acf8ca --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/FactoryMES/CALL_Interface_WebAPI.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using Newtonsoft.Json.Linq; +using System.Security.Cryptography; +using MisDataSaveDate.MOM; +using Newtonsoft.Json; +using System.Configuration; +using ExternalDataSync; +namespace WebApi +{ + public class CALL_Interface_WebAPI + { + + public static JObject CALL_WebApi_CallMaterial(string InterfaceUrl, MaterialSend entity_send) + { + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_CallMaterial"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_DeviceInfoQuery(string InterfaceUrl, DeviceInfo entity_send) + { + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_DeviceInfoQuery"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_MaterialConfirm(string InterfaceUrl, MaterialConfirm entity_send) + { + //var InterfaceUrl = CallWebApiUrl_MaterialInfoConfirm; + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_MaterialInfoConfirm"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_JobStart(string InterfaceUrl, JobStart entity_send) + { + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_ProcessJobStart"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_DeviceAlarm(string InterfaceUrl, DeviceAlarm entity_send) + { + //var InterfaceUrl = CallWebApiUrl_AlarmInfoUpload; + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_AlarmInfoUpload"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_JobFinished(string InterfaceUrl, JobFinished entity_send) + { + //var InterfaceUrl = CallWebApiUrl_ProcessJobFinish; + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_ProcessJobFinish"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_FinishedReport(TaskFinish entity_send) + { + //var InterfaceUrl = CallWebApiUrl_TaskFinishedReport; + string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_TaskFinishedReport"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_MaterialTransfer(string InterfaceUrl, MaterialTransfer entity_send) + { + //string InterfaceUrl = ConfigurationManager.AppSettings["CallWebApiUrl_MaterialTransfer"]; + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject CALL_WebApi_SpotCheckRecord(string InterfaceUrl, SpotCheckResult entity_send) + { + string bodydata = JsonConvert.SerializeObject(entity_send); + return Post_WebAPI(InterfaceUrl, bodydata); + } + public static JObject Post_WebAPI(string WebAPI_Url, string m_msg) + { + try + { + if (StateVariable.online_Mes) + { + return JsonConvert.DeserializeObject(WebApi.Post.Post_XK(WebAPI_Url, m_msg)); + } + else + { + return JObject.Parse("{\"code\":404,\"离线工作模式,请求暂存。\":\"\",\"data\":{}}"); + } + } + catch (Exception ex) + { + return new JObject { { "code", 500 }, { "Message", ex.Message }, { "data", new JObject() } }; + } + + } + } + +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Helper/ApiLogHelper.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Helper/ApiLogHelper.cs new file mode 100644 index 0000000..2661454 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Helper/ApiLogHelper.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate.Helper +{ + /// + /// MES系统日志类型枚举 + /// + public enum MesLogType + { + /// + /// 信息日志 + /// + INFO, + /// + /// 警告日志 + /// + WARNING, + /// + /// 错误日志 + /// + ERROR + } + public class ApiLogHelper + { + /// + /// 验证属性值是否有效 + /// + /// + /// + /// + /// + public static bool ValidateProperty(object value, string fieldName, out string errorMessage) + { + if (value == null || value.ToString() == "") + { + errorMessage = $"参数{fieldName}值格式不正确"; + return false; + } + + errorMessage = string.Empty; // 无错误 + return true; + } + /// + /// 非必填项Null值处理 + /// + /// + /// + /// + /// + public static string VHandle(string value) + { + return value == null ? "" : value; + } + + /// + /// + /// + /// + /// 1. 主动调用接口 2. 被调用接口 + /// + /// + /// + public static void SaveLog_Interface_Request(string url, int type, string context, out int AID) + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var param1 = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",type), + new SqlParameter("@请求内容",context), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param1, out DataTable dt, out string errorMessage); + AID = int.Parse(dt.Rows[0][0].ToString()); + } + /// + /// + /// + /// + /// + public static void SaveLog_Interface_Response(string context, int AID) + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param1 = new SqlParameter[] { + new SqlParameter("@响应时间",CreateTime), + new SqlParameter("@响应内容",context), + new SqlParameter("@AID",AID) + }; + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("接口_IOT接口交互日志_响应记录", ref param1, out string errorMessage); + } + + + /// + /// 保存MES系统日志到数据库 + /// + /// 工位号/模块名称 + /// 日志内容 + /// 日志类型:INFO/WARNING/ERROR + public static void SaveMesLog(string opName, string logText, MesLogType logType = MesLogType.INFO) + { + string logTypeStr = logType.ToString(); + var param1 = new SqlParameter[] { + new SqlParameter("@工位号", opName), + new SqlParameter("@日志类型", logTypeStr), + new SqlParameter("@日志文本", logText), + }; + + try + { + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MES_系统日志_增加", ref param1, out DataTable dt, out string errorMessage); + + // 同时记录到Log4Net + if (logType == MesLogType.ERROR) + { + MyLog4Net.MyLogHelper.Error("MesLog", $"[{opName}] {logText}"); + } + else if (logType == MesLogType.WARNING) + { + MyLog4Net.MyLogHelper.Error("MesLog", $"[{opName}] {logText}"); + } + else + { + MyLog4Net.MyLogHelper.Info("MesLog", $"[{opName}] {logText}"); + } + + if (!string.IsNullOrEmpty(errorMessage)) + { + MyLog4Net.MyLogHelper.Error("SaveMesLog", $"保存日志到数据库失败:{errorMessage}"); + } + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error("SaveMesLog", $"保存日志异常:{ex.Message}"); + } + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Other/CheckDate.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Other/CheckDate.cs new file mode 100644 index 0000000..41c8673 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Other/CheckDate.cs @@ -0,0 +1,361 @@ +using MisDataSaveDate; +using MisDataSaveDate.MOM; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http; +using DataLinkMesWork2; +using static MisDataSaveDate.Helper.ApiLogHelper; +using MisDataFunDll; + +namespace ExternalDataSync.MOM +{ + public class Other + { + public static string OnlineCheckData(string url, [FromBody] JObject jobj) + { + var result = new OnlineCheckDataResponse(); + result.Code = "200"; + result.Message = ""; + result.MsgId = ""; + result.Data = ""; + + string errorMessage = string.Empty; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("接收检测数据_res", retString1); + return retString1; + } + + string str = jobj.ToString(); + // 存储接口请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject(str); + if (onlineCheckData == null) + { + throw new Exception("请求体反序列化失败!"); + } + if (string.IsNullOrWhiteSpace(onlineCheckData.MsgId)) + { + throw new Exception("参数MsgId为空!"); + } + // 设置响应的MsgId(带回请求编号) + result.MsgId = onlineCheckData.MsgId; + + if (string.IsNullOrWhiteSpace(onlineCheckData.OpCode)) + { + throw new Exception("参数OpCode为空!"); + } + if (string.IsNullOrWhiteSpace(onlineCheckData.ProductionCode)) + { + throw new Exception("参数ProductionCode为空!"); + } + if (string.IsNullOrWhiteSpace(onlineCheckData.ScanTime)) + { + throw new Exception("参数ScanTime为空!"); + } + if (string.IsNullOrWhiteSpace(onlineCheckData.CheckPerson)) + { + throw new Exception("参数CheckPerson为空!"); + } + + string opName = onlineCheckData.OpCode; + int idTagCf = 0; + + SqlParameter[] paramIndex = new SqlParameter[8]; + paramIndex[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode); + paramIndex[1] = new SqlParameter("@工位号", opName); + paramIndex[2] = new SqlParameter("@操作者工号", onlineCheckData.CheckPerson); + paramIndex[3] = new SqlParameter("@扫码时间", onlineCheckData.ScanTime); + paramIndex[4] = new SqlParameter("@合格标志", onlineCheckData.QualityMark); + paramIndex[5] = new SqlParameter("@完成时间", onlineCheckData.EndTime); + paramIndex[6] = new SqlParameter("@能耗", onlineCheckData.Powerused); + paramIndex[7] = new SqlParameter("@Id_tagCF", SqlDbType.Int) + { + Direction = ParameterDirection.Output + }; + + DataAccess2.ExecuteStoredProcedure("测量数据合格索引_增加_测试设备", ref paramIndex, out errorMessage); + if (!string.IsNullOrEmpty(errorMessage)) + { + throw new Exception(errorMessage); + } + + if (paramIndex[7].Value == null || paramIndex[7].Value == DBNull.Value) + { + throw new Exception("测量数据合格索引_增加_测试设备 未返回Id_tagCF!"); + } + + idTagCf = Convert.ToInt32(paramIndex[7].Value); + + List detailList = onlineCheckData.CheckData ?? new List(); + + foreach (var item in detailList) + { + var paramDetail = new SqlParameter[] + { + new SqlParameter("@Id_tagCF", idTagCf), + new SqlParameter("@EngineID", onlineCheckData.ProductionCode), + new SqlParameter("@TagID", item.CheckCode ?? string.Empty), + new SqlParameter("@TagValue", item.CheckValue ?? string.Empty), + new SqlParameter("@IsGoodBad", item.QualityMark), + new SqlParameter("@工位号", opName), + new SqlParameter("@理论值", item.StandardValue ?? string.Empty), + new SqlParameter("@上限值", item.MaxValue ?? string.Empty), + new SqlParameter("@下限值", item.MinValue ?? string.Empty), + new SqlParameter("@测量项目", item.CheckName ?? string.Empty), + new SqlParameter("@测量单位", item.Unit ?? string.Empty) + }; + + DataAccess2.ExecuteStoredProcedure("测量数据合格_增加_测试设备", ref paramDetail, out errorMessage); + if (!string.IsNullOrEmpty(errorMessage)) + { + throw new Exception(errorMessage); + } + } + // 存储到接口表里 + MisDataFun.SaveQualityInterfaceData(opName, onlineCheckData.ProductionCode); + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("接收检测数据_res", retString); + return retString; + } + + public static string OnlineStatusData(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + result.Data = ""; + + string errorMessage = string.Empty; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("接收设备状态数据_res", retString1); + return retString1; + } + + string str = jobj.ToString(); + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + var statusData = JsonConvert.DeserializeObject(str); + if (statusData == null) + { + throw new Exception("请求体反序列化失败!"); + } + if (string.IsNullOrWhiteSpace(statusData.MsgId)) + { + throw new Exception("参数MsgId为空!"); + } + if (string.IsNullOrWhiteSpace(statusData.DeviceCode)) + { + throw new Exception("参数DeviceCode为空!"); + } + if (string.IsNullOrWhiteSpace(statusData.DataType)) + { + throw new Exception("参数DataType为空!"); + } + if (statusData.CheckData == null || statusData.CheckData.Count == 0) + { + throw new Exception("参数CheckData为空!"); + } + + string dataType = statusData.DataType.ToUpper(); + + if (dataType == "STATUS") + { + // 设备运行状态监测 - 必填字段校验 + string deviceStatus = GetCheckDataValue(statusData.CheckData, "DeviceStatus"); + string statusTime = GetCheckDataValue(statusData.CheckData, "StatusTime"); + string statusCode = GetCheckDataValue(statusData.CheckData, "StatusCode"); + + if (string.IsNullOrWhiteSpace(deviceStatus)) + { + throw new Exception("设备状态(DeviceStatus)为必填项!"); + } + if (string.IsNullOrWhiteSpace(statusTime)) + { + throw new Exception("状态时间(StatusTime)为必填项!"); + } + if (string.IsNullOrWhiteSpace(statusCode)) + { + throw new Exception("状态代码(StatusCode)为必填项!"); + } + + // 非必填字段 + string malfunctionCode = GetCheckDataValue(statusData.CheckData, "MalfunctionCode"); + string malfunctionName = GetCheckDataValue(statusData.CheckData, "MalfunctionName"); + string malfunctionExplain = GetCheckDataValue(statusData.CheckData, "Malfunctionexplain"); + string flag = GetCheckDataValue(statusData.CheckData, "Flag"); + string remark = GetCheckDataValue(statusData.CheckData, "Remark"); + string alarmRemove = GetCheckDataValue(statusData.CheckData, "alarmRemove"); + + var param = new SqlParameter[] + { + new SqlParameter("@DeviceCode", statusData.DeviceCode), + new SqlParameter("@DeviceStatus", deviceStatus), + new SqlParameter("@StatusTime", DateTime.Parse(statusTime)), + new SqlParameter("@StatusCode", statusCode), + new SqlParameter("@MalfunctionCode", string.IsNullOrWhiteSpace(malfunctionCode) ? (object)DBNull.Value : malfunctionCode), + new SqlParameter("@MalfunctionName", string.IsNullOrWhiteSpace(malfunctionName) ? (object)DBNull.Value : malfunctionName), + new SqlParameter("@Malfunctionexplain", string.IsNullOrWhiteSpace(malfunctionExplain) ? (object)DBNull.Value : malfunctionExplain), + new SqlParameter("@Flag", string.IsNullOrWhiteSpace(flag) ? (object)DBNull.Value : flag), + new SqlParameter("@Remark", string.IsNullOrWhiteSpace(remark) ? (object)DBNull.Value : remark), + new SqlParameter("@alarmRemove", string.IsNullOrWhiteSpace(alarmRemove) ? (object)DBNull.Value : alarmRemove) + }; + + DataAccess2.ExecuteStoredProcedure("EquipmentStatus_Backup_TestDeviceAdd", ref param, out errorMessage); + if (!string.IsNullOrEmpty(errorMessage)) + { + throw new Exception(errorMessage); + } + } + else if (dataType == "USE") + { + // 设备使用情况记录 - 必填字段校验 + string workDate = GetCheckDataValue(statusData.CheckData, "WorkDate"); + + if (string.IsNullOrWhiteSpace(workDate)) + { + throw new Exception("工作日期(WorkDate)为必填项!"); + } + + // 非必填字段 + string onhours = GetCheckDataValue(statusData.CheckData, "Onhours"); + string workhours = GetCheckDataValue(statusData.CheckData, "Workhours"); + string powerused = GetCheckDataValue(statusData.CheckData, "Powerused"); + string flag = GetCheckDataValue(statusData.CheckData, "Flag"); + + var param = new SqlParameter[] + { + new SqlParameter("@Device", statusData.DeviceCode), + new SqlParameter("@WorkDate", DateTime.Parse(workDate)), + new SqlParameter("@Onhours", string.IsNullOrWhiteSpace(onhours) ? (object)DBNull.Value : double.Parse(onhours)), + new SqlParameter("@Workhours", string.IsNullOrWhiteSpace(workhours) ? (object)DBNull.Value : double.Parse(workhours)), + new SqlParameter("@Powerused", string.IsNullOrWhiteSpace(powerused) ? (object)DBNull.Value : double.Parse(powerused)), + new SqlParameter("@Flag", string.IsNullOrWhiteSpace(flag) ? (object)DBNull.Value : flag) + }; + + DataAccess2.ExecuteStoredProcedure("EquipmentUse_Backup_TestDeviceAdd", ref param, out errorMessage); + if (!string.IsNullOrEmpty(errorMessage)) + { + throw new Exception(errorMessage); + } + } + else + { + throw new Exception($"DataType值不正确,只支持Status或Use,当前值:{statusData.DataType}"); + } + } + catch (Exception err) + { + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("接收设备状态数据_res", retString); + return retString; + } + + /// + /// 从CheckData列表中获取指定StatuCode的StatuValue + /// + private static string GetCheckDataValue(List checkDataList, string statuCode) + { + var item = checkDataList.FirstOrDefault(x => x.StatuCode?.Trim().Equals(statuCode, StringComparison.OrdinalIgnoreCase) == true); + return item?.StatuValue ?? string.Empty; + } + + /// + /// 获取位置待测试产品信息 + /// + public static string GetWaitCheckProductData(string url, [FromBody] JObject jobj) + { + var result = new GetWaitCheckProductDataResponse(); + result.Code = "200"; + result.Message = ""; + result.MsgId = ""; + result.Data = new GetWaitCheckProductDataResult(); + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info("获取待测产品信息_res", retString1); + return retString1; + } + + string str = jobj.ToString(); + // 存储接口请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + var requestData = JsonConvert.DeserializeObject(str); + if (requestData == null) + { + throw new Exception("请求体反序列化失败!"); + } + if (string.IsNullOrWhiteSpace(requestData.MsgId)) + { + throw new Exception("参数MsgId为空!"); + } + // 设置响应的MsgId(带回请求编号) + result.MsgId = requestData.MsgId; + + if (string.IsNullOrWhiteSpace(requestData.OpCode)) + { + throw new Exception("参数OpCode为空!"); + } + + // TODO: 后续实现查询待测产品逻辑 + // 目前固定返回无待测产品 + result.Data = new GetWaitCheckProductDataResult + { + ProductionCode = "", + ProductModel = "", + ProductModelCode = 0 + }; + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(retString, AID); + MyLog4Net.MyLogHelper.Info("获取待测产品信息_res", retString); + return retString; + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/Other/DewPointData.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/Other/DewPointData.cs new file mode 100644 index 0000000..938fa0e --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/Other/DewPointData.cs @@ -0,0 +1,527 @@ +using DataLinkMesWork2; +using MisDataFunDll; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Globalization; +using System.Web.Http; +using static MisDataSaveDate.Helper.ApiLogHelper; + +namespace ExternalDataSync.MOM +{ + public static class DewPointDataHandler + { + private const string DefaultFlagValue = "0"; + + public static string OnlineDewPointResultData(string url, [FromBody] JObject jobj) + { + return ExecuteRequest(url, jobj, "接收露点仪测试结果数据", request => + { + string msgId = RequireText(request.MsgId, "MsgId"); + string deviceCode = RequireText(request.DeviceCode, "DeviceCode"); + string testDateText = RequireText(request.TestDate, "TestDate"); + if (request.TestItems == null || request.TestItems.Count == 0) + { + throw new Exception("参数TestItems为空!"); + } + + DateTime testDate = ParseDate(testDateText, "TestDate"); + DateTime? startTime = CombineDateAndTime(testDate, request.StartTime, "StartTime"); + DateTime? endTime = CombineDateAndTime(testDate, request.EndTime, "EndTime"); + DateTime actionTime = startTime ?? endTime ?? testDate; + string serialNumber = CleanText(request.SectionNo); + string userNumber = GetDefaultUser(request.UserNumber); + int overallQualityMark = request.IsQualified == false ? 2 : 1; + + int idTagCf = SaveMeasurementIndex(serialNumber, deviceCode, userNumber, actionTime, overallQualityMark); + + foreach (MeasurementDetail detail in BuildResultDetails(request, overallQualityMark)) + { + SaveMeasurementDetail(idTagCf, serialNumber, deviceCode, detail); + } + + SaveQualityInterfaceRecord(deviceCode, serialNumber); + return msgId; + }); + } + + public static string OnlineDewPointTechnologyData(string url, [FromBody] JObject jobj) + { + return ExecuteRequest(url, jobj, "接收露点仪工艺采集数据", request => + { + string msgId = RequireText(request.MsgId, "MsgId"); + string deviceCode = RequireText(request.DeviceCode, "DeviceCode"); + string serialNumber = CleanText(request.SerialNumber); + string userNumber = GetDefaultUser(request.UserNumber); + DateTime actionTime = ParseDateTimeOrNow(request.CreateTime, "CreateTime"); + + int idTagCf = SaveMeasurementIndex(serialNumber, deviceCode, userNumber, actionTime, 1); + + foreach (MeasurementDetail detail in BuildTechnologyDetails(request)) + { + SaveMeasurementDetail(idTagCf, serialNumber, deviceCode, detail); + } + + SaveQualityInterfaceRecord(deviceCode, serialNumber); + return msgId; + }); + } + + public static string OnlineDewPointUseData(string url, [FromBody] JObject jobj) + { + return ExecuteRequest(url, jobj, "接收露点仪设备使用情况数据", request => + { + string msgId = RequireText(request.MsgId, "MsgId"); + string deviceCode = RequireText(request.DeviceCode, "DeviceCode"); + DateTime testDate = ParseDate(RequireText(request.TestDate, "TestDate"), "TestDate"); + int? durationMinutes = ParseNullableInt(request.DurationMinutes, "DurationMinutes"); + + SqlParameter[] parameters = new SqlParameter[] + { + new SqlParameter("@Device", ToDbValue(deviceCode, 50)), + new SqlParameter("@WorkDate", testDate.Date), + new SqlParameter("@Onhours", durationMinutes.HasValue ? (object)durationMinutes.Value : DBNull.Value), + new SqlParameter("@Workhours", durationMinutes.HasValue ? (object)durationMinutes.Value : DBNull.Value), + new SqlParameter("@Powerused", DBNull.Value), + new SqlParameter("@Flag", ToDbValue(CleanText(request.Flag2), 10, DefaultFlagValue)) + }; + + ExecuteStoredProcedureOrThrow("EquipmentUse_Backup_TestDeviceAdd", ref parameters); + return msgId; + }); + } + + public static string OnlineDewPointStatusData(string url, [FromBody] JObject jobj) + { + return ExecuteRequest(url, jobj, "接收露点仪设备状态数据", request => + { + string msgId = RequireText(request.MsgId, "MsgId"); + string deviceCode = RequireText(request.DeviceCode, "DeviceCode"); + string status = RequireText(request.Status, "Status"); + string statusCode = RequireText(request.StatusCode, "StatusCode"); + DateTime statusTime = ParseDateTime(RequireText(request.StatusTime, "StatusTime"), "StatusTime"); + + SqlParameter[] parameters = new SqlParameter[] + { + new SqlParameter("@DeviceCode", ToDbValue(deviceCode, 20)), + new SqlParameter("@DeviceStatus", ToDbValue(status, 10)), + new SqlParameter("@StatusTime", statusTime), + new SqlParameter("@StatusCode", ToDbValue(statusCode, 4)), + new SqlParameter("@MalfunctionCode", ToNullableDbValue(request.FaultInfo == null ? string.Empty : request.FaultInfo.FaultCode, 4)), + new SqlParameter("@MalfunctionName", ToNullableDbValue(request.FaultInfo == null ? string.Empty : request.FaultInfo.FaultName, 40)), + new SqlParameter("@Malfunctionexplain", ToNullableDbValue(request.FaultInfo == null ? string.Empty : request.FaultInfo.FaultDescription, 40)), + new SqlParameter("@Flag", ToDbValue(CleanText(request.Flag3), 1, DefaultFlagValue)), + new SqlParameter("@Remark", DBNull.Value), + new SqlParameter("@alarmRemove", DBNull.Value) + }; + + ExecuteStoredProcedureOrThrow("EquipmentStatus_Backup_TestDeviceAdd", ref parameters); + return msgId; + }); + } + + private static string ExecuteRequest(string url, JObject jobj, string logTitle, Func executor) + { + OnlineCheckDataResponse result = new OnlineCheckDataResponse + { + Code = "200", + Message = "", + MsgId = "", + Data = "" + }; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string invalidText = JsonConvert.SerializeObject(result); + MyLog4Net.MyLogHelper.Info(logTitle + "_res", invalidText); + return invalidText; + } + + string requestText = jobj.ToString(); + SaveLog_Interface_Request(url, 2, requestText, out int aid); + + try + { + TRequest request = JsonConvert.DeserializeObject(requestText); + if (request == null) + { + throw new Exception("请求体反序列化失败!"); + } + + result.MsgId = executor(request); + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + + string responseText = JsonConvert.SerializeObject(result); + SaveLog_Interface_Response(responseText, aid); + MyLog4Net.MyLogHelper.Info(logTitle + "_res", responseText); + return responseText; + } + + private static List BuildResultDetails(ResultDataRequest request, int overallQualityMark) + { + List details = new List(); + + for (int i = 0; i < request.TestItems.Count; i++) + { + ResultTestItem item = request.TestItems[i]; + if (item == null) + { + continue; + } + + string itemName = RequireText(item.ItemName, "TestItems[" + i + "].ItemName"); + details.Add(new MeasurementDetail + { + TagId = itemName, + MeasurementName = itemName, + TagValue = GetTokenText(item.MeasuredValue), + QualityMark = MapQualityMark(item.QualityMark, overallQualityMark), + StandardValue = GetTokenText(item.SpecifiedValue), + Unit = CleanText(item.Unit) + }); + } + + // Environment 暂时保留字段,但当前不参与入库。 + return details; + } + + private static List BuildTechnologyDetails(TechnologyDataRequest request) + { + List details = new List(); + + AddTechnologyDetail(details, "CheckData", request.CheckData); + AddTechnologyDetail(details, "TechnologyData", request.TechnologyData); + + if (details.Count == 0) + { + throw new Exception("参数CheckData和TechnologyData均为空!"); + } + + return details; + } + + private static void AddTechnologyDetail(List details, string fieldName, string fieldValue) + { + string value = CleanText(fieldValue); + if (string.IsNullOrWhiteSpace(value)) + { + return; + } + + details.Add(new MeasurementDetail + { + TagId = fieldName, + MeasurementName = fieldName, + TagValue = value, + QualityMark = 1, + StandardValue = "", + Unit = "" + }); + } + + private static int SaveMeasurementIndex(string serialNumber, string deviceCode, string userNumber, DateTime actionTime, int qualityMark) + { + SqlParameter[] parameters = new SqlParameter[] + { + new SqlParameter("@EngineID", ToNullableDbValue(serialNumber, 100)), + new SqlParameter("@工位号", ToDbValue(deviceCode, 50)), + new SqlParameter("@操作者工号", ToDbValue(userNumber, 50, "AUTO")), + new SqlParameter("@扫码时间", actionTime), + new SqlParameter("@合格标志", qualityMark), + new SqlParameter("@Id_tagCF", SqlDbType.Int) { Direction = ParameterDirection.Output } + }; + + ExecuteStoredProcedureOrThrow("测量数据合格索引_增加_测试设备", ref parameters); + + if (parameters[5].Value == null || parameters[5].Value == DBNull.Value) + { + throw new Exception("测量数据合格索引_增加_测试设备 未返回Id_tagCF!"); + } + + return Convert.ToInt32(parameters[5].Value); + } + + private static void SaveMeasurementDetail(int idTagCf, string serialNumber, string deviceCode, MeasurementDetail detail) + { + SqlParameter[] parameters = new SqlParameter[] + { + new SqlParameter("@Id_tagCF", idTagCf), + new SqlParameter("@EngineID", ToNullableDbValue(serialNumber, 100)), + new SqlParameter("@TagID", ToDbValue(detail.TagId, 50)), + new SqlParameter("@TagValue", ToDbValue(detail.TagValue, 100)), + new SqlParameter("@IsGoodBad", detail.QualityMark), + new SqlParameter("@工位号", ToDbValue(deviceCode, 50)), + new SqlParameter("@理论值", ToDbValue(detail.StandardValue, 50)), + new SqlParameter("@上限值", ToDbValue(string.Empty, 50)), + new SqlParameter("@下限值", ToDbValue(string.Empty, 50)), + new SqlParameter("@测量项目", ToDbValue(detail.MeasurementName, 50)), + new SqlParameter("@测量单位", ToDbValue(detail.Unit, 50)) + }; + + ExecuteStoredProcedureOrThrow("测量数据合格_增加_测试设备", ref parameters); + } + + private static void SaveQualityInterfaceRecord(string deviceCode, string serialNumber) + { + if (!string.IsNullOrWhiteSpace(deviceCode) && !string.IsNullOrWhiteSpace(serialNumber)) + { + MisDataFun.SaveQualityInterfaceData(deviceCode, serialNumber); + } + } + + private static int MapQualityMark(int? sourceQualityMark, int defaultQualityMark) + { + if (!sourceQualityMark.HasValue) + { + return defaultQualityMark; + } + + if (sourceQualityMark.Value == 0) + { + return 1; + } + + if (sourceQualityMark.Value == 1) + { + return 2; + } + + return sourceQualityMark.Value; + } + + private static int? ParseNullableInt(JToken token, string fieldName) + { + string text = GetTokenText(token); + if (string.IsNullOrWhiteSpace(text)) + { + return null; + } + + if (int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out int result) || + int.TryParse(text, NumberStyles.Integer, CultureInfo.CurrentCulture, out result)) + { + return result; + } + + throw new Exception("参数" + fieldName + "格式不正确!"); + } + + private static DateTime ParseDate(string text, string fieldName) + { + if (DateTime.TryParseExact(text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) || + DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out result) || + DateTime.TryParse(text, CultureInfo.CurrentCulture, DateTimeStyles.None, out result)) + { + return result.Date; + } + + throw new Exception("参数" + fieldName + "格式不正确!"); + } + + private static DateTime ParseDateTime(string text, string fieldName) + { + if (DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) || + DateTime.TryParse(text, CultureInfo.CurrentCulture, DateTimeStyles.None, out result)) + { + return result; + } + + throw new Exception("参数" + fieldName + "格式不正确!"); + } + + private static DateTime ParseDateTimeOrNow(string text, string fieldName) + { + string value = CleanText(text); + if (string.IsNullOrWhiteSpace(value)) + { + return DateTime.Now; + } + + return ParseDateTime(value, fieldName); + } + + private static DateTime? CombineDateAndTime(DateTime date, string timeText, string fieldName) + { + string text = CleanText(timeText); + if (string.IsNullOrWhiteSpace(text)) + { + return null; + } + + if (TimeSpan.TryParse(text, CultureInfo.InvariantCulture, out TimeSpan timePart) || + TimeSpan.TryParse(text, CultureInfo.CurrentCulture, out timePart)) + { + return date.Date.Add(timePart); + } + + throw new Exception("参数" + fieldName + "格式不正确!"); + } + + private static string RequireText(string value, string fieldName) + { + string text = CleanText(value); + if (string.IsNullOrWhiteSpace(text)) + { + throw new Exception("参数" + fieldName + "为空!"); + } + + return text; + } + + private static string RequireText(JToken value, string fieldName) + { + string text = GetTokenText(value); + if (string.IsNullOrWhiteSpace(text)) + { + throw new Exception("参数" + fieldName + "为空!"); + } + + return text; + } + + private static string CleanText(string value) + { + return value == null ? string.Empty : value.Trim(); + } + + private static string GetDefaultUser(string userNumber) + { + string value = CleanText(userNumber); + return string.IsNullOrWhiteSpace(value) ? "AUTO" : value; + } + + private static string GetTokenText(JToken token) + { + return token == null || token.Type == JTokenType.Null ? string.Empty : token.ToString().Trim(); + } + + private static object ToDbValue(string value, int maxLength) + { + return ToDbValue(value, maxLength, string.Empty); + } + + private static object ToDbValue(string value, int maxLength, string defaultValue) + { + string text = CleanText(value); + if (string.IsNullOrWhiteSpace(text)) + { + text = defaultValue ?? string.Empty; + } + + return text.Length > maxLength ? text.Substring(0, maxLength) : text; + } + + private static object ToNullableDbValue(string value, int maxLength) + { + string text = CleanText(value); + if (string.IsNullOrWhiteSpace(text)) + { + return DBNull.Value; + } + + return text.Length > maxLength ? text.Substring(0, maxLength) : text; + } + + private static void ExecuteStoredProcedureOrThrow(string procedureName, ref SqlParameter[] parameters) + { + DataAccess2.ExecuteStoredProcedure(procedureName, ref parameters, out string errorMessage); + if (!string.IsNullOrWhiteSpace(errorMessage)) + { + throw new Exception(errorMessage); + } + } + + private sealed class ResultDataRequest + { + public string DeviceCode { get; set; } = string.Empty; + public string EndTime { get; set; } = string.Empty; + public ResultEnvironment Environment { get; set; } = new ResultEnvironment(); + public bool? IsQualified { get; set; } + public JToken MsgId { get; set; } + public JToken PowerUsed { get; set; } + public string SectionNo { get; set; } = string.Empty; + public string StartTime { get; set; } = string.Empty; + public string TestDate { get; set; } = string.Empty; + public List TestItems { get; set; } = new List(); + public string UserNumber { get; set; } = string.Empty; + } + + private sealed class ResultEnvironment + { + public JToken Humidity { get; set; } + public JToken Temperature { get; set; } + } + + private sealed class ResultTestItem + { + public string ItemName { get; set; } = string.Empty; + public JToken MeasuredValue { get; set; } + public int? QualityMark { get; set; } + public JToken SpecifiedValue { get; set; } + public string Unit { get; set; } = string.Empty; + } + + private sealed class TechnologyDataRequest + { + public string CheckData { get; set; } = string.Empty; + public string CreateTime { get; set; } = string.Empty; + public string DeviceCode { get; set; } = string.Empty; + public string Flag { get; set; } = string.Empty; + public string MsgId { get; set; } = string.Empty; + public string PowerUsed { get; set; } = string.Empty; + public string SerialNumber { get; set; } = string.Empty; + public string TechnologyData { get; set; } = string.Empty; + public string UserNumber { get; set; } = string.Empty; + } + + private sealed class EquipmentUseRequest + { + public string CreateTime { get; set; } = string.Empty; + public string DeviceCode { get; set; } = string.Empty; + public JToken DurationMinutes { get; set; } + public string Flag2 { get; set; } = string.Empty; + public JToken MsgId { get; set; } + public string StartTime { get; set; } = string.Empty; + public string TestDate { get; set; } = string.Empty; + } + + private sealed class EquipmentStatusRequest + { + public string CreateTime { get; set; } = string.Empty; + public string DeviceCode { get; set; } = string.Empty; + public FaultInfo FaultInfo { get; set; } = new FaultInfo(); + public JToken MsgId { get; set; } + public string Status { get; set; } = string.Empty; + public string StatusCode { get; set; } = string.Empty; + public string StatusTime { get; set; } = string.Empty; + public string Flag3 { get; set; } = string.Empty; + } + + private sealed class FaultInfo + { + public string FaultCode { get; set; } = string.Empty; + public string FaultDescription { get; set; } = string.Empty; + public string FaultName { get; set; } = string.Empty; + } + + private sealed class MeasurementDetail + { + public string TagId { get; set; } = string.Empty; + public string MeasurementName { get; set; } = string.Empty; + public string TagValue { get; set; } = string.Empty; + public int QualityMark { get; set; } + public string StandardValue { get; set; } = string.Empty; + public string Unit { get; set; } = string.Empty; + } + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/StateVariable.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/StateVariable.cs new file mode 100644 index 0000000..2df9e86 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/StateVariable.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ExternalDataSync +{ + public static class StateVariable + { + public static bool online_Mes = true; + } +} diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/WEB/WEB_BusinessLogic.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/WEB/WEB_BusinessLogic.cs new file mode 100644 index 0000000..1631abc --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/WEB/WEB_BusinessLogic.cs @@ -0,0 +1,411 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Configuration; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using ExternalDataSync; +using MesServerWork; +using MisDataSaveDate; +using System.Net.Http; +using System.Web.Http; +using MisDataSaveDate.MOM; +using System.Data.SqlClient; +using static MisDataSaveDate.Helper.ApiLogHelper; +using WebApi; +using System.Security.Policy; +using System.Data; +using MisDataFunDll; +using System.Net; + +namespace MisDataSaveDate +{ + /// + /// WEB业务处理类 + /// + public class WEB_BusinessLogic + { + /// + /// WEB端发来的请求 + /// + /// 请求URL + /// 请求的JSON对象 + /// 处理结果 + public static string WEB_Request(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader(); + result.code = 200; + result.message = ""; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + SaveMesLog("WEB进入请求", "参数格式不正确!", Helper.MesLogType.ERROR); + MyLog4Net.MyLogHelper.Info("WEB请求进入接口res:", retString1); + return retString1; + } + + string str = jobj.ToString(); + //存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + // 解析WEB请求内容 + WEB_Request webRequest = JsonConvert.DeserializeObject(str); + + // 必填字段校验 + if (string.IsNullOrWhiteSpace(webRequest.type)) + { + throw new Exception("请求类型(type)不能为空"); + } + switch (webRequest.type) + { + case "OperAtion_JobStart": + // 手动重新开始工作 + // 使用JObject的索引器或Value方法来获取值 + string workStation1 = webRequest.paramObj?["工位号"]?.ToString() ?? ""; + string orderNo1 = webRequest.paramObj?["订单号"]?.ToString() ?? ""; + string workpieceNo1 = webRequest.paramObj?["工件编号"]?.ToString() ?? ""; + + // 验证必要参数 + if (string.IsNullOrWhiteSpace(workStation1) || + string.IsNullOrWhiteSpace(orderNo1) || + string.IsNullOrWhiteSpace(workpieceNo1)) + { + throw new Exception("OperAtion_JobStart 缺少必要参数:工位号、订单号或工件编号"); + } + + CALL_Inerface_DataHandle.CALL_Inerface_JobStart(workStation1, orderNo1, workpieceNo1); + break; + + case "OperAtion_JobFinished": + // 手动完成工作 + // 使用JObject的索引器或Value方法来获取值 + string workStation2 = webRequest.paramObj?["工位号"]?.ToString() ?? ""; + string orderNo2 = webRequest.paramObj?["订单号"]?.ToString() ?? ""; + string workpieceNo2 = webRequest.paramObj?["工件编号"]?.ToString() ?? ""; + + // 验证必要参数 + if (string.IsNullOrWhiteSpace(workStation2) || + string.IsNullOrWhiteSpace(orderNo2) || + string.IsNullOrWhiteSpace(workpieceNo2)) + { + throw new Exception("OperAtion_JobFinished 缺少必要参数:工位号、订单号或工件编号"); + } + + CALL_Inerface_DataHandle.CALL_Inerface_JobFinished(workStation2, orderNo2, workpieceNo2); + break; + + default: + result.code = 500; + result.message = "无此类型~"; + break; + } + } + catch (Exception err) + { + // 记录错误日志 + SaveMesLog("WEB端调用接口", err.Message, Helper.MesLogType.ERROR); + + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + // 存储响应日志 + SaveLog_Interface_Response(retString, AID); + return retString; + } + + /// + /// 批量读取PLC点位值 + /// + /// 请求URL + /// 请求的JSON对象,包含OpName和TagTypeCodeIDs数组 + /// 处理结果 + public static string WEB_ReadPLCValues(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader> + { + code = 200, + message = "", + Data = new List() + }; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + SaveMesLog("WEB批量读取PLC点位值", "参数格式不正确!", Helper.MesLogType.ERROR); + MyLog4Net.MyLogHelper.Info("WEB_ReadPLCValues res:", retString1); + return retString1; + } + + string str = jobj.ToString(); + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + string opName = jobj["OpName"]?.ToString() ?? ""; + JArray tagTypeCodeIDsArray = jobj["TagTypeCodeIDs"] as JArray; + + // 参数校验 + if (string.IsNullOrEmpty(opName)) + { + throw new Exception("工位号(OpName)不能为空"); + } + + if (tagTypeCodeIDsArray == null || tagTypeCodeIDsArray.Count == 0) + { + throw new Exception("TagTypeCodeID数组不能为空"); + } + + int[] tagTypeCodeIDs = tagTypeCodeIDsArray.Select(x => (int)x).ToArray(); + + // 读取工位全部数据 + var rtList = MIS_BASE.ReadPLC_OpName(opName); + if (rtList == null) + { + throw new Exception($"读取工位[{opName}]数据失败"); + } + + var pp = JsonConvert.SerializeObject(rtList); + // 使用 dynamic 类型避免程序集引用问题 + var tagValues = JsonConvert.DeserializeObject>(pp); + + // 根据传入的TagTypeCodeID数组过滤并返回对应的值 + foreach (var tagTypeCodeID in tagTypeCodeIDs) + { + var tagResult = new PLCTagValueResult + { + TagTypeCodeID = tagTypeCodeID, + Success = false, + TagValue = null, + Message = "" + }; + + try + { + var matchedTag = tagValues.Where(x => (int)x.Value.TagTypeCodeID == tagTypeCodeID).FirstOrDefault(); + if (matchedTag.Value != null) + { + tagResult.Success = true; + tagResult.TagValue = (int)matchedTag.Value.TagValue; + tagResult.TagName = (string)matchedTag.Value.TagName; + tagResult.OpName = (string)matchedTag.Value.OpName; + tagResult.TimeStamp = (string)matchedTag.Value.TimeStamp; + } + else + { + tagResult.Message = $"未找到TagTypeCodeID={tagTypeCodeID}的点位"; + } + } + catch (Exception ex) + { + tagResult.Message = $"读取TagTypeCodeID={tagTypeCodeID}失败: {ex.Message}"; + } + + result.Data.Add(tagResult); + } + + result.message = "读取成功"; + } + catch (Exception err) + { + // 记录错误日志 + SaveMesLog("WEB批量读取PLC点位值", err.Message, Helper.MesLogType.ERROR); + + result.code = 500; + result.message = err.Message; + result.Data = null; + } + + string retString = JsonConvert.SerializeObject(result); + // 存储响应日志 + SaveLog_Interface_Response(retString, AID); + return retString; + } + + /// + /// 写入PLC点位值 + /// + /// 请求URL + /// 请求的JSON对象,包含TagTypeCodeID、OpName和TagValue + /// 处理结果 + public static string WEB_WritePLC(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader + { + code = 200, + message = "", + Data = null + }; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + SaveMesLog("WEB写入PLC", "参数格式不正确!", Helper.MesLogType.ERROR); + MyLog4Net.MyLogHelper.Info("WEB_WritePLC res:", retString1); + return retString1; + } + + string str = jobj.ToString(); + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + int tagTypeCodeID = jobj["TagTypeCodeID"]?.Value() ?? 0; + string opName = jobj["OpName"]?.ToString() ?? ""; + object tagValue = jobj["TagValue"]?.ToObject(); + + // 参数校验 + if (string.IsNullOrEmpty(opName)) + { + throw new Exception("工位号(OpName)不能为空"); + } + + if (tagTypeCodeID == 0) + { + throw new Exception("TagTypeCodeID不能为0"); + } + + // 调用MIS_BASE.WritePLC方法写入PLC + bool writeResult = MIS_BASE.WritePLC(tagTypeCodeID, opName, tagValue); + + if (writeResult) + { + result.code = 200; + result.message = "写入成功"; + result.Data = new { Success = true }; + } + else + { + result.code = 500; + result.message = "写入失败"; + result.Data = new { Success = false }; + } + } + catch (Exception err) + { + // 记录错误日志 + SaveMesLog("WEB写入PLC", err.Message, Helper.MesLogType.ERROR); + + result.code = 500; + result.message = err.Message; + result.Data = new { Success = false }; + } + + string retString = JsonConvert.SerializeObject(result); + // 存储响应日志 + SaveLog_Interface_Response(retString, AID); + return retString; + } + + /// + /// 磨合转序 + /// 调用AGV转序接口,成功后执行转序存储过程 + /// + /// 请求URL + /// 请求的JSON对象,包含转序相关参数 + /// 处理结果 + public static string WEB_RunningInTransfer(string url, [FromBody] JObject jobj) + { + var result = new MsgResHeader + { + code = 200, + message = "", + Data = null + }; + + if (jobj == null) + { + result.code = 500; + result.message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + SaveMesLog("WEB磨合转序", "参数格式不正确!", Helper.MesLogType.ERROR); + MyLog4Net.MyLogHelper.Info("WEB_RunningInTransfer res:", retString1); + return retString1; + } + + string str = jobj.ToString(); + // 存储请求日志 + SaveLog_Interface_Request(url, 2, str, out int AID); + + try + { + // 获取参数 + string startPositionCode = jobj["startPositionCode"]?.ToString() ?? ""; + string endPositionCode = jobj["endPositionCode"]?.ToString() ?? ""; + string productCode = jobj["productCode"]?.ToString() ?? ""; + string productModel = jobj["productModel"]?.ToString() ?? ""; + string targetProcess = jobj["targetProcess"]?.ToString() ?? ""; + string targetProcessNo = jobj["targetProcessNo"]?.ToString() ?? ""; + + // 参数校验 + if (string.IsNullOrEmpty(startPositionCode) || string.IsNullOrEmpty(endPositionCode)) + { + throw new Exception("起始库位号和目标库位号不能为空"); + } + + // 1. 调用AGV转序接口 + var agvResult = CALL_Inerface_DataHandle.CALL_Inerface_MaterialTransfer(startPositionCode, endPositionCode); + int agvCode = 500; + int.TryParse(agvResult["code"]?.ToString() ?? "500", out agvCode); + + if (agvCode != 200) + { + result.code = agvCode; + result.message = $"AGV调度失败:{agvResult["message"]?.ToString() ?? "未知错误"}"; + } + else + { + // 2. AGV调度成功,执行转序存储过程 + var param = new SqlParameter[] { + new SqlParameter("@库位号", startPositionCode), + new SqlParameter("@产品编号", productCode), + new SqlParameter("@产品型号", productModel), + new SqlParameter("@目标库位号", endPositionCode), + new SqlParameter("@目标工序", targetProcess), + new SqlParameter("@目标工序号", targetProcessNo) + }; + + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("XD_磨合_开始下一序", ref param, out string errMessage); + + if (!string.IsNullOrEmpty(errMessage)) + { + result.code = 500; + result.message = $"AGV调度成功,但存储过程执行失败:{errMessage}"; + } + else + { + result.code = 200; + result.message = "转序操作成功"; + } + } + } + catch (Exception err) + { + // 记录错误日志 + SaveMesLog("WEB磨合转序", err.Message, Helper.MesLogType.ERROR); + + result.code = 500; + result.message = err.Message; + } + + string retString = JsonConvert.SerializeObject(result); + // 存储响应日志 + SaveLog_Interface_Response(retString, AID); + return retString; + } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/WebAPI/WEB/WEB_Models.cs b/Interface_WebAPI/SlMesDbIterface/WebAPI/WEB/WEB_Models.cs new file mode 100644 index 0000000..25d54ca --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/WebAPI/WEB/WEB_Models.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace MisDataSaveDate +{ + /// + /// WEB请求类型 + /// + public class WEB_Request + { + /// + /// Type 操作类型 用来区分Web的各操作 + /// + public string type { get; set; } + + /// + /// 参数对象 根据Type 会传递不同的参数 + /// 使用JObject可以接收任意JSON结构的数据,无需定义实体类 + /// + public JObject paramObj { get; set; } + } + + /// + /// PLC点位值返回结果 + /// + public class PLCTagValueResult + { + /// + /// TagTypeCodeID + /// + public int TagTypeCodeID { get; set; } + + /// + /// 是否读取成功 + /// + public bool Success { get; set; } + + /// + /// 点位值 + /// + public object TagValue { get; set; } + + /// + /// 点位名称 + /// + public string TagName { get; set; } + + /// + /// 工位号 + /// + public string OpName { get; set; } + + /// + /// 时间戳 + /// + public string TimeStamp { get; set; } + + /// + /// 消息(错误时返回错误信息) + /// + public string Message { get; set; } + } +} \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/app.config b/Interface_WebAPI/SlMesDbIterface/app.config new file mode 100644 index 0000000..b6e72bd --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/icon/002_列表.png b/Interface_WebAPI/SlMesDbIterface/icon/002_列表.png new file mode 100644 index 0000000..81abc65 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/002_列表.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/0780fca3def52d8a02649c7aa2f8093a.gif b/Interface_WebAPI/SlMesDbIterface/icon/0780fca3def52d8a02649c7aa2f8093a.gif new file mode 100644 index 0000000..f27d4fa Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/0780fca3def52d8a02649c7aa2f8093a.gif differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/BOSS-数据管理.ico b/Interface_WebAPI/SlMesDbIterface/icon/BOSS-数据管理.ico new file mode 100644 index 0000000..0cda236 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/BOSS-数据管理.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/BOSS-数据管理.png b/Interface_WebAPI/SlMesDbIterface/icon/BOSS-数据管理.png new file mode 100644 index 0000000..eca58d7 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/BOSS-数据管理.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/JD.png b/Interface_WebAPI/SlMesDbIterface/icon/JD.png new file mode 100644 index 0000000..abe9aa8 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/JD.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/MBE风格多色图标-密码.png b/Interface_WebAPI/SlMesDbIterface/icon/MBE风格多色图标-密码.png new file mode 100644 index 0000000..e20eaa8 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/MBE风格多色图标-密码.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/action_Cancel_16xLG.png b/Interface_WebAPI/SlMesDbIterface/icon/action_Cancel_16xLG.png new file mode 100644 index 0000000..ac08d59 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/action_Cancel_16xLG.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/bitbug_favicon.ico b/Interface_WebAPI/SlMesDbIterface/icon/bitbug_favicon.ico new file mode 100644 index 0000000..4e9b14c Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/bitbug_favicon.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/excelICON.ico b/Interface_WebAPI/SlMesDbIterface/icon/excelICON.ico new file mode 100644 index 0000000..f7dcbf6 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/excelICON.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/jk.ico b/Interface_WebAPI/SlMesDbIterface/icon/jk.ico new file mode 100644 index 0000000..fe585a8 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/jk.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/panlClose.png b/Interface_WebAPI/SlMesDbIterface/icon/panlClose.png new file mode 100644 index 0000000..462a22f Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/panlClose.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/ssbj.png b/Interface_WebAPI/SlMesDbIterface/icon/ssbj.png new file mode 100644 index 0000000..10dc152 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/ssbj.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/staticjd.png b/Interface_WebAPI/SlMesDbIterface/icon/staticjd.png new file mode 100644 index 0000000..f891867 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/staticjd.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/任务监控和查询.png b/Interface_WebAPI/SlMesDbIterface/icon/任务监控和查询.png new file mode 100644 index 0000000..ff8cca0 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/任务监控和查询.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/倾斜校准.png b/Interface_WebAPI/SlMesDbIterface/icon/倾斜校准.png new file mode 100644 index 0000000..92e6fc7 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/倾斜校准.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/关闭.png b/Interface_WebAPI/SlMesDbIterface/icon/关闭.png new file mode 100644 index 0000000..b78aef6 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/关闭.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/关闭系统.png b/Interface_WebAPI/SlMesDbIterface/icon/关闭系统.png new file mode 100644 index 0000000..ffd64a8 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/关闭系统.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/分布图.ico b/Interface_WebAPI/SlMesDbIterface/icon/分布图.ico new file mode 100644 index 0000000..d2bd021 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/分布图.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/分布图.png b/Interface_WebAPI/SlMesDbIterface/icon/分布图.png new file mode 100644 index 0000000..c41710c Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/分布图.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/动态数据查询.png b/Interface_WebAPI/SlMesDbIterface/icon/动态数据查询.png new file mode 100644 index 0000000..ad87d56 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/动态数据查询.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/增加.png b/Interface_WebAPI/SlMesDbIterface/icon/增加.png new file mode 100644 index 0000000..4bfbb6b Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/增加.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/密码.png b/Interface_WebAPI/SlMesDbIterface/icon/密码.png new file mode 100644 index 0000000..295d5a9 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/密码.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/手动打印.png b/Interface_WebAPI/SlMesDbIterface/icon/手动打印.png new file mode 100644 index 0000000..a682191 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/手动打印.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/按键分割线.png b/Interface_WebAPI/SlMesDbIterface/icon/按键分割线.png new file mode 100644 index 0000000..f54e139 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/按键分割线.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/按键分割线浅.png b/Interface_WebAPI/SlMesDbIterface/icon/按键分割线浅.png new file mode 100644 index 0000000..db55df6 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/按键分割线浅.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/断开.png b/Interface_WebAPI/SlMesDbIterface/icon/断开.png new file mode 100644 index 0000000..fe5b4e9 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/断开.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/断开连接.png b/Interface_WebAPI/SlMesDbIterface/icon/断开连接.png new file mode 100644 index 0000000..8221ffc Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/断开连接.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/日志.ico b/Interface_WebAPI/SlMesDbIterface/icon/日志.ico new file mode 100644 index 0000000..37a300e Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/日志.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/日志.jpg b/Interface_WebAPI/SlMesDbIterface/icon/日志.jpg new file mode 100644 index 0000000..c5912e7 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/日志.jpg differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/日志.png b/Interface_WebAPI/SlMesDbIterface/icon/日志.png new file mode 100644 index 0000000..1ef853f Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/日志.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/权限角色管理.png b/Interface_WebAPI/SlMesDbIterface/icon/权限角色管理.png new file mode 100644 index 0000000..8ab50e8 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/权限角色管理.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/添加.png b/Interface_WebAPI/SlMesDbIterface/icon/添加.png new file mode 100644 index 0000000..47b1193 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/添加.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/清除.jpg b/Interface_WebAPI/SlMesDbIterface/icon/清除.jpg new file mode 100644 index 0000000..4df456b Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/清除.jpg differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/用户.png b/Interface_WebAPI/SlMesDbIterface/icon/用户.png new file mode 100644 index 0000000..f7b6826 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/用户.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/系统管理.png b/Interface_WebAPI/SlMesDbIterface/icon/系统管理.png new file mode 100644 index 0000000..136f392 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/系统管理.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/系统管理和监控服务.png b/Interface_WebAPI/SlMesDbIterface/icon/系统管理和监控服务.png new file mode 100644 index 0000000..dab233f Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/系统管理和监控服务.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/质控管理.png b/Interface_WebAPI/SlMesDbIterface/icon/质控管理.png new file mode 100644 index 0000000..ad6a993 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/质控管理.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/返修.jpg b/Interface_WebAPI/SlMesDbIterface/icon/返修.jpg new file mode 100644 index 0000000..cc57e91 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/返修.jpg differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/连接.png b/Interface_WebAPI/SlMesDbIterface/icon/连接.png new file mode 100644 index 0000000..cc7650b Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/连接.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/配置.ico b/Interface_WebAPI/SlMesDbIterface/icon/配置.ico new file mode 100644 index 0000000..d028cc1 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/配置.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/配置.png b/Interface_WebAPI/SlMesDbIterface/icon/配置.png new file mode 100644 index 0000000..e16ab0b Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/配置.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/配置2.ico b/Interface_WebAPI/SlMesDbIterface/icon/配置2.ico new file mode 100644 index 0000000..45b4c44 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/配置2.ico differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/配置2.png b/Interface_WebAPI/SlMesDbIterface/icon/配置2.png new file mode 100644 index 0000000..e5e7dc5 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/配置2.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/icon/重新加载数据.png b/Interface_WebAPI/SlMesDbIterface/icon/重新加载数据.png new file mode 100644 index 0000000..c98d847 Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/icon/重新加载数据.png differ diff --git a/Interface_WebAPI/SlMesDbIterface/packages.config b/Interface_WebAPI/SlMesDbIterface/packages.config new file mode 100644 index 0000000..d63e604 --- /dev/null +++ b/Interface_WebAPI/SlMesDbIterface/packages.config @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/SlMesDbIterface/系统管理和监控服务.ico b/Interface_WebAPI/SlMesDbIterface/系统管理和监控服务.ico new file mode 100644 index 0000000..6a4cb0f Binary files /dev/null and b/Interface_WebAPI/SlMesDbIterface/系统管理和监控服务.ico differ diff --git a/Interface_WebAPI/WebApi/02_WebApi.csproj b/Interface_WebAPI/WebApi/02_WebApi.csproj new file mode 100644 index 0000000..eb740e0 --- /dev/null +++ b/Interface_WebAPI/WebApi/02_WebApi.csproj @@ -0,0 +1,107 @@ + + + + + Debug + AnyCPU + {5C6E31A8-8B45-4459-BA62-07AF6135DF4A} + Exe + WebApi + WebApi + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + LocalIntranet + + + false + + + Properties\app.manifest + + + + ..\packages\log4net.2.0.14\lib\net45\log4net.dll + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll + + + + ..\packages\Microsoft.AspNet.Cors.5.2.9\lib\net45\System.Web.Cors.dll + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.9\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.Cors.5.2.9\lib\net45\System.Web.Http.Cors.dll + + + ..\packages\Microsoft.AspNet.WebApi.SelfHost.5.2.9\lib\net45\System.Web.Http.SelfHost.dll + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + + + {c7c5e929-be10-4ed6-94db-b8d65e05e52f} + 01_DatabaseClient + + + + \ No newline at end of file diff --git a/Interface_WebAPI/WebApi/ApiTools.cs b/Interface_WebAPI/WebApi/ApiTools.cs new file mode 100644 index 0000000..a51e14d --- /dev/null +++ b/Interface_WebAPI/WebApi/ApiTools.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http; +using System.Net.Http; +using System.Text.RegularExpressions; + +namespace WebApi +{ + public enum ResponseCode + { + Fail = 00000, + Success = 00200, + } + + public class ApiTools + { + private string msgModel = "{{\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}"; + public ApiTools() + { + } + public HttpResponseMessage MsgFormat(ResponseCode code, string explanation, string result) + { + string r = @"^(\-|\+)?\d+(\.\d+)?$"; + string json = string.Empty; + if (Regex.IsMatch(result, r) || result.ToLower() == "true" || result.ToLower() == "false" || result == "[]" || result.Contains('{')) + { + json = string.Format(msgModel, (int)code, explanation, result); + } + else + { + if (result.Contains('"')) + { + json = string.Format(msgModel, (int)code, explanation, result); + } + else + { + json = string.Format(msgModel, (int)code, explanation, "\"" + result + "\""); + } + } + return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }; + } + } +} diff --git a/Interface_WebAPI/WebApi/App.config b/Interface_WebAPI/WebApi/App.config new file mode 100644 index 0000000..c2f5d55 --- /dev/null +++ b/Interface_WebAPI/WebApi/App.config @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Interface_WebAPI/WebApi/Controller/ZSavePositionController.cs b/Interface_WebAPI/WebApi/Controller/ZSavePositionController.cs new file mode 100644 index 0000000..9bfb916 --- /dev/null +++ b/Interface_WebAPI/WebApi/Controller/ZSavePositionController.cs @@ -0,0 +1,119 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; + + +namespace WebApi +{ + + [RoutePrefix("api/ZSavePosition")] //定义路由前缀 + public class ZSavePositionController : ApiController + { + /// + /// 插入数据库 + /// + /// + /// + [HttpPost] + public void Insert(JObject jObject) + { + string pp = ""; + try + { + var z_Save_Position = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(jObject)); + + //z_Save_Position.OpName = "a1"; + //z_Save_Position.Value = "asd"; + //z_Save_Position.OperationTime = "2022/06/29 16:40:43"; + //z_Save_Position.ProjectCode = "123"; + + string sql = "INSERT INTO z_save_position(OpName, Value, OperationTime, ProjectCode) VALUES('" + z_Save_Position.OpName + "', '" + z_Save_Position.Value + "', '" + z_Save_Position.OperationTime + "', '" + z_Save_Position.ProjectCode + "');\n"; + var res = GlobalVar.dbClient.ExecNonQuery(sql); + + pp = res.ToString(); + + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + // Console.WriteLine(err.Message); + } + } + + [HttpPost] + public HttpResponseMessage SelectPage([FromBody] JObject jobj) + { + string pp = ""; + try + { + var OpName = jobj["OpName"].ToString(); + var StartTime = jobj["StartTime"].ToString(); + var EndTime = jobj["EndTime"].ToString(); + var PageCurrent = jobj["PageCurrent"].ToString(); + var PageSize = jobj["PageSize"].ToString(); + + string sql = "SELECT * FROM z_save_position " + + "WHERE(OperationTime BETWEEN '" + StartTime + "' AND '" + EndTime + "') AND OpName like '" + OpName + "%' " + + "ORDER BY OperationTime;\n"; + var res = GlobalVar.dbClient.ExecQuery(sql); + + var zSavePersonList = Z_Save_Position.DataTableToClass(res); + + var newZSaveList = DatabaseClient.DBClient.SplitePage(zSavePersonList, Convert.ToInt32(PageSize), Convert.ToInt32(PageCurrent)); + var tableData = (JArray)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(newZSaveList)); + JObject resjobj = new JObject() { + new JProperty("ItemCount", zSavePersonList.Count.ToString()), + new JProperty("TableData",tableData) + }; + + pp = resjobj.ToString(); + + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + // Console.WriteLine(err.Message); + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } + + [HttpPost] + public HttpResponseMessage Select([FromBody] JObject jobj) + { + string pp = ""; + try + { + var OpName = jobj["OpName"].ToString(); + var StartTime = jobj["StartTime"].ToString(); + var EndTime = jobj["EndTime"].ToString(); + + string sql = "SELECT * FROM z_save_position " + + "WHERE(OperationTime BETWEEN '"+StartTime+"' AND '"+EndTime+"') AND OpName like '"+OpName+"%' " + + "ORDER BY OperationTime;\n"; + var res = GlobalVar.dbClient.ExecQuery(sql); + + var zSavePersonList = Z_Save_Position.DataTableToClass(res); + + var zSavePersonListStr = JsonConvert.SerializeObject(zSavePersonList); + + pp = zSavePersonListStr.ToString(); + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + // Console.WriteLine (err.Message); + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } + } +} diff --git a/Interface_WebAPI/WebApi/Controller/ZSaveTagController.cs b/Interface_WebAPI/WebApi/Controller/ZSaveTagController.cs new file mode 100644 index 0000000..4371fde --- /dev/null +++ b/Interface_WebAPI/WebApi/Controller/ZSaveTagController.cs @@ -0,0 +1,122 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; + + +namespace WebApi +{ + + [RoutePrefix("api/ZSaveTag")] //定义路由前缀 + public class ZSaveTagController : ApiController + { + + /// + /// 插入数据库 + /// + /// + /// + [HttpPost] + public void Insert(JObject jObject) + { + string pp = ""; + try + { + var z_Save_Tag = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(jObject)); + + string sql = "" + + "INSERT INTO z_save_tag (OpName, TagID, Value, KeepTime, OperationTime, ProjectCode) " + + " VALUES('"+ z_Save_Tag.OpName+ "', '"+ z_Save_Tag.TagID+ "', '"+ z_Save_Tag.Value+ "', '"+ z_Save_Tag .KeepTime+ "', '"+ z_Save_Tag .OperationTime+ "', '"+ z_Save_Tag .ProjectCode+ "'); \n"; + var res = GlobalVar.dbClient.ExecNonQuery(sql); + + pp = res.ToString(); + + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + } + // HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") }; + // return result; + } + + [HttpPost] + public HttpResponseMessage SelectPage([FromBody]JObject jobj) + { + string pp = ""; + + try + { + var OpName = jobj["OpName"].ToString(); + var StartTime = jobj["StartTime"].ToString(); + var EndTime = jobj["EndTime"].ToString(); + var PageCurrent = jobj["PageCurrent"].ToString(); + var PageSize = jobj["PageSize"].ToString(); + + + string sql = "SELECT * FROM z_save_tag " + + "WHERE(OperationTime BETWEEN '" + StartTime + "' AND '" + EndTime + "') AND OpName like '" + OpName + "%' " + + "ORDER BY OperationTime;\n"; + var res = GlobalVar.dbClient.ExecQuery(sql); + + var zSavePersonList = Z_Save_Position.DataTableToClass(res); + + var newZSaveList = DatabaseClient.DBClient.SplitePage(zSavePersonList, Convert.ToInt32(PageSize), Convert.ToInt32(PageCurrent)); + var tableData = (JArray)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(newZSaveList)); + JObject resjobj = new JObject() { + new JProperty("ItemCount", zSavePersonList.Count.ToString()), + new JProperty("TableData",tableData) + }; + + pp = resjobj.ToString() + //.Replace("\r\n","") + ; + + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + // Console.WriteLine(err.Message); + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } + + [HttpPost] + public HttpResponseMessage Select([FromBody] JObject jobj) + { + string pp = ""; + try + { + string OpName = jobj["OpName"].ToString(); + string StartTime = jobj["StartTime"].ToString(); + string EndTime = jobj["EndTime"].ToString(); + + string sql = "SELECT * FROM z_save_tag " + + "WHERE(OperationTime BETWEEN '"+StartTime+"' AND '"+EndTime+"') AND OpName like '"+OpName+"%' " + + "ORDER BY OperationTime;\n"; + var res = GlobalVar.dbClient.ExecQuery(sql); + + var zSavePersonList = Z_Save_Position.DataTableToClass(res); + + var zSavePersonListStr = JsonConvert.SerializeObject(zSavePersonList); + + pp = zSavePersonListStr.ToString(); + } + catch (Exception err) + { + GlobalVar.log.Error(err.Message); + // Console.WriteLine(err.Message); + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } + } +} diff --git a/Interface_WebAPI/WebApi/GlobalVar.cs b/Interface_WebAPI/WebApi/GlobalVar.cs new file mode 100644 index 0000000..1f22604 --- /dev/null +++ b/Interface_WebAPI/WebApi/GlobalVar.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DatabaseClient; +using log4net; + +namespace WebApi +{ + class GlobalVar + { + public static DatabaseClient.DBClient dbClient; + public static ILog log = LogManager.GetLogger("WebApi"); + } +} diff --git a/Interface_WebAPI/WebApi/InitServer.cs b/Interface_WebAPI/WebApi/InitServer.cs new file mode 100644 index 0000000..6c5c09c --- /dev/null +++ b/Interface_WebAPI/WebApi/InitServer.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Web.Http; +using System.Web.Http.Cors; +using System.Web.Http.SelfHost; + +namespace WebApi +{ + + + public class InitServer + { + HttpSelfHostConfiguration config = null; + HttpSelfHostServer server = null; + public InitServer(string Url_WebApi) + { + // var Url_WebApi = System.Configuration.ConfigurationManager.AppSettings["Url_WebApi"]; + Init(Url_WebApi); + } + public void Init(string url) + { + config = new HttpSelfHostConfiguration(url); + + // 启用跨域 + config.EnableCors(new EnableCorsAttribute("*", "*", "*")); + // 启用特性路由 + config.MapHttpAttributeRoutes(); + + //config.Routes.MapHttpRoute( + // name: "DefaultApi", + // routeTemplate: "api/{controller}/{id}", + // defaults: new { id = RouteParameter.Optional } + //); + + // 自定义路由匹配到action + config.Routes.MapHttpRoute( + name: "API Default", + routeTemplate: "api/{controller}/{action}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + + + + server = new HttpSelfHostServer(config); + + server.OpenAsync().Wait(); + + + } + public class JsonContentNegotiator : IContentNegotiator + { + private readonly JsonMediaTypeFormatter _jsonFormatter; + + public JsonContentNegotiator(JsonMediaTypeFormatter formatter) + { + _jsonFormatter = formatter; + } + public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable formatters) + { + var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json")); + return result; + } + } + } +} diff --git a/Interface_WebAPI/WebApi/Program.cs b/Interface_WebAPI/WebApi/Program.cs new file mode 100644 index 0000000..531e9ae --- /dev/null +++ b/Interface_WebAPI/WebApi/Program.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DatabaseClient; + + +namespace WebApi +{ + + internal class Program + { + static void Main(string[] args) + { + + // CallDbFactoryTest(); + + #region DBConfig + var DatabaseType = System.Configuration.ConfigurationManager.AppSettings["DatabaseType"]; + var connString = ""; + switch (DatabaseType.ToLower()) + { + case "mysql": + { + connString = System.Configuration.ConfigurationManager.AppSettings["MysqlConnectString"]; + break; + } + case "mssql": + { + connString = System.Configuration.ConfigurationManager.AppSettings["MssqlConnectString"]; + break; + } + case "sqlite": + { + connString = System.Configuration.ConfigurationManager.AppSettings["SqliteConnectString"]; + break; + } + default: + { + connString = System.Configuration.ConfigurationManager.AppSettings["MysqlConnectString"]; + break; + } + } + + GlobalVar.dbClient = new DBClientFactory(DatabaseType).Create(); + GlobalVar.dbClient.Connect(connString); + #endregion + + var WebApiUrl = System.Configuration.ConfigurationManager.AppSettings["WebApiUrl"]; + new InitServer(WebApiUrl); + + + //GlobalVar.log.Error("错误", new Exception("发生了一个异常"));//错误 + //GlobalVar.log.Fatal("严重错误", new Exception("发生了一个致命错误"));//严重错误 + //GlobalVar.log.Info("信息"); //记录一般信息 + //GlobalVar.log.Debug("调试信息");//记录调试信息 + //GlobalVar.log.Warn("警告");//记录警告信息 + + + GlobalVar.log.Info("Start WebApi server..."); //记录一般信息 + GlobalVar.log.Info(" " + WebApiUrl); //记录一般信息 + // Console.WriteLine("Start WebApi server..."); + // Console.WriteLine(" " + WebApiUrl); + + Console.ReadKey(); + } + + static void CallDbFactoryTest() + { + DBClientFactory factory = new DBClientFactory("Mysql"); + // 只需切换 MySqlDatabaseFactory 就可切换数据库 + var mySqlClient = factory.Create(); + + + // MySqlClient sqlClient = new MySqlClient(); + mySqlClient.Connect("server=localhost;database=mytest;username=root;password=123456;"); + var ds = mySqlClient.ExecQuery("select * from Z_Save_Position"); + var zSavePositionList = Z_Save_Position.DataTableToClass(ds); + } + } +} diff --git a/Interface_WebAPI/WebApi/Properties/AssemblyInfo.cs b/Interface_WebAPI/WebApi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..35fc201 --- /dev/null +++ b/Interface_WebAPI/WebApi/Properties/AssemblyInfo.cs @@ -0,0 +1,39 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WebApi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WebApi")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5c6e31a8-8b45-4459-ba62-07af6135df4a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +// 指定log4net 的配置文件 +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] \ No newline at end of file diff --git a/Interface_WebAPI/WebApi/Properties/app.manifest b/Interface_WebAPI/WebApi/Properties/app.manifest new file mode 100644 index 0000000..db843ba --- /dev/null +++ b/Interface_WebAPI/WebApi/Properties/app.manifest @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/WebApi/Z_Save_Position.cs b/Interface_WebAPI/WebApi/Z_Save_Position.cs new file mode 100644 index 0000000..f22f343 --- /dev/null +++ b/Interface_WebAPI/WebApi/Z_Save_Position.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using System.Data; + +namespace WebApi +{ + class Z_Save_Position + { + public int ID; + public string OpName; + public string Value; + public string OperationTime; + public string ProjectCode; + + public Z_Save_Position() { } + + public static List DataTableToClass(DataTable dt_Z_Save_Position) + { + List z_Save_PositionList = new List(); + Z_Save_Position z_Save_Position; + for (int i = 0; i < dt_Z_Save_Position.Rows.Count; i++) + { + z_Save_Position = new Z_Save_Position(); + var row = dt_Z_Save_Position.Rows[i]; + z_Save_Position.ID = Convert.ToInt32(row["ID"]); + z_Save_Position.OpName = row["OpName"].ToString(); + z_Save_Position.Value = row["Value"].ToString(); + z_Save_Position.OperationTime = row["OperationTime"].ToString(); + z_Save_Position.ProjectCode = row["ProjectCode"].ToString(); + z_Save_PositionList.Add(z_Save_Position); + } + + return z_Save_PositionList; + } + } +} diff --git a/Interface_WebAPI/WebApi/Z_Save_Tag.cs b/Interface_WebAPI/WebApi/Z_Save_Tag.cs new file mode 100644 index 0000000..4626848 --- /dev/null +++ b/Interface_WebAPI/WebApi/Z_Save_Tag.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebApi +{ + class Z_Save_Tag + { + public int ID; + public string OpName; + public string TagID; + public string Value; + public string KeepTime; + public string OperationTime; + public string ProjectCode; + public Z_Save_Tag() + { + + } + public static List DataTableToClass(DataTable dt_Z_Save_Tag) + { + List z_Save_TagList = new List(); + Z_Save_Tag z_Save_Tag; + for (int i = 0; i < dt_Z_Save_Tag.Rows.Count; i++) + { + z_Save_Tag = new Z_Save_Tag(); + + var row = dt_Z_Save_Tag.Rows[i]; + z_Save_Tag.ID = Convert.ToInt32(row["ID"]); + z_Save_Tag.OpName = row["OpName"].ToString(); + z_Save_Tag.TagID = row["TagID"].ToString(); + z_Save_Tag.Value = row["Value"].ToString(); + z_Save_Tag.KeepTime = row["KeepTime"].ToString(); + z_Save_Tag.OperationTime = row["OperationTime"].ToString(); + z_Save_Tag.ProjectCode = row["ProjectCode"].ToString(); + + z_Save_TagList.Add(z_Save_Tag); + } + + return z_Save_TagList; + } + } +} diff --git a/Interface_WebAPI/WebApi/log4net.config b/Interface_WebAPI/WebApi/log4net.config new file mode 100644 index 0000000..5ec9cd8 --- /dev/null +++ b/Interface_WebAPI/WebApi/log4net.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/WebApi/mysql.sql b/Interface_WebAPI/WebApi/mysql.sql new file mode 100644 index 0000000..af19273 --- /dev/null +++ b/Interface_WebAPI/WebApi/mysql.sql @@ -0,0 +1,30 @@ +CREATE DATABASE mytest; +USE mytest; +# show databases; +# show engines; +# show variables like '%character%'; + +-- auto-generated definition +create table z_save_position +( + ID int auto_increment + primary key, + OpName varchar(50) null, + Value varchar(200) null, + OperationTime datetime null, + ProjectCode varchar(50) null +)engine = InnoDB; + + +-- auto-generated definition +create table z_save_tag +( + ID int auto_increment + primary key, + OpName varchar(50) null, + TagID varchar(50) null, + Value varchar(200) null, + KeepTime varchar(50) null, + OperationTime datetime null, + ProjectCode varchar(50) null +)engine = InnoDB; \ No newline at end of file diff --git a/Interface_WebAPI/WebApi/packages.config b/Interface_WebAPI/WebApi/packages.config new file mode 100644 index 0000000..49b7fab --- /dev/null +++ b/Interface_WebAPI/WebApi/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Interface_WebAPI/mytest.sqlite b/Interface_WebAPI/mytest.sqlite new file mode 100644 index 0000000..a6d844e Binary files /dev/null and b/Interface_WebAPI/mytest.sqlite differ diff --git a/MES基础数据.xlsx b/MES基础数据.xlsx new file mode 100644 index 0000000..2740181 Binary files /dev/null and b/MES基础数据.xlsx differ diff --git a/Mes32X32.ico b/Mes32X32.ico new file mode 100644 index 0000000..ec465b2 Binary files /dev/null and b/Mes32X32.ico differ diff --git a/MisDataFun.sln b/MisDataFun.sln new file mode 100644 index 0000000..d62dd3a --- /dev/null +++ b/MisDataFun.sln @@ -0,0 +1,109 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MisDataFun", "MisDataFun\MisDataFun\MisDataFun.csproj", "{DD9131C7-BF40-45B0-827A-C5E46FC8A89E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01-MesDataFunction", "Common\09MesDataFunction\MesDataFunction\01-MesDataFunction.csproj", "{90E76FB4-646D-45E2-95DB-0B8AB4E465D6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Function", "Function", "{4BF576F8-7AFE-41D3-A998-2AE62375DEC6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "00_MyLog4Net", "Common\MyLog4Net\00_MyLog4Net.csproj", "{1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1051", "MisDataFunction\Function1051\Function1051.csproj", "{B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1052", "MisDataFunction\Function1052\Function1052.csproj", "{5FEE5C91-8419-49FF-B2C2-47476F0B8C68}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1053", "MisDataFunction\Function1053\Function1053.csproj", "{CA8A12C5-7BF0-4489-93FA-180B1C492BBA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1054", "MisDataFunction\Function1054\Function1054.csproj", "{CC45D613-11B9-48AF-B073-6523D6273525}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalDataSync", "Interface_WebAPI\SlMesDbIterface\ExternalDataSync.csproj", "{2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|x86.ActiveCfg = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|x86.Build.0 = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|Any CPU.Build.0 = Release|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|x86.ActiveCfg = Release|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|x86.Build.0 = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|x86.ActiveCfg = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|x86.Build.0 = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.Build.0 = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|x86.ActiveCfg = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|x86.Build.0 = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|x86.ActiveCfg = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|x86.Build.0 = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|Any CPU.Build.0 = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|x86.ActiveCfg = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|x86.Build.0 = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|x86.ActiveCfg = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|x86.Build.0 = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|Any CPU.Build.0 = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|x86.ActiveCfg = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|x86.Build.0 = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|x86.ActiveCfg = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|x86.Build.0 = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|Any CPU.Build.0 = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|x86.ActiveCfg = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|x86.Build.0 = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|x86.ActiveCfg = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|x86.Build.0 = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|Any CPU.Build.0 = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|x86.ActiveCfg = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|x86.Build.0 = Release|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Debug|x86.ActiveCfg = Debug|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Debug|x86.Build.0 = Debug|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Release|Any CPU.Build.0 = Release|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Release|x86.ActiveCfg = Release|Any CPU + {CC45D613-11B9-48AF-B073-6523D6273525}.Release|x86.Build.0 = Release|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Debug|x86.ActiveCfg = Debug|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Debug|x86.Build.0 = Debug|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Release|Any CPU.Build.0 = Release|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Release|x86.ActiveCfg = Release|Any CPU + {2F33D79D-1DFF-4CDA-B357-FCD5221CAB9A}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + {CC45D613-11B9-48AF-B073-6523D6273525} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9BB32B35-134E-4853-B853-73A014D416DF} + EndGlobalSection +EndGlobal diff --git a/MisDataFun/MisDataFun/App.config b/MisDataFun/MisDataFun/App.config new file mode 100644 index 0000000..3eedead --- /dev/null +++ b/MisDataFun/MisDataFun/App.config @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/Mes32X32.ico b/MisDataFun/MisDataFun/Mes32X32.ico new file mode 100644 index 0000000..ec465b2 Binary files /dev/null and b/MisDataFun/MisDataFun/Mes32X32.ico differ diff --git a/MisDataFun/MisDataFun/MisDataFun.Designer.cs b/MisDataFun/MisDataFun/MisDataFun.Designer.cs new file mode 100644 index 0000000..be54a6c --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.Designer.cs @@ -0,0 +1,1952 @@ + +namespace MisDataSaveDate +{ + partial class MesServerMisDataFun + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MesServerMisDataFun)); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.ToolStripMenuItem_PlcDebug = new System.Windows.Forms.ToolStripMenuItem(); + this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.版本信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.关于迈思ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.webApi调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.textBox_WEB_TO_MES = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.textBox_PLC_TO_MES = new System.Windows.Forms.TextBox(); + this.panel8 = new System.Windows.Forms.Panel(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.button9 = new System.Windows.Forms.Button(); + this.button10 = new System.Windows.Forms.Button(); + this.button11 = new System.Windows.Forms.Button(); + this.button12 = new System.Windows.Forms.Button(); + this.button13 = new System.Windows.Forms.Button(); + this.button14 = new System.Windows.Forms.Button(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.button15 = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.button16 = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.textBox_MES_TO_WEB = new System.Windows.Forms.TextBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.checkBox_PLC_TO_MES = new System.Windows.Forms.CheckBox(); + this.button_PLC_TO_MES_Clear = new System.Windows.Forms.Button(); + this.button_PLC_TO_MES_Big = new System.Windows.Forms.Button(); + this.button_PLC_TO_MES_Small = new System.Windows.Forms.Button(); + this.panel3 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.dataGridView_CheckOpName = new System.Windows.Forms.DataGridView(); + this.选择 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.工位号 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.checkBox__MES_TO_WEB = new System.Windows.Forms.CheckBox(); + this.button_MES_TO_WEB_Clear = new System.Windows.Forms.Button(); + this.button_MES_TO_WEB_Small = new System.Windows.Forms.Button(); + this.button_MES_TO_WEB_Big = new System.Windows.Forms.Button(); + this.panel4 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); + this.button_WEB_TO_MES_Big = new System.Windows.Forms.Button(); + this.button_WEB_TO_MES_Small = new System.Windows.Forms.Button(); + this.checkBox_WEB_TO_MES = new System.Windows.Forms.CheckBox(); + this.button_WEB_TO_MES_Clear = new System.Windows.Forms.Button(); + this.panel5 = new System.Windows.Forms.Panel(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.textBox_MqttText = new System.Windows.Forms.TextBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); + this.panel6 = new System.Windows.Forms.Panel(); + this.button_SaveData = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.comboBox_OpNameList = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button_ToWEB = new System.Windows.Forms.Button(); + this.button_WebToMES = new System.Windows.Forms.Button(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage6 = new System.Windows.Forms.TabPage(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.tabPage5 = new System.Windows.Forms.TabPage(); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.panel7 = new System.Windows.Forms.Panel(); + this.dgv_OpName = new System.Windows.Forms.DataGridView(); + this.OpCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.OpName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MesDll = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PLC = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PLC代码 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.label11 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.button20 = new System.Windows.Forms.Button(); + this.MesEngineDataWritePlc = new System.Windows.Forms.Button(); + this.button18 = new System.Windows.Forms.Button(); + this.textBox1_EngineID = new System.Windows.Forms.TextBox(); + this.textBox2_EngineTypeID = new System.Windows.Forms.TextBox(); + this.textBox3_palletCode = new System.Windows.Forms.TextBox(); + this.button17 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.panel_Signal_Conf = new System.Windows.Forms.Panel(); + this.pb_OnLine_Print = new System.Windows.Forms.PictureBox(); + this.label28 = new System.Windows.Forms.Label(); + this.pb_OnLine_SQL = new System.Windows.Forms.PictureBox(); + this.label14 = new System.Windows.Forms.Label(); + this.pb_OnLine_MQTT = new System.Windows.Forms.PictureBox(); + this.label15 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.txt_PLC_39 = new System.Windows.Forms.TextBox(); + this.txt_PLC_11 = new System.Windows.Forms.TextBox(); + this.txt_PLC_10 = new System.Windows.Forms.TextBox(); + this.txt_PLC_9 = new System.Windows.Forms.TextBox(); + this.txt_Interval = new System.Windows.Forms.TextBox(); + this.cb_F5 = new System.Windows.Forms.CheckBox(); + this.label27 = new System.Windows.Forms.Label(); + this.label26 = new System.Windows.Forms.Label(); + this.label25 = new System.Windows.Forms.Label(); + this.label24 = new System.Windows.Forms.Label(); + this.btn_PLC_59 = new System.Windows.Forms.Button(); + this.btn_PLC_2 = new System.Windows.Forms.Button(); + this.btn_PLC_43 = new System.Windows.Forms.Button(); + this.btn_PLC_1002 = new System.Windows.Forms.Button(); + this.btn_MES_5 = new System.Windows.Forms.Button(); + this.btn_PLC_1001 = new System.Windows.Forms.Button(); + this.btn_PLC_44 = new System.Windows.Forms.Button(); + this.btn_PLC_1000 = new System.Windows.Forms.Button(); + this.btn_MES_66 = new System.Windows.Forms.Button(); + this.btn_MES_7 = new System.Windows.Forms.Button(); + this.btn_PLC_19 = new System.Windows.Forms.Button(); + this.btn_MES_20 = new System.Windows.Forms.Button(); + this.label13 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.richTextBox1_mqtt = new System.Windows.Forms.RichTextBox(); + this.timer_Status = new System.Windows.Forms.Timer(this.components); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel_RunningStatu = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_RunningStatus = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_StartTime = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_RunTime = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_WorkStationNum = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_Version = new System.Windows.Forms.ToolStripStatusLabel(); + this.menuStrip1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.panel8.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); + this.panel3.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CheckOpName)).BeginInit(); + this.panel4.SuspendLayout(); + this.tableLayoutPanel4.SuspendLayout(); + this.panel5.SuspendLayout(); + this.panel2.SuspendLayout(); + this.tableLayoutPanel5.SuspendLayout(); + this.panel6.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.panel7.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_OpName)).BeginInit(); + this.groupBox4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_Print)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_SQL)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_MQTT)).BeginInit(); + this.groupBox2.SuspendLayout(); + this.statusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripMenuItem_PlcDebug, + this.帮助ToolStripMenuItem, + this.webApi调试ToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(1053, 25); + this.menuStrip1.TabIndex = 2; + this.menuStrip1.Text = "menuStrip1"; + // + // ToolStripMenuItem_PlcDebug + // + this.ToolStripMenuItem_PlcDebug.Name = "ToolStripMenuItem_PlcDebug"; + this.ToolStripMenuItem_PlcDebug.Size = new System.Drawing.Size(89, 21); + this.ToolStripMenuItem_PlcDebug.Text = "PLC信号调试"; + this.ToolStripMenuItem_PlcDebug.Click += new System.EventHandler(this.ToolStripMenuItem_PlcDebug_Click); + // + // 帮助ToolStripMenuItem + // + this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.版本信息ToolStripMenuItem, + this.关于迈思ToolStripMenuItem}); + this.帮助ToolStripMenuItem.Name = "帮助ToolStripMenuItem"; + this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(44, 21); + this.帮助ToolStripMenuItem.Text = "帮助"; + // + // 版本信息ToolStripMenuItem + // + this.版本信息ToolStripMenuItem.Name = "版本信息ToolStripMenuItem"; + this.版本信息ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.版本信息ToolStripMenuItem.Text = "版本信息"; + this.版本信息ToolStripMenuItem.Click += new System.EventHandler(this.版本信息ToolStripMenuItem_Click); + // + // 关于迈思ToolStripMenuItem + // + this.关于迈思ToolStripMenuItem.Name = "关于迈思ToolStripMenuItem"; + this.关于迈思ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.关于迈思ToolStripMenuItem.Text = "关于迈思"; + this.关于迈思ToolStripMenuItem.Click += new System.EventHandler(this.关于迈思ToolStripMenuItem_Click); + // + // webApi调试ToolStripMenuItem + // + this.webApi调试ToolStripMenuItem.Name = "webApi调试ToolStripMenuItem"; + this.webApi调试ToolStripMenuItem.Size = new System.Drawing.Size(90, 21); + this.webApi调试ToolStripMenuItem.Text = "WebApi调试"; + this.webApi调试ToolStripMenuItem.Click += new System.EventHandler(this.webAPI接口测试ToolStripMenuItem_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F)); + this.tableLayoutPanel1.Controls.Add(this.groupBox5, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.groupBox3, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.panel3, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.panel4, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.panel5, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.panel2, 0, 3); + this.tableLayoutPanel1.Location = new System.Drawing.Point(334, 319); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(590, 341); + this.tableLayoutPanel1.TabIndex = 3; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.textBox_WEB_TO_MES); + this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox5.Location = new System.Drawing.Point(2, 172); + this.groupBox5.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox5.Size = new System.Drawing.Size(386, 64); + this.groupBox5.TabIndex = 4; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "页面发送到MES系统信息"; + // + // textBox_WEB_TO_MES + // + this.textBox_WEB_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox_WEB_TO_MES.Location = new System.Drawing.Point(2, 16); + this.textBox_WEB_TO_MES.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.textBox_WEB_TO_MES.Multiline = true; + this.textBox_WEB_TO_MES.Name = "textBox_WEB_TO_MES"; + this.textBox_WEB_TO_MES.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_WEB_TO_MES.Size = new System.Drawing.Size(382, 46); + this.textBox_WEB_TO_MES.TabIndex = 1; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.textBox_PLC_TO_MES); + this.groupBox1.Controls.Add(this.panel8); + this.groupBox1.Location = new System.Drawing.Point(2, 2); + this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox1.Size = new System.Drawing.Size(386, 64); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "设备PLC信号"; + // + // textBox_PLC_TO_MES + // + this.textBox_PLC_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox_PLC_TO_MES.Location = new System.Drawing.Point(2, 16); + this.textBox_PLC_TO_MES.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.textBox_PLC_TO_MES.Multiline = true; + this.textBox_PLC_TO_MES.Name = "textBox_PLC_TO_MES"; + this.textBox_PLC_TO_MES.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_PLC_TO_MES.Size = new System.Drawing.Size(382, 46); + this.textBox_PLC_TO_MES.TabIndex = 0; + // + // panel8 + // + this.panel8.Controls.Add(this.button4); + this.panel8.Controls.Add(this.button5); + this.panel8.Controls.Add(this.button6); + this.panel8.Controls.Add(this.button7); + this.panel8.Controls.Add(this.button8); + this.panel8.Controls.Add(this.button9); + this.panel8.Controls.Add(this.button10); + this.panel8.Controls.Add(this.button11); + this.panel8.Controls.Add(this.button12); + this.panel8.Controls.Add(this.button13); + this.panel8.Controls.Add(this.button14); + this.panel8.Controls.Add(this.checkBox1); + this.panel8.Controls.Add(this.checkBox2); + this.panel8.Controls.Add(this.button15); + this.panel8.Controls.Add(this.label6); + this.panel8.Controls.Add(this.button16); + this.panel8.Controls.Add(this.label7); + this.panel8.Controls.Add(this.richTextBox1); + this.panel8.Location = new System.Drawing.Point(-327, -264); + this.panel8.Name = "panel8"; + this.panel8.Size = new System.Drawing.Size(1039, 646); + this.panel8.TabIndex = 5; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(510, 307); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(75, 23); + this.button4.TabIndex = 1479; + this.button4.Text = "工作完成M"; + this.button4.UseVisualStyleBackColor = true; + // + // button5 + // + this.button5.Location = new System.Drawing.Point(510, 280); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(75, 23); + this.button5.TabIndex = 1479; + this.button5.Text = "工作完成M"; + this.button5.UseVisualStyleBackColor = true; + // + // button6 + // + this.button6.Location = new System.Drawing.Point(510, 251); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(75, 23); + this.button6.TabIndex = 1478; + this.button6.Text = "工作完成M"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.workOverMES_Click); + // + // button7 + // + this.button7.Location = new System.Drawing.Point(510, 222); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(75, 23); + this.button7.TabIndex = 1478; + this.button7.Text = "保存完成M"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.saveOverMES_Click); + // + // button8 + // + this.button8.Location = new System.Drawing.Point(510, 193); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(75, 23); + this.button8.TabIndex = 1478; + this.button8.Text = "允许保存P"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.allowSavePLC_Click); + // + // button9 + // + this.button9.Location = new System.Drawing.Point(509, 164); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(75, 23); + this.button9.TabIndex = 1478; + this.button9.Text = "允许工作M"; + this.button9.UseVisualStyleBackColor = true; + this.button9.Click += new System.EventHandler(this.allowWorkMES_Click); + // + // button10 + // + this.button10.Location = new System.Drawing.Point(509, 135); + this.button10.Name = "button10"; + this.button10.Size = new System.Drawing.Size(75, 23); + this.button10.TabIndex = 1478; + this.button10.Text = "传递机型P"; + this.button10.UseVisualStyleBackColor = true; + this.button10.Click += new System.EventHandler(this.EngineGetOverPLC_Click); + // + // button11 + // + this.button11.Location = new System.Drawing.Point(509, 106); + this.button11.Name = "button11"; + this.button11.Size = new System.Drawing.Size(75, 23); + this.button11.TabIndex = 1478; + this.button11.Text = "传递机型M"; + this.button11.UseVisualStyleBackColor = true; + this.button11.Click += new System.EventHandler(this.EngineGetOverMES_Click); + // + // button12 + // + this.button12.Location = new System.Drawing.Point(510, 77); + this.button12.Name = "button12"; + this.button12.Size = new System.Drawing.Size(75, 23); + this.button12.TabIndex = 1478; + this.button12.Text = "申请上线P"; + this.button12.UseVisualStyleBackColor = true; + this.button12.Click += new System.EventHandler(this.PartLoadPLC_Click); + // + // button13 + // + this.button13.Location = new System.Drawing.Point(509, 48); + this.button13.Name = "button13"; + this.button13.Size = new System.Drawing.Size(75, 23); + this.button13.TabIndex = 1478; + this.button13.Text = "工件到位P"; + this.button13.UseVisualStyleBackColor = true; + this.button13.Click += new System.EventHandler(this.WorkStartPLC_Click); + // + // button14 + // + this.button14.Location = new System.Drawing.Point(703, 6); + this.button14.Name = "button14"; + this.button14.Size = new System.Drawing.Size(158, 39); + this.button14.TabIndex = 1477; + this.button14.Text = "初始化报警"; + this.button14.UseVisualStyleBackColor = true; + this.button14.Click += new System.EventHandler(this.button2_Click); + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(11, 27); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(72, 16); + this.checkBox1.TabIndex = 1475; + this.checkBox1.Text = "质量数据"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(11, 7); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(72, 16); + this.checkBox2.TabIndex = 1476; + this.checkBox2.Text = "监控数据"; + this.checkBox2.UseVisualStyleBackColor = true; + // + // button15 + // + this.button15.Location = new System.Drawing.Point(867, 6); + this.button15.Name = "button15"; + this.button15.Size = new System.Drawing.Size(161, 39); + this.button15.TabIndex = 4; + this.button15.Text = "MQTT服务状态"; + this.button15.UseVisualStyleBackColor = true; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(91, 7); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(65, 12); + this.label6.TabIndex = 1471; + this.label6.Text = "工位编号:"; + // + // button16 + // + this.button16.Location = new System.Drawing.Point(187, 19); + this.button16.Name = "button16"; + this.button16.Size = new System.Drawing.Size(62, 26); + this.button16.TabIndex = 1474; + this.button16.Text = "读取数据"; + this.button16.UseVisualStyleBackColor = true; + this.button16.Click += new System.EventHandler(this.button_ReadData_Click); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(600, 27); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(29, 12); + this.label7.TabIndex = 1; + this.label7.Text = "日志"; + // + // richTextBox1 + // + this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.richTextBox1.Location = new System.Drawing.Point(591, 47); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.Size = new System.Drawing.Size(437, 601); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.textBox_MES_TO_WEB); + this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox3.Location = new System.Drawing.Point(2, 70); + this.groupBox3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox3.Size = new System.Drawing.Size(386, 98); + this.groupBox3.TabIndex = 2; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "MES系统发送到页面信息"; + // + // textBox_MES_TO_WEB + // + this.textBox_MES_TO_WEB.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox_MES_TO_WEB.Location = new System.Drawing.Point(2, 16); + this.textBox_MES_TO_WEB.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.textBox_MES_TO_WEB.Multiline = true; + this.textBox_MES_TO_WEB.Name = "textBox_MES_TO_WEB"; + this.textBox_MES_TO_WEB.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_MES_TO_WEB.Size = new System.Drawing.Size(382, 80); + this.textBox_MES_TO_WEB.TabIndex = 1; + // + // panel1 + // + this.panel1.Controls.Add(this.tableLayoutPanel3); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(392, 2); + this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(196, 64); + this.panel1.TabIndex = 10; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.ColumnCount = 4; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel3.Controls.Add(this.checkBox_PLC_TO_MES, 0, 0); + this.tableLayoutPanel3.Controls.Add(this.button_PLC_TO_MES_Clear, 3, 0); + this.tableLayoutPanel3.Controls.Add(this.button_PLC_TO_MES_Big, 2, 0); + this.tableLayoutPanel3.Controls.Add(this.button_PLC_TO_MES_Small, 1, 0); + this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 2; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(196, 64); + this.tableLayoutPanel3.TabIndex = 3; + // + // checkBox_PLC_TO_MES + // + this.checkBox_PLC_TO_MES.AutoSize = true; + this.checkBox_PLC_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBox_PLC_TO_MES.Location = new System.Drawing.Point(2, 2); + this.checkBox_PLC_TO_MES.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.checkBox_PLC_TO_MES.Name = "checkBox_PLC_TO_MES"; + this.checkBox_PLC_TO_MES.Size = new System.Drawing.Size(54, 22); + this.checkBox_PLC_TO_MES.TabIndex = 0; + this.checkBox_PLC_TO_MES.Text = "监控"; + this.checkBox_PLC_TO_MES.UseVisualStyleBackColor = true; + // + // button_PLC_TO_MES_Clear + // + this.button_PLC_TO_MES_Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.button_PLC_TO_MES_Clear.Location = new System.Drawing.Point(138, 2); + this.button_PLC_TO_MES_Clear.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_PLC_TO_MES_Clear.Name = "button_PLC_TO_MES_Clear"; + this.button_PLC_TO_MES_Clear.Size = new System.Drawing.Size(56, 22); + this.button_PLC_TO_MES_Clear.TabIndex = 1; + this.button_PLC_TO_MES_Clear.Text = "清空"; + this.button_PLC_TO_MES_Clear.UseVisualStyleBackColor = true; + // + // button_PLC_TO_MES_Big + // + this.button_PLC_TO_MES_Big.Location = new System.Drawing.Point(99, 2); + this.button_PLC_TO_MES_Big.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_PLC_TO_MES_Big.Name = "button_PLC_TO_MES_Big"; + this.button_PLC_TO_MES_Big.Size = new System.Drawing.Size(34, 20); + this.button_PLC_TO_MES_Big.TabIndex = 2; + this.button_PLC_TO_MES_Big.Text = "+"; + this.button_PLC_TO_MES_Big.UseVisualStyleBackColor = true; + // + // button_PLC_TO_MES_Small + // + this.button_PLC_TO_MES_Small.Location = new System.Drawing.Point(60, 2); + this.button_PLC_TO_MES_Small.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_PLC_TO_MES_Small.Name = "button_PLC_TO_MES_Small"; + this.button_PLC_TO_MES_Small.Size = new System.Drawing.Size(34, 20); + this.button_PLC_TO_MES_Small.TabIndex = 2; + this.button_PLC_TO_MES_Small.Text = "-"; + this.button_PLC_TO_MES_Small.UseVisualStyleBackColor = true; + // + // panel3 + // + this.panel3.Controls.Add(this.tableLayoutPanel2); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(392, 70); + this.panel3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(196, 98); + this.panel3.TabIndex = 12; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 4; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel2.Controls.Add(this.dataGridView_CheckOpName, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.checkBox__MES_TO_WEB, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.button_MES_TO_WEB_Clear, 3, 0); + this.tableLayoutPanel2.Controls.Add(this.button_MES_TO_WEB_Small, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.button_MES_TO_WEB_Big, 2, 0); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 2; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(196, 98); + this.tableLayoutPanel2.TabIndex = 1; + // + // dataGridView_CheckOpName + // + this.dataGridView_CheckOpName.AllowUserToAddRows = false; + this.dataGridView_CheckOpName.AllowUserToDeleteRows = false; + this.dataGridView_CheckOpName.AllowUserToResizeColumns = false; + this.dataGridView_CheckOpName.AllowUserToResizeRows = false; + this.dataGridView_CheckOpName.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView_CheckOpName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.选择, + this.工位号}); + this.tableLayoutPanel2.SetColumnSpan(this.dataGridView_CheckOpName, 4); + this.dataGridView_CheckOpName.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView_CheckOpName.Location = new System.Drawing.Point(2, 28); + this.dataGridView_CheckOpName.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.dataGridView_CheckOpName.MultiSelect = false; + this.dataGridView_CheckOpName.Name = "dataGridView_CheckOpName"; + this.dataGridView_CheckOpName.RowHeadersVisible = false; + this.dataGridView_CheckOpName.RowHeadersWidth = 62; + this.dataGridView_CheckOpName.RowTemplate.Height = 30; + this.dataGridView_CheckOpName.Size = new System.Drawing.Size(192, 68); + this.dataGridView_CheckOpName.TabIndex = 3; + // + // 选择 + // + this.选择.DataPropertyName = "选择"; + this.选择.HeaderText = "选择"; + this.选择.MinimumWidth = 8; + this.选择.Name = "选择"; + this.选择.Width = 60; + // + // 工位号 + // + this.工位号.DataPropertyName = "工位号"; + this.工位号.HeaderText = "工位号"; + this.工位号.MinimumWidth = 8; + this.工位号.Name = "工位号"; + this.工位号.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.工位号.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.工位号.Width = 218; + // + // checkBox__MES_TO_WEB + // + this.checkBox__MES_TO_WEB.AutoSize = true; + this.checkBox__MES_TO_WEB.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBox__MES_TO_WEB.Location = new System.Drawing.Point(2, 2); + this.checkBox__MES_TO_WEB.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.checkBox__MES_TO_WEB.Name = "checkBox__MES_TO_WEB"; + this.checkBox__MES_TO_WEB.Size = new System.Drawing.Size(54, 22); + this.checkBox__MES_TO_WEB.TabIndex = 0; + this.checkBox__MES_TO_WEB.Text = "监控"; + this.checkBox__MES_TO_WEB.UseVisualStyleBackColor = true; + // + // button_MES_TO_WEB_Clear + // + this.button_MES_TO_WEB_Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.button_MES_TO_WEB_Clear.Location = new System.Drawing.Point(138, 2); + this.button_MES_TO_WEB_Clear.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_MES_TO_WEB_Clear.Name = "button_MES_TO_WEB_Clear"; + this.button_MES_TO_WEB_Clear.Size = new System.Drawing.Size(56, 22); + this.button_MES_TO_WEB_Clear.TabIndex = 2; + this.button_MES_TO_WEB_Clear.Text = "清空"; + this.button_MES_TO_WEB_Clear.UseVisualStyleBackColor = true; + // + // button_MES_TO_WEB_Small + // + this.button_MES_TO_WEB_Small.Location = new System.Drawing.Point(60, 2); + this.button_MES_TO_WEB_Small.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_MES_TO_WEB_Small.Name = "button_MES_TO_WEB_Small"; + this.button_MES_TO_WEB_Small.Size = new System.Drawing.Size(34, 20); + this.button_MES_TO_WEB_Small.TabIndex = 4; + this.button_MES_TO_WEB_Small.Text = "-"; + this.button_MES_TO_WEB_Small.UseVisualStyleBackColor = true; + // + // button_MES_TO_WEB_Big + // + this.button_MES_TO_WEB_Big.Location = new System.Drawing.Point(99, 2); + this.button_MES_TO_WEB_Big.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_MES_TO_WEB_Big.Name = "button_MES_TO_WEB_Big"; + this.button_MES_TO_WEB_Big.Size = new System.Drawing.Size(34, 20); + this.button_MES_TO_WEB_Big.TabIndex = 4; + this.button_MES_TO_WEB_Big.Text = "+"; + this.button_MES_TO_WEB_Big.UseVisualStyleBackColor = true; + // + // panel4 + // + this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel4.Controls.Add(this.tableLayoutPanel4); + this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel4.Location = new System.Drawing.Point(392, 172); + this.panel4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(196, 64); + this.panel4.TabIndex = 13; + // + // tableLayoutPanel4 + // + this.tableLayoutPanel4.ColumnCount = 4; + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel4.Controls.Add(this.button_WEB_TO_MES_Big, 2, 0); + this.tableLayoutPanel4.Controls.Add(this.button_WEB_TO_MES_Small, 1, 0); + this.tableLayoutPanel4.Controls.Add(this.checkBox_WEB_TO_MES, 0, 0); + this.tableLayoutPanel4.Controls.Add(this.button_WEB_TO_MES_Clear, 3, 0); + this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.tableLayoutPanel4.Name = "tableLayoutPanel4"; + this.tableLayoutPanel4.RowCount = 2; + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel4.Size = new System.Drawing.Size(194, 62); + this.tableLayoutPanel4.TabIndex = 0; + // + // button_WEB_TO_MES_Big + // + this.button_WEB_TO_MES_Big.Location = new System.Drawing.Point(98, 2); + this.button_WEB_TO_MES_Big.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_WEB_TO_MES_Big.Name = "button_WEB_TO_MES_Big"; + this.button_WEB_TO_MES_Big.Size = new System.Drawing.Size(34, 20); + this.button_WEB_TO_MES_Big.TabIndex = 6; + this.button_WEB_TO_MES_Big.Text = "+"; + this.button_WEB_TO_MES_Big.UseVisualStyleBackColor = true; + // + // button_WEB_TO_MES_Small + // + this.button_WEB_TO_MES_Small.Location = new System.Drawing.Point(60, 2); + this.button_WEB_TO_MES_Small.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_WEB_TO_MES_Small.Name = "button_WEB_TO_MES_Small"; + this.button_WEB_TO_MES_Small.Size = new System.Drawing.Size(34, 20); + this.button_WEB_TO_MES_Small.TabIndex = 5; + this.button_WEB_TO_MES_Small.Text = "-"; + this.button_WEB_TO_MES_Small.UseVisualStyleBackColor = true; + // + // checkBox_WEB_TO_MES + // + this.checkBox_WEB_TO_MES.AutoSize = true; + this.checkBox_WEB_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBox_WEB_TO_MES.Location = new System.Drawing.Point(2, 2); + this.checkBox_WEB_TO_MES.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.checkBox_WEB_TO_MES.Name = "checkBox_WEB_TO_MES"; + this.checkBox_WEB_TO_MES.Size = new System.Drawing.Size(54, 22); + this.checkBox_WEB_TO_MES.TabIndex = 0; + this.checkBox_WEB_TO_MES.Text = "监控"; + this.checkBox_WEB_TO_MES.UseVisualStyleBackColor = true; + // + // button_WEB_TO_MES_Clear + // + this.button_WEB_TO_MES_Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.button_WEB_TO_MES_Clear.Location = new System.Drawing.Point(136, 2); + this.button_WEB_TO_MES_Clear.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_WEB_TO_MES_Clear.Name = "button_WEB_TO_MES_Clear"; + this.button_WEB_TO_MES_Clear.Size = new System.Drawing.Size(56, 22); + this.button_WEB_TO_MES_Clear.TabIndex = 1; + this.button_WEB_TO_MES_Clear.Text = "清空"; + this.button_WEB_TO_MES_Clear.UseVisualStyleBackColor = true; + // + // panel5 + // + this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel5.Controls.Add(this.comboBox1); + this.panel5.Controls.Add(this.textBox_MqttText); + this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel5.Location = new System.Drawing.Point(393, 240); + this.panel5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(194, 99); + this.panel5.TabIndex = 14; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(3, 6); + this.comboBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(188, 20); + this.comboBox1.TabIndex = 4; + // + // textBox_MqttText + // + this.textBox_MqttText.Location = new System.Drawing.Point(3, 32); + this.textBox_MqttText.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBox_MqttText.Multiline = true; + this.textBox_MqttText.Name = "textBox_MqttText"; + this.textBox_MqttText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_MqttText.Size = new System.Drawing.Size(186, 94); + this.textBox_MqttText.TabIndex = 15; + // + // panel2 + // + this.panel2.Controls.Add(this.tableLayoutPanel5); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(3, 240); + this.panel2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(384, 99); + this.panel2.TabIndex = 15; + // + // tableLayoutPanel5 + // + this.tableLayoutPanel5.ColumnCount = 2; + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F)); + this.tableLayoutPanel5.Controls.Add(this.panel6, 1, 0); + this.tableLayoutPanel5.Controls.Add(this.tabControl1, 0, 0); + this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel5.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tableLayoutPanel5.Name = "tableLayoutPanel5"; + this.tableLayoutPanel5.RowCount = 1; + this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel5.Size = new System.Drawing.Size(384, 99); + this.tableLayoutPanel5.TabIndex = 0; + // + // panel6 + // + this.panel6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel6.Controls.Add(this.button_SaveData); + this.panel6.Controls.Add(this.label1); + this.panel6.Controls.Add(this.label3); + this.panel6.Controls.Add(this.comboBox_OpNameList); + this.panel6.Controls.Add(this.label2); + this.panel6.Controls.Add(this.button_ToWEB); + this.panel6.Controls.Add(this.button_WebToMES); + this.panel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel6.Location = new System.Drawing.Point(187, 2); + this.panel6.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(194, 95); + this.panel6.TabIndex = 0; + // + // button_SaveData + // + this.button_SaveData.Location = new System.Drawing.Point(13, 95); + this.button_SaveData.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button_SaveData.Name = "button_SaveData"; + this.button_SaveData.Size = new System.Drawing.Size(56, 18); + this.button_SaveData.TabIndex = 4; + this.button_SaveData.Text = "保存质量数据"; + this.button_SaveData.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(4, 6); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(41, 12); + this.label1.TabIndex = 2; + this.label1.Text = "工位号"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(63, 62); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(125, 12); + this.label3.TabIndex = 3; + this.label3.Text = "WEB|CMD|OpName|Walue"; + // + // comboBox_OpNameList + // + this.comboBox_OpNameList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox_OpNameList.FormattingEnabled = true; + this.comboBox_OpNameList.Location = new System.Drawing.Point(51, 2); + this.comboBox_OpNameList.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBox_OpNameList.Name = "comboBox_OpNameList"; + this.comboBox_OpNameList.Size = new System.Drawing.Size(140, 20); + this.comboBox_OpNameList.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(63, 34); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(125, 12); + this.label2.TabIndex = 3; + this.label2.Text = "MES|CMD|OpName|Walue"; + // + // button_ToWEB + // + this.button_ToWEB.Location = new System.Drawing.Point(5, 30); + this.button_ToWEB.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.button_ToWEB.Name = "button_ToWEB"; + this.button_ToWEB.Size = new System.Drawing.Size(52, 22); + this.button_ToWEB.TabIndex = 0; + this.button_ToWEB.Text = "到页面"; + this.button_ToWEB.UseVisualStyleBackColor = true; + // + // button_WebToMES + // + this.button_WebToMES.Location = new System.Drawing.Point(6, 58); + this.button_WebToMES.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.button_WebToMES.Name = "button_WebToMES"; + this.button_WebToMES.Size = new System.Drawing.Size(51, 22); + this.button_WebToMES.TabIndex = 0; + this.button_WebToMES.Text = "到业务"; + this.button_WebToMES.UseVisualStyleBackColor = true; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage6); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Controls.Add(this.tabPage3); + this.tabControl1.Controls.Add(this.tabPage4); + this.tabControl1.Controls.Add(this.tabPage5); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(3, 2); + this.tabControl1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(178, 95); + this.tabControl1.TabIndex = 1; + // + // tabPage6 + // + this.tabPage6.Location = new System.Drawing.Point(4, 22); + this.tabPage6.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage6.Name = "tabPage6"; + this.tabPage6.Size = new System.Drawing.Size(170, 69); + this.tabPage6.TabIndex = 5; + this.tabPage6.Text = "订单信息"; + this.tabPage6.UseVisualStyleBackColor = true; + // + // tabPage1 + // + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage1.Size = new System.Drawing.Size(171, 69); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "产品信息"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // tabPage2 + // + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage2.Size = new System.Drawing.Size(171, 69); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "工步信息"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // tabPage3 + // + this.tabPage3.Location = new System.Drawing.Point(4, 22); + this.tabPage3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Size = new System.Drawing.Size(171, 69); + this.tabPage3.TabIndex = 2; + this.tabPage3.Text = "物料信息"; + this.tabPage3.UseVisualStyleBackColor = true; + // + // tabPage4 + // + this.tabPage4.Location = new System.Drawing.Point(4, 22); + this.tabPage4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage4.Name = "tabPage4"; + this.tabPage4.Size = new System.Drawing.Size(171, 69); + this.tabPage4.TabIndex = 3; + this.tabPage4.Text = "操作图片"; + this.tabPage4.UseVisualStyleBackColor = true; + // + // tabPage5 + // + this.tabPage5.Location = new System.Drawing.Point(4, 22); + this.tabPage5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tabPage5.Name = "tabPage5"; + this.tabPage5.Size = new System.Drawing.Size(171, 69); + this.tabPage5.TabIndex = 4; + this.tabPage5.Text = "PLC信号"; + this.tabPage5.UseVisualStyleBackColor = true; + // + // columnHeader6 + // + this.columnHeader6.Text = "TagID"; + this.columnHeader6.Width = 70; + // + // columnHeader7 + // + this.columnHeader7.Text = "测量项目"; + this.columnHeader7.Width = 130; + // + // columnHeader8 + // + this.columnHeader8.Text = "值"; + this.columnHeader8.Width = 100; + // + // columnHeader9 + // + this.columnHeader9.Text = "工位号"; + this.columnHeader9.Width = 70; + // + // columnHeader10 + // + this.columnHeader10.Text = "地址"; + this.columnHeader10.Width = 100; + // + // panel7 + // + this.panel7.Controls.Add(this.dgv_OpName); + this.panel7.Controls.Add(this.groupBox4); + this.panel7.Controls.Add(this.panel_Signal_Conf); + this.panel7.Controls.Add(this.pb_OnLine_Print); + this.panel7.Controls.Add(this.label28); + this.panel7.Controls.Add(this.pb_OnLine_SQL); + this.panel7.Controls.Add(this.label14); + this.panel7.Controls.Add(this.pb_OnLine_MQTT); + this.panel7.Controls.Add(this.label15); + this.panel7.Controls.Add(this.groupBox2); + this.panel7.Controls.Add(this.label13); + this.panel7.Controls.Add(this.button2); + this.panel7.Controls.Add(this.label4); + this.panel7.Controls.Add(this.richTextBox1_mqtt); + this.panel7.Location = new System.Drawing.Point(9, 28); + this.panel7.Name = "panel7"; + this.panel7.Size = new System.Drawing.Size(1039, 637); + this.panel7.TabIndex = 5; + // + // dgv_OpName + // + this.dgv_OpName.AllowUserToAddRows = false; + this.dgv_OpName.AllowUserToDeleteRows = false; + this.dgv_OpName.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dgv_OpName.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgv_OpName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.OpCode, + this.OpName, + this.MesDll, + this.PLC, + this.PLC代码}); + this.dgv_OpName.Location = new System.Drawing.Point(11, 66); + this.dgv_OpName.Name = "dgv_OpName"; + this.dgv_OpName.ReadOnly = true; + this.dgv_OpName.RowHeadersVisible = false; + this.dgv_OpName.RowHeadersWidth = 62; + this.dgv_OpName.RowTemplate.Height = 23; + this.dgv_OpName.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_OpName.Size = new System.Drawing.Size(209, 558); + this.dgv_OpName.TabIndex = 1488; + this.dgv_OpName.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_OpName_CellClick); + // + // OpCode + // + this.OpCode.DataPropertyName = "工位号"; + this.OpCode.HeaderText = "工位号"; + this.OpCode.MinimumWidth = 8; + this.OpCode.Name = "OpCode"; + this.OpCode.ReadOnly = true; + this.OpCode.Width = 80; + // + // OpName + // + this.OpName.DataPropertyName = "工位名称"; + this.OpName.HeaderText = "工位名称"; + this.OpName.MinimumWidth = 8; + this.OpName.Name = "OpName"; + this.OpName.ReadOnly = true; + this.OpName.Width = 120; + // + // MesDll + // + this.MesDll.DataPropertyName = "MesDll"; + this.MesDll.HeaderText = "MesDll"; + this.MesDll.MinimumWidth = 8; + this.MesDll.Name = "MesDll"; + this.MesDll.ReadOnly = true; + this.MesDll.Width = 90; + // + // PLC + // + this.PLC.DataPropertyName = "PLC"; + this.PLC.HeaderText = "PLC"; + this.PLC.MinimumWidth = 8; + this.PLC.Name = "PLC"; + this.PLC.ReadOnly = true; + this.PLC.Width = 150; + // + // PLC代码 + // + this.PLC代码.DataPropertyName = "PLC代码"; + this.PLC代码.HeaderText = "PLC代码"; + this.PLC代码.MinimumWidth = 8; + this.PLC代码.Name = "PLC代码"; + this.PLC代码.ReadOnly = true; + this.PLC代码.Width = 150; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.label11); + this.groupBox4.Controls.Add(this.label10); + this.groupBox4.Controls.Add(this.label12); + this.groupBox4.Controls.Add(this.button20); + this.groupBox4.Controls.Add(this.MesEngineDataWritePlc); + this.groupBox4.Controls.Add(this.button18); + this.groupBox4.Controls.Add(this.textBox1_EngineID); + this.groupBox4.Controls.Add(this.textBox2_EngineTypeID); + this.groupBox4.Controls.Add(this.textBox3_palletCode); + this.groupBox4.Controls.Add(this.button17); + this.groupBox4.Controls.Add(this.button3); + this.groupBox4.Controls.Add(this.button1); + this.groupBox4.Location = new System.Drawing.Point(630, 318); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(343, 216); + this.groupBox4.TabIndex = 1487; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "调试写入"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label11.Location = new System.Drawing.Point(13, 21); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(65, 12); + this.label11.TabIndex = 1471; + this.label11.Text = "机型代码:"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.Location = new System.Drawing.Point(13, 48); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(65, 12); + this.label10.TabIndex = 1471; + this.label10.Text = "产品编号:"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label12.Location = new System.Drawing.Point(13, 75); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(65, 12); + this.label12.TabIndex = 1471; + this.label12.Text = "托盘编号:"; + // + // button20 + // + this.button20.Location = new System.Drawing.Point(255, 37); + this.button20.Name = "button20"; + this.button20.Size = new System.Drawing.Size(78, 34); + this.button20.TabIndex = 1478; + this.button20.Text = "打印机测试"; + this.button20.UseVisualStyleBackColor = true; + this.button20.Click += new System.EventHandler(this.button20_Click); + // + // MesEngineDataWritePlc + // + this.MesEngineDataWritePlc.Location = new System.Drawing.Point(8, 123); + this.MesEngineDataWritePlc.Name = "MesEngineDataWritePlc"; + this.MesEngineDataWritePlc.Size = new System.Drawing.Size(113, 23); + this.MesEngineDataWritePlc.TabIndex = 1478; + this.MesEngineDataWritePlc.Text = "MES信息回写PLC"; + this.MesEngineDataWritePlc.UseVisualStyleBackColor = true; + this.MesEngineDataWritePlc.Click += new System.EventHandler(this.MesEngineDataWritePlc_Click); + // + // button18 + // + this.button18.Location = new System.Drawing.Point(6, 98); + this.button18.Name = "button18"; + this.button18.Size = new System.Drawing.Size(115, 19); + this.button18.TabIndex = 1478; + this.button18.Text = "上述写入PLC"; + this.button18.UseVisualStyleBackColor = true; + this.button18.Click += new System.EventHandler(this.button18_Click); + // + // textBox1_EngineID + // + this.textBox1_EngineID.Location = new System.Drawing.Point(84, 45); + this.textBox1_EngineID.Name = "textBox1_EngineID"; + this.textBox1_EngineID.Size = new System.Drawing.Size(166, 21); + this.textBox1_EngineID.TabIndex = 1480; + this.textBox1_EngineID.Text = "001MBE0700000Q1590100001"; + // + // textBox2_EngineTypeID + // + this.textBox2_EngineTypeID.Location = new System.Drawing.Point(84, 14); + this.textBox2_EngineTypeID.Name = "textBox2_EngineTypeID"; + this.textBox2_EngineTypeID.Size = new System.Drawing.Size(166, 21); + this.textBox2_EngineTypeID.TabIndex = 1480; + this.textBox2_EngineTypeID.Text = "1"; + // + // textBox3_palletCode + // + this.textBox3_palletCode.Location = new System.Drawing.Point(83, 72); + this.textBox3_palletCode.Name = "textBox3_palletCode"; + this.textBox3_palletCode.Size = new System.Drawing.Size(167, 21); + this.textBox3_palletCode.TabIndex = 1480; + this.textBox3_palletCode.Text = "12"; + // + // button17 + // + this.button17.Location = new System.Drawing.Point(6, 178); + this.button17.Name = "button17"; + this.button17.Size = new System.Drawing.Size(105, 32); + this.button17.TabIndex = 1478; + this.button17.Text = "模拟写入RFID"; + this.button17.UseVisualStyleBackColor = true; + this.button17.Click += new System.EventHandler(this.button17_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(228, 177); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(105, 34); + this.button3.TabIndex = 1478; + this.button3.Text = "模拟检测完成"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(117, 178); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(105, 32); + this.button1.TabIndex = 1478; + this.button1.Text = "模拟写入电芯码"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // panel_Signal_Conf + // + this.panel_Signal_Conf.Location = new System.Drawing.Point(837, 13); + this.panel_Signal_Conf.Name = "panel_Signal_Conf"; + this.panel_Signal_Conf.Size = new System.Drawing.Size(41, 50); + this.panel_Signal_Conf.TabIndex = 1486; + this.panel_Signal_Conf.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_Signal_Conf_MouseDoubleClick); + // + // pb_OnLine_Print + // + this.pb_OnLine_Print.Image = global::MisDataFun.Properties.Resources.断开状态; + this.pb_OnLine_Print.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.pb_OnLine_Print.Location = new System.Drawing.Point(891, 13); + this.pb_OnLine_Print.Name = "pb_OnLine_Print"; + this.pb_OnLine_Print.Size = new System.Drawing.Size(38, 35); + this.pb_OnLine_Print.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb_OnLine_Print.TabIndex = 1485; + this.pb_OnLine_Print.TabStop = false; + // + // label28 + // + this.label28.AutoSize = true; + this.label28.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label28.Location = new System.Drawing.Point(891, 51); + this.label28.Name = "label28"; + this.label28.Size = new System.Drawing.Size(41, 12); + this.label28.TabIndex = 1484; + this.label28.Text = "打印机"; + // + // pb_OnLine_SQL + // + this.pb_OnLine_SQL.Image = global::MisDataFun.Properties.Resources.断开状态; + this.pb_OnLine_SQL.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.pb_OnLine_SQL.Location = new System.Drawing.Point(938, 13); + this.pb_OnLine_SQL.Name = "pb_OnLine_SQL"; + this.pb_OnLine_SQL.Size = new System.Drawing.Size(38, 35); + this.pb_OnLine_SQL.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb_OnLine_SQL.TabIndex = 1485; + this.pb_OnLine_SQL.TabStop = false; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label14.Location = new System.Drawing.Point(938, 51); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(41, 12); + this.label14.TabIndex = 1484; + this.label14.Text = "服务器"; + // + // pb_OnLine_MQTT + // + this.pb_OnLine_MQTT.Image = global::MisDataFun.Properties.Resources.断开状态; + this.pb_OnLine_MQTT.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.pb_OnLine_MQTT.Location = new System.Drawing.Point(985, 13); + this.pb_OnLine_MQTT.Name = "pb_OnLine_MQTT"; + this.pb_OnLine_MQTT.Size = new System.Drawing.Size(38, 35); + this.pb_OnLine_MQTT.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb_OnLine_MQTT.TabIndex = 1483; + this.pb_OnLine_MQTT.TabStop = false; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label15.Location = new System.Drawing.Point(990, 51); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(29, 12); + this.label15.TabIndex = 1482; + this.label15.Text = "MQTT"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.txt_PLC_39); + this.groupBox2.Controls.Add(this.txt_PLC_11); + this.groupBox2.Controls.Add(this.txt_PLC_10); + this.groupBox2.Controls.Add(this.txt_PLC_9); + this.groupBox2.Controls.Add(this.txt_Interval); + this.groupBox2.Controls.Add(this.cb_F5); + this.groupBox2.Controls.Add(this.label27); + this.groupBox2.Controls.Add(this.label26); + this.groupBox2.Controls.Add(this.label25); + this.groupBox2.Controls.Add(this.label24); + this.groupBox2.Controls.Add(this.btn_PLC_59); + this.groupBox2.Controls.Add(this.btn_PLC_2); + this.groupBox2.Controls.Add(this.btn_PLC_43); + this.groupBox2.Controls.Add(this.btn_PLC_1002); + this.groupBox2.Controls.Add(this.btn_MES_5); + this.groupBox2.Controls.Add(this.btn_PLC_1001); + this.groupBox2.Controls.Add(this.btn_PLC_44); + this.groupBox2.Controls.Add(this.btn_PLC_1000); + this.groupBox2.Controls.Add(this.btn_MES_66); + this.groupBox2.Controls.Add(this.btn_MES_7); + this.groupBox2.Controls.Add(this.btn_PLC_19); + this.groupBox2.Controls.Add(this.btn_MES_20); + this.groupBox2.Location = new System.Drawing.Point(226, 66); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(398, 564); + this.groupBox2.TabIndex = 1481; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "监控和调试"; + // + // txt_PLC_39 + // + this.txt_PLC_39.Location = new System.Drawing.Point(156, 147); + this.txt_PLC_39.Name = "txt_PLC_39"; + this.txt_PLC_39.Size = new System.Drawing.Size(232, 21); + this.txt_PLC_39.TabIndex = 1484; + // + // txt_PLC_11 + // + this.txt_PLC_11.Location = new System.Drawing.Point(156, 120); + this.txt_PLC_11.Name = "txt_PLC_11"; + this.txt_PLC_11.Size = new System.Drawing.Size(232, 21); + this.txt_PLC_11.TabIndex = 1484; + // + // txt_PLC_10 + // + this.txt_PLC_10.Location = new System.Drawing.Point(156, 96); + this.txt_PLC_10.Name = "txt_PLC_10"; + this.txt_PLC_10.Size = new System.Drawing.Size(232, 21); + this.txt_PLC_10.TabIndex = 1484; + // + // txt_PLC_9 + // + this.txt_PLC_9.Location = new System.Drawing.Point(156, 73); + this.txt_PLC_9.Name = "txt_PLC_9"; + this.txt_PLC_9.Size = new System.Drawing.Size(232, 21); + this.txt_PLC_9.TabIndex = 1484; + // + // txt_Interval + // + this.txt_Interval.Location = new System.Drawing.Point(8, 26); + this.txt_Interval.Name = "txt_Interval"; + this.txt_Interval.Size = new System.Drawing.Size(67, 21); + this.txt_Interval.TabIndex = 1483; + this.txt_Interval.Text = "100"; + // + // cb_F5 + // + this.cb_F5.AutoSize = true; + this.cb_F5.Location = new System.Drawing.Point(81, 30); + this.cb_F5.Name = "cb_F5"; + this.cb_F5.Size = new System.Drawing.Size(72, 16); + this.cb_F5.TabIndex = 1482; + this.cb_F5.Text = "刷新状态"; + this.cb_F5.UseVisualStyleBackColor = true; + this.cb_F5.CheckedChanged += new System.EventHandler(this.cb_F5_CheckedChanged); + // + // label27 + // + this.label27.AutoSize = true; + this.label27.Location = new System.Drawing.Point(6, 149); + this.label27.Name = "label27"; + this.label27.Size = new System.Drawing.Size(119, 12); + this.label27.TabIndex = 1481; + this.label27.Text = "工单号(39)PLC 600"; + // + // label26 + // + this.label26.AutoSize = true; + this.label26.Location = new System.Drawing.Point(6, 122); + this.label26.Name = "label26"; + this.label26.Size = new System.Drawing.Size(131, 12); + this.label26.TabIndex = 1481; + this.label26.Text = "产品型号(11)PLC 544"; + // + // label25 + // + this.label25.AutoSize = true; + this.label25.Location = new System.Drawing.Point(6, 98); + this.label25.Name = "label25"; + this.label25.Size = new System.Drawing.Size(131, 12); + this.label25.TabIndex = 1481; + this.label25.Text = "总成编号(10)PLC 504"; + // + // label24 + // + this.label24.AutoSize = true; + this.label24.Location = new System.Drawing.Point(6, 75); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(125, 12); + this.label24.TabIndex = 1481; + this.label24.Text = "机型代码(9)PLC 502"; + // + // btn_PLC_59 + // + this.btn_PLC_59.Location = new System.Drawing.Point(198, 396); + this.btn_PLC_59.Name = "btn_PLC_59"; + this.btn_PLC_59.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_59.TabIndex = 1479; + this.btn_PLC_59.Text = "拧紧完成(59)PLC 501.1"; + this.btn_PLC_59.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_59.UseVisualStyleBackColor = true; + this.btn_PLC_59.Click += new System.EventHandler(this.button19_Click); + // + // btn_PLC_2 + // + this.btn_PLC_2.Location = new System.Drawing.Point(8, 321); + this.btn_PLC_2.Name = "btn_PLC_2"; + this.btn_PLC_2.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_2.TabIndex = 1478; + this.btn_PLC_2.Text = "工件到位(2)PLC 500.1"; + this.btn_PLC_2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_2.UseVisualStyleBackColor = true; + this.btn_PLC_2.Click += new System.EventHandler(this.WorkStartPLC_Click); + // + // btn_PLC_43 + // + this.btn_PLC_43.Location = new System.Drawing.Point(8, 350); + this.btn_PLC_43.Name = "btn_PLC_43"; + this.btn_PLC_43.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_43.TabIndex = 1478; + this.btn_PLC_43.Text = "申请上线(43)PLC 500.3"; + this.btn_PLC_43.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_43.UseVisualStyleBackColor = true; + this.btn_PLC_43.Click += new System.EventHandler(this.PartLoadPLC_Click); + // + // btn_PLC_1002 + // + this.btn_PLC_1002.Location = new System.Drawing.Point(198, 372); + this.btn_PLC_1002.Name = "btn_PLC_1002"; + this.btn_PLC_1002.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_1002.TabIndex = 1479; + this.btn_PLC_1002.Text = "机床故障(1002)PLC 587.3"; + this.btn_PLC_1002.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_1002.UseVisualStyleBackColor = true; + this.btn_PLC_1002.Click += new System.EventHandler(this.toolErrorPLC_Click); + // + // btn_MES_5 + // + this.btn_MES_5.Location = new System.Drawing.Point(8, 382); + this.btn_MES_5.Name = "btn_MES_5"; + this.btn_MES_5.Size = new System.Drawing.Size(174, 23); + this.btn_MES_5.TabIndex = 1478; + this.btn_MES_5.Text = "传递机型(5)MES 0.1"; + this.btn_MES_5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_5.UseVisualStyleBackColor = true; + this.btn_MES_5.Click += new System.EventHandler(this.EngineGetOverMES_Click); + // + // btn_PLC_1001 + // + this.btn_PLC_1001.Location = new System.Drawing.Point(198, 347); + this.btn_PLC_1001.Name = "btn_PLC_1001"; + this.btn_PLC_1001.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_1001.TabIndex = 1479; + this.btn_PLC_1001.Text = "循环开始(1001)PLC 587.2"; + this.btn_PLC_1001.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_1001.UseVisualStyleBackColor = true; + this.btn_PLC_1001.Click += new System.EventHandler(this.toolStartPLC_Click); + // + // btn_PLC_44 + // + this.btn_PLC_44.Location = new System.Drawing.Point(8, 412); + this.btn_PLC_44.Name = "btn_PLC_44"; + this.btn_PLC_44.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_44.TabIndex = 1478; + this.btn_PLC_44.Text = "传递机型(44)PLC 500.4"; + this.btn_PLC_44.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_44.UseVisualStyleBackColor = true; + this.btn_PLC_44.Click += new System.EventHandler(this.EngineGetOverPLC_Click); + // + // btn_PLC_1000 + // + this.btn_PLC_1000.Location = new System.Drawing.Point(198, 323); + this.btn_PLC_1000.Name = "btn_PLC_1000"; + this.btn_PLC_1000.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_1000.TabIndex = 1479; + this.btn_PLC_1000.Text = "机床上电(1000)PLC 587.1"; + this.btn_PLC_1000.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_1000.UseVisualStyleBackColor = true; + this.btn_PLC_1000.Click += new System.EventHandler(this.toolPoweredPLC_Click); + // + // btn_MES_66 + // + this.btn_MES_66.Location = new System.Drawing.Point(8, 440); + this.btn_MES_66.Name = "btn_MES_66"; + this.btn_MES_66.Size = new System.Drawing.Size(174, 23); + this.btn_MES_66.TabIndex = 1478; + this.btn_MES_66.Text = "允许工作(66)MES 1.1"; + this.btn_MES_66.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_66.UseVisualStyleBackColor = true; + this.btn_MES_66.Click += new System.EventHandler(this.allowWorkMES_Click); + // + // btn_MES_7 + // + this.btn_MES_7.Location = new System.Drawing.Point(8, 525); + this.btn_MES_7.Name = "btn_MES_7"; + this.btn_MES_7.Size = new System.Drawing.Size(174, 23); + this.btn_MES_7.TabIndex = 1478; + this.btn_MES_7.Text = "工作完成(7)MES 0.3"; + this.btn_MES_7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_7.UseVisualStyleBackColor = true; + this.btn_MES_7.Click += new System.EventHandler(this.workOverMES_Click); + // + // btn_PLC_19 + // + this.btn_PLC_19.Location = new System.Drawing.Point(8, 467); + this.btn_PLC_19.Name = "btn_PLC_19"; + this.btn_PLC_19.Size = new System.Drawing.Size(174, 23); + this.btn_PLC_19.TabIndex = 1478; + this.btn_PLC_19.Text = "允许保存(19)PLC 587.0"; + this.btn_PLC_19.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_19.UseVisualStyleBackColor = true; + this.btn_PLC_19.Click += new System.EventHandler(this.allowSavePLC_Click); + // + // btn_MES_20 + // + this.btn_MES_20.Location = new System.Drawing.Point(8, 496); + this.btn_MES_20.Name = "btn_MES_20"; + this.btn_MES_20.Size = new System.Drawing.Size(174, 23); + this.btn_MES_20.TabIndex = 1478; + this.btn_MES_20.Text = "保存完成(20)MES 11.3"; + this.btn_MES_20.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_20.UseVisualStyleBackColor = true; + this.btn_MES_20.Click += new System.EventHandler(this.saveOverMES_Click); + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("宋体", 26F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label13.Location = new System.Drawing.Point(377, 5); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(345, 35); + this.label13.TabIndex = 1; + this.label13.Text = "GIS126数据采集程序"; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(630, 544); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(121, 39); + this.button2.TabIndex = 1477; + this.button2.Text = "初始化报警"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(600, 27); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(29, 12); + this.label4.TabIndex = 1; + this.label4.Text = "日志"; + // + // richTextBox1_mqtt + // + this.richTextBox1_mqtt.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.richTextBox1_mqtt.Location = new System.Drawing.Point(630, 75); + this.richTextBox1_mqtt.Name = "richTextBox1_mqtt"; + this.richTextBox1_mqtt.ReadOnly = true; + this.richTextBox1_mqtt.Size = new System.Drawing.Size(402, 240); + this.richTextBox1_mqtt.TabIndex = 0; + this.richTextBox1_mqtt.Text = ""; + // + // timer_Status + // + this.timer_Status.Enabled = true; + this.timer_Status.Interval = 1000; + this.timer_Status.Tick += new System.EventHandler(this.timer_Status_Tick); + // + // statusStrip1 + // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel_RunningStatu, + this.toolStripStatusLabel_RunningStatus, + this.toolStripStatusLabel2, + this.toolStripStatusLabel_StartTime, + this.toolStripStatusLabel3, + this.toolStripStatusLabel_RunTime, + this.toolStripStatusLabel1, + this.toolStripStatusLabel_WorkStationNum, + this.toolStripStatusLabel4, + this.toolStripStatusLabel_Version}); + this.statusStrip1.Location = new System.Drawing.Point(0, 668); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(1053, 35); + this.statusStrip1.TabIndex = 1479; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabel_RunningStatu + // + this.toolStripStatusLabel_RunningStatu.Name = "toolStripStatusLabel_RunningStatu"; + this.toolStripStatusLabel_RunningStatu.Size = new System.Drawing.Size(68, 30); + this.toolStripStatusLabel_RunningStatu.Text = "运行状态:"; + // + // toolStripStatusLabel_RunningStatus + // + this.toolStripStatusLabel_RunningStatus.ActiveLinkColor = System.Drawing.Color.Red; + this.toolStripStatusLabel_RunningStatus.AutoSize = false; + this.toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Yellow; + this.toolStripStatusLabel_RunningStatus.Name = "toolStripStatusLabel_RunningStatus"; + this.toolStripStatusLabel_RunningStatus.Size = new System.Drawing.Size(62, 30); + this.toolStripStatusLabel_RunningStatus.Text = "变量模拟"; + // + // toolStripStatusLabel2 + // + this.toolStripStatusLabel2.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left; + this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; + this.toolStripStatusLabel2.Size = new System.Drawing.Size(72, 30); + this.toolStripStatusLabel2.Text = "启动时间:"; + // + // toolStripStatusLabel_StartTime + // + this.toolStripStatusLabel_StartTime.AutoSize = false; + this.toolStripStatusLabel_StartTime.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.toolStripStatusLabel_StartTime.Name = "toolStripStatusLabel_StartTime"; + this.toolStripStatusLabel_StartTime.Size = new System.Drawing.Size(130, 30); + this.toolStripStatusLabel_StartTime.Text = "2018/08/08 08:08:08"; + // + // toolStripStatusLabel3 + // + this.toolStripStatusLabel3.Name = "toolStripStatusLabel3"; + this.toolStripStatusLabel3.Size = new System.Drawing.Size(68, 30); + this.toolStripStatusLabel3.Text = "运行时长:"; + // + // toolStripStatusLabel_RunTime + // + this.toolStripStatusLabel_RunTime.AutoSize = false; + this.toolStripStatusLabel_RunTime.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.toolStripStatusLabel_RunTime.Name = "toolStripStatusLabel_RunTime"; + this.toolStripStatusLabel_RunTime.Size = new System.Drawing.Size(145, 30); + this.toolStripStatusLabel_RunTime.Text = "0天0小时0分0秒"; + this.toolStripStatusLabel_RunTime.Click += new System.EventHandler(this.toolStripStatusLabel_RunTime_Click); + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(68, 30); + this.toolStripStatusLabel1.Text = "工位数量:"; + // + // toolStripStatusLabel_WorkStationNum + // + this.toolStripStatusLabel_WorkStationNum.AutoSize = false; + this.toolStripStatusLabel_WorkStationNum.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.toolStripStatusLabel_WorkStationNum.Name = "toolStripStatusLabel_WorkStationNum"; + this.toolStripStatusLabel_WorkStationNum.Size = new System.Drawing.Size(35, 30); + this.toolStripStatusLabel_WorkStationNum.Text = "100"; + // + // toolStripStatusLabel4 + // + this.toolStripStatusLabel4.Name = "toolStripStatusLabel4"; + this.toolStripStatusLabel4.Size = new System.Drawing.Size(44, 30); + this.toolStripStatusLabel4.Text = "版本:"; + // + // toolStripStatusLabel_Version + // + this.toolStripStatusLabel_Version.Name = "toolStripStatusLabel_Version"; + this.toolStripStatusLabel_Version.Size = new System.Drawing.Size(42, 30); + this.toolStripStatusLabel_Version.Text = "8.6.12"; + // + // MesServerMisDataFun + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1053, 703); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.panel7); + this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.menuStrip1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.MaximumSize = new System.Drawing.Size(1912, 1058); + this.MinimumSize = new System.Drawing.Size(979, 694); + this.Name = "MesServerMisDataFun"; + this.Text = "MesServer Function V2025-07-20--1150"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MisDataFun_FormClosing); + this.Load += new System.EventHandler(this.SaveData_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.panel8.ResumeLayout(false); + this.panel8.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.panel1.ResumeLayout(false); + this.tableLayoutPanel3.ResumeLayout(false); + this.tableLayoutPanel3.PerformLayout(); + this.panel3.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CheckOpName)).EndInit(); + this.panel4.ResumeLayout(false); + this.tableLayoutPanel4.ResumeLayout(false); + this.tableLayoutPanel4.PerformLayout(); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); + this.panel2.ResumeLayout(false); + this.tableLayoutPanel5.ResumeLayout(false); + this.panel6.ResumeLayout(false); + this.panel6.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.panel7.ResumeLayout(false); + this.panel7.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_OpName)).EndInit(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_Print)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_SQL)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_MQTT)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TextBox textBox_PLC_TO_MES; + private System.Windows.Forms.Button button_WEB_TO_MES_Clear; + private System.Windows.Forms.CheckBox checkBox_WEB_TO_MES; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TextBox textBox_MES_TO_WEB; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.TextBox textBox_WEB_TO_MES; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.CheckBox checkBox_PLC_TO_MES; + private System.Windows.Forms.Button button_PLC_TO_MES_Clear; + private System.Windows.Forms.Button button_PLC_TO_MES_Big; + private System.Windows.Forms.Button button_PLC_TO_MES_Small; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.DataGridView dataGridView_CheckOpName; + private System.Windows.Forms.DataGridViewCheckBoxColumn 选择; + private System.Windows.Forms.DataGridViewTextBoxColumn 工位号; + private System.Windows.Forms.CheckBox checkBox__MES_TO_WEB; + private System.Windows.Forms.Button button_MES_TO_WEB_Clear; + private System.Windows.Forms.Button button_MES_TO_WEB_Small; + private System.Windows.Forms.Button button_MES_TO_WEB_Big; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; + private System.Windows.Forms.Button button_WEB_TO_MES_Big; + private System.Windows.Forms.Button button_WEB_TO_MES_Small; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.Button button_WebToMES; + private System.Windows.Forms.Button button_ToWEB; + private System.Windows.Forms.TextBox textBox_MqttText; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBox_OpNameList; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_PlcDebug; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; + private System.Windows.Forms.Panel panel6; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.TabPage tabPage4; + private System.Windows.Forms.TabPage tabPage5; + private System.Windows.Forms.TabPage tabPage6; + private System.Windows.Forms.Button button_SaveData; + private System.Windows.Forms.Panel panel7; + private System.Windows.Forms.RichTextBox richTextBox1_mqtt; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Timer timer_Status; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_RunningStatu; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_RunningStatus; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_StartTime; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_RunTime; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_WorkStationNum; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_Version; + private System.Windows.Forms.ToolStripMenuItem 帮助ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 版本信息ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 关于迈思ToolStripMenuItem; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button btn_PLC_2; + private System.Windows.Forms.Button btn_MES_5; + private System.Windows.Forms.Button btn_MES_7; + private System.Windows.Forms.Button btn_MES_20; + private System.Windows.Forms.Button btn_PLC_19; + private System.Windows.Forms.Button btn_MES_66; + private System.Windows.Forms.Button btn_PLC_44; + private System.Windows.Forms.Button btn_PLC_43; + private System.Windows.Forms.Button btn_PLC_1001; + private System.Windows.Forms.Button btn_PLC_1000; + private System.Windows.Forms.Panel panel8; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.Button button9; + private System.Windows.Forms.Button button10; + private System.Windows.Forms.Button button11; + private System.Windows.Forms.Button button12; + private System.Windows.Forms.Button button13; + private System.Windows.Forms.Button button14; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.Button button15; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.ColumnHeader columnHeader9; + private System.Windows.Forms.ColumnHeader columnHeader10; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button button16; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Button btn_PLC_1002; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button17; + private System.Windows.Forms.TextBox textBox3_palletCode; + private System.Windows.Forms.TextBox textBox2_EngineTypeID; + private System.Windows.Forms.TextBox textBox1_EngineID; + private System.Windows.Forms.Button button18; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Button btn_PLC_59; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.PictureBox pb_OnLine_SQL; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.PictureBox pb_OnLine_MQTT; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox txt_Interval; + private System.Windows.Forms.CheckBox cb_F5; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.TextBox txt_PLC_9; + private System.Windows.Forms.TextBox txt_PLC_11; + private System.Windows.Forms.TextBox txt_PLC_10; + private System.Windows.Forms.Label label26; + private System.Windows.Forms.Label label25; + private System.Windows.Forms.TextBox txt_PLC_39; + private System.Windows.Forms.Label label27; + private System.Windows.Forms.Panel panel_Signal_Conf; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.PictureBox pb_OnLine_Print; + private System.Windows.Forms.Label label28; + private System.Windows.Forms.Button button20; + private System.Windows.Forms.DataGridView dgv_OpName; + private System.Windows.Forms.Button MesEngineDataWritePlc; + private System.Windows.Forms.DataGridViewTextBoxColumn OpCode; + private System.Windows.Forms.DataGridViewTextBoxColumn OpName; + private System.Windows.Forms.DataGridViewTextBoxColumn MesDll; + private System.Windows.Forms.DataGridViewTextBoxColumn PLC; + private System.Windows.Forms.DataGridViewTextBoxColumn PLC代码; + private System.Windows.Forms.ToolStripMenuItem webApi调试ToolStripMenuItem; + } +} + diff --git a/MisDataFun/MisDataFun/MisDataFun.cs b/MisDataFun/MisDataFun/MisDataFun.cs new file mode 100644 index 0000000..2dfb975 --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.cs @@ -0,0 +1,1585 @@ +using DataLinkMesWork; +using MesDataFunction; +using MesServerWork; +using MesWork.PLC; +using MQTTnet; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Receiving; +using MQTTnet.Extensions.ManagedClient; +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics; +using System.Threading; +using System.Windows.Forms; +using SystemFramework; +using System.IO; +using System.Net; +using System.Text; +using MesServerFunctions; +using System.Threading.Tasks; +using MesWork; +using System.Drawing; +using MES_SIGNAL_CONF; +using SlMesDbIterface; +using System.Net.NetworkInformation; +using ExternalDataSync; +using OpcBasic; +using System.Collections.Concurrent; +using MisDataFunDll; +using DataLinkMesWork2; +using System.Linq; +using WebApi; + +namespace MisDataSaveDate +{ + /// + /// + /// + public partial class MesServerMisDataFun : Form + { + public static string WebSvrUrlPort = ConfigurationManager.AppSettings["Url_WebApi"]; + public static int IsWriteMonitorLog = Convert.ToInt32(ConfigurationManager.AppSettings["IsWriteMonitorLog"]); + public static string OnlineCheckDataUrl = ConfigurationManager.AppSettings["OnlineCheckDataUrl"].ToString(); + public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"]; + public static int IsDemoMesServer = Convert.ToInt32(ConfigurationManager.AppSettings["IsDemoMesServer"]); + public static string IsRecordTagStatus = ConfigurationManager.AppSettings["IsRecordTagStatus"]; + public static string BasicDataTableFile = ConfigurationManager.AppSettings["BasicDataTableFile"]; + public static string PrintURL = ConfigurationManager.AppSettings["PrintURL"]; + public static int webApiPort = Convert.ToInt32(ConfigurationManager.AppSettings["WebSvrPort"]); + public static string webapi_MesIP = ConfigurationManager.AppSettings["Webapi_MesIP"]; + + + WebApi.InitServer initServer = null; + static Hashtable hashtableTopicList = new Hashtable(); + // 同一工位的状态日志按顺序串行执行,避免多线程下写表顺序错乱。 + private static readonly ConcurrentDictionary DeviceStatusLogLocks = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + + // IOT 设备状态枚举:文字 → 代码(0~7) + private static readonly Dictionary DeviceStatusMap = new Dictionary + { + { "关机", "0" }, + { "开机启动中", "1" }, + { "重报警停机", "2" }, + { "重故障停机", "3" }, + { "运行", "4" }, + { "待机", "5" }, + { "轻报警运行", "6" }, + { "维护停机", "7" }, + }; + + // MES 报警异常类型枚举:文字 → 代码(1~4) + private static readonly Dictionary AlarmExceptionTypeMap = new Dictionary + { + { "设备异常", "1" }, + { "物料异常", "2" }, + { "生产异常", "3" }, + { "质量异常", "4" }, + }; + + static bool OnLineMqtt = false; + static bool OnLine_SQL = false; + static bool OnLine_Mes = false; + static bool OnLine_Mes_Cache = false; + static bool OnLine_Print = false; + static bool IsLoopReadShow = false; + + /// + /// 允许使用附加功能的变量,只有在系统开始加载Tag时,才允许读取PLC数据 + /// + public static bool AllowLoad; + /// + /// + /// + MesWork.OpcForm opcForm = null; + /// + /// + /// + public static string WorkStationNum_Now; + /// + /// + /// + DateTime StartTime; + + public static Color color_Faw = Color.FromArgb(0, 44, 101);//蓝色,大众:0,44,101 + + public static Color color_Good = Color.FromArgb(132, 185, 235);//浅蓝,自定义 + public static Color color_Wait = Color.FromArgb(240, 230, 140);//淡黄,显示等待状态 + public static Color color_Bad = SystemColors.ActiveBorder;//灰色,显示操作过程 + public static Color color_Control = SystemColors.Control;//控件默认颜色 + public static Color color_Grey = Color.FromArgb(192, 192, 192);//灰色,Table底色 + + public static Color color_Green = Color.FromArgb(22, 161, 136);//绿色 + public static Color color_Yellow = Color.FromArgb(246, 227, 74);//黄色 + public static Color color_Red = Color.FromArgb(255, 0, 0);//红色 + + [STAThread] + static void Main() + { + new System.Threading.Mutex(true, "MES_ZK_SVR", out bool bCanRun); + if (!bCanRun) + { + MessageBox.Show("MES中控程序 已经在运行!不可重复启动!"); + return; + } + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + //new MES_CONF().ShowDialog(); + + Application.Run(new MesServerMisDataFun()); + } + + + + public MesServerMisDataFun() + { + InitializeComponent(); + Control.CheckForIllegalCrossThreadCalls = false; + Never_Know.Hello_You_All_Never_Know = Hello_You_All_Never_Know; + + PP.ConnectionString_MES = ConnectionString_MES; + PP.PrintURL = PrintURL; + PP.IsDemoMesServer = IsDemoMesServer; + ApplicationConfig.ConnectionString_MES = ConnectionString_MES; + + CommunicationCheckOnLine(); + MisData01(); + Init_dataGridView_CheckOpName(); + MIS_BASE.InitHashtable_MesServerCode(); + InitMesSerVerCode(); + initServer = new WebApi.InitServer(webApiPort); + // 工位在线状态监控 + OpWorkStatusWatch(); + + // 在这里调用开启线程方法 进行消费请求失败接口请求 每分钟消费一次 先读取 后重试 + StartFailedInterfaceRetryThread(); + StartElectricityThread(); + + // 自监控心跳 + //InitAllOpHeartBeat(); + } + public void MisData01() + { + var dt_Signal = MisDataFunDll.MisDataFun.dt_Signal(); + var dt_Device = MisDataFunDll.MisDataFun.dt_Device(); + var dt_TagTypeDataType = MisDataFunDll.MisDataFun.dt_TagTypeDataType(); + + var sql = + $" SELECT [工位号],[工位名称],[PLC],[PLC代码],[MesDll]" + + $" FROM [MES_计划BOM_工位与名称] WHERE [是否启用MES] = 1" + + $" ORDER BY [工位号]"; + SqlOperation.ExecuteSql(sql, out DataTable dt_SqlOp, out string errorSqlOp); + dgv_OpName.DataSource = dt_SqlOp; + + var mp = new MesWorkPlc(); + + StartTime = Convert.ToDateTime(toolStripStatusLabel_StartTime.Text = DateTime.Now.ToString()); + Runtime_Thread(); + + if (mp.LoadOPCData(dt_Signal, dt_Device, IsDemoMesServer, IsWriteMonitorLog, true, false, out string error)) + { + MesDataFunction.LoadTagTypeCodeID.Load(dt_TagTypeDataType); + + //查询出“全部原始基本数据列表” + var drs = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=101 or 变量类型代码 = 102 or 变量类型代码 = 105"); + if (drs.Length > 1) + { + MIS_BASE.BasicDataTagValue = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=101 or 变量类型代码 = 102 or 变量类型代码 = 105").CopyToDataTable(); + if (MIS_BASE.BasicDataTagValue.Columns.Contains("上限值")) + { + MIS_BASE.BasicDataTagValue.Columns["上限值"].ColumnName = "值上限"; + } + if (MIS_BASE.BasicDataTagValue.Columns.Contains("下限值")) + { + MIS_BASE.BasicDataTagValue.Columns["下限值"].ColumnName = "值下限"; + } + } + + // BasicDataTagValue = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 监控属性代码 = '{DataLinkMesWork.ApplicationConfig.MES_Code.ToString()}'").CopyToDataTable(); + //查询出“MES_基本数据_测量范围” + MesServerWork.MIS_BASE.BasicDataTagValueUpDown = MesWork.PlcLinkForm.dt_BasicData; + if (MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns.Contains("上限值")) + { + MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns["上限值"].ColumnName = "值上限"; + } + if (MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns.Contains("下限值")) + { + MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns["下限值"].ColumnName = "值下限"; + } + // 模拟时,写入质量数据 + if (IsDemoMesServer == 1) + { + InitBasicDataTagValue(); + } + + // 变量代码与其他字段的对应关系 + MesServerWork.MIS_BASE.InitHashtableTagID(); + toolStripStatusLabel_WorkStationNum.Text = MesWork.PlcLinkForm.opNameList.Count.ToString(); + + AllowLoad = true; + if (IsDemoMesServer == 1) + { + toolStripStatusLabel_RunningStatus.Text = "变量模拟"; + toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Yellow; + } + else + { + toolStripStatusLabel_RunningStatus.Text = "PLC"; + toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Green; + } + MesWorkPlc.D_OPCTagData_TagDataOnChangeMIS -= OPCTagData_TagDataOnChange; + MesWorkPlc.D_OPCTagData_TagDataOnChangeMIS += OPCTagData_TagDataOnChange; + } + } + + + + private void OpWorkStatusWatch() + { + List opNameList = PlcLinkForm.opNameList; + new Thread(new ThreadStart(delegate () { + while (true) + { + Thread.Sleep(1000 * 60); + foreach (string OpName in opNameList) + { + if (OpName.IndexOf("-0") == -1 && OpName.IndexOf("-10") == -1 && OpName.IndexOf("-11") == -1 && OpName.IndexOf("-12") == -1 && OpName.IndexOf("ET") == -1) + { + // 查询各状态点位值 + int toolPowered = Convert.ToInt32(MIS_BASE.ReadPLC(1000, OpName)); // 机床上电 + int toolStart = Convert.ToInt32(MIS_BASE.ReadPLC(1001, OpName)); // 循环开始 + int toolErr = Convert.ToInt32(MIS_BASE.ReadPLC(1002, OpName)); // 循环开始 + float energy = 0; //能耗 + // 单独记录OEE统计的表 + OpWorkRunStatusSave(OpName, toolPowered, toolStart, toolErr, energy); + } + } + } + })) + { IsBackground = true }.Start(); + + new Thread(new ThreadStart(delegate () { + while (true) + { + NetState_MES(); + Thread.Sleep(1000 * 10); + } + })) + { IsBackground = true }.Start(); + } + + public static async Task NetState_MES() + { + Ping ping = new Ping(); + try + { + PingReply reply = await ping.SendPingAsync(webapi_MesIP); + + if (reply.Status == IPStatus.Success) + { + OnLine_Mes = true; + } + else + { + OnLine_Mes = false; + } + StateVariable.online_Mes = OnLine_Mes; + } + catch + { + OnLine_Mes = false; + } + } + + /// + /// 获得Function调用信息 + /// + private void InitMesSerVerCode() + { + MisDataFunDll.MisDataFun.GetMesServerCodeAndMesDll(out MisDataFunDll.MisDataFun.hashtable_MesServerCode, out MisDataFunDll.MisDataFun.hashtable_MesDll); + MisDataFunDll.MisDataFun.GetBaseData_tagTable_TagName(out MisDataFunDll.MisDataFun.hashtable_TagName, out MisDataFunDll.MisDataFun.hashtable_TagTypeTagName); + + FuntionMesRead.GetAlarmInit(); + } + + public void SaveData_Load(object sender, EventArgs e) + { + MyLog4Net.MyLogHelper.LogCommit += MyLogHelper_LogCommit; + MqttLink(); + Thread.Sleep(200); + MesWorkPlc.StartServer(); //开启监控服务 + new TaskFactory().StartNew(delegate () + { + DataTable dt; + MisDataFunDll.MisDataFun.Alarm_Moby_Search(out dt); + DataTable dt1 = MisDataFunDll.MisDataFun.GetCheckOpName(); + for (int i = 0; i < dt1.Rows.Count; i++) + { + string opName = dt1.Rows[i]["工位号"].ToString(); + FuntionMesRead.Alarm_Insert_Init(opName); + } + }); + } + /// + /// 模拟时,写入质量数据 + /// + private void InitBasicDataTagValue() + { + string tagID; + double tagValue; + //写工位总合格标志 变量类型代码=21 + for (int i = 0; i < MesWork.PlcLinkForm.dt_BasicData.Rows.Count; i++) + { + if (MesWork.PlcLinkForm.dt_BasicData.Rows[i]["变量类型代码"].ToString() == "21") + { + tagID = MesWork.PlcLinkForm.dt_BasicData.Rows[i]["TagID"].ToString(); + MesServerWork.MIS_BASE.Write_TagID(tagID, 1); + } + } + if (MesServerWork.MIS_BASE.BasicDataTagValue != null) + { + for (int i = 0; i < MesServerWork.MIS_BASE.BasicDataTagValue.Rows.Count; i++) + { + try + { + switch (Convert.ToInt32(MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["变量排序"])) + { + + case 0: + tagID = MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["TagID"].ToString(); + MesServerWork.MIS_BASE.Write_TagID(tagID, 1); + break; + case 1: + case 2: + case 3: + tagID = MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["TagID"].ToString(); + tagValue = Convert.ToDouble(MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["列位置"]) * 100 + + Convert.ToDouble(MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["变量排序"]) / 100; + MesServerWork.MIS_BASE.Write_TagID(tagID, tagValue); + break; + + } + } + catch { } + + } + } + + } + + + private void Init_dataGridView_CheckOpName() + { + try + { + var dt1 = MisDataFunDll.MisDataFun.GetCheckOpName(); + comboBox_OpNameList.DataSource = dt1; + comboBox_OpNameList.ValueMember = "工位号"; + comboBox_OpNameList.DisplayMember = "工位号"; + } + catch (Exception ex) { } + } + + + #region mqtt相关 + private async Task MqttLink() + { + List TopicFilterList = new List(); + string url; + //string topicMqttTargetTopicPLC; + //string topicMqttTargetTopicTagTypeCodeID; + string TopicList; + string[] TopicListFunItems; + string[] TopicListItems; + url = ConfigurationManager.AppSettings["MqttUrl"]; + TopicList = ConfigurationManager.AppSettings["TopicList"]; + TopicListItems = TopicList.Split('|'); + for (int i = 0; i < TopicListItems.Length; i++) + { + TopicListFunItems = TopicListItems[i].Split(','); + hashtableTopicList.Add(TopicListFunItems[0], TopicListFunItems[1]); + } + + await Mqtt.StartAsync(); + + foreach (var topic in TopicListItems) + { + TopicListFunItems = topic.Split(','); + + Mqtt.mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = TopicListFunItems[0] }); + } + Mqtt.mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected); + Mqtt.mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected); + Mqtt.mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived); + + } + private string Hello_You_All_Never_Know(string[] args) + { + return Guid.NewGuid().ToString() + Guid.NewGuid().ToString(); + //return string.Empty; + } + /// + /// + /// + /// + private void OnSubscriberConnected(MqttClientConnectedEventArgs x) + { + MyLog4Net.MyLogHelper.Info("Mqtt:", "Mqtt连接成功!"); + OnLineMqtt = true; + } + /// + /// + /// + /// + private void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x) + { + try + { + MyLog4Net.MyLogHelper.Error("Mqtt:", "Mqtt断开连接!Reason:" + x.Reason); + OnLineMqtt = false; + } + catch (Exception err) + { + } + } + /// + /// + /// + /// + public void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x) + { + ThreadPool.QueueUserWorkItem(MIS_Funtion_WEB, x); + } + #endregion + + /// + /// mqtt 接收web和barcode数据 + /// + /// + public void MIS_Funtion_WEB(object e) + { + try + { + MqttApplicationMessageReceivedEventArgs x = (MqttApplicationMessageReceivedEventArgs)e; + var rec = x.ApplicationMessage.ConvertPayloadToString(); + MisDataFunDll.MisDataFun.TransferInfToMES(rec); + } + catch (Exception ex) + { + //MIS_Funtion(topicFunItem, "Exception:" + ex.Message); + } + } + /// + /// 接收内部PLC数据变化 + /// + /// + public void MIS_Funtion_PLC(object e) + { + var rec = e.ToString(); + try + { + MisDataFunDll.MisDataFun.TransferInfToMES(rec); + } + catch (Exception ex) + { + //MIS_Funtion(topicFunItem, "Exception:" + ex.Message);A + } + } + + + static public void TagTypeCodeID_Insert(string opName, string TagTypeCodeID, string TagID, string TagValue, DateTime arrivedTime, DateTime leavedTime, int TimeDiff) + { + string procedureName; + procedureName = "测量数据设备状态日志_增加数据"; + SqlParameter[] thisParms = new SqlParameter[7]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@信号类型代码", TagTypeCodeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@TagID", TagID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", TagValue); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + public static bool OpWorkRunStatusSave(string opName, int kj, int yx, int gz, float energy) + { + string produceName = "XD_工位运行状态_增加"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@开机", kj); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@运行", yx); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@故障", gz); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@能耗", energy); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + private void MisDataFun_FormClosing(object sender, FormClosingEventArgs e) + { + if (MessageBox.Show("您确认要退出MES程序吗?该操作会停止MES进行数据处理!", "", MessageBoxButtons.OKCancel) == DialogResult.OK) + { + Process.GetCurrentProcess().Kill(); + } + else + { + e.Cancel = true; + } + } + + private void timer_Status_Tick(object sender, EventArgs e) + { + timer_Status.Enabled = false; + Show_OnLineState(); + + if (!AllowLoad) return; + Runtime_Thread(); + + timer_Status.Enabled = true; + } + + private void Show_OnLineState() + { + OnLineState_C(pb_OnLine_Print, OnLine_Print); + OnLineState_C(pb_OnLine_SQL, OnLine_SQL); + OnLineState_C(pb_OnLine_MQTT, OnLineMqtt); + } + private void CommunicationCheckOnLine() + { + + new Thread(new ThreadStart(delegate () + { + while (true) + { + try + { + OnLine_SQL = DataLinkMesWork.SQLCommon.ExecuteDataTable("select getdate()", ConnectionString_MES, out DataTable dt, out string err); + } + catch (Exception) { } + Thread.Sleep(5000); + } + })) + { IsBackground = true }.Start(); + + new Thread(new ThreadStart(delegate () + { + var ip = PrintURL.Split(':')[0]; + while (true) + { + try + { + OnLine_Print = new System.Net.NetworkInformation.Ping().Send(ip).Status == System.Net.NetworkInformation.IPStatus.Success; + } + catch (Exception) { } + Thread.Sleep(5000); + } + })) + { IsBackground = true }.Start(); + + } + private void OnLineState_C(PictureBox pb, bool onLine) + { + pb.Image = onLine ? global::MisDataFun.Properties.Resources.连接状态 + : global::MisDataFun.Properties.Resources.断开状态; + } + private void MyLogHelper_LogCommit(object sender, MyLog4Net.MyLogEventArgs e) + { + var module = e.Module; + var message = e.Message; + + var log = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + module + " " + message + "\r\n"; + if (this.InvokeRequired) + { + this.Invoke(new Action(() => + { + this.richTextBox1_mqtt.AppendText(log); + this.richTextBox1_mqtt.Focus(); + })); + } + else + { + this.richTextBox1_mqtt.AppendText(log); + this.richTextBox1_mqtt.Focus(); + } + + } + + + public void OPCTagData_TagDataOnChange(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + + // 处理MIS业务 保存数据 + // ThreadPool.QueueUserWorkItem(Function.MIS_Funtion, e); + // 处理MES业务 Function + ThreadPool.QueueUserWorkItem(TagData_MisData_TagDataOnChangeCustomeEvetnArgs, e); + //ThreadPool.QueueUserWorkItem(TagData_MisData_TagDataOnChange, e); + // 设备状态日志 + ThreadPool.QueueUserWorkItem(TagTypeCodeID_TagDataOnChange, e); + //发送通讯服务器 MES web界面显示用 加工位号 + ThreadPool.QueueUserWorkItem(TransferInfToWebServer, e); + //改变控件状态 + //showMessagePLCInvoke(e); + //更新状态窗口控件状态 + //ExcutePlcChange(e); + } + /// + /// 发送信号变化到function + /// + /// + private void TagData_MisData_TagDataOnChangeCustomeEvetnArgs(object msgEvent) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs e = (DeviceDriver_BasicData.CustomeEvetnArgs)msgEvent; + string OpName = e.OpName.ToString();//工位号 + string MesCode = e.TagType.ToString();//变量类型代码 + object tagValue = e.TagValue;//变量(0或者1) + string TagTypeCodeID = e.TagTypeCodeID.ToString();//变量类型代码 + string TagID = e.TagID.ToString(); + string cmd = ""; + cmd = MIS_BASE.hashtable_TagTypeTagName[MesCode]; + string mesServerdllName; + + mesServerdllName = GetMesServeDllByOpName(OpName); + string fun = "fun_" + cmd; + int mesServerCode; + mesServerCode = GetMesServerCodeByOpName(OpName); + string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(e); + + string msg; + if (cmd == null) + { + cmd = MesCode; + msg = $"PLC|{cmd}|{OpName}|{rvMsg}"; + } + else + { + msg = $"PLC|{cmd}|{OpName}|{rvMsg}"; + } + try + { + if (HandleTagChangeSideEffects(e, OpName, TagTypeCodeID, TagID, tagValue)) + { + return; + } + } + catch (Exception err) + { + return; + } + MIS_Funtion_PLC(msg); + // asyncSendMessagePLC(mesServerdllName, msg, OpName); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TagData_Lable_TagDataOnChange"); + } + } + + // 统一处理 Tag 变化带出的附加动作:14 写镜像点位,103 发报警消息,1000/1001/103 记录设备状态日志。 + private bool HandleTagChangeSideEffects(DeviceDriver_BasicData.CustomeEvetnArgs e, string opName, string tagTypeCodeID, string tagID, object tagValue) + { + if (tagTypeCodeID == "14") + { + MIS_BASE.Write_TagValueByTagTypeID(15, opName, tagValue); + return true; + } + + if (tagTypeCodeID == "103") + { + DataRow errDt = FuntionMesRead.Send_AlarmMsg(tagID, Convert.ToInt32(tagValue).ToString()); + // 报警产生时上报 MES 接口(仅重故障停机类型上报工厂MES) + if (errDt != null && Convert.ToInt32(tagValue) == 1 && errDt["测量位置"].ToString() == "重故障停机") + { + string mesAlarmType = errDt["测量单位"].ToString(); + if (AlarmExceptionTypeMap.ContainsKey(mesAlarmType)) mesAlarmType = AlarmExceptionTypeMap[mesAlarmType]; + WebApi.CALL_Inerface_DataHandle.CALL_Inerface_DeviceAlarm(opName, tagID, mesAlarmType, errDt["测量项目"].ToString()); + } + } + + if (tagTypeCodeID == "1000" || tagTypeCodeID == "1001" || tagTypeCodeID == "103") + { + ExecuteDeviceStatusLogInOrder(opName, () => HandleDeviceStatusLog(e, opName, tagTypeCodeID)); + } + + return false; + } + + // 设备状态日志业务集中放在这里,按点位类型分别处理上电、循环、报警。 + private void HandleDeviceStatusLog(DeviceDriver_BasicData.CustomeEvetnArgs e, string opName, string tagTypeCodeID) + { + if (tagTypeCodeID == "1000") + { + errorPortSave(opName, Convert.ToBoolean(e.TagValue) ? DeviceStatusMap["待机"] : DeviceStatusMap["关机"]); + return; + } + + if (tagTypeCodeID == "1001") + { + errorPortSave(opName, Convert.ToBoolean(e.TagValue) ? DeviceStatusMap["运行"] : DeviceStatusMap["待机"]); + return; + } + + if (tagTypeCodeID == "103") + { + // 通过 IOT类型(测量位置)文本自动匹配状态码 + string iotType = e.ShaftID?.ToString() ?? ""; + DeviceStatusMap.TryGetValue(iotType, out string alarmStatusCode); + alarmStatusCode = alarmStatusCode ?? "6"; // 未匹配默认轻报警运行 + + string errorCode = e.TagID?.ToString(); + string malfunctionName = e.ItemName?.ToString(); + if (!string.IsNullOrEmpty(errorCode) && errorCode.Length > 4) + errorCode = errorCode.Substring(errorCode.Length - 4); + + // 报警产生=1 / 报警解除=0 + int alarmRemove = Convert.ToInt32(e.TagValue) == 1 ? 1 : 0; + errorPortSave(opName, alarmStatusCode, errorCode, malfunctionName, null, null, alarmRemove); + + // 报警解除后处理 + if (alarmRemove == 0) + { + // 1. 先补写当前设备实际状态(运行/待机/关机) + string restoreStatus = Convert.ToInt32(MIS_BASE.ReadPLC(1001, opName)) == 1 ? DeviceStatusMap["运行"] + : Convert.ToInt32(MIS_BASE.ReadPLC(1000, opName)) == 1 ? DeviceStatusMap["待机"] + : DeviceStatusMap["关机"]; + errorPortSave(opName, restoreStatus); + + // 2. 查找仍然活跃的报警,如果有则补写一条,确保最新记录反映真实报警状态 + var rtList = MIS_BASE.ReadPLC_OpName(opName); + var json = JsonConvert.SerializeObject(rtList); + var tagValues = JsonConvert.DeserializeObject>(json); + if (tagValues != null) + { + var activeAlarm = tagValues.FirstOrDefault(kvp => + kvp.Value.TagTypeCodeID.ToString() == "103" && + string.Equals(kvp.Value.TagValue?.ToString(), bool.TrueString, StringComparison.OrdinalIgnoreCase)); + + if (activeAlarm.Key != null) + { + // 从报警缓存中获取报警详情并补写 + string activeTagID = activeAlarm.Key; + DataRow alarmDt = FuntionMesRead.Base_ObjList[activeTagID] as DataRow; + if (alarmDt != null) + { + string activeIotType = alarmDt["测量位置"].ToString(); + DeviceStatusMap.TryGetValue(activeIotType, out string activeStatus); + activeStatus = activeStatus ?? "6"; + + string activeCode = activeTagID; + if (!string.IsNullOrEmpty(activeCode) && activeCode.Length > 4) + activeCode = activeCode.Substring(activeCode.Length - 4); + + errorPortSave(opName, activeStatus, activeCode, alarmDt["测量项目"].ToString(), null, null, 1); + } + } + } + } + } + } + + // 同一工位串行、不同工位并行,避免报警解除与运行/待机补写互相穿插。 + private void ExecuteDeviceStatusLogInOrder(string opName, Action action) + { + string lockKey = opName ?? string.Empty; + object syncRoot = DeviceStatusLogLocks.GetOrAdd(lockKey, key => new object()); + lock (syncRoot) + { + action(); + } + } + + public static bool errorPortSave(string opName, string DeviceStatus, string MalfunctionCode = null, string MalfunctionName = null, string Malfunctionexplain = null, string Remark = null, int? alarmRemove = null) + { + string produceName = "接口_工位运行状态_增加"; + SqlParameter[] thisParms = new SqlParameter[7]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@状态代码", DeviceStatus); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@故障代码", MalfunctionCode); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@故障名称", MalfunctionName); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@故障说明", Malfunctionexplain); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@备注", Remark); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@alarmRemove", (object)alarmRemove ?? DBNull.Value); + return DataAccess2.ExecuteStoredProcedure(produceName, ref thisParms, out string errorMessage); + } + + /// + /// 根据工位号获取MesServerCode + /// + /// + /// + private static int GetMesServerCodeByOpName(string OpName) + { + try + { + if (MesServerWork.MIS_BASE.hashtable_MesServerCode.ContainsKey(OpName)) + { + return Convert.ToInt32(MesServerWork.MIS_BASE.hashtable_MesServerCode[OpName]); + } + return 0; + } + catch + { + return 0; + } + } + /// + /// 根据工位号获取MesServerDll + /// + /// + /// + private static string GetMesServeDllByOpName(string OpName) + { + try + { + if (MesServerWork.MIS_BASE.hashtable_MesDll.ContainsKey(OpName)) + { + return MesServerWork.MIS_BASE.hashtable_MesDll[OpName].ToString(); + } + return ""; + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "GetMesServeDllByOpName"); + return ""; + } + } + /// + /// 数据库记录信号变化 + /// + /// + private void TagTypeCodeID_TagDataOnChange(object msgEvent) + { + if (IsRecordTagStatus != "1") return; + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs e = (DeviceDriver_BasicData.CustomeEvetnArgs)msgEvent; + + string tagValue; + if (e.TagValue == null) return; + + switch (e.TagValue.ToString().ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + + string TagTypeCodeID; + string opName; + string TagID; + string TagValue; + DateTime arrivedTime; + DateTime leavedTime; + int TimeDiff; + opName = e.OpName.ToString(); + TagValue = tagValue; + TagTypeCodeID = e.TagTypeCodeID.ToString(); + TagID = e.TagID.ToString(); + leavedTime = Convert.ToDateTime(e.TimeStamp); + arrivedTime = Convert.ToDateTime(e.TimeStampBefore); + TimeDiff = Convert.ToInt32(e.TagKeepTime); + + if (TagTypeCodeID != "14" && TagTypeCodeID != "15") + { + TagTypeCodeID_Insert(opName, TagTypeCodeID, TagID, TagValue, arrivedTime, leavedTime, TimeDiff); + } + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TagTypeCodeID_TagDataOnChange"); + } + + } + /// + /// 向MES通讯服务器发送消息 + /// + /// + private void TransferInfToWebServer(object msg1) + { + int tagType; + string opName; + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)msg1; + //e值不能为空 + if (msgEvent.TagValue == null) return; + tagType = Convert.ToInt32(msgEvent.TagType); + opName = msgEvent.OpName.ToString(); + + if (!MesServerWork.MIS_BASE.m_WorkStart_OpName.ContainsKey(opName)) return; //当前系统是否存在该工位 + + string cmd; + string tagValue; + string msgSvr; + try + { + switch (Convert.ToInt32(msgEvent.TagValueType)) + { + case 11: + tagValue = (Convert.ToInt32(msgEvent.TagValue)).ToString(); + break; + default: + tagValue = msgEvent.TagValue.ToString(); + break; + } + cmd = MIS_BASE.hashtable_TagTypeTagName[tagType.ToString()]; + if (Convert.ToInt32(MIS_BASE.hashtable_WebTagTypeChange[cmd]) == 0 && MIS_BASE.hashtable_WebTagTypeChange[cmd] != null) return; + + if (cmd != "" && cmd != null) + { + msgSvr = "MES|" + cmd + "|" + opName + "|" + tagValue; + } + else + { + return; + } + //MES web界面显示用 + MIS_SendMessage.asyncSendMessageQos0(msgSvr); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TransferInfToWebServer"); + } + } + + private void button_ReadData_Click(object sender, EventArgs e) + { + + } + + + private void ToolStripMenuItem_PlcDebug_Click(object sender, EventArgs e) + { + if (opcForm != null) + { + opcForm.Close(); + opcForm.Dispose(); + opcForm = null; + } + + opcForm = new MesWork.OpcForm(IsDemoMesServer); + opcForm.Show(); + } + /// + /// 关于迈思按钮 + /// + /// + /// + private void 关于迈思ToolStripMenuItem_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start("http://www.meswork.com"); + } + /// + /// 版本信息按钮 + /// + /// + /// + private void 版本信息ToolStripMenuItem_Click(object sender, EventArgs e) + { + VersionsInformation VersionForm = new VersionsInformation(); + VersionForm.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + FuntionMesRead.GetAlarmInit(); + MyLog4Net.MyLogHelper.Info($"报警更新:", "报警信息更新完成!"); + } + + private void WritePLCBoolData_Click(int TagTypeCodeId) + { + string OpName = WorkStationNum_Now; + string tagValue = MIS_BASE.Read_TagValueByTagTypeID(TagTypeCodeId, OpName).ToString(); + bool tagValueBool = false; + if (tagValue.ToLower() == "true" || tagValue == "1") + { + tagValueBool = false; + } + else + { + tagValueBool = true; + } + + MIS_BASE.Write_TagValueByTagTypeID(TagTypeCodeId, OpName, tagValueBool); + } + private void WorkStartPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(2); + } + + private void PartLoadPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(43); + } + + private void EngineGetOverMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(5); + } + + private void EngineGetOverPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(44); + } + + private void allowWorkMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(66); + } + + private void allowSavePLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(19); + } + + private void saveOverMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(20); + } + + private void workOverMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(7); + } + + private void toolPoweredPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(1000); + } + + private void toolStartPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(1001); + } + + private void toolErrorPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(1002); + } + + private void button1_Click(object sender, EventArgs e) + { + MIS_BASE.Write_TagValueByTagTypeID(200, WorkStationNum_Now, "001MBE0700000QF3D0000001"); + MIS_BASE.Write_TagValueByTagTypeID(201, WorkStationNum_Now, "001MBE0700000QF3D0000002"); + MIS_BASE.Write_TagValueByTagTypeID(202, WorkStationNum_Now, "001MBE0700000QF3D0000003"); + MIS_BASE.Write_TagValueByTagTypeID(203, WorkStationNum_Now, "001MBE0700000QF3D0000004"); + MIS_BASE.Write_TagValueByTagTypeID(204, WorkStationNum_Now, "001MBE0700000QF3D0000005"); + MIS_BASE.Write_TagValueByTagTypeID(205, WorkStationNum_Now, "001MBE0700000QF3D0000006"); + MIS_BASE.Write_TagValueByTagTypeID(206, WorkStationNum_Now, "001MBE0700000QF3D0000007"); + MIS_BASE.Write_TagValueByTagTypeID(207, WorkStationNum_Now, "001MBE0700000QF3D0000008"); + } + + private void button3_Click(object sender, EventArgs e) + { + try + { + string bodydata = @" +{ + ""MsgId"": ""745e296b-f277-4dd0-bf0b-5f3ccf97ab10"", + ""OpCode"": ""OP430-1"", + ""ProductionCode"": ""001PBE0700000Q17E0100001"", + ""CheckTime"": ""2024-10-29 14:58:58"", + ""CheckPerson"": ""张三"", + ""QualityMark"": 1, + ""CheckData"": [ + { + ""CheckCode"": ""PL10_M0001_001"", + ""CheckName"": ""12电芯电压"", + ""Unit"": ""V"", + ""StandardValue"": ""10"", + ""MinValue"": ""10.1"", + ""MaxValue"": ""9.8"", + ""CheckValue"": ""10"", + ""QualityMark"":1 + }, + { + ""CheckCode"": ""PL10_M0001_002"", + ""CheckName"": ""12电芯压差"", + ""Unit"": ""mV"", + ""StandardValue"": ""0.2"", + ""MinValue"": ""0"", + ""MaxValue"": ""0.3"", + ""CheckValue"": ""0.16"", + ""QualityMark"": 1 + }, + { + ""CheckCode"": ""PL10_M0001_001"", + ""CheckName"": ""23电芯电压"", + ""Unit"": ""V"", + ""StandardValue"": ""10"", + ""MinValue"": ""10.1"", + ""MaxValue"": ""9.8"", + ""CheckValue"": ""9.96"", + ""QualityMark"":1 + }, + { + ""CheckCode"": ""PL10_M0001_002"", + ""CheckName"": ""23电芯压差"", + ""Unit"": ""mV"", + ""StandardValue"": ""0.2"", + ""MinValue"": ""0"", + ""MaxValue"": ""0.3"", + ""CheckValue"": ""0.17"", + ""QualityMark"": 1 + } + ] +} + +"; + + string retString; + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(OnlineCheckDataUrl); + request.Method = "post"; + byte[] bytes = Encoding.UTF8.GetBytes(bodydata); + request.Accept = "*/*"; + request.ContentType = "application/json;charset=utf-8"; + + // 反序列化后先把JSON做接口记录 + //存储日志 + int AID = -1; + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var reqParam = new SqlParameter[] { + new SqlParameter("@接口地址",OnlineCheckDataUrl), + new SqlParameter("@接口类型",1), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",bodydata), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref reqParam, out DataTable reqDt, out string errorMessage); + + if (reqDt.Rows.Count > 0) + { + AID = Convert.ToInt32(reqDt.Rows[0]["AID"]); + } + + request.ContentLength = bytes.Length; + + // 准备请求体 + Stream myResponseStream = request.GetRequestStream(); + myResponseStream.Write(bytes, 0, bytes.Length); + //发送webapi请求 等待相应 + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); + retString = myStreamReader.ReadToEnd(); + + //响应结果 + CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var resParam = new SqlParameter[] { + new SqlParameter("@AID",AID), + new SqlParameter("@响应时间",CreateTime), + new SqlParameter("@响应内容",retString) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_响应记录", ref resParam, out DataTable dt, out errorMessage); + + // 序列化响应内容 + msgResHeader mrh = JsonConvert.DeserializeObject(retString); + int statusCode = (int)response.StatusCode; + // 对响应内容进行处理 更新数据库标志 + if (statusCode == 200) + { + myStreamReader.Close(); + myResponseStream.Close(); + string msg = "请求发送成功!详细信息查看日志"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + if (response != null) + { + // 失败 + if (mrh.Code != "200") + { + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", "【接收上传质量数据接口】失败"); + } + response.Close(); + } + if (request != null) + { + request.Abort(); + } + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", err.Message); + } + } + + private void button17_Click(object sender, EventArgs e) + { + MIS_BASE.Read_EngineID_MES(WorkStationNum_Now, out string EngineID_MES); + MIS_BASE.Read_EngineTypeID_MES(WorkStationNum_Now, out int EngineTypeID_MES); + MIS_BASE.Write_TagValueByTagTypeID(10, WorkStationNum_Now, EngineID_MES); + MIS_BASE.Write_TagValueByTagTypeID(9, WorkStationNum_Now, EngineTypeID_MES); + MIS_BASE.Write_TagValueByTagTypeID(80, WorkStationNum_Now, 12); + } + + private void button18_Click(object sender, EventArgs e) + { + string EngineID = textBox1_EngineID.Text; + string EngineTypeID = textBox2_EngineTypeID.Text; + string palletCode = textBox3_palletCode.Text; + + MIS_BASE.Write_TagValueByTagTypeID(10, WorkStationNum_Now, EngineID); + MIS_BASE.Write_TagValueByTagTypeID(9, WorkStationNum_Now, EngineTypeID); + MIS_BASE.Write_TagValueByTagTypeID(80, WorkStationNum_Now, palletCode); + } + + private void button19_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(59); + } + + + /// + /// 界面上的开启时间 + /// + void Runtime_Thread() + { + try + { + DateTime Now = DateTime.Now; + TimeSpan x = Now.Subtract(StartTime); + toolStripStatusLabel_RunTime.Text = x.Days.ToString() + "天" + x.Hours.ToString("00") + "小时" + x.Minutes.ToString("00") + "分" + x.Seconds.ToString("00") + "秒"; + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, err.Message); + } + } + + private void cb_F5_CheckedChanged(object sender, EventArgs e) + { + var interval = Convert.ToInt32(txt_Interval.Text); + + if (IsLoopReadShow = cb_F5.Checked) + { + var t = new Thread(new ParameterizedThreadStart(LoopReadShowTask)); + t.IsBackground = true; + t.Start(interval); + } + } + + private void toolStripStatusLabel_RunTime_Click(object sender, EventArgs e) + { + } + + public void LoopReadShowTask(object _interval) + { + var interval = (int)_interval; + while (true) + { + try + { + if (IsLoopReadShow == false) + { + return; + } + + ShowSignal(txt_PLC_9, WorkStationNum_Now); + ShowSignal(txt_PLC_10, WorkStationNum_Now); + ShowSignal(txt_PLC_11, WorkStationNum_Now); + ShowSignal(txt_PLC_39, WorkStationNum_Now); + + ShowSignal(btn_PLC_2, WorkStationNum_Now); + ShowSignal(btn_PLC_43, WorkStationNum_Now); + ShowSignal(btn_MES_5, WorkStationNum_Now); + + ShowSignal(btn_PLC_44, WorkStationNum_Now); + ShowSignal(btn_MES_66, WorkStationNum_Now); + + + ShowSignal(btn_PLC_19, WorkStationNum_Now); + ShowSignal(btn_MES_20, WorkStationNum_Now); + ShowSignal(btn_MES_7, WorkStationNum_Now); + + ShowSignal(btn_PLC_1000, WorkStationNum_Now); + ShowSignal(btn_PLC_1001, WorkStationNum_Now); + ShowSignal(btn_PLC_1002, WorkStationNum_Now); + ShowSignal(btn_PLC_59, WorkStationNum_Now); + + } + catch (Exception err) + { + } + Thread.Sleep(interval); + } + + } + + + public void ShowSignal(Control c, string opName) + { + var tagTypeCodeID = Convert.ToInt32(c.Name.Split('_')[2]); + if (c is TextBox) + { + try + { + c.Text = PlcLinkForm.ReadPLC(tagTypeCodeID, opName).ToString(); + + } + catch (Exception err) + { + c.Text = "不存在该信号!"; + } + } + if (c is Button) + { + try + { + c.BackColor = PlcLinkForm.ReadPLC(tagTypeCodeID, opName).ToString().ToLower() + .Replace("true", "1").Replace("false", "0") == "1" + ? color_Green : color_Bad; + } + catch (Exception err) + { + c.BackColor = color_Red; + } + } + + } + + private void panel_Signal_Conf_MouseDoubleClick(object sender, MouseEventArgs e) + { + new MES_CONF().ShowDialog(); + } + + private void button20_Click(object sender, EventArgs e) + { + PrinterCommandCenter.PrintToPrinter(textBox1_EngineID.Text); + } + + private void dgv_OpName_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex > -1) + { + if (AllowLoad) + { + WorkStationNum_Now = dgv_OpName.CurrentRow.Cells["OpCode"].Value.ToString(); + } + } + } + + private void webAPI接口测试ToolStripMenuItem_Click(object sender, EventArgs e) + { + new SlMesDbIterface.Form_MoveSqlTable().Show(); + } + + private void MesEngineDataWritePlc_Click(object sender, EventArgs e) + { + // 把工件编号、订单号、产品型号代码、产品型号 写入PLC + string OpName = WorkStationNum_Now; + MIS_BASE.WritePLC(9, OpName, MIS_BASE.ReadPLC(73, OpName)); // 机型标志 + MIS_BASE.WritePLC(11, OpName, MIS_BASE.ReadPLC(75, OpName)); // 产品型号 + MIS_BASE.WritePLC(39, OpName, MIS_BASE.ReadPLC(116, OpName)); // 订单号 + MIS_BASE.WritePLC(10, OpName, MIS_BASE.ReadPLC(74, OpName)); // 机型标志 + } + + /// + /// 启动失败接口重试线程 + /// + private void StartFailedInterfaceRetryThread() + { + new Thread(new ThreadStart(delegate () + { + while (true) + { + try + { + ProcessFailedInterfaceRetry(); + } + catch (Exception ex) + { + ApplicationLog.WriteLog(ex, "ProcessFailedInterfaceRetry异常"); + } + Thread.Sleep(1000 * 60); // 每分钟执行一次 + } + })) + { IsBackground = true }.Start(); + } + + private void StartElectricityThread() + { + new Thread(new ThreadStart(delegate () + { + List opNames = new List { }; + string lineName = ConfigurationManager.AppSettings["WebapiPostHeader_Systemcode"].ToString(); + //MES_ZHDQ_126GLKG MES_ZHDQ_126DLQ MES_ZHDQ_126ZZ + if (lineName == "MES_ZHDQ_126GLKG") opNames = new List { "AC09ET1", "AC09ET2", "AC09ET3" }; + if (lineName == "MES_ZHDQ_126DLQ") opNames = new List { "AC06ET1", "AC06ET2", "AC06ET3" }; + if (lineName == "MES_ZHDQ_126ZZ") opNames = new List { "AC1101" }; + while (true) + { + try + { + foreach (string opName in opNames) + { + int kwh = Convert.ToInt32(PlcLinkForm.ReadPLC(501, opName)); + string produceName = "XD_电能数据_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@正向有功", kwh); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + + SaveElectricityHarmonicData(opName); + } + } + catch (Exception ex) + { + ApplicationLog.WriteLog(ex, "StartElectricityThread异常"); + } + Thread.Sleep(1000 * 60); // 每分钟执行一次 + } + })) + { IsBackground = true }.Start(); + } + + /// + /// 采集电能表谐波数据,点位 506-525,每分钟随电能数据一起保存。 + /// + private void SaveElectricityHarmonicData(string opName) + { + string produceName = "XD_电能表谐波数据_增加"; + SqlParameter[] thisParms = new SqlParameter[] + { + new SqlParameter("@工位号", opName), + new SqlParameter("@A相电压总谐波畸变", ReadElectricityHarmonicValue(506, opName)), + new SqlParameter("@B相电压总谐波畸变", ReadElectricityHarmonicValue(507, opName)), + new SqlParameter("@C相电压总谐波畸变", ReadElectricityHarmonicValue(508, opName)), + new SqlParameter("@系统电压总谐波畸变", ReadElectricityHarmonicValue(509, opName)), + new SqlParameter("@A相电流总谐波畸变", ReadElectricityHarmonicValue(510, opName)), + new SqlParameter("@B相电流总谐波畸变", ReadElectricityHarmonicValue(511, opName)), + new SqlParameter("@C相电流总谐波畸变", ReadElectricityHarmonicValue(512, opName)), + new SqlParameter("@系统电流总谐波畸变", ReadElectricityHarmonicValue(513, opName)), + new SqlParameter("@A相电压奇次谐波畸变", ReadElectricityHarmonicValue(514, opName)), + new SqlParameter("@B相电压奇次谐波畸变", ReadElectricityHarmonicValue(515, opName)), + new SqlParameter("@C相电压奇次谐波畸变", ReadElectricityHarmonicValue(516, opName)), + new SqlParameter("@A相电流奇次谐波畸变", ReadElectricityHarmonicValue(517, opName)), + new SqlParameter("@B相电流奇次谐波畸变", ReadElectricityHarmonicValue(518, opName)), + new SqlParameter("@C相电流奇次谐波畸变", ReadElectricityHarmonicValue(519, opName)), + new SqlParameter("@A相电压偶次谐波畸变", ReadElectricityHarmonicValue(520, opName)), + new SqlParameter("@B相电压偶次谐波畸变", ReadElectricityHarmonicValue(521, opName)), + new SqlParameter("@C相电压偶次谐波畸变", ReadElectricityHarmonicValue(522, opName)), + new SqlParameter("@A相电流偶次谐波畸变", ReadElectricityHarmonicValue(523, opName)), + new SqlParameter("@B相电流偶次谐波畸变", ReadElectricityHarmonicValue(524, opName)), + new SqlParameter("@C相电流偶次谐波畸变", ReadElectricityHarmonicValue(525, opName)) + }; + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + private object ReadElectricityHarmonicValue(int tagTypeCodeID, string opName) + { + try + { + object value = PlcLinkForm.ReadPLC(tagTypeCodeID, opName); + if (value == null || string.IsNullOrWhiteSpace(value.ToString())) + { + return DBNull.Value; + } + + return Convert.ToDouble(value); + } + catch + { + return DBNull.Value; + } + } + + /// + /// 处理失败接口重试逻辑 + /// + private void ProcessFailedInterfaceRetry() + { + try + { + // 读取失败记录 + var readParams = new SqlParameter[0]; + bool hasData = SqlOperation.ExecuteStoredProcedure("接口_IOT接口_上报失败记录_缓存表_读取", readParams, out DataTable dt, out string readError); + + if (hasData && dt != null && dt.Rows.Count > 0) + { + var row = dt.Rows[0]; + int aid = Convert.ToInt32(row["AID"]); + string interfaceName = row["接口名称"].ToString(); + string interfaceUrl = row["接口地址"].ToString(); + string requestContent = row["请求内容"].ToString(); + + // 重试接口调用 + string responseContent = RetryInterfaceCall(interfaceUrl, requestContent); + + // 判断重试结果 + bool isSuccess = IsRetrySuccess(responseContent); + int resultType = isSuccess ? 1 : 2; // 1:成功删除记录, 2:失败更新记录 + + // 更新状态 + var updateParams = new SqlParameter[] + { + new SqlParameter("@AID", aid), + new SqlParameter("@响应内容", responseContent), + new SqlParameter("@result", resultType) + }; + SqlOperation.ExecuteStoredProcedure("接口_IOT接口_上报失败记录_缓存表_更新状态", updateParams, out string updateError); + + if (isSuccess) + { + ApplicationLog.WriteLog($"接口重试成功: {interfaceName}, AID: {aid}"); + } + else + { + ApplicationLog.WriteLog($"接口重试失败: {interfaceName}, AID: {aid}, 响应: {responseContent}"); + } + } + } + catch (Exception ex) + { + ApplicationLog.WriteLog(ex, "ProcessFailedInterfaceRetry处理异常"); + } + } + + /// + /// 重试接口调用 + /// + /// 接口地址 + /// 请求内容 + /// 响应内容 + private string RetryInterfaceCall(string interfaceUrl, string requestContent) + { + try + { + // 直接使用Post_Auto方法发送数据库读取的报文 + return Post.Post_XK(interfaceUrl, requestContent); + } + catch (Exception ex) + { + return JsonConvert.SerializeObject(new { code = 500, message = ex.Message, data = new object() }); + } + } + + /// + /// 判断重试是否成功 + /// + /// 响应内容 + /// 是否成功 + private bool IsRetrySuccess(string responseContent) + { + try + { + var response = JsonConvert.DeserializeObject(responseContent); + return response.code.ToString() == "200"; + } + catch + { + return false; + } + } + + + } + + +} diff --git a/MisDataFun/MisDataFun/MisDataFun.csproj b/MisDataFun/MisDataFun/MisDataFun.csproj new file mode 100644 index 0000000..7ab4290 --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.csproj @@ -0,0 +1,261 @@ + + + + + Debug + AnyCPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E} + WinExe + MisDataFun + MisDataFun + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + Mes32X32.ico + + + app.manifest + + + + Form + + + MES_CONF.cs + + + + Form + + + MisDataFun.cs + + + + + + + + + MES_CONF.cs + + + MisDataFun.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + ..\..\dll_common\BasicData.dll + + + ..\..\dll_common\BouncyCastle.Crypto.dll + + + False + ..\..\dll_common\ConLink.dll + + + ..\..\dll_common\ConLink19.dll + + + ..\..\dll_common\DataLinkMesWork.dll + + + False + ..\..\dll_common\ICSharpCode.SharpZipLib.dll + + + ..\..\dll_common\MesControl.dll + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + + ..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll + + + ..\..\dll_common\Monitor.MesWork.dll + + + ..\..\dll_common\MQTTnet.dll + + + ..\..\dll_common\MQTTnet.Extensions.ManagedClient.dll + + + ..\..\dll_common\Newtonsoft.Json.dll + + + False + ..\..\dll_common\NPOI.dll + + + False + ..\..\dll_common\NPOI.OOXML.dll + + + False + ..\..\dll_common\NPOI.OpenXml4Net.dll + + + False + ..\..\dll_common\NPOI.OpenXmlFormats.dll + + + ..\..\dll_common\Opc.Ua.Client.dll + + + ..\..\dll_common\Opc.Ua.Configuration.dll + + + ..\..\dll_common\Opc.Ua.Core.dll + + + ..\..\dll_common\OpcUaHelper.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + + + + + + + + False + ..\..\dll_common\System.Net.Http.Formatting.dll + + + False + ..\..\dll_fun\System.Net.Security.dll + + + False + ..\..\dll_fun\System.Net.WebSockets.dll + + + False + ..\..\dll_fun\System.Net.WebSockets.Client.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.Algorithms.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.Encoding.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.Primitives.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.X509Certificates.dll + + + ..\..\dll_common\System.Web.Cors.dll + + + + ..\..\dll_common\System.Web.Http.dll + + + ..\..\dll_common\System.Web.Http.Cors.dll + + + ..\..\dll_common\System.Web.Http.SelfHost.dll + + + + + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 01-MesDataFunction + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + {2f33d79d-1dff-4cda-b357-fcd5221cab9a} + ExternalDataSync + + + {b5a0baa3-c1a7-4aab-9486-2e650adaca7e} + Function1051 + + + {5fee5c91-8419-49ff-b2c2-47476f0b8c68} + Function1052 + + + {ca8a12c5-7bf0-4489-93fa-180b1c492bba} + Function1053 + + + {cc45d613-11b9-48af-b073-6523d6273525} + Function1054 + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/MisDataFun.resx b/MisDataFun/MisDataFun/MisDataFun.resx new file mode 100644 index 0000000..0b9bac2 --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.resx @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 22, 12 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 267, 7 + + + 137, 15 + + + 36 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABMLAAATCwAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKEgMgChczIA + occyAKHqMgChmTIAoTwyAKEJMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQQyAKEvMgChdzIA + odYyAKH7MgCh/zIAof8yAKH/MgCh6jIAoacyAKFJMgChEjIAoQAyAKEAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChADIAoQoyAKE+MgChkTIA + oeoyAKH+MgCh+TIAoe0yAKH+MgCh/zIAofwyAKH3MgCh/jIAofgyAKHBMgChZDIAoR4yAKEBMgChAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChATIAoRUyAKFcMgChujIA + ofEyAKH/MgCh9DIAobcyAKFPMgChfjIAof8yAKH/MgCh5TIAoVUyAKGLMgCh4jIAofwyAKH9MgCh2TIA + oYcyAKEoMgChBTIAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChAjIAoSYyAKF2MgCh0DIA + ofcyAKH+MgCh8zIAof8yAKGjMgChDTIAoQAyAKFpMgCh/zIAof8yAKHhMgChHjIAoQIyAKEiMgChbjIA + ocoyAKH3MgCh/jIAoeUyAKGfMgChQTIAoQsyAKEAAAAAAAAAAAAAAAAAMgChCDIAoUEyAKGXMgCh4jIA + of4yAKH/MgChzzIAoW0yAKFoMgCh+zIAoZcyAKEAMgChADIAoWkyAKH/MgCh/zIAoeEyAKEeMgChADIA + oQAyAKEBMgChETIAoVAyAKGiMgCh8DIAof8yAKH0MgChuTIAoW0yAKEVMgChADIAoQAyAKG2MgCh7TIA + of8yAKHvMgCh7jIAofgyAKFLMgChADIAoTcyAKH1MgChlzIAoQAyAKEAMgChaTIAof8yAKH/MgCh4TIA + oR4yAKEAAAAAAAAAAAAAAAAAMgChADIAoQcyAKE4MgChijIAod8yAKH9MgCh+zIAoc4yAKFdMgChADIA + of8yAKHlMgChlDIAoToyAKGgMgCh7jIAoSwyAKEAMgChFzIAodgyAKGZMgChADIAoQAyAKFpMgCh/zIA + of8yAKHxMgChfDIAoSkyAKEBMgChAAAAAAAAAAAAAAAAADIAoQAyAKECMgChITIAoW8yAKG/MgCh/zIA + oZYyAKEAMgCh/zIAoZoyAKEBMgChADIAoZkyAKHSMgChEjIAoQAyAKEGMgChujIAoZoyAKEAMgChADIA + oWkyAKH/MgCh/zIAof0yAKH+MgCh4TIAoZIyAKFEMgChDjIAoQAyAKEAAAAAAAAAAAAAAAAAMgChADIA + oUIyAKH7MgChlzIAoQAyAKH/MgChlzIAoQAyAKEAMgChmjIAobMyAKEEMgChADIAoQAyAKGcMgChmzIA + oQAyAKEAMgChaTIAof8yAKH/MgCh4zIAoZYyAKHRMgCh+zIAofQyAKHDMgChZDIAoSIyAKEBMgChAAAA + AAAyAKEAMgChPzIAofsyAKGXMgChADIAof8yAKGXMgChADIAoQAyAKGaMgChiDIAoQAAAAAAMgChADIA + oYgyAKGaMgChADIAoQAyAKFpMgCh/zIAof8yAKHhMgChIDIAoRIyAKFeMgChqzIAoe0yAKH+MgCh3jIA + oYYyAKEqMgChADIAoQAyAKE/MgCh+zIAoZcyAKEAMgCh/zIAoZcyAKEAMgChADIAoZgyAKFtMgChAAAA + AAAyAKEAMgChXDIAoZQyAKEAMgChADIAoWkyAKH/MgCh/zIAoeEyAKEeMgChADIAoQAyAKEGMgChMDIA + oX8yAKHTMgCh+jIAoWkyAKEAMgChADIAoT8yAKH7MgChlzIAoQAyAKH/MgChlzIAoQAyAKEAMgChlTIA + oWMyAKEAAAAAADIAoQAyAKE2MgChhTIAoQAyAKEAMgChaTIAof8yAKH/MgCh4TIAoR4yAKEAAAAAAAAA + AAAyAKEAMgChATIAoRUyAKFYMgChQDIAoQAyAKEAMgChPzIAofsyAKGXMgChADIAof8yAKGXMgChADIA + oQAyAKGLMgChQTIAoQAyAKEFMgChADIAoSMyAKF4MgChADIAoQAyAKFpMgCh/zIAof8yAKHhMgChHjIA + oQAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQAyAKEBMgChADIAoQAyAKE/MgCh+zIAoZcyAKEAMgCh/zIA + oZcyAKEAMgChADIAoXcyAKEkMgChBzIAoUIyAKEBMgChFjIAoWUyAKEBMgChADIAoWkyAKH/MgCh/zIA + oeEyAKEeMgChADIAoQAyAKE5MgChSTIAoQ8yAKEBMgChAAAAAAAAAAAAMgChADIAoT8yAKH7MgChlzIA + oQAyAKH/MgChlzIAoQAyAKECMgChWzIAoQ8yAKEVMgChhTIAoQoyAKEHMgChMzIAoQEyAKEAMgChaTIA + of8yAKH/MgCh4TIAoR4yAKEAMgChADIAoWkyAKH1MgChyzIAoX8yAKE4MgChBTIAoQAyAKEAMgChPzIA + ofsyAKGXMgChADIAof8yAKGXMgChADIAoQMyAKFZMgChCzIAoS4yAKHDMgChGjIAoQAAAAAAAAAAADIA + oQAyAKFpMgCh/zIAof8yAKHhMgChHjIAoQAyAKEAMgChLDIAoaEyAKHkMgCh/DIAoe8yAKGrMgChUzIA + oREyAKFBMgCh+zIAoZcyAKEAMgCh/zIAoZcyAKEAMgChBzIAoVAyAKEEMgChQTIAodoyAKEjMgChAAAA + AAAAAAAAMgChADIAoWkyAKH/MgCh/zIAoeEyAKEeMgChAAAAAAAyAKEAMgChBjIAoSAyAKFyMgChwjIA + ofMyAKH4MgCh0zIAobMyAKH9MgChljIAoQAyAKH/MgChlzIAoQAyAKEBMgChBDIAoQAyAKFKMgCh7jIA + oT0yAKEAAAAAADIAoQAyAKEAMgChbDIAof8yAKH/MgCh4TIAoR8yAKEAAAAAAAAAAAAAAAAAMgChADIA + oQEyAKELMgChRzIAoZYyAKHeMgCh/TIAof8yAKGWMgChADIAof8yAKGXMgChAAAAAAAAAAAAMgChADIA + oW0yAKH/MgChZDIAoQAyAKEEMgChHDIAoWAyAKHPMgCh/zIAof8yAKH3MgChkTIAoS8yAKELMgChADIA + oQAAAAAAAAAAAAAAAAAyAKEAMgChATIAoSAyAKF2MgCh/zIAoZYyAKEAMgCh/zIAoZcyAKEAAAAAADIA + oQAyAKEAMgChljIAof8yAKGeMgChOTIAoZEyAKHcMgCh+TIAof8yAKH/MgCh/zIAof8yAKH+MgCh6jIA + obgyAKFXMgChITIAoQEyAKEAAAAAAAAAAAAAAAAAMgChADIAoT8yAKH7MgChlzIAoQAyAKH/MgChlzIA + oQAAAAAAMgChADIAoQwyAKG9MgCh/zIAofMyAKHyMgCh/jIAof8yAKH/MgCh/zIAofoyAKH3MgCh/jIA + of8yAKH/MgCh/zIAofsyAKHbMgChmzIAoUwyAKENMgChATIAoQAyAKEAMgChPzIAofsyAKGXMgChADIA + of8yAKGXMgChATIAoRkyAKFbMgChsTIAofAyAKH/MgCh/zIAof8yAKH/MgCh/DIAoeYyAKGxMgChVTIA + oUIyAKGFMgCh1TIAofUyAKH/MgCh/zIAof8yAKH/MgCh9DIAocUyAKGDMgChMDIAoQYyAKE/MgCh+zIA + oZcyAKEAMgCh/zIAocEyAKGOMgCh2TIAofcyAKH/MgCh/zIAof8yAKH/MgCh7jIAobMyAKFwMgChJjIA + oQoyAKEAMgChADIAoQEyAKEXMgChTTIAoZsyAKHYMgCh/TIAof8yAKH/MgCh/zIAof4yAKHqMgChszIA + oZgyAKH+MgChljIAoQAyAKH/MgCh/zIAof8yAKH/MgCh/zIAof8yAKH0MgChyTIAoYEyAKE/MgChBzIA + oQAAAAAAMgChADIAoSIyAKF2MgChQjIAoRIyAKEAMgChATIAoR4yAKFjMgChrjIAoecyAKH9MgCh/zIA + of8yAKH/MgCh/zIAof8yAKGWMgChADIAof8yAKH/MgCh/zIAofkyAKHWMgChmjIAoUIyAKERMgChATIA + oQAyAKEGMgChFTIAoQMyAKEAMgChKDIAoZUyAKHHMgChxjIAoXcyAKE3MgChBzIAoQAyAKEGMgChKTIA + oXYyAKHDMgCh7jIAof4yAKH/MgCh/zIAoZYyAKEAMgChrjIAoeYyAKH+MgCh0zIAoVcyAKELMgChADIA + oQAyAKEAMgChADIAoVUyAKHAMgChkjIAoVYyAKEUMgChATIAoRYyAKFhMgChqzIAodUyAKGmMgChZTIA + oR8yAKEDMgChBDIAoS0yAKGiMgCh9DIAofUyAKHGMgChWTIAoQAyAKEGMgChKjIAoWsyAKHBMgCh3DIA + ocEyAKFwMgChJTIAoQYyAKEAMgChDDIAoTgyAKF/MgChyjIAocMyAKGUMgChMzIAoQsyAKEEMgChJjIA + oWUyAKG/MgCh0TIAoaYyAKGoMgCh1TIAodYyAKGNMgChQTIAoRAyAKEAMgChAAAAAAAyAKEAMgChADIA + oQ8yAKE8MgChkDIAoc8yAKHfMgChpDIAoVIyAKEcMgChADIAoQEyAKETMgChRzIAoZ8yAKHGMgChvzIA + oWQyAKEtMgChMzIAoY8yAKHvMgCh5zIAoa8yAKFcMgChHDIAoQMyAKEAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAADIAoQAyAKECMgChFTIAoVcyAKGaMgCh3DIAodEyAKGaMgChSDIAoQsyAKEAMgChATIA + oSUyAKGGMgCh6TIAofEyAKHhMgChtzIAoXAyAKErMgChBTIAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKElMgChXTIAobgyAKHbMgChxTIA + oYUyAKFbMgChqzIAodEyAKHLMgChhDIAoTsyAKELMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChCzIA + oTcyAKGTMgCh0zIAofAyAKG2MgChWjIAoRcyAKEBMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA/+Af//+AB//8AAD/8AAAP8AIAA8AGDABARg+AQEYD4ERGAPxMZgAcTOY + ADEzmDAxM5g8MTKIPzEgCDDxIAgwMSB4MAEgeDgBJHg+ATxAD8E8AAHxOAAAMQAAAAEAAwABABwgAQBE + BAEBwAABAEAAA+AAAA/4AAB//wAD///gD/8= + + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/Properties/AssemblyInfo.cs b/MisDataFun/MisDataFun/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d797f42 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MisDataSaveDate")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("大连迈思信息技术有限公司")] +[assembly: AssemblyProduct("MisDataSaveDate")] +[assembly: AssemblyCopyright("Copyright © 大连迈思信息技术有限公司 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("9aede061-8490-436a-b38b-9495dc908f19")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFun/MisDataFun/Properties/Resources.Designer.cs b/MisDataFun/MisDataFun/Properties/Resources.Designer.cs new file mode 100644 index 0000000..34e1c57 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace MisDataFun.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MisDataFun.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 断开状态 { + get { + object obj = ResourceManager.GetObject("断开状态", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 连接状态 { + get { + object obj = ResourceManager.GetObject("连接状态", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/MisDataFun/MisDataFun/Properties/Resources.resx b/MisDataFun/MisDataFun/Properties/Resources.resx new file mode 100644 index 0000000..19c6ed7 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Resources.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\断开状态.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\连接状态.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/Properties/Settings.Designer.cs b/MisDataFun/MisDataFun/Properties/Settings.Designer.cs new file mode 100644 index 0000000..2e69221 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace MesServerMisDataFun.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/MisDataFun/MisDataFun/Properties/Settings.settings b/MisDataFun/MisDataFun/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/MisDataFun/MisDataFun/Resources/断开状态.png b/MisDataFun/MisDataFun/Resources/断开状态.png new file mode 100644 index 0000000..0ae6189 Binary files /dev/null and b/MisDataFun/MisDataFun/Resources/断开状态.png differ diff --git a/MisDataFun/MisDataFun/Resources/连接状态.png b/MisDataFun/MisDataFun/Resources/连接状态.png new file mode 100644 index 0000000..fcf9db7 Binary files /dev/null and b/MisDataFun/MisDataFun/Resources/连接状态.png differ diff --git a/MisDataFun/MisDataFun/app.manifest b/MisDataFun/MisDataFun/app.manifest new file mode 100644 index 0000000..75867c2 --- /dev/null +++ b/MisDataFun/MisDataFun/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun/MisDataFun/jsconfig1.json b/MisDataFun/MisDataFun/jsconfig1.json new file mode 100644 index 0000000..afb797c --- /dev/null +++ b/MisDataFun/MisDataFun/jsconfig1.json @@ -0,0 +1,10 @@ +{ + "exclude": [ + "**/bin", + "**/bower_components", + "**/jspm_packages", + "**/node_modules", + "**/obj", + "**/platforms" + ] +} \ No newline at end of file diff --git a/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.Designer.cs b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.Designer.cs new file mode 100644 index 0000000..4cd9051 --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.Designer.cs @@ -0,0 +1,113 @@ +namespace MES_SIGNAL_CONF +{ + partial class MES_CONF + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.btn_ConfigToSql = new System.Windows.Forms.Button(); + this.label_ReadExcel = new System.Windows.Forms.Label(); + this.label_WriteSql = new System.Windows.Forms.Label(); + this.txt_Msg = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btn_ConfigToSql + // + this.btn_ConfigToSql.Location = new System.Drawing.Point(487, 74); + this.btn_ConfigToSql.Name = "btn_ConfigToSql"; + this.btn_ConfigToSql.Size = new System.Drawing.Size(161, 36); + this.btn_ConfigToSql.TabIndex = 0; + this.btn_ConfigToSql.Text = "重新将配置写入数据库"; + this.btn_ConfigToSql.UseVisualStyleBackColor = true; + this.btn_ConfigToSql.Click += new System.EventHandler(this.btn_ConfigToSql_Click); + // + // label_ReadExcel + // + this.label_ReadExcel.AutoSize = true; + this.label_ReadExcel.Location = new System.Drawing.Point(12, 16); + this.label_ReadExcel.Name = "label_ReadExcel"; + this.label_ReadExcel.Size = new System.Drawing.Size(95, 12); + this.label_ReadExcel.TabIndex = 1; + this.label_ReadExcel.Text = "label_ReadExcel"; + // + // label_WriteSql + // + this.label_WriteSql.AutoSize = true; + this.label_WriteSql.Location = new System.Drawing.Point(12, 42); + this.label_WriteSql.Name = "label_WriteSql"; + this.label_WriteSql.Size = new System.Drawing.Size(89, 12); + this.label_WriteSql.TabIndex = 1; + this.label_WriteSql.Text = "label_WriteSql"; + // + // txt_Msg + // + this.txt_Msg.Location = new System.Drawing.Point(14, 116); + this.txt_Msg.Multiline = true; + this.txt_Msg.Name = "txt_Msg"; + this.txt_Msg.Size = new System.Drawing.Size(634, 316); + this.txt_Msg.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 70); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(335, 36); + this.label1.TabIndex = 3; + this.label1.Text = "使用到数据库的表:\r\n读取:MES_计划BOM_工位与名称([是否启用MES] = 1)\r\n写入:MES_基本变量_原始数据、MES_基本变量设备类型对应表"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // MES_CONF + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(660, 437); + this.Controls.Add(this.label1); + this.Controls.Add(this.txt_Msg); + this.Controls.Add(this.label_WriteSql); + this.Controls.Add(this.label_ReadExcel); + this.Controls.Add(this.btn_ConfigToSql); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "MES_CONF"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "MES监控系统信号配置"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btn_ConfigToSql; + private System.Windows.Forms.Label label_ReadExcel; + private System.Windows.Forms.Label label_WriteSql; + private System.Windows.Forms.TextBox txt_Msg; + private System.Windows.Forms.Label label1; + } +} + diff --git a/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.cs b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.cs new file mode 100644 index 0000000..43222ea --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.cs @@ -0,0 +1,248 @@ +using SlMesDbIterface; +using System; +using System.Data; +using System.Linq; +using System.Windows.Forms; +using static System.Configuration.ConfigurationManager; + +namespace MES_SIGNAL_CONF +{ + public partial class MES_CONF : Form + { + + + public MES_CONF() + { + InitializeComponent(); + label_ReadExcel.Text = $"读取位置:{MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile}"; + label_WriteSql.Text = $"写入位置:{MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES}"; + } + + private void btn_ConfigToSql_Click(object sender, EventArgs e) + { + LoadOpcData(); + WriteLog(""); + } + + public void WriteLog(string msg) + { + txt_Msg.Text = txt_Msg.Text + $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}]{msg}\r\n"; + } + + /// + /// 线体类型枚举定义 + /// 1 = 普通工位(默认) + /// 2 = 库位 + /// 3 = 磨合库位 + /// 4 = 总装断路器接驳库位 + /// + private enum LineType + { + Normal = 1, // 普通工位 - 使用 MES_信号表模板 + Storage = 2, // 库位 - 使用 MES_信号表模板(库位) + RunInStorage = 3, // 磨合库位 - 使用 MES_信号表模板(磨合库位) + BreakerDockStorage = 4 // 总装断路器接驳库位 - 使用 MES_信号表模板(总装断路器接驳库位) + } + + /// + /// 线体类型与信号表模板的映射配置 + /// Key: 线体类型枚举 + /// Value: Excel中的模板Sheet名称 + /// + private static readonly System.Collections.Generic.Dictionary LineTypeTemplateMapping = + new System.Collections.Generic.Dictionary + { + { LineType.Normal, "MES_信号表模板" }, + { LineType.Storage, "MES_信号表模板(库位)" }, + { LineType.RunInStorage, "MES_信号表模板(磨合库位)" }, + { LineType.BreakerDockStorage, "MES_信号表模板(总装断路器接驳库位)" } + }; + + private void LoadOpcData() + { + DataTable dt_Tag = null; + + Select_Station(out DataTable dt_Station); + DataTable dt_Tag_Mes = new DataTable(); + if (NPOITest.ExeclHelper.ExcelToDataTable(MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile, "MES_基本变量原始数据", true).Select($"是否启用='1'").Length > 0) + { + dt_Tag_Mes = NPOITest.ExeclHelper.ExcelToDataTable(MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile, "MES_基本变量原始数据", true).Select($"是否启用='1'").CopyToDataTable(); + } + + // 加载各类型信号表模板 + var templateCache = new System.Collections.Generic.Dictionary(); + foreach (var mapping in LineTypeTemplateMapping) + { + try + { + var templateData = NPOITest.ExeclHelper.ExcelToDataTable( + MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile, + mapping.Value, + true); + var enabledRows = templateData.Select($"是否启用='1'"); + if (enabledRows.Length > 0) + { + templateCache[mapping.Key] = enabledRows.CopyToDataTable(); + } + } + catch (Exception ex) + { + WriteLog($"加载模板 [{mapping.Value}] 失败: {ex.Message}"); + } + } + + var dt_Device = NPOITest.ExeclHelper.ExcelToDataTable(MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile, "设备类型对应表", true).Select($"是否启用='1'").CopyToDataTable(); + + // 使用默认模板结构初始化结果表 + dt_Tag = templateCache.ContainsKey(LineType.Normal) + ? templateCache[LineType.Normal].Clone() + : new DataTable(); + + // 按线体类型分组处理工位 + foreach (var lineTypeEntry in LineTypeTemplateMapping) + { + var lineTypeValue = ((int)lineTypeEntry.Key).ToString(); + DataRow[] stationRows; + + if (lineTypeEntry.Key == LineType.Normal) + { + // 普通工位:线体类型=1 或 NULL 或 空值,同时排除所有特殊类型(2, 3, ...) + // 构建排除条件:(线体类型 IS NULL OR 线体类型 = '' OR 线体类型 = '1' OR (线体类型 <> '2' AND 线体类型 <> '3' ...)) + var specialTypeValues = LineTypeTemplateMapping.Keys + .Where(lt => lt != LineType.Normal) + .Select(lt => (int)lt) + .ToList(); + + // 筛选出所有非特殊类型的工位 + stationRows = dt_Station.AsEnumerable() + .Where(row => + { + var lineTypeVal = row["线体类型"]?.ToString()?.Trim() ?? ""; + // 空值或NULL视为普通工位 + if (string.IsNullOrEmpty(lineTypeVal)) return true; + // 尝试解析为数字 + if (int.TryParse(lineTypeVal, out int lineTypeInt)) + { + // 不是特殊类型则为普通工位 + return !specialTypeValues.Contains(lineTypeInt); + } + // 无法解析为数字,视为普通工位 + return true; + }) + .ToArray(); + } + else + { + // 特殊类型:精确匹配 + stationRows = dt_Station.Select($"线体类型 = '{lineTypeValue}'"); + } + + if (stationRows.Length == 0) continue; + if (!templateCache.ContainsKey(lineTypeEntry.Key)) + { + WriteLog($"警告: 线体类型 [{lineTypeEntry.Key}] 的模板未加载,跳过 {stationRows.Length} 个工位"); + continue; + } + + var templateTable = templateCache[lineTypeEntry.Key]; + + foreach (DataRow stationRow in stationRows) + { + var 工位代码 = stationRow["工位代码"].ToString(); + var 工位名称 = stationRow["工位名称"].ToString(); + var PLC = stationRow["PLC"].ToString(); + var stationName = stationRow["工位号"].ToString(); + var PLC代码 = stationRow["PLC代码"].ToString(); + + var dt_Tag_Model_Copy = templateTable.Copy(); + UpdateOpTable(dt_Tag_Model_Copy, 工位代码, stationName, 工位名称, PLC, PLC代码); + dt_Tag.Merge(dt_Tag_Model_Copy); + } + } + + dt_Tag.Merge(dt_Tag_Mes); + dt_Tag.TableName = "MES_基本变量_原始数据"; + SqlOperation.ExecuteSql($"truncate table {dt_Tag.TableName}", out string err1); + if (err1 != "") WriteLog($"truncate table {dt_Tag.TableName}:{err1}"); + WriteLog($"清空了数据库表:{dt_Tag.TableName}"); + SqlOperation.SqlbulkcopyInsert(dt_Tag, out string err2); + if (err2 != "") WriteLog($"写入数据库表 {dt_Tag.TableName}:{err2}"); + WriteLog($"写入数据库表:{dt_Tag.TableName}"); + + // 调用存储过程:根据 XD_产线报警定义 + 工位表 自动生成报警点位 + WriteLog("开始生成报警点位..."); + SqlOperation.ExecuteSql("EXEC MES_基本变量_原始数据_报警数据_增加", out DataTable dtAlarmResult, out string errAlarm); + if (errAlarm != "") + { + WriteLog($"生成报警点位失败:{errAlarm}"); + } + else + { + if (dtAlarmResult != null && dtAlarmResult.Rows.Count > 0) + { + foreach (DataRow row in dtAlarmResult.Rows) + { + WriteLog($" {row["工位号"]}:生成 {row["生成数量"]} 条报警变量"); + } + } + WriteLog("报警点位生成完成!"); + } + + dt_Device.TableName = "MES_基本变量设备类型对应表"; + SqlOperation.ExecuteSql($"truncate table {dt_Device.TableName}", out string err11); + if (err11 != "") WriteLog($"truncate table {dt_Device.TableName}:{err11}"); + + WriteLog($"清空了数据库表:{dt_Device.TableName}"); + SqlOperation.SqlbulkcopyInsert(dt_Device, out string err22); + if (err22 != "") WriteLog($"清空了数据库表 {dt_Device.TableName}:{err22}"); + WriteLog($"写入数据库表:{dt_Device.TableName}"); + + } + + + private void UpdateOpTable(DataTable dt, string 工位代码, string opName, string opNameName, string ip, string dbName) + { + foreach (DataRow row in dt.Rows) + { + //TagID TagName 工位号 数据来源 IP DbName 变量特点 变量类型代码 + + var TagID = row["TagID"].ToString(); + + row["TagID"] = TagID.Replace("****", 工位代码.PadLeft(4, '0')); + //row["TagID"] = Guid.NewGuid().ToString ().ToUpper (); + row["工位号"] = opName; + row["数据来源"] = opNameName; + row["IP"] = ip; + row["DbName"] = dbName; + + row["监控组"] = $"{row["监控组"].ToString()}_{opName}"; + + + } + } + + public static void Select_Station(out DataTable dt) + { + var sql = + $" SELECT *" + + $" FROM [MES_计划BOM_工位与名称] WHERE [是否启用MES] = 1" + + $" ORDER BY [工位号]"; + SqlOperation.ExecuteSql(sql, out dt, out string error); + } + + public static void Select_OpTable_Alarm(out DataTable dt) + { + var sql = + $" SELECT *" + + $" FROM [MES_基本变量_原始数据] WHERE [type] = 9" + + $" ORDER BY [TagID]"; + SqlOperation.ExecuteSql(sql, out dt, out string error); + } + + + private void label1_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.resx b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/mes_signal_conf/SqlOperation.cs b/MisDataFun/MisDataFun/mes_signal_conf/SqlOperation.cs new file mode 100644 index 0000000..47fb6ce --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/SqlOperation.cs @@ -0,0 +1,68 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +namespace SlMesDbIterface +{ + public class SqlOperation + { + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, ref sqlParameters, out errorMessage); + } + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataTable dt, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, ref sqlParameters, out dt, out errorMessage); + } + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, ref sqlParameters, out ds, out errorMessage); + } + public static bool ExecuteSql(string sql, out DataTable dt, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteSql(sql, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, out dt, out errorMessage); + } + + public static bool ExecuteSql(string sql, out DataSet ds, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteDataset(sql, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, out ds, out errorMessage); + } + + public static bool ExecuteSql(string sql, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteSql(sql, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, out errorMessage); + } + + + /// + /// 通过SqlBulkCopy复制table数据到数据库 + /// + /// + public static bool SqlbulkcopyInsert(DataTable dt,out string ErrMsg) + { + bool success = false; + ErrMsg = ""; + try + { + // SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(connectString, SqlBulkCopyOptions.KeepIdentity);//删除自增ID插入原始数据 + SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, SqlBulkCopyOptions.UseInternalTransaction);//批量事务处理 + sqlbulkcopy.DestinationTableName = dt.TableName;//数据库中的表名 + for (int i = 0; i < dt.Columns.Count; i++) + { + var columnName = dt.Columns[i].ColumnName.ToString(); + sqlbulkcopy.ColumnMappings.Add(columnName, columnName); + } + sqlbulkcopy.WriteToServer(dt); + success = true; + } + catch (Exception err) + { + ErrMsg=err.Message; + } + return success; + + } + + + } +} diff --git a/MisDataFun/MisDataFun/webApi/Analysis_MOM_Msg.cs b/MisDataFun/MisDataFun/webApi/Analysis_MOM_Msg.cs new file mode 100644 index 0000000..11ba6d8 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/Analysis_MOM_Msg.cs @@ -0,0 +1,386 @@ +using DataLinkMesWork1; +using MesServerWork; +using MisDataFunDll; +using MyLog4Net; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Net.Sockets; +using System.Reflection.Emit; +using System.Web.Http; + +namespace MisDataSaveDate +{ + public class Analysis_MOM_Msg + { + /// + /// UUID生成 + /// + /// + public static string UuidUtil() + { + string result = Guid.NewGuid().ToString(); + + return result; + } + + /// + /// 获取时间戳 + /// + /// + public static Int64 GetTimeStamp() + { + TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds); + } + /// + /// 接收检测数据 + /// + /// + /// + public static string OnlineCheckData(string url, [FromBody] JObject jobj) + { + var result = new msgResHeader(); + result.MsgId = ""; + result.Message = ""; + result.Code = "200"; + result.Data = ""; + + string errorMessage = ""; + string parentID = ""; + int AID = -1; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收检测数据_res", retString1); + return retString1; + } + int isError = 0; + string str = jobj.ToString(); + try + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",str), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param, out DataTable dt, out errorMessage); + + // 解析订单内容,存储数据库,根据实际业务来写 + OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject(str); + if (onlineCheckData.MsgId == "") + { + throw new Exception("参数MsgId为空!"); + } + result.MsgId = onlineCheckData.MsgId; + if (onlineCheckData.OpCode == "") + { + throw new Exception("参数OpCode为空!"); + } + if (onlineCheckData.ProductionCode == "") + { + throw new Exception("参数ProductionCode为空!"); + } + string OpName = onlineCheckData.OpCode; + int Id_tagCF = 0; + SqlParameter[] param1 = new SqlParameter[6]; + param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode); + param1[1] = new SqlParameter("@工位号", OpName); + param1[2] = new SqlParameter("@操作者工号", onlineCheckData.CheckPerson); + param1[3] = new SqlParameter("@扫码时间", onlineCheckData.ScanTime); + param1[4] = new SqlParameter("@合格标志", onlineCheckData.QualityMark); + param1[5] = new SqlParameter("@Id_tagCF", Id_tagCF); + param1[5].Direction = ParameterDirection.Output; + DataAccess.ExecuteStoredProcedure("测量数据合格索引_增加_测试设备", ref param1, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + Id_tagCF = Convert.ToInt32(param1[5].Value.ToString()); + + List onlineCheckData_CheckDataList = onlineCheckData.CheckData; + + for (int i = 0; i < onlineCheckData_CheckDataList.Count; i++) + { + OnlineCheckData_CheckData onlineCheckData_CheckData = onlineCheckData_CheckDataList[i]; + + var param2 = new SqlParameter[] { + new SqlParameter("@Id_tagCF", Id_tagCF), + new SqlParameter("@EngineID", onlineCheckData.ProductionCode), + new SqlParameter("@TagID",onlineCheckData_CheckData.CheckCode), + new SqlParameter("@TagValue",onlineCheckData_CheckData.CheckValue), + new SqlParameter("@IsGoodBad",onlineCheckData_CheckData.QualityMark), + new SqlParameter("@工位号",OpName), + new SqlParameter("@理论值",onlineCheckData_CheckData.StandardValue), + new SqlParameter("@上限值",onlineCheckData_CheckData.MaxValue), + new SqlParameter("@下限值",onlineCheckData_CheckData.MinValue), + new SqlParameter("@测量项目",onlineCheckData_CheckData.CheckName), + new SqlParameter("@测量单位",onlineCheckData_CheckData.Unit), + }; + DataAccess.ExecuteStoredProcedure("测量数据合格_增加_测试设备", ref param2, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + + // 查询PLC是否传递机型,保证工位有件,可以写保存完成和工作完成 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out bool tagValue); + if (tagValue) + { + // 电芯段OP040流程比较特殊,无PLC保存数据的流程,可以直接写完成。 + if (OpName == "OP040") + { + //通知PLC,MES保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //通知PLC,MES工作完成 + MIS_BASE.Write_MesWorkFinish(OpName, true); + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES保存数据完成!"); + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES工作完成!"); + } + else + { + // 查看PLC是否完成流程,如果完成的话流程结束,否则的话要等PLC完成流程(即允许保存) + DataTable dt2 = MisDataFunDll.MisDataFun.CheckAllFinish(OpName, onlineCheckData.ProductionCode, 2); + string msg1 = "查询PLC流程出错"; + if (dt2 != null && dt2.Rows.Count > 0) + { + string result1 = dt2.Rows[0]["result"].ToString(); + msg1 = dt2.Rows[0]["msg"].ToString(); + + if (result1 == "1") //已完成 + { + //通知PLC,MES保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //通知PLC,MES工作完成 + MIS_BASE.Write_MesWorkFinish(OpName, true); + MisDataFunDll. MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", msg1); + MisDataFunDll. MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES保存数据完成!"); + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES工作完成!"); + } + else + { + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", msg1); + } + } + else + { + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", msg1); + } + } + + } + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + MisDataFunDll.MisDataFun.LogRecording_OP("All", "ERROR", "MIS", err.Message); + } + string retString = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收检测数据_res", retString); + + return retString; + } + /// + /// 接收查询检测次数 + /// + /// + /// + public static string OnlineCheckDataCount(string url, [FromBody] JObject jobj) + { + var result = new msgResHeader2(); + result.MsgId = ""; + result.Message = ""; + result.Code = "200"; + result.Data = new checkCountData(); + result.Data.CheckCountOk = 0; + result.Data.CheckCountNg = 0; + string errorMessage = ""; + string parentID = ""; + int AID = -1; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收查询检测次数_res", retString1); + return retString1; + } + int isError = 0; + string str = jobj.ToString(); + try + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",str), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param, out DataTable dt, out errorMessage); + + // 解析订单内容,存储数据库,根据实际业务来写 + OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject(str); + if (onlineCheckData.MsgId == "") + { + throw new Exception("参数MsgId为空!"); + } + result.MsgId = onlineCheckData.MsgId; + if (onlineCheckData.OpCode == "") + { + throw new Exception("参数OpCode为空!"); + } + if (onlineCheckData.ProductionCode == "") + { + throw new Exception("参数ProductionCode为空!"); + } + + SqlParameter[] param1 = new SqlParameter[2]; + param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode); + param1[1] = new SqlParameter("@工位号", onlineCheckData.OpCode); + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("CATL_测量数据合格_查询测试次数_测试设备", ref param1, out DataTable dt1, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + if (dt1 != null && dt1.Rows.Count > 0) + { + result.Data.CheckCountOk = Convert.ToInt32(dt1.Rows[0]["OK"]); + result.Data.CheckCountNg = Convert.ToInt32(dt1.Rows[0]["NG"]); + } + + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + string retString = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收查询检测次数_res", retString); + return retString; + } + /// + /// 接收打印任务 + /// + /// + /// + public static string ReceivePrintTask(string url, [FromBody] JObject jobj) + { + var result = new msgResHeader(); + result.MsgId = ""; + result.Message = ""; + result.Code = "200"; + result.Data = ""; + + string errorMessage = ""; + string parentID = ""; + int AID = -1; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收打印任务_res", retString1); + return retString1; + } + + string str = jobj.ToString(); + try + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",str), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param, out DataTable dt, out errorMessage); + + // 解析订单内容,存储数据库,根据实际业务来写 + PrintTaskData printTaskData = JsonConvert.DeserializeObject(str); + if (printTaskData.printTemplete == "") + { + throw new Exception("参数printTemplete为空!"); + } + + if (printTaskData.productCode == "") + { + throw new Exception("参数productCode为空!"); + } + if (printTaskData.printDate == "") + { + throw new Exception("参数printDate为空!"); + } + string msg = $"MARK|{printTaskData.printTemplete}|{printTaskData.productCode},{printTaskData.printDate}"; + + // 连接打印机 + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + try + { + //socket.Connect(MesWorkForm.MarkingMachine_Ip, int.Parse(MesWorkForm.MarkingMachine_Port)); + } + catch (Exception err) + { + throw new Exception("连接打印机失败:" + err.Message); + } + // 发送数据 + try + { + if (socket.Connected) + { + byte[] decBytes = System.Text.Encoding.UTF8.GetBytes(msg); + //socket.Send(decBytes); + socket.Send(decBytes, 0, decBytes.Length, SocketFlags.None); + } + else + { + throw new Exception("连接打印机失败"); + } + } + catch (Exception err) + { + throw new Exception("发送打印数据失败:" + err.Message); + } + // 关闭 + try + { + if (socket.Connected) + { + socket.Shutdown(SocketShutdown.Both); + socket.Close(100); + } + } + catch (Exception ex) + { + } + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + string retString = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收打印任务_res", retString); + return retString; + } + + } +} diff --git a/MisDataFun/MisDataFun/webApi/Controller/ipcControll.cs b/MisDataFun/MisDataFun/webApi/Controller/ipcControll.cs new file mode 100644 index 0000000..c144448 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/Controller/ipcControll.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; +using System.Runtime.Remoting.Messaging; + + +namespace MisDataSaveDate +{ + + public class IpcController : ApiController + { + readonly string headUrl = "Project/"; + + [HttpPost] + [Route("OnlineCheckData")] + public HttpResponseMessage ReceiveMomPlanData([FromBody] JObject jobj) + { + + return new HttpResponseMessage + { + Content = new StringContent(Analysis_MOM_Msg.OnlineCheckData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("OnlineCheckDataCount")] + public HttpResponseMessage OnlineCheckDataCount([FromBody] JObject jobj) + { + + return new HttpResponseMessage + { + Content = new StringContent(Analysis_MOM_Msg.OnlineCheckDataCount(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + [HttpPost] + [Route("ReceivePrintTask")] + public HttpResponseMessage ReceivePrintTask([FromBody] JObject jobj) + { + + return new HttpResponseMessage + { + Content = new StringContent(Analysis_MOM_Msg.ReceivePrintTask(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + } +} diff --git a/MisDataFun/MisDataFun/webApi/InitServer.cs b/MisDataFun/MisDataFun/webApi/InitServer.cs new file mode 100644 index 0000000..7c2b03d --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/InitServer.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Web.Http; +using System.Web.Http.Cors; +using System.Web.Http.SelfHost; + +namespace MisDataSaveDate +{ + public class InitServer + { + HttpSelfHostConfiguration config = null; + HttpSelfHostServer server = null; + public InitServer(string Url_WebApi) + { + // var Url_WebApi = System.Configuration.ConfigurationManager.AppSettings["Url_WebApi"]; + Init(Url_WebApi); + } + public void Init(string url) + { + config = new HttpSelfHostConfiguration(url); + + // 启用跨域 + config.EnableCors(new EnableCorsAttribute("*", "*", "*")); + // 启用特性路由 + config.MapHttpAttributeRoutes(); + + //config.Routes.MapHttpRoute( + // name: "DefaultApi", + // routeTemplate: "api/{controller}/{id}", + // defaults: new { id = RouteParameter.Optional } + //); + + // 自定义路由匹配到action + config.Routes.MapHttpRoute( + name: "API Default", + routeTemplate: "api/{controller}/{action}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + + + + server = new HttpSelfHostServer(config); + + server.OpenAsync().Wait(); + + + } + public class JsonContentNegotiator : IContentNegotiator + { + private readonly JsonMediaTypeFormatter _jsonFormatter; + + public JsonContentNegotiator(JsonMediaTypeFormatter formatter) + { + _jsonFormatter = formatter; + } + public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable formatters) + { + var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json")); + return result; + } + } + } +} diff --git a/MisDataFun/MisDataFun/webApi/OnlineCheckData.cs b/MisDataFun/MisDataFun/webApi/OnlineCheckData.cs new file mode 100644 index 0000000..7369a65 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/OnlineCheckData.cs @@ -0,0 +1,98 @@ +using System.Collections.Generic; + +namespace MisDataSaveDate +{ + /// + /// OnlineCheckData + /// + + public class OnlineCheckData + { + /// + /// MsgId + /// + public string MsgId { get; set; } = ""; + /// + /// OpCode + /// + public string OpCode { get; set; } = ""; + /// + /// ProductionCode + /// + public string ProductionCode { get; set; } = ""; + /// + /// CheckTime + /// + public string ScanTime { get; set; } = ""; + + /// + /// CheckPerson + /// + public string CheckPerson { get; set; } = ""; + + /// + /// QualityMark + /// + public int QualityMark { get; set; } = 1; + + public List CheckData { get; set; } = new List(); + } + + public class OnlineCheckData_CheckData + { + /// + /// CheckCode + /// + public string CheckCode { get; set; } = ""; + /// + /// CheckName + /// + public string CheckName { get; set; } = ""; + /// + /// ProductionCode + /// + public string Unit { get; set; } + /// + /// StandardValue + /// + public string StandardValue { get; set; } = ""; + /// + /// MinValue + /// + public string MinValue { get; set; } = ""; + /// + /// MaxValue + /// + public string MaxValue { get; set; } = ""; + /// + /// CheckValue + /// + public string CheckValue { get; set; } = ""; + /// + /// QualityMark + /// + public int QualityMark { get; set; } = 1; + } + public class PrintTaskData + { + /// string msg = $"MARK|{printTemplete}|{productCode},{printDate}"; + + /// + /// printTemplete + /// + public string printTemplete { get; set; } = ""; + /// + /// productCode + /// + public string productCode { get; set; } = ""; + /// + /// printDate + /// + public string printDate { get; set; } = ""; + + } + + + + +} diff --git a/MisDataFun/MisDataFun/webApi/msgResHeader.cs b/MisDataFun/MisDataFun/webApi/msgResHeader.cs new file mode 100644 index 0000000..f7cacc2 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/msgResHeader.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate +{ + public class msgResHeader + { + /// + /// 任务ID + /// + public string MsgId + { + get; + set; + } + /// + /// 返回结果 + /// + public string Code + { + get; + set; + } + /// + /// 返回消息 + /// + public string Message + { + get; + set; + } + /// + /// 返回数据 + /// + public string Data + { + get; + set; + } + } + public class msgResHeader2 + { + /// + /// 任务ID + /// + public string MsgId + { + get; + set; + } + /// + /// 返回结果 + /// + public string Code + { + get; + set; + } + /// + /// 返回消息 + /// + public string Message + { + get; + set; + } + /// + /// 返回数据 + /// + public checkCountData Data + { + get; + set; + } + } + + public class checkCountData + { + /// + /// 检测次数 + /// + public int CheckCountOk + { + get; + set; + } + /// + /// 检测次数 + /// + public int CheckCountNg + { + get; + set; + } + } + +} diff --git a/MisDataFun_Exe/09MesDataFunction.dll b/MisDataFun_Exe/09MesDataFunction.dll new file mode 100644 index 0000000..930dbe5 Binary files /dev/null and b/MisDataFun_Exe/09MesDataFunction.dll differ diff --git a/MisDataFun_Exe/09MesDataFunction.pdb b/MisDataFun_Exe/09MesDataFunction.pdb new file mode 100644 index 0000000..96306ca Binary files /dev/null and b/MisDataFun_Exe/09MesDataFunction.pdb differ diff --git a/MisDataFun_Exe/BasicData.dll b/MisDataFun_Exe/BasicData.dll new file mode 100644 index 0000000..8dfe09b Binary files /dev/null and b/MisDataFun_Exe/BasicData.dll differ diff --git a/MisDataFun_Exe/BouncyCastle.Crypto.dll b/MisDataFun_Exe/BouncyCastle.Crypto.dll new file mode 100644 index 0000000..0310983 Binary files /dev/null and b/MisDataFun_Exe/BouncyCastle.Crypto.dll differ diff --git a/MisDataFun_Exe/ConLink.dll b/MisDataFun_Exe/ConLink.dll new file mode 100644 index 0000000..fa95f29 Binary files /dev/null and b/MisDataFun_Exe/ConLink.dll differ diff --git a/MisDataFun_Exe/ConLink19.dll b/MisDataFun_Exe/ConLink19.dll new file mode 100644 index 0000000..0b665e4 Binary files /dev/null and b/MisDataFun_Exe/ConLink19.dll differ diff --git a/MisDataFun_Exe/DataLinkMesWork.dll b/MisDataFun_Exe/DataLinkMesWork.dll new file mode 100644 index 0000000..57fcd25 Binary files /dev/null and b/MisDataFun_Exe/DataLinkMesWork.dll differ diff --git a/MisDataFun_Exe/EnBaseM.dll b/MisDataFun_Exe/EnBaseM.dll new file mode 100644 index 0000000..ebdeaa2 Binary files /dev/null and b/MisDataFun_Exe/EnBaseM.dll differ diff --git a/MisDataFun_Exe/ExternalDataSync.exe b/MisDataFun_Exe/ExternalDataSync.exe new file mode 100644 index 0000000..fe26901 Binary files /dev/null and b/MisDataFun_Exe/ExternalDataSync.exe differ diff --git a/MisDataFun_Exe/ExternalDataSync.exe.config b/MisDataFun_Exe/ExternalDataSync.exe.config new file mode 100644 index 0000000..b6e72bd --- /dev/null +++ b/MisDataFun_Exe/ExternalDataSync.exe.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFun_Exe/ExternalDataSync.pdb b/MisDataFun_Exe/ExternalDataSync.pdb new file mode 100644 index 0000000..49ce525 Binary files /dev/null and b/MisDataFun_Exe/ExternalDataSync.pdb differ diff --git a/MisDataFun_Exe/Function1051.dll b/MisDataFun_Exe/Function1051.dll new file mode 100644 index 0000000..ed0fecd Binary files /dev/null and b/MisDataFun_Exe/Function1051.dll differ diff --git a/MisDataFun_Exe/Function1051.dll.config b/MisDataFun_Exe/Function1051.dll.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFun_Exe/Function1051.dll.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1051.pdb b/MisDataFun_Exe/Function1051.pdb new file mode 100644 index 0000000..b4c9576 Binary files /dev/null and b/MisDataFun_Exe/Function1051.pdb differ diff --git a/MisDataFun_Exe/Function1052.dll b/MisDataFun_Exe/Function1052.dll new file mode 100644 index 0000000..9d094b6 Binary files /dev/null and b/MisDataFun_Exe/Function1052.dll differ diff --git a/MisDataFun_Exe/Function1052.dll.config b/MisDataFun_Exe/Function1052.dll.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFun_Exe/Function1052.dll.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1052.pdb b/MisDataFun_Exe/Function1052.pdb new file mode 100644 index 0000000..ca30208 Binary files /dev/null and b/MisDataFun_Exe/Function1052.pdb differ diff --git a/MisDataFun_Exe/Function1053.dll b/MisDataFun_Exe/Function1053.dll new file mode 100644 index 0000000..9c4a5bb Binary files /dev/null and b/MisDataFun_Exe/Function1053.dll differ diff --git a/MisDataFun_Exe/Function1053.dll.config b/MisDataFun_Exe/Function1053.dll.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFun_Exe/Function1053.dll.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1053.pdb b/MisDataFun_Exe/Function1053.pdb new file mode 100644 index 0000000..eded3bb Binary files /dev/null and b/MisDataFun_Exe/Function1053.pdb differ diff --git a/MisDataFun_Exe/Function1054.dll b/MisDataFun_Exe/Function1054.dll new file mode 100644 index 0000000..5c7d86f Binary files /dev/null and b/MisDataFun_Exe/Function1054.dll differ diff --git a/MisDataFun_Exe/Function1054.dll.config b/MisDataFun_Exe/Function1054.dll.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFun_Exe/Function1054.dll.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1054.pdb b/MisDataFun_Exe/Function1054.pdb new file mode 100644 index 0000000..bd2ba4a Binary files /dev/null and b/MisDataFun_Exe/Function1054.pdb differ diff --git a/MisDataFun_Exe/Function1055.dll b/MisDataFun_Exe/Function1055.dll new file mode 100644 index 0000000..6dff0e9 Binary files /dev/null and b/MisDataFun_Exe/Function1055.dll differ diff --git a/MisDataFun_Exe/Function1055.dll.config b/MisDataFun_Exe/Function1055.dll.config new file mode 100644 index 0000000..95269f5 --- /dev/null +++ b/MisDataFun_Exe/Function1055.dll.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1055.pdb b/MisDataFun_Exe/Function1055.pdb new file mode 100644 index 0000000..7ca122b Binary files /dev/null and b/MisDataFun_Exe/Function1055.pdb differ diff --git a/MisDataFun_Exe/Function1056.dll b/MisDataFun_Exe/Function1056.dll new file mode 100644 index 0000000..ebaa72f Binary files /dev/null and b/MisDataFun_Exe/Function1056.dll differ diff --git a/MisDataFun_Exe/Function1056.dll.config b/MisDataFun_Exe/Function1056.dll.config new file mode 100644 index 0000000..95269f5 --- /dev/null +++ b/MisDataFun_Exe/Function1056.dll.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1056.pdb b/MisDataFun_Exe/Function1056.pdb new file mode 100644 index 0000000..6704e05 Binary files /dev/null and b/MisDataFun_Exe/Function1056.pdb differ diff --git a/MisDataFun_Exe/Function1057.dll b/MisDataFun_Exe/Function1057.dll new file mode 100644 index 0000000..c0ffd02 Binary files /dev/null and b/MisDataFun_Exe/Function1057.dll differ diff --git a/MisDataFun_Exe/Function1057.dll.config b/MisDataFun_Exe/Function1057.dll.config new file mode 100644 index 0000000..95269f5 --- /dev/null +++ b/MisDataFun_Exe/Function1057.dll.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1057.pdb b/MisDataFun_Exe/Function1057.pdb new file mode 100644 index 0000000..7a40623 Binary files /dev/null and b/MisDataFun_Exe/Function1057.pdb differ diff --git a/MisDataFun_Exe/Function1058.dll b/MisDataFun_Exe/Function1058.dll new file mode 100644 index 0000000..d6427cc Binary files /dev/null and b/MisDataFun_Exe/Function1058.dll differ diff --git a/MisDataFun_Exe/Function1058.dll.config b/MisDataFun_Exe/Function1058.dll.config new file mode 100644 index 0000000..95269f5 --- /dev/null +++ b/MisDataFun_Exe/Function1058.dll.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1058.pdb b/MisDataFun_Exe/Function1058.pdb new file mode 100644 index 0000000..3988268 Binary files /dev/null and b/MisDataFun_Exe/Function1058.pdb differ diff --git a/MisDataFun_Exe/Function1059.dll b/MisDataFun_Exe/Function1059.dll new file mode 100644 index 0000000..bc94061 Binary files /dev/null and b/MisDataFun_Exe/Function1059.dll differ diff --git a/MisDataFun_Exe/Function1059.dll.config b/MisDataFun_Exe/Function1059.dll.config new file mode 100644 index 0000000..95269f5 --- /dev/null +++ b/MisDataFun_Exe/Function1059.dll.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1059.pdb b/MisDataFun_Exe/Function1059.pdb new file mode 100644 index 0000000..c4fbc5c Binary files /dev/null and b/MisDataFun_Exe/Function1059.pdb differ diff --git a/MisDataFun_Exe/Function1060.dll b/MisDataFun_Exe/Function1060.dll new file mode 100644 index 0000000..ff2f7c5 Binary files /dev/null and b/MisDataFun_Exe/Function1060.dll differ diff --git a/MisDataFun_Exe/Function1060.dll.config b/MisDataFun_Exe/Function1060.dll.config new file mode 100644 index 0000000..95269f5 --- /dev/null +++ b/MisDataFun_Exe/Function1060.dll.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun_Exe/Function1060.pdb b/MisDataFun_Exe/Function1060.pdb new file mode 100644 index 0000000..364876f Binary files /dev/null and b/MisDataFun_Exe/Function1060.pdb differ diff --git a/MisDataFun_Exe/ICSharpCode.SharpZipLib.dll b/MisDataFun_Exe/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..84e8c68 Binary files /dev/null and b/MisDataFun_Exe/ICSharpCode.SharpZipLib.dll differ diff --git a/MisDataFun_Exe/MQTTnet.Extensions.ManagedClient.dll b/MisDataFun_Exe/MQTTnet.Extensions.ManagedClient.dll new file mode 100644 index 0000000..99035f6 Binary files /dev/null and b/MisDataFun_Exe/MQTTnet.Extensions.ManagedClient.dll differ diff --git a/MisDataFun_Exe/MQTTnet.dll b/MisDataFun_Exe/MQTTnet.dll new file mode 100644 index 0000000..2951433 Binary files /dev/null and b/MisDataFun_Exe/MQTTnet.dll differ diff --git a/MisDataFun_Exe/MesControl.dll b/MisDataFun_Exe/MesControl.dll new file mode 100644 index 0000000..cd3960b Binary files /dev/null and b/MisDataFun_Exe/MesControl.dll differ diff --git a/MisDataFun_Exe/MesWork.DeviceDriver.dll b/MisDataFun_Exe/MesWork.DeviceDriver.dll new file mode 100644 index 0000000..186755c Binary files /dev/null and b/MisDataFun_Exe/MesWork.DeviceDriver.dll differ diff --git a/MisDataFun_Exe/MisDataFun.exe b/MisDataFun_Exe/MisDataFun.exe new file mode 100644 index 0000000..3df2e95 Binary files /dev/null and b/MisDataFun_Exe/MisDataFun.exe differ diff --git a/MisDataFun_Exe/MisDataFun.exe.config b/MisDataFun_Exe/MisDataFun.exe.config new file mode 100644 index 0000000..3eedead --- /dev/null +++ b/MisDataFun_Exe/MisDataFun.exe.config @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFun_Exe/MisDataFun.pdb b/MisDataFun_Exe/MisDataFun.pdb new file mode 100644 index 0000000..3c8efb6 Binary files /dev/null and b/MisDataFun_Exe/MisDataFun.pdb differ diff --git a/MisDataFun_Exe/Monitor.MesWork.dll b/MisDataFun_Exe/Monitor.MesWork.dll new file mode 100644 index 0000000..1874ca5 Binary files /dev/null and b/MisDataFun_Exe/Monitor.MesWork.dll differ diff --git a/MisDataFun_Exe/Monitor.MesWork.xml b/MisDataFun_Exe/Monitor.MesWork.xml new file mode 100644 index 0000000..f978604 --- /dev/null +++ b/MisDataFun_Exe/Monitor.MesWork.xml @@ -0,0 +1,2860 @@ + + + + Monitor.MesWork + + + + + AlarmListView 的摘要说明。 + + + + + 从OnDataChange发送int tagID, int tagValue到处理程序 + private void OnDataChange(int tagID, int tagValue) + + + + + + + 从OnDataChange发送int tagID, int tagValue到处理程序 + private void OnDataChange(int tagID, int tagValue) + + + + + 必需的设计器变量。 + + + + + 当时发生的报警总行数 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + 报警到达 + + + + + 报警到达 + + + + + 报警解除 + + + + + 报警解除 + + + + + 报警确认 + + + + + 报警确认 + + + + + 报警过滤条件 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警过滤条件 + + + + + 从系统获得 + =null 时,初始化时显示全部报警 + =AlarmItemSelect,初始化时显示AlarmItemSelect条件报警 + + + + + + + + + + 报警到达文字颜色 + + + + + 报警到达文本底色 + + + + + 报警解除文字颜色 + + + + + 报警解除文本底色 + + + + + 报警确认文字颜色 + + + + + 报警确认文本底色 + + + + + 初始化报警显示 + + + + + 报警控件,监控值变化时,图形重绘 + + + + + + 增加TagKey + + + + + =true,调Gif;false不调Gif + + + + + Gif图像 + + + + + Gif图像 + + + + + IsRotation =0不调用Gif;=1调用Gif TagValueType + + + + + IsRotation =0不调用Gif;=1调用Gif + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + + + + + + 绘制图形 + + + + + + 正常绘制 + + + + + + 显示Gif + + + + + + 增加TagKey + + + + + =true,调Gif;false不调Gif + + + + + Gif图像 + + + + + IsRotation =0不调用Gif;=1调用Gif TagValueType + + + + + IsRotation =0不调用Gif;=1调用Gif + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + + + + + + 绘制图形 + + + + + + 正常绘制 + + + + + + 显示Gif + + + + + + PlcLinkStatus 的摘要说明。 + + + + + 显示PLC连接状态 + + + + + + PLC连接正常时图形 + + + + + PLC连接正常时图形 + + + + + PLC连接不正常时图形 + + + + + PLC连接不正常时图形 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + PlcLinkStatusWork 的摘要说明。 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + + + + + + 根据变量是否正确,显示通讯状态 通讯数据交换 + + + + + + 通讯正常 + + + + + 通讯失败 + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + PlcLinkStatusWork 的摘要说明。 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + + + + + + 根据变量是否正确,显示通讯状态 通讯数据交换 + + + + + + 通讯正常 + + + + + 通讯失败 + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 变量类型 + + + + + 变量类型 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示机床状态 + + + + + + 绘制图形 + + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示机床状态 + + + + + + 绘制图形 + + + + + + 增加TagKey + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示到位信号 + + + + + + 绘制图形 + + + + + + 发动机工位在线显示 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 发动机号 + + + + + 发动机号 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + OpName + 工位名称 + + + + + 是否进行具体发动机号追踪 + + + + + 是否进行具体发动机号追踪 + + + + + 具体发动机号追踪发动机号 + 发动机号 + + + + + 具体发动机号追踪 + 发动机号 + + + + + 具体发动机号追踪 + Tag位置0时颜色 + + + + + 具体发动机号追踪 + Tag位置1时颜色 + + + + + + + + + + 发动机号的变化,给本控件的发动机号赋值 + 确定被追踪的发动机号 + + + + + + + 发动机号动态追踪设定 + + + + + + + 显示被追踪的发动机 + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 托盘到位 + + + + + + + 绘制图形 + + + + + + 发动机工位在线显示 + + + + + 当鼠标在上方时出现工件编号 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 发动机号 + + + + + 发动机号 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + OpName + 工位名称 + + + + + 是否进行具体发动机号追踪 + + + + + 是否进行具体发动机号追踪 + + + + + 具体发动机号追踪发动机号 + 发动机号 + + + + + 具体发动机号追踪 + 发动机号 + + + + + 具体发动机号追踪 + Tag位置0时颜色 + + + + + 具体发动机号追踪 + Tag位置1时颜色 + + + + + + + + + + 发动机号的变化,给本控件的发动机号赋值 + 确定被追踪的发动机号 + + + + + + + 发动机号动态追踪设定 + + + + + + + 显示被追踪的发动机 + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 托盘到位 + + + + + + + 绘制图形 + + + + + + UserControlButton 的摘要说明。 + + + + + 发动机号 + + + + + 发动机号 + + + + + 当鼠标在上方时出现发动机号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 机床状态 + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + 变量值 + + + + + 变量值 + + + + + 变量类型 + + + + + 变量类型 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + TagNameID名称 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + 发动机号 + + + + + 发动机号 + + + + + 当鼠标在上方时出现发动机号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示心跳控件 + + + + + + 绘制图形 + + + + + + 增加TagKey + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 绘制图形 + + + + + + 水平方式显示工件编号。 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + 垂直方式显示工件编号。 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + 变量值 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + Button 文本颜色代码 + + + + + + + + + + 显示工件编号 + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + 变量值 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + Button 文本颜色代码 + + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + 增加TagKey + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 绘制图形 + + + + + + 一个强类型的资源类,用于查找本地化的字符串等。 + + + + + 返回此类使用的缓存的 ResourceManager 实例。 + + + + + 重写当前线程的 CurrentUICulture 属性 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + diff --git a/MisDataFun_Exe/MyLog4Net.dll b/MisDataFun_Exe/MyLog4Net.dll new file mode 100644 index 0000000..6271052 Binary files /dev/null and b/MisDataFun_Exe/MyLog4Net.dll differ diff --git a/MisDataFun_Exe/MyLog4Net.pdb b/MisDataFun_Exe/MyLog4Net.pdb new file mode 100644 index 0000000..c1669be Binary files /dev/null and b/MisDataFun_Exe/MyLog4Net.pdb differ diff --git a/MisDataFun_Exe/NPOI.OOXML.dll b/MisDataFun_Exe/NPOI.OOXML.dll new file mode 100644 index 0000000..031d41d Binary files /dev/null and b/MisDataFun_Exe/NPOI.OOXML.dll differ diff --git a/MisDataFun_Exe/NPOI.OpenXml4Net.dll b/MisDataFun_Exe/NPOI.OpenXml4Net.dll new file mode 100644 index 0000000..8da4ac2 Binary files /dev/null and b/MisDataFun_Exe/NPOI.OpenXml4Net.dll differ diff --git a/MisDataFun_Exe/NPOI.OpenXmlFormats.dll b/MisDataFun_Exe/NPOI.OpenXmlFormats.dll new file mode 100644 index 0000000..4a8f87b Binary files /dev/null and b/MisDataFun_Exe/NPOI.OpenXmlFormats.dll differ diff --git a/MisDataFun_Exe/NPOI.dll b/MisDataFun_Exe/NPOI.dll new file mode 100644 index 0000000..1a500e9 Binary files /dev/null and b/MisDataFun_Exe/NPOI.dll differ diff --git a/MisDataFun_Exe/Newtonsoft.Json.dll b/MisDataFun_Exe/Newtonsoft.Json.dll new file mode 100644 index 0000000..7af125a Binary files /dev/null and b/MisDataFun_Exe/Newtonsoft.Json.dll differ diff --git a/MisDataFun_Exe/Opc.Ua.Client.dll b/MisDataFun_Exe/Opc.Ua.Client.dll new file mode 100644 index 0000000..8874d8f Binary files /dev/null and b/MisDataFun_Exe/Opc.Ua.Client.dll differ diff --git a/MisDataFun_Exe/Opc.Ua.Configuration.dll b/MisDataFun_Exe/Opc.Ua.Configuration.dll new file mode 100644 index 0000000..b3f3970 Binary files /dev/null and b/MisDataFun_Exe/Opc.Ua.Configuration.dll differ diff --git a/MisDataFun_Exe/Opc.Ua.Core.dll b/MisDataFun_Exe/Opc.Ua.Core.dll new file mode 100644 index 0000000..ee01d0d Binary files /dev/null and b/MisDataFun_Exe/Opc.Ua.Core.dll differ diff --git a/MisDataFun_Exe/OpcUaHelper.dll b/MisDataFun_Exe/OpcUaHelper.dll new file mode 100644 index 0000000..e95e509 Binary files /dev/null and b/MisDataFun_Exe/OpcUaHelper.dll differ diff --git a/MisDataFun_Exe/SIGNAL_MODEL.xlsx b/MisDataFun_Exe/SIGNAL_MODEL.xlsx new file mode 100644 index 0000000..8dc3517 Binary files /dev/null and b/MisDataFun_Exe/SIGNAL_MODEL.xlsx differ diff --git a/MisDataFun_Exe/System.Net.Http.Formatting.dll b/MisDataFun_Exe/System.Net.Http.Formatting.dll new file mode 100644 index 0000000..e9e80be Binary files /dev/null and b/MisDataFun_Exe/System.Net.Http.Formatting.dll differ diff --git a/MisDataFun_Exe/System.Web.Cors.dll b/MisDataFun_Exe/System.Web.Cors.dll new file mode 100644 index 0000000..6f3da24 Binary files /dev/null and b/MisDataFun_Exe/System.Web.Cors.dll differ diff --git a/MisDataFun_Exe/System.Web.Http.Cors.dll b/MisDataFun_Exe/System.Web.Http.Cors.dll new file mode 100644 index 0000000..fd0b539 Binary files /dev/null and b/MisDataFun_Exe/System.Web.Http.Cors.dll differ diff --git a/MisDataFun_Exe/System.Web.Http.SelfHost.dll b/MisDataFun_Exe/System.Web.Http.SelfHost.dll new file mode 100644 index 0000000..852728e Binary files /dev/null and b/MisDataFun_Exe/System.Web.Http.SelfHost.dll differ diff --git a/MisDataFun_Exe/System.Web.Http.dll b/MisDataFun_Exe/System.Web.Http.dll new file mode 100644 index 0000000..7e3bd30 Binary files /dev/null and b/MisDataFun_Exe/System.Web.Http.dll differ diff --git a/MisDataFun_Exe/WinSCP.exe b/MisDataFun_Exe/WinSCP.exe new file mode 100644 index 0000000..a6e5e59 Binary files /dev/null and b/MisDataFun_Exe/WinSCP.exe differ diff --git a/MisDataFun_Exe/WinSCPnet.dll b/MisDataFun_Exe/WinSCPnet.dll new file mode 100644 index 0000000..c27cf4e Binary files /dev/null and b/MisDataFun_Exe/WinSCPnet.dll differ diff --git a/MisDataFun_Exe/log4net.config b/MisDataFun_Exe/log4net.config new file mode 100644 index 0000000..92f4d40 --- /dev/null +++ b/MisDataFun_Exe/log4net.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFun_Exe/log4net.dll b/MisDataFun_Exe/log4net.dll new file mode 100644 index 0000000..84bf5b6 Binary files /dev/null and b/MisDataFun_Exe/log4net.dll differ diff --git a/MisDataFun_Exe/~$SIGNAL_MODEL.xlsx b/MisDataFun_Exe/~$SIGNAL_MODEL.xlsx new file mode 100644 index 0000000..1e0c8b3 Binary files /dev/null and b/MisDataFun_Exe/~$SIGNAL_MODEL.xlsx differ diff --git a/MisDataFunction/Function1051/DataAccess/DataAccess.cs b/MisDataFunction/Function1051/DataAccess/DataAccess.cs new file mode 100644 index 0000000..a7f91fa --- /dev/null +++ b/MisDataFunction/Function1051/DataAccess/DataAccess.cs @@ -0,0 +1,16 @@ + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1051/DataAccess/vssver2.scc b/MisDataFunction/Function1051/DataAccess/vssver2.scc new file mode 100644 index 0000000..1083b3a Binary files /dev/null and b/MisDataFunction/Function1051/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1051/Db.cs b/MisDataFunction/Function1051/Db.cs new file mode 100644 index 0000000..a0f37b3 --- /dev/null +++ b/MisDataFunction/Function1051/Db.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Db + { + + } +} diff --git a/MisDataFunction/Function1051/Function08.csproj.vspscc b/MisDataFunction/Function1051/Function08.csproj.vspscc new file mode 100644 index 0000000..82c6db2 --- /dev/null +++ b/MisDataFunction/Function1051/Function08.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function08" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1051/Function1051.csproj b/MisDataFunction/Function1051/Function1051.csproj new file mode 100644 index 0000000..5a28b77 --- /dev/null +++ b/MisDataFunction/Function1051/Function1051.csproj @@ -0,0 +1,142 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E} + Library + Properties + Function1051 + Function1051 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + AnyCPU + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 01-MesDataFunction + + + {2f33d79d-1dff-4cda-b357-fcd5221cab9a} + ExternalDataSync + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1051/MesServerFunction/Function1051.cs b/MisDataFunction/Function1051/MesServerFunction/Function1051.cs new file mode 100644 index 0000000..f14cc0a --- /dev/null +++ b/MisDataFunction/Function1051/MesServerFunction/Function1051.cs @@ -0,0 +1,317 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using MisDataFunDll; + + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string TagID = e.TagID.ToString(); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 申请上线 + case "43": + PartLoad(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + // PLC 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + //物料扫码完成(弃用!) + case "49": + fun_MaterislaScanOver(e); + break; + //物料扫码完成 + case "65": + fun_MaterialsVerify(e); + break; + // 写入托盘号后通知MES + case "48": + string write_Pallet_res; + MIS_BASE.Read_TagTypeID(48, m_OpName, out write_Pallet_res); + if (write_Pallet_res.ToLower() == "true" || write_Pallet_res.ToLower() == "1") + { + SendMessageFun.SendInfomation("writePallet", "1", m_OpName); + } + MIS_BASE.WritePLC(70, m_OpName, false); + break; + case "63": + fun_ReqEarlyFeeding(e); + break; + case "64": + fun_ReqTestResistor(e); + break; + } + break; + } + } + } + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + //{ + // //lock1 = new object(); + // //lock (lock1) + // { + // switch (e.TagTypeCodeID.ToString()) + // { + // //PLC 工件到位 + // case "2": + // fun_WorkStart(e); + // break; + // //PLC 允许保存质量数据 + // case "19": + // fun_MesRead(e); + // break; + // //MES 保存数据完成 + // case "20": + // fun_MesReadOver(e); + // break; + // //PLC 传递机型 + // case "44": + // fun_EngineTypeGetOverPLC(e); + // break; + // //MES 合格放行 + // case "51": + // fun_ConfirmOkGo(e); + // break; + // //MES 不合格放行 + // case "8": + // fun_FalseGo(e); + // break; + // //MES 扫描条码 + // case "Barcode": + // fun_Barcode(e); + // break; + // //WEB 处理页面传递过来的数据 + // case "WebSubmit": + // fun_WebSubmit(e); + // break; + // } + // } + + //} + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //2.MES判断是否扫描完成 + //3.若扫描完成,则MES给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + //// ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + + /// + /// 提前上料 + /// + /// + /// + public void fun_ReqEarlyFeeding(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReqEarlyFeeding, e); + } + + /// + /// 请求测试电阻 调用电阻仪 + /// + /// + /// + public void fun_ReqTestResistor(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem( ReqTestResistor, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + + /// + /// 保存完成 20 + /// + /// + /// + public void fun_MesReadOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 物料扫码完成 + /// + public void fun_MaterislaScanOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MaterialsScanOver, e); + } + + /// + /// 物料扫码完成 + /// + public void fun_MaterialsVerify(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MaterialsVerify, e); + } + + /// + /// 保存完成 19 + /// + /// + /// + public void fun_MesRead(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + public int fun_SubLineLoadPartCountMatch() + { + return SubLineLoadPartCountMatch; + } + + + /// + /// MES系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(HeartBeatMES, e); + } + /// + /// PLC系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatPLC(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + //ThreadPool.QueueUserWorkItem(HeartBeatPLC, e); + } + } +} diff --git a/MisDataFunction/Function1051/MesServerFunction/vssver2.scc b/MisDataFunction/Function1051/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..775bb6c Binary files /dev/null and b/MisDataFunction/Function1051/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1051/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1051/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..155058e --- /dev/null +++ b/MisDataFunction/Function1051/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,291 @@ +using System; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +//using SystemFramework; +using WebApi; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 分线上总线的数量 + /// + public static int SubLineLoadPartCount = 2; + /// + /// 分线上总线已经匹配的数量 + /// + public static int SubLineLoadPartCountMatch = 0; + /// + /// 正常逻辑工作 + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + string msg = "【" + OpName + "】" + "PLC传递机型为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //初始化物料临时表 + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + //BaseDataSystemMES.MesServer_Process_EngineTypeOver_BQ_FirstOP(OpName); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(OpName); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(OpName); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(OpName); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(OpName); + + //第四步,获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + // 暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + + //调用工厂MES开工接口 + WebApi.CALL_Inerface_DataHandle.CALL_Inerface_JobStart(OpName, EngineID, OrderForm); + + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + + int isRepair; + int engineTypeID; + + string engineType = ""; + string engineID = ""; + string palletCode = ""; + string orderForm = ""; + string repairCode = ""; + //从监控系统中查询出本工位信息 + //BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + /// + /// 正常匹配分线和总线 + /// + /// + /// 总线工件号 + /// 总线工件机型代码 + /// 总线工件机型 + private void Match(string opName, string engineID, int engineTypeID, string engineType, int PartPallet_Code) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + int engineTypeID_SubLine; + int partPallet_Code_SubLine; + int PalletInfo = 1;//总线托盘状态 + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string AlarmStr; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //第一步:获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + //第二步:获取分线传递机型信号 + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine); + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //第三步:判断合格标志 + MIS_BASE.Read_PalletInfo(opName_SubLine, out PalletInfo); + if (PalletInfo == 2) return; //若不合格则返回不进行匹配 + string OrderForm; + //第四步:获取分线的信息,匹配验证 + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm); + //判断分线数据是否合格 + //if (!BaseDataSystemMES.QulityDataVerify(opName, engineID_SubLine, out AlarmStr) && !BaseDataSystemMES.QualityVerifyStatus_Hash_Read(opName)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, opName); + // return; + //} + + //if (engineTypeID_SubLine == engineTypeID) + //{ + // BaseDataSystemMES.SubLineLoadPartCountMatch_Select(opName, out SubLineLoadPartCountMatch); + // SubLineLoadPartCountMatch = SubLineLoadPartCountMatch + 1; + // BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + + // BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + // MIS_BASE.Write_Match(opName, true);//匹配结果 + // MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + // if(SubLineLoadPartCountMatch== SubLineLoadPartCount) + // { + // MIS_BASE.Write_FixAllow(opName, true); + // SubLineLoadPartCountMatch = 0; + // BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + // } + + // SendMessageFun.SendInfomation("MatchSuccess", "1", opName); + // SendMessageFun.SendMessage(opName, 1, "Match");//匹配结果 + //} + //else + //{ + // MIS_BASE.Write_Match(opName, false);//匹配结果 + // MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成//68:1、取消返修;2、匹配成功 自己监控发送 MES|MatchingCompleted + + // //发送匹配完成和匹配结果信息 + // SendMessageFun.AsyncSendMessage_Notice(opName,"匹配失败,工件型号不匹配!"); + // SendMessageFun.SendInfomation("MatchSuccess", "0", opName); + // SendMessageFun.SendMessage(opName, 0, "Match");//匹配结果 + //} + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog("Match:" + err.ToString()); + + } + } + + + + /// + /// 强制匹配分线和总线 + /// + /// + private void ForceMatch(string opName) + { + try + { + //bool m_EngineGetOver_PLC_SubLine; + //bool m_EngineGetOver_PLC; + + //int engineTypeID_SubLine; + //int engineTypeID; + //int partPallet_Code_SubLine; + //int partPallet_Code; + + //string opName_SubLine = "";//分线工件信息 + //string engineID_SubLine; + //string engineType_SubLine; + //string engineID; + //string engineType; + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + ////获取分线中间交互工位号 + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + //{ + // opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + //} + //if (opName_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine);//1:读取分线工件到位的传递机型信号。 + + //if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //MIS_BASE.Read_EngineGetOver_PLC(opName, out m_EngineGetOver_PLC);//2:读取总线工件到位的传递机型信号。 + + //if (!m_EngineGetOver_PLC) return;//必须工件同时到位才能进行匹配 + //string OrderForm; + //MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm);//获取分线的信息 + //MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out partPallet_Code, out OrderForm); + + //Mis.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + + //MIS_BASE.Write_Match(opName, true);//匹配结果 + //MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + + //SendMessageFun.SendInfomation("MatchSuccess", "1", opName);//界面显示匹配成功 + + //MIS_BASE.Write_FixAllow(opName, true);//允许PLC工作 + + ////发送匹配完成和匹配结果信息 + //sendmessage(opName, 1, "MatchingComplete");//匹配完成 + //sendmessage(opName, 1, "Match");//匹配结果 + } + catch + { + + } + } + } +} diff --git a/MisDataFunction/Function1051/Methods/vssver2.scc b/MisDataFunction/Function1051/Methods/vssver2.scc new file mode 100644 index 0000000..7b1a830 Binary files /dev/null and b/MisDataFunction/Function1051/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1051/OpcServer/Barcode.cs b/MisDataFunction/Function1051/OpcServer/Barcode.cs new file mode 100644 index 0000000..d7549ae --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/Barcode.cs @@ -0,0 +1,236 @@ +using System; +using System.Threading; +using System.Xml.Linq; + +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcode = new object(); + + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + lock(lockBarcode) + { + try + { + //DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + ////+*************DbName***************** + //string DbName = Convert.ToString(msgEvent.OpName); + //string barcode = Convert.ToString(msgEvent.TagValue); + + //int EngineTypeID;//机型代码 + //string EngineType;//机型 + //string EngineID;//工件编号 + + //string OrderForm; + //int Recipe1; + //int Recipe2; + + //bool IsNotRepeatedNumber = false; + ////1:获得申请上线信息后,扫描条码才处理业务 + //bool ispartload; + ////(115) + //int PTO; + ////(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + //int NgearSwitch; + ////(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + //int RgearSwitch; + ////(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + //int SpeedSensor; + ////(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + //string PartTypeMid; + ////(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + //int Tcu_V; + ////判断工件是否到位 + //MIS_BASE.Read_WorkStart(OpName, out ispartload); + //if (!ispartload) + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + // return; + //} + ////判断设备是否申请上线 + //MIS_BASE.Read_PartLoad(OpName, out ispartload); + //if (!ispartload) + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + // return; + //} + //// 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + //// 选小机型 从北汽福田BOM中选 得先维护BOM + //// 变速器序列号 '1333 050 062*16012023*30000001' + + ////扫描完变速器序列号条码号 true + //bool isGetOver_PLC = false; + ////判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + // MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_PLC); + + ////如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + ////否则按装配物料进行验证 + //if (!isGetOver_PLC) + //{ + + // if (barcode.Split('*').Length > 2) + // { + // //2: 判断是否重号, 从数据库获得机型、机型代码等信息 + // string partSn = barcode; + // EngineID = barcode; + + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID_MES, EngineID); + + // //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + // //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + + // //IsRepeatedNumber true 不重号;false 重号; + // IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + // if (IsNotRepeatedNumber) + // { + // BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + + // //MIS_BASE.Write_EngineID_MES(OpName, EngineID); + // //MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + // //MIS_BASE.Write_EngineType_MES(OpName, EngineType); + // //MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + + // BaseDataSystemMES.UpLoadPTO(EngineType, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + // //PTO + // MIS_BASE.WritePLC(115, OpName, PTO); + // //空挡开关检测 + // MIS_BASE.WritePLC(95, OpName, NgearSwitch); + // //倒挡开关检测 + // MIS_BASE.WritePLC(96, OpName, RgearSwitch); + // //里程表检测 + // MIS_BASE.WritePLC(97, OpName, SpeedSensor); + // //大机型扩展 + // MIS_BASE.WritePLC(98, OpName, PartTypeMid); + // //TCU + // MIS_BASE.WritePLC(122, OpName, Tcu_V); + // string tagStartAdr;//= "DB411.10"; + + // // 先查询配方号 根据工位号 去moby表查配方号 + // // 根据配方号 去配方表查配方数据 + // // 写入配方数据 + // BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + // DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + // ////将产品信息写入PLC + // MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + // MIS_BASE.Write_EngineType_MES(OpName, EngineType); + // MIS_BASE.Write_EngineID_MES(OpName, EngineID); + // MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + // //写入到数据库的[北汽福田工位状态监控MOBY]表中 + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType_MES, EngineType); + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID_MES, EngineID); + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + + + // // 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号] + // // [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES] + // // [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + // // [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + // // [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码] + + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName, "产品型号代码_MES", EngineTypeID.ToString()); + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName, "发动机型号_MES", EngineType); + + // MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + + // //Thread.Sleep(5000); + // //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + // //等待PLC将数据写入RFID;写入PLC的DB块,通知MES验证RFID机型数据是否正确传递 + + // //通知web显示 + // SendMessage.ShowMoby(OpName); + // //SendMessageFun.SendMessage("1235", "1111", OpName); + // } + // else + // { + // SendMessageFun.SendInfomation("EngineIDRepeat", "partSn", OpName); + // } + // } + // else + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + // } + //} + //else//验证物料 + //{ + // //物料号 + // { + // //读取PLC的传递机型信号 + // bool tagValue; + // MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + // if (tagValue) + // { + // //验证物料 + // BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + // if (!IsSuccess)//???? + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + // return; + // } + // else + // { + // SendMessageFun.SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + // } + // //判断物料是否验证完成 + // BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + // if (IsSuccess) + // { + // if (IsAllowWork == 1) + // { + // //移到允许保存信号中 + // //BaseDataSystemMES.Material_Insert(OpName, 1); + + // ////更新订单完工数量及物料 + // SendMessageFun.SendMessage("24", "11", OpName); + + // //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + // MIS_BASE.Write_FixAllow(OpName, true); + // } + // else + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + // } + // } + // else + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + // } + // } + // else + // { + // SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + // } + + // } + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:Barcode"); + } + } + + } + + + } +} diff --git a/MisDataFunction/Function1051/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1051/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..ae34da7 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/EngineGetOver.cs @@ -0,0 +1,135 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcodeEngineTypeGetOver = new object(); + + + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + lock(lockBarcodeEngineTypeGetOver) + { + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + string msg = "【" + OpName + "】" + "未能清空MesRead信号,请求复位!"; + SendMessageFun.SendInfomation("AskReset", "1", OpName); + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + return; + } + + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + // 读取MES区数据 校验MES区数据是否符合 同时判断是否此工件已工作过,若已工作过则弹出弹窗提示 + if (EngineTypeID == EngineTypeID_MES & EngineID == EngineID_MES & EngineType == EngineType_MES & OrderForm == OrderForm_MES) + { + if (EngineTypeID == 0 || EngineID == "" || EngineType == "" || OrderForm == "") + { + string msg = "【" + OpName + "】" + "传递机型数据为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + return; + } + + DataTable checkTable = MisDataFun.WorkOrderCheck(OpName,EngineID_MES,OrderForm_MES,EngineType_MES); + int result = Convert.ToInt32(checkTable.Rows[0]["result"]); + string resultMsg = checkTable.Rows[0]["msg"].ToString(); + if (result != 2) + { + + if (result == 3) + { + string msg = "【" + OpName + "】" + resultMsg; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm, OrderForm); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType, EngineType); + //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID, EngineID); + //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm, OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + + SendMessageFun.SendMessage("5123", "11111", OpName); + + // 将工序数据转入临时表中 + //BaseDataSystemMES.ProcessDataToTemp(OpName, EngineTypeID, OrderForm, EngineID); + } + else + { + string msg = "【" + OpName + "】" + resultMsg; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + return; + } + else + { + string msg = "【" + OpName + "】" + "PLC与MES信息不一致!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + + } + else + { + MIS_BASE.Write_FixAllow(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + } + + + + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs b/MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs new file mode 100644 index 0000000..665afe9 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 物料扫码完成 + /// + /// + /// + private void MaterialsScanOver(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code, out string OrderForm); + string materialsCode = MIS_BASE.ReadPLC(40, OpName).ToString(); + var dt = MisDataFun.Get_MaterialsScanOverRes(OpName, OrderForm, EngineID, materialsCode); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + if (result == 1) + { + MIS_BASE.WritePLC(95, OpName, 1); + } + else if (result == 2) + { + MIS_BASE.WritePLC(95, OpName, 2); + } + } + else + { + MIS_BASE.WritePLC(96, OpName, 0); // 提前上料位置 + MIS_BASE.WritePLC(33, OpName, false); // 允许提前上料 + MIS_BASE.Write_EngineID_MES(OpName, ""); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MaterialsVerify.cs b/MisDataFunction/Function1051/OpcServer/MaterialsVerify.cs new file mode 100644 index 0000000..32ee5dd --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MaterialsVerify.cs @@ -0,0 +1,62 @@ +using System; +using System.Data; +using System.Threading; +using System.Xml.Linq; + +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC物料扫码校验 + /// + /// + public void MaterialsVerify(object e) + { + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + int MaterialsTypeCode = Convert.ToInt32(MIS_BASE.ReadPLC(201, OpName)); + string MaterialsCode = MIS_BASE.ReadPLC(40, OpName).ToString(); + + DataTable dt = MisDataFun.XD_MaterialsVerify(OpName, EngineID, MaterialsCode, MaterialsTypeCode); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + if (result == 1) + { + MIS_BASE.WritePLC(95, OpName, 1); // 物料校验成功 + } + else + { + MIS_BASE.WritePLC(95, OpName, 2); // 物料校验失败 + string msg = $"【{OpName}】产品:{EngineID} | 物料码:{MaterialsCode} | 物料类型:{MaterialsTypeCode.ToString()} 物料校验失败!"; + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "MaterialsVerify " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + } + } + else + { + MIS_BASE.WritePLC(95, OpName, 0); // 物料验证结果清空 + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MesRead.cs b/MisDataFunction/Function1051/OpcServer/MesRead.cs new file mode 100644 index 0000000..80abd35 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MesRead.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockMesRead = new object (); + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID,out PartPallet_Code, out OrderForm); + + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + // 保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + + // 保存物料数据 + MisDataFun.Material_Insert(OpName, qualityMask); + + // 保存过站信息 + MisDataFun.WorkStartInsert(OpName, qualityMask); + + // 存追溯表数据 同时质量数据存入 接口表 + MisDataFun.WorkOrderOpWorkOver(OpName, EngineID, OrderForm); + + // 推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + //调用工厂MES接口报工 + WebApi.CALL_Inerface_DataHandle.CALL_Inerface_JobFinished(OpName, EngineID, OrderForm); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MesReadOver.cs b/MisDataFunction/Function1051/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..1b7206b --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MesReadOver.cs @@ -0,0 +1,36 @@ +using System; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + try + { + //DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + + // BaseDataSystemMES.Material_Insert(OpName, tagValue); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/PartLoad.cs b/MisDataFunction/Function1051/OpcServer/PartLoad.cs new file mode 100644 index 0000000..32c3cbf --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/PartLoad.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线(针对上线工位) + /// + /// + /// + private void PartLoad(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + // 读取当前选择的计划中的机型,写入PLC + // 获取订单的机型 + MisDataFun.GetEngineType_Order(OpName, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int parType, out int isCheckOk,out string msg2); + if (isCheckOk == 2) + { + string msg = "【" + OpName + "】" + msg2; + // 判断到线体上有滞留工件 ,让去管理系统进行处理 + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PartLoad " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + else + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType_MES, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID_MES, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + + // 写入机型代码 (大机型) 机型 发动机号 订单号 + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + MIS_BASE.WritePLC(115, OpName, parType); // 托盘类型 1 静 2 动 3 拐 + + // MES传递机型 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + } + } + else + { + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs b/MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs new file mode 100644 index 0000000..3b24ea4 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请提前上料 + /// + /// + /// + private void ReqEarlyFeeding(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + var dt = MisDataFun.Get_ReqEarlyFeedingData(OpName); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + string msg = dt.Rows[0]["msg"].ToString(); + int EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); + if (result == 1) + { + MIS_BASE.WritePLC(96, OpName, EngineTypeID); // 产品型号 + MIS_BASE.Write_EngineID_MES(OpName, dt.Rows[0]["工件编号"].ToString()); + int ReadEngineID = Convert.ToInt32(MIS_BASE.ReadPLC(96, OpName)); + if (EngineTypeID != ReadEngineID) + { + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()}不一致", MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + if (EngineTypeID == 0 || ReadEngineID == 0) + { + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()} 其中存在空值", MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + MIS_BASE.WritePLC(33, OpName, true); // 允许提前上料 + + } + else if (result == 2) + { + MIS_BASE.WritePLC(33, OpName, false); + string msg2 = "【" + OpName + "】" + msg; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + msg2, MisDataSaveDate.Helper.MesLogType.ERROR); + + return; + } + } + else + { + MIS_BASE.WritePLC(96, OpName, 0); // 提前上料位置 + MIS_BASE.WritePLC(33, OpName, false); // 允许提前上料 + //MIS_BASE.Write_EngineID_MES(OpName, ""); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs b/MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs new file mode 100644 index 0000000..7418852 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using MesServerWork; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + private readonly object _lockObject = new object(); + private volatile bool _isTestOk = false; + private string _opName; + private const int DEFAULT_TIMEOUT = 7000; // 默认超时时间(毫秒) + private const int MAX_RETRY_COUNT = 10; // 最大重试次数 + private const int RESULT_LENGTH = 113; // 预期结果长度 + + /// + /// 电阻测试 + /// + private void ReqTestResistor(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + _opName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + TestResistor().GetAwaiter().GetResult(); + } + else + { + ResetPLCValues(); + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {err.Message}"); + ErrPLCValues(); + } + } + + /// + /// 执行电阻测试 + /// + private async Task TestResistor() + { + TcpClient tcpClient = null; + try + { + string IP = ConfigurationManager.AppSettings["ResistorDeviceIP_"+_opName]; + string Port = ConfigurationManager.AppSettings["ResistorDevicePort"]; + + using (tcpClient = new TcpClient()) + { + var connectTask = tcpClient.ConnectAsync(IP, Convert.ToInt32(Port)); + if (await Task.WhenAny(connectTask, Task.Delay(DEFAULT_TIMEOUT)) != connectTask) + { + throw new TimeoutException(_opName+"连接电阻仪超时"); + } + + if (tcpClient.Connected) + { + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试", "电阻仪链接成功!"); + await SendCommand(tcpClient, "01 09 64 00 05 00 00 00 00 00 73"); + + await Task.Delay(DEFAULT_TIMEOUT); + + var readTask = Task.Run(() => Read(tcpClient)); + + int count = 0; + while (!_isTestOk && count < MAX_RETRY_COUNT) + { + await Task.Delay(1000); + await SendCommand(tcpClient, "03 01 04"); + count++; + } + + if (count >= MAX_RETRY_COUNT && !_isTestOk) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试", "测试超时,未收到有效结果"); + ErrPLCValues(); + } + } + } + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试", $"测试过程发生错误: {ex.Message}"); + ErrPLCValues(); + } + finally + { + if (tcpClient != null) + { + tcpClient.Close(); + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试", "电阻仪链接关闭"); + } + } + } + + private void ResetPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, false); + } + } + + private void ErrPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, true); + } + } + + /// + /// 发送命令到电阻仪 + /// + private async Task SendCommand(TcpClient tcpClient, string command) + { + try + { + // 将空格分隔的HEX字符串转换为字节数组 + string[] hexValues = command.Split(' '); + byte[] commandbyte = new byte[hexValues.Length]; + + for (int i = 0; i < hexValues.Length; i++) + { + commandbyte[i] = Convert.ToByte(hexValues[i], 16); + } + + // 发送HEX格式的数据 + await tcpClient.Client.SendAsync(new ArraySegment(commandbyte), SocketFlags.None); + + // 记录发送的命令 + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试Send", $"发送命令: {command}"); + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试Send", $"发送命令失败: {err.Message}"); + throw; + } + } + + private void Read(TcpClient tcpClient) + { + try + { + while (!_isTestOk) + { + if (tcpClient != null && tcpClient.Connected) + { + byte[] byteCommand = new byte[1024]; + int icommand = tcpClient.Client.Receive(byteCommand); + string hexString = BitConverter.ToString(byteCommand, 0, icommand).Replace("-", " "); + + if (hexString.Length == RESULT_LENGTH) + { + DataAnalysis(hexString); + } + } + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试Read", err.Message); + } + } + + private void DataAnalysis(string hexString) + { + try + { + var byteArray = HexStringToByteArray(hexString.Replace(" ", "")); + var start = 2; + + var 状态 = BitConverter.ToInt32(byteArray.Skip(start + 0).Take(4).ToArray(), 0); + if (状态 != 2) return; + var 电压V = BitConverter.ToDouble(byteArray.Skip(start + 4).Take(8).ToArray(), 0); + var 电流A = BitConverter.ToDouble(byteArray.Skip(start + 12).Take(8).ToArray(), 0); + var 电阻uΩ = BitConverter.ToDouble(byteArray.Skip(start + 20).Take(8).ToArray(), 0) * 1000000; + var yyyy = BitConverter.ToUInt16(byteArray.Skip(start + 28).Take(2).ToArray(), 0); + var MM = byteArray[start + 30]; + var dd = byteArray[start + 31]; + var HH = byteArray[start + 32]; + var mm = byteArray[start + 33]; + var ss = byteArray[start + 34]; + var datetime = $"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}"; + + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 电压V); + MIS_BASE.WritePLC(203, _opName, 电流A); + MIS_BASE.WritePLC(204, _opName, 电阻uΩ); + MIS_BASE.WritePLC(34, _opName, true); + _isTestOk = true; + } + + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试", $"电阻结果写入完毕 【电压】{电压V}【电流】{电流A}【电阻】{电阻uΩ}"); + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试DataAnalysis", $"数据分析错误: {ex.Message}"); + } + } + + public static byte[] HexStringToByteArray(string hex) + { + if (hex.Length % 2 != 0) + { + throw new ArgumentException("十六进制字符串长度必须是偶数"); + } + + byte[] bytes = new byte[hex.Length / 2]; + for (int i = 0; i < hex.Length; i += 2) + { + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + } + return bytes; + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1051/OpcServer/WebSubmit.cs b/MisDataFunction/Function1051/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..71febbc --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/WebSubmit.cs @@ -0,0 +1,410 @@ +using System; +using MesServerWork; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +using MisDataFunDll; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + var msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string opName_SubLine = ""; + string engineID = "";//工件信息 + string[] dataArray = Content.Split('|'); + + if (dataArray.Length != 2) + return; + + + string m_Command = dataArray[0].ToString();//消息类型 + string m_Value = dataArray[1].ToString();//消息参数 + string[] m_Value_array = m_Value.Split('&');//消息参数数量 + int m_Value_length = m_Value_array.Length; //消息参数长度 + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + string msg; + bool bolVal; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //修改托盘状态 + + //MisDataFun.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + //BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + //BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + + case "NullWorkGo"://空托盘放行 0不放行 1放行 + try + { + int a = Convert.ToInt32(m_Value); + //修改地址值 + MIS_BASE.Write_PartPalletGoOver(OpName, a); + if (a == 1) + { + SendMessage.AsyncSendMessage_Notice(OpName, "开启空托盘放行!"); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "关闭空托盘放行!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + + break; + case "FixAllow"://重新拧紧 + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + MIS_BASE.Write_RepairUpline_MES(opName_SubLine, true); + //MIS_BASE.Write_PalletInfo(opName_SubLine, 4); + //MIS_BASE.Write_UpdatePalletOK(opName_SubLine, true); + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.WritePLC(113, OpName, Convert.ToInt32(m_Value)); + Thread.Sleep(500); + MIS_BASE.WritePLC(70, OpName, true); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + } + else if (Convert.ToInt32(m_Value) == 0) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + break; + //强制匹配 + case "ForceMatch": + if (Convert.ToInt32(m_Value) == 1) + { + ForceMatch(OpName); + } + break; + case "PalletGO": + + if (Convert.ToInt32(m_Value) == 1) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + } + break; + case "ContinueMatch": + //BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + fun_EngineTypeGetOverPLC(_e); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + // 检查项 检查完成 + case "checkWorkOver": + MIS_BASE.WritePLC(30, OpName,1); + msg = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(msg); + break; + // 重新申请上线 + case "againPartLoad": + // 判断是否有工件到位 + MIS_BASE.Read_WorkStart(OpName, out bolVal); + if (bolVal) + { + MIS_BASE.WritePLC(35, OpName, 1); + msg = "【" + OpName + "】" + "重新申请上线完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + else + { + msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + break; + // 跳过交互 + case "skipWork": + // 判断是否有工件到位 + MIS_BASE.Read_WorkStart(OpName, out bolVal); + if (bolVal) + { + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); // 传递机型 + MIS_BASE.Write_FixAllow(OpName,true); // 允许工作 + MIS_BASE.WritePLC(30, OpName, 1); // 检查完成 + MIS_BASE.Write_MesReadOver(OpName, true); // 保存完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); // 工作完成 + msg = "【" + OpName + "】" + "跳过交互完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + else + { + msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WebSubmit"); + } + } + + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + //BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + InitOpPosion(Opname); + + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + // MOBY数据 + SendMessageFun.SendMessage("5", "1", Opname); + //SendMessageFun.SendMessage("5123", "1111", Opname); + // 物料信息 物料信息 + SendMessage.MaterialList(Opname); + + // 新增查询PLC直通状态 网页显示 + //MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + + private void InitOpPosion(string Opname) + { + int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname)); + string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver; + SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg); + + bool S_WorkStart;//工件到位 DBX0.1 + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + //---------------------------------------------------- + bool S_PartLoad;//申请上线 + MIS_BASE.Read_PartLoad(Opname, out S_PartLoad); + if (S_PartLoad == true) + { + SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname); + } + //---------------------------------------------------- + bool S_EngineGetOver;//传递机型 DBX0.4 + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + } + //---------------------------------------------------- + bool S_FixAllow;//允许工作 DBX3.1 + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + //---------------------------------------------------- + bool S_MesRead;//允许保存 DBX3.1 + MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead); + if (S_MesRead == true) + { + SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname); + } + //---------------------------------------------------- + bool S_ReadOver;//保存完成 + MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver); + if (S_ReadOver == true) + { + SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname); + } + //---------------------------------------------------- + bool S_MaterialVerifyOver;//工作完成 DBX0.3 + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + //---------------------------------------------------- + int S_QualityMask;//合格标志 DBX588 + MIS_BASE.Read_QualityMask(Opname, out S_QualityMask); + if (S_QualityMask == 1) + { + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname); + } + //---------------------------------------------------- + string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环 + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/WorkStart.cs b/MisDataFunction/Function1051/OpcServer/WorkStart.cs new file mode 100644 index 0000000..91e7893 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/WorkStart.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using MesServerWork; +using MisDataFunDll; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //线首显示订单信息 + + if (tagValue == 1) + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStart, tagValue.ToString()); + } + else + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString()); + + // 清除工位数据 + MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + MIS_BASE.Write_EngineType_MES(OpName, ""); + MIS_BASE.Write_EngineID_MES(OpName, ""); + MIS_BASE.Write_OrderForm_MES(OpName, ""); + + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + MIS_BASE.WritePLC(115, OpName, 0); // 清除小机型 + + // 检查项完成 + MIS_BASE.Write_TagTypeID(30, OpName,0); + string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(message); + + // 重新申请上线 + MIS_BASE.WritePLC(35, OpName, 0); + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WorkStart"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/vssver2.scc b/MisDataFunction/Function1051/OpcServer/vssver2.scc new file mode 100644 index 0000000..e8dac03 Binary files /dev/null and b/MisDataFunction/Function1051/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1051/Properties/AssemblyInfo.cs b/MisDataFunction/Function1051/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3608c0 --- /dev/null +++ b/MisDataFunction/Function1051/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function08")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function08")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1051/Properties/vssver2.scc b/MisDataFunction/Function1051/Properties/vssver2.scc new file mode 100644 index 0000000..87eebff Binary files /dev/null and b/MisDataFunction/Function1051/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1051/app.config b/MisDataFunction/Function1051/app.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFunction/Function1051/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1051/mssccprj.scc b/MisDataFunction/Function1051/mssccprj.scc new file mode 100644 index 0000000..f184c61 --- /dev/null +++ b/MisDataFunction/Function1051/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function08.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function08", KRHAAAAA diff --git a/MisDataFunction/Function1051/packages.config b/MisDataFunction/Function1051/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1051/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1051/vssver2.scc b/MisDataFunction/Function1051/vssver2.scc new file mode 100644 index 0000000..93af295 Binary files /dev/null and b/MisDataFunction/Function1051/vssver2.scc differ diff --git a/MisDataFunction/Function1052/DataAccess/DataAccess.cs b/MisDataFunction/Function1052/DataAccess/DataAccess.cs new file mode 100644 index 0000000..574d619 --- /dev/null +++ b/MisDataFunction/Function1052/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1052 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1052/DataAccess/vssver2.scc b/MisDataFunction/Function1052/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1052/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1052/Function02.csproj.vspscc b/MisDataFunction/Function1052/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1052/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1052/Function1052.csproj b/MisDataFunction/Function1052/Function1052.csproj new file mode 100644 index 0000000..9872729 --- /dev/null +++ b/MisDataFunction/Function1052/Function1052.csproj @@ -0,0 +1,175 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68} + Library + Properties + Function1052 + Function1052 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {2f33d79d-1dff-4cda-b357-fcd5221cab9a} + ExternalDataSync + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1052/MesServerFunction/Fun_1052.cs b/MisDataFunction/Function1052/MesServerFunction/Fun_1052.cs new file mode 100644 index 0000000..36930ec --- /dev/null +++ b/MisDataFunction/Function1052/MesServerFunction/Fun_1052.cs @@ -0,0 +1,259 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using MisDataFunDll; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string TagID = e.TagID.ToString(); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //PLC 工位合格标志 + case "21": + fun_IsOk(e); + break; + //物料扫码完成 + case "65": + fun_MaterialsVerify(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + fun_ReqEarlyFeeding(e); + break; + case "64": + fun_ReqTestResistor(e); + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 提前上料 + /// + /// + /// + public void fun_ReqEarlyFeeding(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReqEarlyFeeding, e); + } + + /// + /// 请求测试电阻 调用电阻仪 + /// + /// + /// + public void fun_ReqTestResistor(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReqTestResistor, e); + } + + /// + /// 物料扫码完成 + /// + public void fun_MaterialsVerify(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MaterialsVerify, e); + } + + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + /// + /// 工位是否合格 + /// + /// + /// + public void fun_IsOk(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(IsOk, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + } +} diff --git a/MisDataFunction/Function1052/MesServerFunction/vssver2.scc b/MisDataFunction/Function1052/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1052/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1052/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1052/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..7f859ed --- /dev/null +++ b/MisDataFunction/Function1052/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,109 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + string msg = "【" + OpName + "】" + "PLC传递机型为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + MisDataFun.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + //MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + //SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + //第四步,获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + + //调用工厂MES开工接口 + WebApi.CALL_Inerface_DataHandle.CALL_Inerface_JobStart(OpName, EngineID, OrderForm); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + //MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + //MisDataFun.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + } +} diff --git a/MisDataFunction/Function1052/Methods/vssver2.scc b/MisDataFunction/Function1052/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1052/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1052/OpcServer/Barcode.cs b/MisDataFunction/Function1052/OpcServer/Barcode.cs new file mode 100644 index 0000000..6d2013c --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/Barcode.cs @@ -0,0 +1,89 @@ +using System; +using System.Windows.Forms; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + MisDataFun.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + + //获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1052/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..276639f --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/EngineGetOver.cs @@ -0,0 +1,119 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + string msg = "【" + OpName + "】" + "未能清空MesRead信号,请求复位!"; + SendMessageFun.SendInfomation("AskReset", "1", OpName); + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + // 读取MES区数据 校验MES区数据是否符合 同时判断是否此工件已工作过,若已工作过则弹出弹窗提示 + if (EngineID != "" & EngineType != "" & OrderForm != "") + { + DataTable checkTable = MisDataFun.WorkOrderCheck(OpName, EngineID, OrderForm, EngineType); + int result = Convert.ToInt32(checkTable.Rows[0]["result"]); + //int result = 1; + string resultMsg = checkTable.Rows[0]["msg"].ToString(); + if (result != 2) + { + if (result == 3) + { + string msg = "【" + OpName + "】" + resultMsg; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 "+ msg, MisDataSaveDate.Helper.MesLogType.ERROR); + } + int parType = Convert.ToInt32(checkTable.Rows[0]["小机型"]); + EngineTypeID = Convert.ToInt32(checkTable.Rows[0]["型号代码"]); + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + + MIS_BASE.WritePLC(115, OpName, parType); // 托盘类型 1 静 2 动 3 拐 + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm, OrderForm); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType_MES, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID_MES, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + SendMessage.ShowMoby(OpName); + SendMessageFun.SendMessage("5123", "1111", OpName); + } + else + { + string msg = "【" + OpName + "】" + resultMsg; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + } + + return; + } + else + { + string msg = "【" + OpName + "】" + "读取信息存在空值!"; + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + + } + else + { + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + + } + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/MaterialsVerify.cs b/MisDataFunction/Function1052/OpcServer/MaterialsVerify.cs new file mode 100644 index 0000000..32ee5dd --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/MaterialsVerify.cs @@ -0,0 +1,62 @@ +using System; +using System.Data; +using System.Threading; +using System.Xml.Linq; + +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC物料扫码校验 + /// + /// + public void MaterialsVerify(object e) + { + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + int MaterialsTypeCode = Convert.ToInt32(MIS_BASE.ReadPLC(201, OpName)); + string MaterialsCode = MIS_BASE.ReadPLC(40, OpName).ToString(); + + DataTable dt = MisDataFun.XD_MaterialsVerify(OpName, EngineID, MaterialsCode, MaterialsTypeCode); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + if (result == 1) + { + MIS_BASE.WritePLC(95, OpName, 1); // 物料校验成功 + } + else + { + MIS_BASE.WritePLC(95, OpName, 2); // 物料校验失败 + string msg = $"【{OpName}】产品:{EngineID} | 物料码:{MaterialsCode} | 物料类型:{MaterialsTypeCode.ToString()} 物料校验失败!"; + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "MaterialsVerify " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + } + } + else + { + MIS_BASE.WritePLC(95, OpName, 0); // 物料验证结果清空 + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/MesRead.cs b/MisDataFunction/Function1052/OpcServer/MesRead.cs new file mode 100644 index 0000000..17a29af --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/MesRead.cs @@ -0,0 +1,89 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + //MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + // 保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + + // 保存物料数据 + MisDataFun.Material_Insert(OpName, qualityMask); + + // 测量数据发动机在线状态 + MisDataFun.WorkStartInsert(OpName, qualityMask); + + // 存追溯表数据 + MisDataFun.WorkOrderOpWorkOver(OpName, EngineID, OrderForm); + + // 推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + //调用工厂MES接口报工 + WebApi.CALL_Inerface_DataHandle.CALL_Inerface_JobFinished(OpName, EngineID, OrderForm); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs b/MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs new file mode 100644 index 0000000..4409019 --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请提前上料 + /// + /// + /// + private void ReqEarlyFeeding(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + var dt = MisDataFun.Get_ReqEarlyFeedingData(OpName); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + string msg = dt.Rows[0]["msg"].ToString(); + int EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); + if (result == 1) + { + MIS_BASE.WritePLC(96, OpName, EngineTypeID); // 产品型号 + MIS_BASE.Write_EngineID_MES(OpName, dt.Rows[0]["工件编号"].ToString()); + int ReadEngineID = Convert.ToInt32(MIS_BASE.ReadPLC(96, OpName)); + if (EngineTypeID != ReadEngineID) + { + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()}不一致", MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + if (EngineTypeID == 0 || ReadEngineID == 0) + { + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()} 其中存在空值", MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + MIS_BASE.WritePLC(33, OpName, true); // 允许提前上料 + + } + else if (result == 2) + { + MIS_BASE.WritePLC(33, OpName, false); + string msg2 = "【" + OpName + "】" + msg; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + msg2, MisDataSaveDate.Helper.MesLogType.ERROR); + return; + } + } + else + { + MIS_BASE.WritePLC(96, OpName, 0); // 提前上料位置 + MIS_BASE.WritePLC(33, OpName, false); // 允许提前上料 + MIS_BASE.Write_EngineID_MES(OpName, ""); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/ReqTestResistor.cs b/MisDataFunction/Function1052/OpcServer/ReqTestResistor.cs new file mode 100644 index 0000000..e3e0b82 --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/ReqTestResistor.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using MesServerWork; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + private readonly object _lockObject = new object(); + private volatile bool _isTestOk = false; + private string _opName; + private const int DEFAULT_TIMEOUT = 7000; // 默认超时时间(毫秒) + private const int MAX_RETRY_COUNT = 10; // 最大重试次数 + private const int RESULT_LENGTH = 113; // 预期结果长度 + + /// + /// 电阻测试 + /// + private void ReqTestResistor(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + _opName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + TestResistor().GetAwaiter().GetResult(); + } + else + { + ResetPLCValues(); + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {err.Message}"); + ErrPLCValues(); + } + } + + /// + /// 执行电阻测试 + /// + private async Task TestResistor() + { + TcpClient tcpClient = null; + try + { + string IP = ConfigurationManager.AppSettings["ResistorDeviceIP_" + _opName]; + string Port = ConfigurationManager.AppSettings["ResistorDevicePort"]; + + using (tcpClient = new TcpClient()) + { + var connectTask = tcpClient.ConnectAsync(IP, Convert.ToInt32(Port)); + if (await Task.WhenAny(connectTask, Task.Delay(DEFAULT_TIMEOUT)) != connectTask) + { + throw new TimeoutException("连接电阻仪超时"); + } + + if (tcpClient.Connected) + { + MyLog4Net.MyLogHelper.Info("电阻测试", "电阻仪链接成功!"); + await SendCommand(tcpClient, "01 09 64 00 05 00 00 00 00 00 73"); + + await Task.Delay(DEFAULT_TIMEOUT); + + var readTask = Task.Run(() => Read(tcpClient)); + + int count = 0; + while (!_isTestOk && count < MAX_RETRY_COUNT) + { + await Task.Delay(1000); + await SendCommand(tcpClient, "03 01 04"); + count++; + } + + if (count >= MAX_RETRY_COUNT && !_isTestOk) + { + MyLog4Net.MyLogHelper.Error("电阻测试", "测试超时,未收到有效结果"); + ErrPLCValues(); + } + } + } + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {ex.Message}"); + ErrPLCValues(); + } + finally + { + if (tcpClient != null) + { + tcpClient.Close(); + MyLog4Net.MyLogHelper.Info("电阻测试", "电阻仪链接关闭"); + } + } + } + + private void ResetPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, false); + } + } + + private void ErrPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, true); + } + } + + /// + /// 发送命令到电阻仪 + /// + private async Task SendCommand(TcpClient tcpClient, string command) + { + try + { + // 将空格分隔的HEX字符串转换为字节数组 + string[] hexValues = command.Split(' '); + byte[] commandbyte = new byte[hexValues.Length]; + + for (int i = 0; i < hexValues.Length; i++) + { + commandbyte[i] = Convert.ToByte(hexValues[i], 16); + } + + // 发送HEX格式的数据 + await tcpClient.Client.SendAsync(new ArraySegment(commandbyte), SocketFlags.None); + + // 记录发送的命令 + MyLog4Net.MyLogHelper.Info("电阻测试Send", $"发送命令: {command}"); + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试Send", $"发送命令失败: {err.Message}"); + throw; + } + } + + private void Read(TcpClient tcpClient) + { + try + { + while (!_isTestOk) + { + if (tcpClient != null && tcpClient.Connected) + { + byte[] byteCommand = new byte[1024]; + int icommand = tcpClient.Client.Receive(byteCommand); + string hexString = BitConverter.ToString(byteCommand, 0, icommand).Replace("-", " "); + + if (hexString.Length == RESULT_LENGTH) + { + DataAnalysis(hexString); + } + } + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试Read", err.Message); + } + } + + private void DataAnalysis(string hexString) + { + try + { + var byteArray = HexStringToByteArray(hexString.Replace(" ", "")); + var start = 2; + + var 状态 = BitConverter.ToInt32(byteArray.Skip(start + 0).Take(4).ToArray(), 0); + if (状态 != 2) return; + var 电压V = BitConverter.ToDouble(byteArray.Skip(start + 4).Take(8).ToArray(), 0); + var 电流A = BitConverter.ToDouble(byteArray.Skip(start + 12).Take(8).ToArray(), 0); + var 电阻uΩ = BitConverter.ToDouble(byteArray.Skip(start + 20).Take(8).ToArray(), 0) * 1000000; + var yyyy = BitConverter.ToUInt16(byteArray.Skip(start + 28).Take(2).ToArray(), 0); + var MM = byteArray[start + 30]; + var dd = byteArray[start + 31]; + var HH = byteArray[start + 32]; + var mm = byteArray[start + 33]; + var ss = byteArray[start + 34]; + var datetime = $"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}"; + + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 电压V); + MIS_BASE.WritePLC(203, _opName, 电流A); + MIS_BASE.WritePLC(204, _opName, 电阻uΩ); + MIS_BASE.WritePLC(34, _opName, true); + _isTestOk = true; + } + + MyLog4Net.MyLogHelper.Info("电阻测试", $"电阻结果写入完毕 【电压】{电压V}【电流】{电流A}【电阻】{电阻uΩ}"); + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error("电阻测试DataAnalysis", $"数据分析错误: {ex.Message}"); + } + } + + public static byte[] HexStringToByteArray(string hex) + { + if (hex.Length % 2 != 0) + { + throw new ArgumentException("十六进制字符串长度必须是偶数"); + } + + byte[] bytes = new byte[hex.Length / 2]; + for (int i = 0; i < hex.Length; i += 2) + { + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + } + return bytes; + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1052/OpcServer/WebSubmit.cs b/MisDataFunction/Function1052/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..cd3512e --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/WebSubmit.cs @@ -0,0 +1,352 @@ +using System; +using MesServerWork; +using MisDataSaveDate; +using System.Collections; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + return; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + string msg; + bool bolVal; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + //MisDataFun.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + //BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件) + //工作完成 + EngineTypeGetOver_PLC_Work_Skip(OpName); + break; + case "twoWork"://重新工作工件重新工作(重新工作工件) + //允许工作 + EngineTypeGetOver_PLC_Work_two(OpName); + break; + // 检查项 检查完成 + case "checkWorkOver": + MIS_BASE.WritePLC(30, OpName, 1); + string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(message); + break; + // 跳过交互 + case "skipWork": + // 判断是否有工件到位 + MIS_BASE.Read_WorkStart(OpName, out bolVal); + if (bolVal) + { + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); // 传递机型 + MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + MIS_BASE.WritePLC(30, OpName, 1); // 检查完成 + MIS_BASE.Write_MesReadOver(OpName, true); // 保存完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); // 工作完成 + msg = "【" + OpName + "】" + "跳过交互完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + else + { + msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + MisDataFun.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + + InitOpPosion(Opname); + + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + // MOBY数据 + SendMessageFun.SendMessage("5", "1", Opname); + // 物料信息 物料信息 + SendMessage.MaterialList(Opname); + + // 新增查询PLC直通状态 网页显示 + //MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + } + + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + + private void InitOpPosion(string Opname) + { + int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname)); + string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver; + SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg); + + bool S_WorkStart;//工件到位 DBX0.1 + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + //---------------------------------------------------- + bool S_PartLoad;//申请上线 + MIS_BASE.Read_PartLoad(Opname, out S_PartLoad); + if (S_PartLoad == true) + { + SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname); + } + //---------------------------------------------------- + bool S_EngineGetOver;//传递机型 DBX0.4 + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + } + //---------------------------------------------------- + bool S_FixAllow;//允许工作 DBX3.1 + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + //---------------------------------------------------- + bool S_MesRead;//允许保存 DBX3.1 + MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead); + if (S_MesRead == true) + { + SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname); + } + //---------------------------------------------------- + bool S_ReadOver;//保存完成 + MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver); + if (S_ReadOver == true) + { + SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname); + } + //---------------------------------------------------- + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + //---------------------------------------------------- + int S_QualityMask;//合格标志 DBX588 + MIS_BASE.Read_QualityMask(Opname, out S_QualityMask); + if (S_QualityMask == 1) + { + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname); + } + //---------------------------------------------------- + string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环 + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/WorkIsOk.cs b/MisDataFunction/Function1052/OpcServer/WorkIsOk.cs new file mode 100644 index 0000000..3149bce --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/WorkIsOk.cs @@ -0,0 +1,44 @@ +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工位合格标志 + /// + /// + /// + private void IsOk(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + //判断是否合格 + if (qualityMask == 1) + { + qualityMask = 1; + } else { + qualityMask = 0; + } + //通知WEB修改状态 + string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString(); + SendMessage.AsyncSendMessage(message); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/WorkStart.cs b/MisDataFunction/Function1052/OpcServer/WorkStart.cs new file mode 100644 index 0000000..7fc448c --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/WorkStart.cs @@ -0,0 +1,57 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStart, tagValue.ToString()); + } + else + { + MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + MIS_BASE.Write_EngineType_MES(OpName, ""); + MIS_BASE.Write_EngineID_MES(OpName, ""); + MIS_BASE.Write_OrderForm_MES(OpName, ""); + + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + // 检查项完成 + MIS_BASE.Write_TagTypeID(30, OpName, 0); + string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(message); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/vssver2.scc b/MisDataFunction/Function1052/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1052/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1052/Properties/AssemblyInfo.cs b/MisDataFunction/Function1052/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1052/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1052/Properties/vssver2.scc b/MisDataFunction/Function1052/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1052/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1052/app.config b/MisDataFunction/Function1052/app.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFunction/Function1052/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1052/mssccprj.scc b/MisDataFunction/Function1052/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1052/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1052/packages.config b/MisDataFunction/Function1052/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1052/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1052/vssver2.scc b/MisDataFunction/Function1052/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1052/vssver2.scc differ diff --git a/MisDataFunction/Function1053/DataAccess/DataAccess.cs b/MisDataFunction/Function1053/DataAccess/DataAccess.cs new file mode 100644 index 0000000..cd36930 --- /dev/null +++ b/MisDataFunction/Function1053/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1053 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1053/DataAccess/vssver2.scc b/MisDataFunction/Function1053/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1053/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1053/Db.cs b/MisDataFunction/Function1053/Db.cs new file mode 100644 index 0000000..cce85a9 --- /dev/null +++ b/MisDataFunction/Function1053/Db.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Db + { + + + } +} diff --git a/MisDataFunction/Function1053/Function02.csproj.vspscc b/MisDataFunction/Function1053/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1053/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1053/Function1053.csproj b/MisDataFunction/Function1053/Function1053.csproj new file mode 100644 index 0000000..9500104 --- /dev/null +++ b/MisDataFunction/Function1053/Function1053.csproj @@ -0,0 +1,172 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA} + Library + Properties + Function1053 + Function1053 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {2f33d79d-1dff-4cda-b357-fcd5221cab9a} + ExternalDataSync + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1053/MesServerFunction/Fun_1053.cs b/MisDataFunction/Function1053/MesServerFunction/Fun_1053.cs new file mode 100644 index 0000000..7b44663 --- /dev/null +++ b/MisDataFunction/Function1053/MesServerFunction/Fun_1053.cs @@ -0,0 +1,270 @@ +using MesServerWork; +using MisDataFunDll; +using MisDataSaveDate; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string TagID = e.TagID.ToString(); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 申请上线 + case "43": + PartLoad(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //PLC 工位合格标志 + case "21": + fun_IsOk(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + //空料握手plc + case "49": + fun_Handshake(e); + break; + //待上料数量plc + case "38": + UpdateWait_NUM_PLC(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + //物料扫码完成 + case "65": + fun_MaterialsVerify(e); + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DeviceDriver_BasicData .CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 物料扫码完成 + /// + public void fun_MaterialsVerify(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MaterialsVerify, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + /// + /// 工位是否合格 + /// + /// + /// + public void fun_IsOk(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(IsOk, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + + + /// + /// 空料握手plc + /// + public void fun_Handshake(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + //ThreadPool.QueueUserWorkItem(Handshake_Fun, e); + } + + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + + } +} diff --git a/MisDataFunction/Function1053/MesServerFunction/vssver2.scc b/MisDataFunction/Function1053/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1053/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1053/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1053/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..46e4f96 --- /dev/null +++ b/MisDataFunction/Function1053/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,115 @@ +using System; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + string msg = "【" + OpName + "】" + "PLC传递机型为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessageFun.AsyncSendMessage_Notice(OpName, msg); + return; + } + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + MisDataFun.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + //MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + //SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + //第四步,获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + MIS_BASE.Write_WorkStart(OpName, true); + MIS_BASE.Write_FixAllow(OpName, true); + MIS_BASE.Write_EngineTypeGetOver_PLC(OpName, true); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "1"); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + SendMessageFun.SendMessage("1235", "1111", OpName); + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + //MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + //string orderForm = ""; + //int engineTypeID; + //string engineType = ""; + //string engineID = ""; + //string palletCode = ""; + //int isRepair; + //string repairCode = ""; + ////从监控系统中查询出本工位信息 + //MisDataFun.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + + /// + /// 更新待上料数量 + /// + /// + private void UpdateWait_NUM_PLC(object e) + { + } + } +} diff --git a/MisDataFunction/Function1053/Methods/vssver2.scc b/MisDataFunction/Function1053/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1053/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1053/OpcServer/Barcode.cs b/MisDataFunction/Function1053/OpcServer/Barcode.cs new file mode 100644 index 0000000..24a7187 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/Barcode.cs @@ -0,0 +1,79 @@ +using System; +using System.Data; +using System.Windows.Forms; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + + MisDataFun.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认!"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + //获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + if (IsAllowWork == 1) + { + // 保存物料信息 + MisDataFun.Material_Insert(OpName, 1); + + SendMessageFun.SendMessage("24", "11", OpName); + + // 物料验证完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认!"); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1053/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..f46a8c4 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/EngineGetOver.cs @@ -0,0 +1,72 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + if(msgEvent.TagValueUp.ToString() == "6") + { + MIS_BASE.Write_FixAllow(OpName, false); + string Program_No = ""; + MisDataFun.GetEngineType_Order(OpName, Program_No, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int isCheckOk, out int planCount, out int haveUplaodCount, out int remainingQuantity, out string msg2); + if (isCheckOk == 2) + { + string msg = "【" + OpName + "】" + msg2; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Error("PartLoad", msg); + return; + } + else + { + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm, OrderForm); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType_MES, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID_MES, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, 0, OrderForm); + } + } + } + catch (Exception err) + { + // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码 + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err); + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/HeartBeat.cs b/MisDataFunction/Function1053/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..b94f253 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/HeartBeat.cs @@ -0,0 +1,34 @@ +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/MaterialsVerify.cs b/MisDataFunction/Function1053/OpcServer/MaterialsVerify.cs new file mode 100644 index 0000000..32ee5dd --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/MaterialsVerify.cs @@ -0,0 +1,62 @@ +using System; +using System.Data; +using System.Threading; +using System.Xml.Linq; + +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC物料扫码校验 + /// + /// + public void MaterialsVerify(object e) + { + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + int MaterialsTypeCode = Convert.ToInt32(MIS_BASE.ReadPLC(201, OpName)); + string MaterialsCode = MIS_BASE.ReadPLC(40, OpName).ToString(); + + DataTable dt = MisDataFun.XD_MaterialsVerify(OpName, EngineID, MaterialsCode, MaterialsTypeCode); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + if (result == 1) + { + MIS_BASE.WritePLC(95, OpName, 1); // 物料校验成功 + } + else + { + MIS_BASE.WritePLC(95, OpName, 2); // 物料校验失败 + string msg = $"【{OpName}】产品:{EngineID} | 物料码:{MaterialsCode} | 物料类型:{MaterialsTypeCode.ToString()} 物料校验失败!"; + MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "MaterialsVerify " + msg, MisDataSaveDate.Helper.MesLogType.ERROR); + } + } + else + { + MIS_BASE.WritePLC(95, OpName, 0); // 物料验证结果清空 + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/MesRead.cs b/MisDataFunction/Function1053/OpcServer/MesRead.cs new file mode 100644 index 0000000..af14ba5 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/MesRead.cs @@ -0,0 +1,88 @@ +using MesServerWork; +using MesWork; +using MisDataFunDll; +using System; +using System.Data; +using System.Threading; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0"); + Thread.Sleep(500); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "1"); + if (tagValue == 1) + { + bool isEngineGetOver; + DataRow mobyData = MisDataFun.GetMobyTableByOpName(OpName).Rows[0]; + EngineTypeID_MES = Convert.ToInt32(mobyData["产品型号代码_MES"]); + EngineType_MES = mobyData["发动机型号_MES"].ToString(); + EngineID_MES = mobyData["变速器序列号_MES"].ToString(); + OrderForm_MES = mobyData["订单号_MES"].ToString(); + isEngineGetOver = Convert.ToBoolean(mobyData["允许工作"]); + + if (!isEngineGetOver) + { + string msg2 = "【" + OpName + "】" + "请先开始订单生产后再进行保存,当前未允许工作!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg2); + return; + } + + // 存追溯表数据 + MisDataFun.WorkOrderOpWorkOver(OpName, EngineID_MES, OrderForm_MES); + + // 保存物料数据 + MisDataFun.Material_Insert(OpName, 1); + + // 测量数据发动机在线状态 + MisDataFun.WorkStartInsert(OpName, 1); + + //通知设备,MES的质量数据(和物料数据)保存完成 + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "1"); + Thread.Sleep(1000 * 1); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.WorkStart, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.EngineTypeGetOverPLC, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.PartLoad, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "0"); + + + string msg = "【" + OpName + "】" + "工件数据保存完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + } + catch (Exception err) + { + // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码 + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err); + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/PartLoad.cs b/MisDataFunction/Function1053/OpcServer/PartLoad.cs new file mode 100644 index 0000000..b51c56a --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/PartLoad.cs @@ -0,0 +1,55 @@ +using System; +using System.Threading; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线(针对上线工位) + /// + /// + /// + private void PartLoad(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + // 清空MOBY表中所有数据 + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.WorkStart, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.EngineTypeGetOverPLC, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.PartLoad, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "0"); + Thread.Sleep(500); + // 按照生产排序顺序获取订单相关数据 + // 获取到数据 显示 申请上线、传递机型、允许工作三个点位 + // 显示对应物料信息、 + + if (tagValue == 1) + { + + } + else + { + ////上线工位清MES传递机型信号 + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //// 清除报警 + } + } + catch (Exception err) + { + // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码 + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err); + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/WebSubmit.cs b/MisDataFunction/Function1053/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..242f6fa --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/WebSubmit.cs @@ -0,0 +1,336 @@ +using System; +using MesServerWork; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + return; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + //BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + //BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件) + //工作完成 + EngineTypeGetOver_PLC_Work_Skip(OpName); + break; + case "twoWork"://重新工作工件重新工作(重新工作工件) + //允许工作 + EngineTypeGetOver_PLC_Work_two(OpName); + break; + case "SelectOrderForm"://分线接受前端模拟传递机型 + _e.TagValueUp = "6"; + EngineTypeGetOver_PLC(_e); + break; + case "outLineOpNameWorkOver"://分线接受前端模拟工作完成 + _e.TagValueUp = "6"; + _e.TagValue = 1; + MesRead(_e); + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + //BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string OpName) + { + InitOpPosion(OpName); + + ////3显示操作指导图片 PicShow_String_FirstOpName + //SendMessage.PicShow_FirstOpName(OpOpNamename); + ////1(直接在界面通过选择机型确认工序内容) + //SendMessage.ProcessList_FirstOpName(OpName); + //// MOBY数据 + //SendMessageFun.SendMessage("5", "1", OpName); + //// 物料信息 物料信息 + //SendMessage.MaterialList(OpName); + + SendMessageFun.SendMessage("315", "111", OpName); + + // 新增查询PLC直通状态 网页显示 + //MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(OpName); + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + + private void InitOpPosion(string Opname) + { + int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname)); + string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver; + SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg); + + bool S_WorkStart;//工件到位 DBX0.1 + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + //---------------------------------------------------- + bool S_PartLoad;//申请上线 + MIS_BASE.Read_PartLoad(Opname, out S_PartLoad); + if (S_PartLoad == true) + { + SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname); + } + //---------------------------------------------------- + bool S_EngineGetOver;//传递机型 DBX0.4 + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + } + //---------------------------------------------------- + bool S_FixAllow;//允许工作 DBX3.1 + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + //---------------------------------------------------- + bool S_MesRead;//允许保存 DBX3.1 + MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead); + if (S_MesRead == true) + { + SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname); + } + //---------------------------------------------------- + bool S_ReadOver;//保存完成 + MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver); + if (S_ReadOver == true) + { + SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname); + } + //---------------------------------------------------- + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + //---------------------------------------------------- + int S_QualityMask;//合格标志 DBX588 + MIS_BASE.Read_QualityMask(Opname, out S_QualityMask); + if (S_QualityMask == 1) + { + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname); + } + //---------------------------------------------------- + string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环 + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/WorkIsOk.cs b/MisDataFunction/Function1053/OpcServer/WorkIsOk.cs new file mode 100644 index 0000000..3149bce --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/WorkIsOk.cs @@ -0,0 +1,44 @@ +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工位合格标志 + /// + /// + /// + private void IsOk(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + //判断是否合格 + if (qualityMask == 1) + { + qualityMask = 1; + } else { + qualityMask = 0; + } + //通知WEB修改状态 + string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString(); + SendMessage.AsyncSendMessage(message); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/WorkStart.cs b/MisDataFunction/Function1053/OpcServer/WorkStart.cs new file mode 100644 index 0000000..c634017 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/WorkStart.cs @@ -0,0 +1,49 @@ +using MesServerWork; +using System; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //if (tagValue > 0) + //{ + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.WorkStart, tagValue.ToString()); + //} + //else + //{ + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString()); + // MIS_BASE.Write_MesReadOver(OpName, false); + // MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FixAllow(OpName, false); + // MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + // //工作完成 + // MIS_BASE.Write_MaterialVerifyOver(OpName, false); + // MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + // MIS_BASE.Write_EngineType_MES(OpName, ""); + // MIS_BASE.Write_EngineID_MES(OpName, ""); + // MIS_BASE.Write_OrderForm_MES(OpName, ""); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/vssver2.scc b/MisDataFunction/Function1053/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1053/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1053/Properties/AssemblyInfo.cs b/MisDataFunction/Function1053/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1053/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1053/Properties/vssver2.scc b/MisDataFunction/Function1053/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1053/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1053/app.config b/MisDataFunction/Function1053/app.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFunction/Function1053/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1053/mssccprj.scc b/MisDataFunction/Function1053/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1053/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1053/packages.config b/MisDataFunction/Function1053/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1053/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1053/vssver2.scc b/MisDataFunction/Function1053/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1053/vssver2.scc differ diff --git a/MisDataFunction/Function1054/DataAccess/DataAccess.cs b/MisDataFunction/Function1054/DataAccess/DataAccess.cs new file mode 100644 index 0000000..574d619 --- /dev/null +++ b/MisDataFunction/Function1054/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1052 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1054/DataAccess/vssver2.scc b/MisDataFunction/Function1054/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1054/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1054/Db.cs b/MisDataFunction/Function1054/Db.cs new file mode 100644 index 0000000..1190bb0 --- /dev/null +++ b/MisDataFunction/Function1054/Db.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Db + { + + } +} diff --git a/MisDataFunction/Function1054/Function02.csproj.vspscc b/MisDataFunction/Function1054/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1054/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1054/Function1054.csproj b/MisDataFunction/Function1054/Function1054.csproj new file mode 100644 index 0000000..c1e7839 --- /dev/null +++ b/MisDataFunction/Function1054/Function1054.csproj @@ -0,0 +1,182 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {CC45D613-11B9-48AF-B073-6523D6273525} + Library + Properties + Function1054 + Function1054 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + {2f33d79d-1dff-4cda-b357-fcd5221cab9a} + ExternalDataSync + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + diff --git a/MisDataFunction/Function1054/MesServerFunction/Fun_1054.cs b/MisDataFunction/Function1054/MesServerFunction/Fun_1054.cs new file mode 100644 index 0000000..d0e9734 --- /dev/null +++ b/MisDataFunction/Function1054/MesServerFunction/Fun_1054.cs @@ -0,0 +1,328 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + string OpName = m_OpName; + switch (m_Source) + { + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + // AGV相关变量类型代码处理说明: + // 301:AGV请求进入 + // 302:AGV器具放置完毕 + // 303:AGV退出光栅 + // 304:送料信息验证完成 + // 305:送料信息验证结果 + // 305:任务发送状态 0 没有 1 发送 2 失败 + // 311:请求叫料 + // 312:请求退空 + // 313:请求退料 + // 314:允许AGV进入 + // 315:允许AGV离开 + // 316:器具码扫描完毕 + // 317:退回并重新配送 + // 318:器具号 + // 319:请求上料机型 + // 320:收到状态反馈点 + // 321:转序 + // 322:下空托盘 + // 323:上空托盘 + // 324:点对点 + // 500:AGV请求下降 + // 501:AGV请求举升 + // 550:允许AGV下降 + // 551:允许AGV举升 + + // 请求叫料 + case "311": + fun_CallMaterials(e); + break; + // 请求退空 + case "312": + fun_RequestReturns(e); + break; + // 请求退料 + case "313": + fun_RequestReturnMaterial(e); + break; + // 允许AGV进入 + case "314": + fun_AllowAGVEnter(e); + break; + // 允许AGV离开 + case "315": + fun_AllowAGVLeave(e); + break; + // 器具码扫描完毕 + case "316": + fun_ToolCodeScanOver(e); + break; + // 退回并重新配送 + case "317": + fun_ReturnAndRedispatch(e); + break; + // 收到任务状态握手 + case "320": + //MIS_BASE.WritePLC(306, m_OpName, 0); + break; + // 转序 + case "321": + fun_TransferSequence(e); + break; + // 下空托盘 + case "322": + fun_UnloadEmptyTray(e); + break; + // 上空托盘 + case "323": + fun_LoadEmptyTray(e); + break; + // 允许AGV下降 + case "550": + fun_AllowAGVLower(e); + break; + // 允许AGV举升 + case "551": + fun_AllowAGVRaise(e); + break; + // AGV插头完成 + case "400": + break; + // AGV拔插头完成 + case "401": + break; + // MES允许开始磨合 + case "402": + break; + // MES反馈磨合结束 + case "403": + break; + // 托盘压紧气缸压紧 + case "404": + if (tagValue == "1") MIS_BASE.WritePLC(405, OpName, false); + break; + // 托盘压紧气缸松开 + case "405": + if (tagValue == "1") MIS_BASE.WritePLC(404, OpName, false); + break; + // 插头推靠气缸推靠 + case "406": + if (tagValue == "1") MIS_BASE.WritePLC(407, OpName, false); + break; + // 插头推靠气缸退回 + case "407": + if (tagValue == "1") MIS_BASE.WritePLC(406, OpName, false); + break; + // 自动模式 + case "408": + if (tagValue == "1") MIS_BASE.WritePLC(409, OpName, false); // 自动掉手动模式 + break; + // 手动模式 + case "409": + if (tagValue == "1") MIS_BASE.WritePLC(408, OpName, false); // 自动掉自动模式 + break; + // 请求上线 + case "450": + MisDataFun.Rrunning_UpdateOpCallStatus(OpName, Convert.ToInt32(tagValue)); // 更新至数据库库位状态 + break; + // 请求下线 + case "451": + break; + // 请求插插头 + case "452": + // 需要调用AGV插插头接口 去插 + break; + // 请求拔插头 + case "453": + break; + // 开始磨合 + case "454": + break; + // 磨合完成 + case "455": + break; + // 推靠气缸原位 + case "456": + break; + // 推靠气缸到位 + case "457": + break; + // 压紧气缸原位 + case "458": + break; + // 压紧气缸到位 + case "459": + break; + } + break; + } + } + } + + // 叫料流程 + // 1.请求叫料 收到请求叫料后 调用叫料接口 后续收到AGV的 + // 2.收到工厂 请求进入接口(工厂未开发 跳过) 发给PLC AGV请求进入 + // 3.收到允许AGV进入 调用接口(未开发 跳过) 允许进入 + // 4.收到 器具码扫码完成 根据318器具号 调用器具号查询接口 得出校验结果 + // 5.若器具码校验通过 调用 确认物料配送接口 调用成功后 给PLC发送 送料信息验证结果(1 合格 2 不合格) 和 送料信息验证完成 + // 6.收到AGV请求离开接口后(未开发 跳过) 发送给PLC请求离开点位 + // 7.收到PLC允许离开信号后 调用AGV允许离开接口(未开发 跳过) + + // 退空托流程 + // 1.收到请求退空 调用退空托接口 + // 2.如叫料AGV请求进入 请求离开。。。。 只不过不需要扫描器具码部分 + + + // AGV相关方法声明(PLC触发的信号) + /// + /// 请求叫料 + /// + public void fun_CallMaterials(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(CallMaterials, e); + } + + /// + /// 请求退空 + /// + public void fun_RequestReturns(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(RequestReturns, e); + } + + /// + /// 请求退料 + /// + public void fun_RequestReturnMaterial(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(RequestReturnMaterial, e); + } + + /// + /// 允许AGV进入 + /// + public void fun_AllowAGVEnter(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(AllowAGVEnter, e); + } + + /// + /// 允许AGV离开 + /// + public void fun_AllowAGVLeave(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(AllowAGVLeave, e); + } + + /// + /// 允许AGV下降 + /// + public void fun_AllowAGVLower(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(AllowAGVLower, e); + } + + /// + /// 允许AGV举升 + /// + public void fun_AllowAGVRaise(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(AllowAGVRaise, e); + } + + /// + /// 器具码扫描完毕 + /// + public void fun_ToolCodeScanOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ToolCodeScanOver, e); + } + + /// + /// 退回并重新配送 + /// + public void fun_ReturnAndRedispatch(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReturnAndRedispatch, e); + } + + /// + /// 转序 + /// + public void fun_TransferSequence(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(TransferSequence, e); + } + + /// + /// 下空托盘 + /// + public void fun_UnloadEmptyTray(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(UnloadEmptyTray, e); + } + + /// + /// 上空托盘 + /// + public void fun_LoadEmptyTray(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(LoadEmptyTray, e); + } + + /// + /// 点对点 + /// + public void fun_PointToPoint(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(PointToPoint, e); + } + + } +} diff --git a/MisDataFunction/Function1054/MesServerFunction/vssver2.scc b/MisDataFunction/Function1054/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1054/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1054/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1054/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..3d43608 --- /dev/null +++ b/MisDataFunction/Function1054/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,177 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + //int IsAllowWork; + //int RepairPartStatusPLC = 0; + //int MES_QualityMask = 1; + + + + ////电子看板_装配零件_临时表_增加_北汽 + ////第二步,将零件信息转移到零件_临时表中 + //BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + ////通知web显示 + //SendMessageFun.SendMessage("123", "111", OpName); + ////MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + ////MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + ////SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + ////SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + //MIS_BASE.Read_TagTypeID(201, OpName, out string EngineTypeID_QiaoKe); + + //Db.OP50_OPA90_MatchResult(EngineTypeID, Convert.ToInt32(EngineTypeID_QiaoKe), EngineID, OrderForm, out int MatchResult, out string MatchResultStr); + //if (MatchResult == 1) + //{ + // // 轮毂线 + // MIS_BASE.Write_Match(OpName, true);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + // return; + //} + //else if (MatchResult == 2) // 分等待状态 与 报警状态 等待的话就等A60 工作完成时判断清除等待 写入A90 的匹配结果 匹配完成 允许工作 + //{ + // MIS_BASE.WritePLC(29, OpName, true); // 开始等待 通知A60 保存完成时更新下等待状态与匹配状态 + // return; + //} + //else + //{ + // // 将根据轮毂号 工位号 时间 报错内容 存储到数据库中供查询 + // BaseDataSystemMES.HeLi_OoNameAlarmRecord_Add(OpName, EngineID, MatchResultStr); + // // 匹配结果不成功 + // MIS_BASE.Write_Match(OpName, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + // return; + //} + + + + + + //// 判断分线是否 传递机型 + //if (EngineGetOver_SubLine) + //{ + // string EngineTypeID_MainLine; + // int EngineTypeID_MainLineQiaoKe; + // // 读取主线桥壳机型 + // MIS_BASE.Read_EngineTypeID(OpName_MainLine, out EngineTypeID_MainLineQiaoKe); + // // 读取分线存储的桥壳机型 + // MIS_BASE.Read_TagTypeID(38, OpName_SubLine, out EngineTypeID_MainLine); + + // if (Convert.ToInt32(EngineTypeID_MainLine) == EngineTypeID) + // { + // Db.OP50_OPA90_MatchResult(EngineTypeID, Convert.ToInt32(EngineTypeID_MainLine), EngineTypeID_MainLineQiaoKe, out int MatchResult); + + // if (MatchResult == 0) // 不匹配 + // { + // // 主线 + // MIS_BASE.Write_Match(OpName_MainLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_MainLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_MainLine, false); // 允许工作 + // // 分线 + // MIS_BASE.Write_Match(OpName_SubLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_SubLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_SubLine, false); // 允许工作 + + // // 写入分线 等待 0 + // MIS_BASE.WritePLC(29, OpName_SubLine, "0"); + // } + // if (MatchResult == 1) // 允许抓 + // { + // // 主线 + // MIS_BASE.Write_Match(OpName_MainLine, true);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_MainLine, true);// 匹配完成 + // // 分线 + // MIS_BASE.Write_Match(OpName_SubLine, true);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_SubLine, true);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_MainLine, true); // 允许工作 + + // // 写入分线 等待 0 + // MIS_BASE.WritePLC(29, OpName_SubLine, "0"); + // } + // if (MatchResult == 2) // 等待 + // { + // // 写入分线 等待 1 + // MIS_BASE.WritePLC(29, OpName_SubLine, "1"); + // } + // } + // else // 不匹配 + // { + // // 主线 + // MIS_BASE.Write_Match(OpName_MainLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_MainLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_MainLine, false); // 允许工作 + // // 分线 + // MIS_BASE.Write_Match(OpName_SubLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_SubLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_SubLine, false); // 允许工作 + + // // 写入分线 等待 0 + // MIS_BASE.WritePLC(29, OpName_SubLine, "0"); + // } + //} + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + //MisDataFun.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + } +} diff --git a/MisDataFunction/Function1054/Methods/vssver2.scc b/MisDataFunction/Function1054/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1054/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1054/OpcServer/AllowAGVEnter.cs b/MisDataFunction/Function1054/OpcServer/AllowAGVEnter.cs new file mode 100644 index 0000000..badabb1 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/AllowAGVEnter.cs @@ -0,0 +1,51 @@ +using MesServerWork; +using MisDataFunDll; +using System; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许AGV进入 + /// + /// + private void AllowAGVEnter(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + string msg; + + // PLC允许AGV离开信号被置位后,应调用AGV允许进入接口 + MIS_BASE.Read_EngineID(OpName, out string EngineID); + bool isOk = MisDataSaveDate.AGV_BusinessLogic.PassAgvInOut(OpName, EngineID, "apply"); + + if (isOk) + { + msg = $"【{OpName}】允许AGV进入成功!"; + } + else + { + msg = $"【{OpName}】允许AGV进入失败!请注意!"; + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("AllowAGVLeave", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "AllowAGVEnter", "0"); + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/AllowAGVLeave.cs b/MisDataFunction/Function1054/OpcServer/AllowAGVLeave.cs new file mode 100644 index 0000000..e93fae1 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/AllowAGVLeave.cs @@ -0,0 +1,55 @@ +using MesServerWork; +using MisDataFunDll; +using System; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许AGV离开 + /// + /// + private void AllowAGVLeave(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg = $"【{OpName}】允许AGV离开"; + if (tagValue == 1) + { + + + // PLC允许AGV离开信号被置位后,应调用AGV允许离开接口 + MIS_BASE.Read_EngineID(OpName,out string EngineID); + bool isOk = MisDataSaveDate.AGV_BusinessLogic.PassAgvInOut(OpName, EngineID, "release"); + + if (isOk) { + msg = $"【{OpName}】允许AGV离开失败!请注意!"; + } + else + { + msg = $"【{OpName}】允许AGV离开成功!"; + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("AllowAGVLeave", msg); + + // 记录允许AGV离开状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "AllowAGVLeave", "1"); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "AllowAGVLeave", "0"); + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/AllowAGVLower.cs b/MisDataFunction/Function1054/OpcServer/AllowAGVLower.cs new file mode 100644 index 0000000..6d4cf9f --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/AllowAGVLower.cs @@ -0,0 +1,51 @@ +using MesServerWork; +using MisDataFunDll; +using System; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许AGV下降 + /// + /// + private void AllowAGVLower(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + string msg; + + // PLC允许AGV下降信号被置位后,应调用AGV允许下降接口 + MIS_BASE.Read_EngineID(OpName, out string EngineID); + bool isOk = MisDataSaveDate.AGV_BusinessLogic.PassAgvInOut(OpName, EngineID, "lower"); + + if (isOk) + { + msg = $"【{OpName}】允许AGV下降成功!"; + } + else + { + msg = $"【{OpName}】允许AGV下降失败!请注意!"; + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("AllowAGVLower", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "AllowAGVLower", "0"); + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} diff --git a/MisDataFunction/Function1054/OpcServer/AllowAGVRaise.cs b/MisDataFunction/Function1054/OpcServer/AllowAGVRaise.cs new file mode 100644 index 0000000..09b42c2 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/AllowAGVRaise.cs @@ -0,0 +1,51 @@ +using MesServerWork; +using MisDataFunDll; +using System; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许AGV举升 + /// + /// + private void AllowAGVRaise(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + string msg; + + // PLC允许AGV举升信号被置位后,应调用AGV允许举升接口 + MIS_BASE.Read_EngineID(OpName, out string EngineID); + bool isOk = MisDataSaveDate.AGV_BusinessLogic.PassAgvInOut(OpName, EngineID, "raise"); + + if (isOk) + { + msg = $"【{OpName}】允许AGV举升成功!"; + } + else + { + msg = $"【{OpName}】允许AGV举升失败!请注意!"; + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("AllowAGVRaise", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "AllowAGVRaise", "0"); + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} diff --git a/MisDataFunction/Function1054/OpcServer/CallMaterials.cs b/MisDataFunction/Function1054/OpcServer/CallMaterials.cs new file mode 100644 index 0000000..b51b05a --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/CallMaterials.cs @@ -0,0 +1,68 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Data; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 请求叫料 + /// + /// + private void CallMaterials(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + if (tagValue == 1) + { + + // 记录叫料请求状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "CallMaterials", "1"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "2"); + // 调用叫料接口 + // deliveryType: 1退托盘,2叫料,3送料,4转序 + DataTable outType = MisDataFun.GetRequestReturnMaterials_Type(OpName, "2"); + string sendType = outType.Rows[0]["type"].ToString(); + bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, sendType); + if (isOk) + { + // 发送消息通知 + msg = $"【{OpName}】请求叫料成功"; + MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + } + else + { + msg = $"【{OpName}】请求叫料失败"; + MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + } + + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("CallMaterials", msg); + + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "CallMaterials", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/LoadEmptyTray.cs b/MisDataFunction/Function1054/OpcServer/LoadEmptyTray.cs new file mode 100644 index 0000000..adbdac1 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/LoadEmptyTray.cs @@ -0,0 +1,63 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 上空托盘操作 + /// + /// + private void LoadEmptyTray(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + + if (tagValue == 1) + { + // 记录上空托盘请求状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "LoadEmptyTray", "1"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "6"); + + // 调用上空托盘接口 + // deliveryType: 1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, "6"); + if (isOk) + { + msg = $"【{OpName}】上空托盘操作成功"; + MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + } + else + { + msg = $"【{OpName}】上空托盘操作失败"; + MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("LoadEmptyTray", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "LoadEmptyTray", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/PointToPoint.cs b/MisDataFunction/Function1054/OpcServer/PointToPoint.cs new file mode 100644 index 0000000..c999e50 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/PointToPoint.cs @@ -0,0 +1,64 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 点对点操作 + /// + /// + private void PointToPoint(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + + if (tagValue == 1) + { + // 记录点对点请求状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "PointToPoint", "1"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "7"); + + // 调用点对点接口 + // deliveryType: 1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + // 注意:终点位置暂时为空,等业务明确后再补充 + bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, "7"); + if (isOk) + { + msg = $"【{OpName}】点对点操作成功"; + MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + } + else + { + msg = $"【{OpName}】点对点操作失败"; + MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("PointToPoint", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "PointToPoint", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/RequestReturnMaterial.cs b/MisDataFunction/Function1054/OpcServer/RequestReturnMaterial.cs new file mode 100644 index 0000000..2f4088a --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/RequestReturnMaterial.cs @@ -0,0 +1,121 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Data; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 请求退料 + /// + /// + private void RequestReturnMaterial(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + + if (tagValue == 1) + { + // 记录退料请求状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "RequestReturnMaterial", "1"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "3"); + + // 调用退料接口 + // deliveryType: 1退托盘,2叫料,3送料,4转序 + DataTable outType = MisDataFun.GetRequestReturnMaterials_Type(OpName, "3"); + string sendType = outType.Rows[0]["type"].ToString(); + bool isOk; + if (sendType == "4") + { + // 调用转序接口 走转序流程 + string EngineID = DateTime.Now.ToString("yyyyMMddHHmm"); + string EngineType = "NONE"; + DataTable nextDT = MisDataFun.Rrunning_GetNextStoreData(OpName, EngineID, EngineType); + string targetStoreCode = nextDT.Rows[0]["目标库位号"].ToString(); + string targetProcessCode = nextDT.Rows[0]["目标工序号"].ToString(); + string targetProcess = nextDT.Rows[0]["目标工序"].ToString(); + + + // 1. 调用AGV转序接口 + var agvResult = CALL_Inerface_DataHandle.CALL_Inerface_MaterialTransfer(OpName, targetStoreCode); + int agvCode = 500; + int.TryParse(agvResult["code"]?.ToString() ?? "500", out agvCode); + + if (agvCode != 200) + { + // AGV调度失败 + isOk = false; + msg = $"【{OpName}】AGV调度失败:{agvResult["message"]?.ToString() ?? "未知错误"}"; + } + else + { + // 2. AGV调度成功,执行转序存储过程 + var param = new System.Data.SqlClient.SqlParameter[] { + new System.Data.SqlClient.SqlParameter("@库位号", OpName), + new System.Data.SqlClient.SqlParameter("@产品编号", EngineID), + new System.Data.SqlClient.SqlParameter("@产品型号", EngineType), + new System.Data.SqlClient.SqlParameter("@目标库位号", targetStoreCode), + new System.Data.SqlClient.SqlParameter("@目标工序", targetProcess), + new System.Data.SqlClient.SqlParameter("@目标工序号", targetProcessCode) + }; + + DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("XD_磨合_开始下一序", ref param, out string errMessage); + + if (!string.IsNullOrEmpty(errMessage)) + { + isOk = false; + msg = $"【{OpName}】AGV调度成功,但XD_磨合_开始下一序存储过程执行失败:{errMessage}"; + } + else + { + isOk = true; + msg = $"【{OpName}】转序操作成功"; + } + } + } + else + { + isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, sendType); + + } + if (isOk) + { + // 发送消息通知 + msg = $"【{OpName}】请求退料成功"; + MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + } + else + { + msg = $"【{OpName}】请求退料失败"; + MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + } + + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("RequestReturnMaterial", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "RequestReturnMaterial", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 器具放置完毕 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/RequestReturns.cs b/MisDataFunction/Function1054/OpcServer/RequestReturns.cs new file mode 100644 index 0000000..73206c9 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/RequestReturns.cs @@ -0,0 +1,68 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Data; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 请求退空 + /// + /// + private void RequestReturns(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + + if (tagValue == 1) + { + // 记录退空请求状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "RequestReturns", "1"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "1"); + + // 调用退料接口 + // deliveryType: 1退托盘,2叫料,3送料,4转序 + DataTable outType = MisDataFun.GetRequestReturnMaterials_Type(OpName, "1"); + string sendType = outType.Rows[0]["type"].ToString(); + bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, sendType); + if (isOk) + { + // 发送消息通知 + msg = $"【{OpName}】请求退空托成功"; + MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + } + else + { + msg = $"【{OpName}】请求退空托失败"; + MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + } + + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("RequestReturns", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "RequestReturns", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 器具放置完毕 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/ReturnAndRedispatch.cs b/MisDataFunction/Function1054/OpcServer/ReturnAndRedispatch.cs new file mode 100644 index 0000000..a5d79c2 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/ReturnAndRedispatch.cs @@ -0,0 +1,55 @@ +using System; +using MesServerWork; +using MisDataFunDll; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 退回并重新配送 + /// + /// + private void ReturnAndRedispatch(object e) + { + try + { + //DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + // // 这个流程不太对 具体流程待二次确认 + // // 记录退回并重新配送状态 + // MisDataFun.Location_MIS_MOBY_Insert(OpName, "ReturnAndRedispatch", "1"); + + // // 当器具码校验不通过时,PLC会置位此信号 + // // 需要通知AGV退回当前器具并重新配送正确的物料 + // // 调用工厂叫料接口,类型为送料(3) + // MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "3"); + // CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, "3"); + + // // 发送消息通知 + // string msg = $"【{OpName}】请求退回物料,退回并重新配送"; + // SendMessage.AsyncSendMessage_Notice(OpName, msg); + // MyLog4Net.MyLogHelper.Info("ReturnAndRedispatch", msg); + //} + //else + //{ + // MisDataFun.Location_MIS_MOBY_Insert(OpName, "ReturnAndRedispatch", "0"); + // MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + // MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 + // MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + // MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + // MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + //} + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/ToolCodeScanOver.cs b/MisDataFunction/Function1054/OpcServer/ToolCodeScanOver.cs new file mode 100644 index 0000000..42a2b01 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/ToolCodeScanOver.cs @@ -0,0 +1,102 @@ +using System; +using MesServerWork; +using WebApi; +using MisDataSaveDate.MOM; +using System.Linq; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 器具码扫描完毕 + /// + /// + private void ToolCodeScanOver(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + // 记录器具码扫描完毕状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "ToolCodeScanOver", "1"); + + // 获取器具号(318) + string containerNo = MIS_BASE.ReadPLC(318, OpName).ToString(); + + // 记录器具号 + if (!string.IsNullOrEmpty(containerNo)) + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "器具号", containerNo); + } + + // 调用器具信息查询接口 + DeviceInfoResponse deviceInfoResult = CALL_Inerface_DataHandle.CALL_Inerface_DeviceInfoQuery(OpName, containerNo); + + // 处理器具信息查询结果 + bool isValid = true; + string validationMsg = ""; + + //if (deviceInfoResult != null && deviceInfoResult.code == 200 && deviceInfoResult.data != null) + //{ + // isValid = true; + + // if (deviceInfoResult.data.businessdata != null && deviceInfoResult.data.businessdata.Count > 0) + // { + // var firstMaterial = deviceInfoResult.data.businessdata.First(); + // MisDataFun.Location_MIS_MOBY_Insert(OpName, "物料编号", firstMaterial.sku); + // MisDataFun.Location_MIS_MOBY_Insert(OpName, "批次号", firstMaterial.batchno); + // MisDataFun.Location_MIS_MOBY_Insert(OpName, "数量", firstMaterial.qty); + + // validationMsg = $"器具验证成功,物料编号:{firstMaterial.sku}"; + // } + + // // 调用物料配送确认接口 + // CALL_Inerface_DataHandle.CALL_Inerface_MaterialConfirm(OpName, containerNo); + //} + //else + //{ + // // 器具信息查询失败 + // isValid = false; + // validationMsg = deviceInfoResult?.message ?? "器具信息查询失败"; + //} + bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_MaterialConfirm(OpName, containerNo); + + // 根据校验结果写入验证结果 + // 送料信息验证结果(305):1 合格 2 不合格 + MIS_BASE.WritePLC(305, OpName, isOk ? "1" : "2"); + + // 送料信息验证完成(304) + MIS_BASE.WritePLC(304, OpName, true); + + // 更新验证状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "送料验证结果", isOk ? "1" : "2"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "当前状态", validationMsg); + + // 发送消息通知 + string msg = $"【{OpName}】器具码扫描完毕,器具号:{containerNo},{validationMsg} 验证结果{isOk.ToString()}"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("ToolCodeScanOver", msg); + } + else + { + // 清除验证完成信号 + MIS_BASE.WritePLC(305, OpName, "0"); + MIS_BASE.WritePLC(304, OpName, false); + + // 记录器具码扫描完毕状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "ToolCodeScanOver", "0"); + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/TransferSequence.cs b/MisDataFunction/Function1054/OpcServer/TransferSequence.cs new file mode 100644 index 0000000..5ac5b09 --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/TransferSequence.cs @@ -0,0 +1,63 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 转序操作 + /// + /// + private void TransferSequence(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + + if (tagValue == 1) + { + //// 记录转序请求状态 + //MisDataFun.Location_MIS_MOBY_Insert(OpName, "TransferSequence", "1"); + //MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "4"); + + //// 调用转序接口 + //// deliveryType: 1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + //bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, "4"); + //if (isOk) + //{ + // msg = $"【{OpName}】转序操作成功"; + // MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + //} + //else + //{ + // msg = $"【{OpName}】转序操作失败"; + // MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + //} + + //SendMessage.AsyncSendMessage_Notice(OpName, msg); + //MyLog4Net.MyLogHelper.Info("TransferSequence", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "TransferSequence", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 器具放置完毕 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/UnloadEmptyTray.cs b/MisDataFunction/Function1054/OpcServer/UnloadEmptyTray.cs new file mode 100644 index 0000000..302c03f --- /dev/null +++ b/MisDataFunction/Function1054/OpcServer/UnloadEmptyTray.cs @@ -0,0 +1,63 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using WebApi; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 下空托盘操作 + /// + /// + private void UnloadEmptyTray(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + string msg; + + if (tagValue == 1) + { + // 记录下空托盘请求状态 + MisDataFun.Location_MIS_MOBY_Insert(OpName, "UnloadEmptyTray", "1"); + MisDataFun.Location_MIS_MOBY_Insert(OpName, "配送类型", "5"); + + // 调用下空托盘接口 + // deliveryType: 1退托盘,2叫料,3送料,4转序,5下空,6上空,7点对点 + bool isOk = CALL_Inerface_DataHandle.CALL_Inerface_CallMaterial(OpName, "5"); + if (isOk) + { + msg = $"【{OpName}】下空托盘操作成功"; + MIS_BASE.WritePLC(306, OpName, 1); // 任务状态反馈 + } + else + { + msg = $"【{OpName}】下空托盘操作失败"; + MIS_BASE.WritePLC(306, OpName, 2); // 任务状态反馈 + } + + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Info("UnloadEmptyTray", msg); + } + else + { + MisDataFun.Location_MIS_MOBY_Insert(OpName, "UnloadEmptyTray", "0"); + MIS_BASE.WritePLC(301, OpName, false); // 请求进入 + MIS_BASE.WritePLC(302, OpName, false); // 托盘到位 + MIS_BASE.WritePLC(303, OpName, false); // AGV已离开 + MIS_BASE.WritePLC(305, OpName, "0"); // 比对结果 + MIS_BASE.WritePLC(304, OpName, false); // 比对完成 + MIS_BASE.WritePLC(306, OpName, 0); // 任务状态反馈 + } + } + catch (Exception err) + { + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err); + } + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1054/OpcServer/vssver2.scc b/MisDataFunction/Function1054/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1054/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1054/Properties/AssemblyInfo.cs b/MisDataFunction/Function1054/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1054/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1054/Properties/vssver2.scc b/MisDataFunction/Function1054/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1054/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1054/app.config b/MisDataFunction/Function1054/app.config new file mode 100644 index 0000000..92624b0 --- /dev/null +++ b/MisDataFunction/Function1054/app.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1054/mssccprj.scc b/MisDataFunction/Function1054/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1054/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1054/packages.config b/MisDataFunction/Function1054/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1054/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1054/vssver2.scc b/MisDataFunction/Function1054/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1054/vssver2.scc differ diff --git a/MisDataFunction/Function1055/DataAccess/DataAccess.cs b/MisDataFunction/Function1055/DataAccess/DataAccess.cs new file mode 100644 index 0000000..68cdca4 --- /dev/null +++ b/MisDataFunction/Function1055/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1055/DataAccess/vssver2.scc b/MisDataFunction/Function1055/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1055/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1055/Db.cs b/MisDataFunction/Function1055/Db.cs new file mode 100644 index 0000000..03abc44 --- /dev/null +++ b/MisDataFunction/Function1055/Db.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; +using System.Net.NetworkInformation; + +namespace MesServerFunctions +{ + public class Db + { + public static bool OP051_OP050_NeedWork(string EngineID, string opName,string orderForm, out int MatchResult) + { + DataTable dt = new DataTable(); + MatchResult = 0; + string produceName = "合力_OP050前停判断_下工位是否需要工作"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["是否需要工作"]); + return true; + } + } + return false; + } + public static bool OP051_OP050_NeedWork_Save(string EngineID, int MatchResult) + { + + string produceName = "合力_OP050是否需要工作_插入"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否需要工作", MatchResult); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + public static bool OPA90_TO_OP50_CheckTwoFinish(out int MainLineAllowWork) + { + DataTable dt; + MainLineAllowWork = 2; + string produceName = "合力_OP050是否允许工作_判断"; + SqlParameter[] thisParms = new SqlParameter[0]; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MainLineAllowWork = Convert.ToInt32(dt.Rows[0]["是否允许工作"]); + return true; + } + } + return false; + } + } +} diff --git a/MisDataFunction/Function1055/Function02.csproj.vspscc b/MisDataFunction/Function1055/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1055/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1055/Function1055.csproj b/MisDataFunction/Function1055/Function1055.csproj new file mode 100644 index 0000000..9850355 --- /dev/null +++ b/MisDataFunction/Function1055/Function1055.csproj @@ -0,0 +1,169 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {86DF6A20-91FC-4B62-AABF-116F933E31AA} + Library + Properties + Function1055 + Function1055 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1055/MesServerFunction/Fun_1055.cs b/MisDataFunction/Function1055/MesServerFunction/Fun_1055.cs new file mode 100644 index 0000000..bd3e090 --- /dev/null +++ b/MisDataFunction/Function1055/MesServerFunction/Fun_1055.cs @@ -0,0 +1,242 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //PLC 工位合格标志 + case "21": + fun_IsOk(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + //MES 将MES传递的数据回传到这个变量,如果是人为修改的,也需要更新到这个变量 (DBX589 37) + case "37": + MIS_BASE.WritePLC(77, m_OpName, m_Value); // 回写到MES托盘状态 + MIS_BASE.Write_FixAllow(m_OpName, true); // 允许工作 + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + /// + /// 工位是否合格 + /// + /// + /// + public void fun_IsOk(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(IsOk, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + + } +} diff --git a/MisDataFunction/Function1055/MesServerFunction/vssver2.scc b/MisDataFunction/Function1055/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1055/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1055/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1055/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..ab76f41 --- /dev/null +++ b/MisDataFunction/Function1055/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,120 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + //MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + //MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + //SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + //SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + // 暂时先屏蔽掉 + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + //return; + } + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + //MIS_BASE.Read_TagTypeID(201, OpName, out string EngineTypeID_QiaoKe); + Db.OP051_OP050_NeedWork(EngineID, OpName, OrderForm, out int MatchResult); + + if (MatchResult == 2) // 不匹配 没有需要装配的轮毂了 + { + MIS_BASE.Write_Match(OpName, false);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, false);// 匹配完成 + MIS_BASE.WritePLC(77, OpName, "2"); ;// 托盘是否需要工作 1:需要工作 2:不需要工作 + + } + else if (MatchResult == 1) //匹配 有需要装配的轮毂 + { + MIS_BASE.Write_Match(OpName, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + MIS_BASE.WritePLC(77, OpName, "1");// 托盘是否需要工作 1:需要工作 2:不需要工作 + MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + } + else + { + MIS_BASE.WritePLC(29, OpName, true); // 开始等待 通知A60 保存完成时更新下等待状态与匹配状态 + } + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1055/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1055/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1055/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1055/Methods/UDP.Send.cs b/MisDataFunction/Function1055/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1055/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1055/Methods/vssver2.scc b/MisDataFunction/Function1055/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1055/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1055/OpcServer/Barcode.cs b/MisDataFunction/Function1055/OpcServer/Barcode.cs new file mode 100644 index 0000000..1f9ea05 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/Barcode.cs @@ -0,0 +1,90 @@ +using System; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1055/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1055/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..06e6b33 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1055/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..59d2445 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/EngineGetOver.cs @@ -0,0 +1,79 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + //判断该订单数据是否已经工作过,有的话则在WEB跳出弹窗选择 并同时禁止工作 + //DataTable dt2 = BaseDataSystemMES.EngineIsTwoWork(OpName, OrderForm, EngineID); + //if (dt2.Rows[0]["result"].ToString() == "1") //已完成 + //{ + // //不允许工作 + // MIS_BASE.Write_FixAllow(OpName, false); + // //通知WEB校验重新工作还是跳过 点重新工作给允许工作,点跳过给工作完成 + // string message = "MES|Engine_Is_TwoWork|" + OpName + "|1"; + // SendMessage.AsyncSendMessage(message); + //} + //else + //{ + // EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + //} + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + } +} diff --git a/MisDataFunction/Function1055/OpcServer/FalseGO.cs b/MisDataFunction/Function1055/OpcServer/FalseGO.cs new file mode 100644 index 0000000..14b5771 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/FalseGO.cs @@ -0,0 +1,46 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //不合格放行信号 + //MIS_BASE.Write_FalseGO(OpName, true); + //总合格标志2(不合格) + + BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/HeartBeat.cs b/MisDataFunction/Function1055/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/MesRead.cs b/MisDataFunction/Function1055/OpcServer/MesRead.cs new file mode 100644 index 0000000..5fe6452 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/MesRead.cs @@ -0,0 +1,77 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + string NeedWork; + + if (tagValue == 1) + { + // 记录050前停工位的是否需要工作 + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.Read_TagTypeID(37, OpName, out NeedWork); + Db.OP051_OP050_NeedWork_Save(EngineID, Convert.ToInt32(NeedWork)); + + int qualityMask; + // 保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + // 保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + + // 测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + // 推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //统计在线产量,在线节拍 + //SendMessage.SendActuallyCount(OpName, tagValue); + var result = MesFunctions.EnginePart_OutStation(OpName, EngineID, qualityMask); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/MesReadOver.cs b/MisDataFunction/Function1055/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1055/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..63c11b3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/MesSaveNowData.cs @@ -0,0 +1,40 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Net.Mime.MediaTypeNames; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(OpName); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + OpName + "|" + message); + //SendMessageFun.SendMessageMESToWEB("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/WebSubmit.cs b/MisDataFunction/Function1055/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..d7ca28c --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/WebSubmit.cs @@ -0,0 +1,304 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + return; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件) + //工作完成 + EngineTypeGetOver_PLC_Work_Skip(OpName); + break; + case "twoWork"://重新工作工件重新工作(重新工作工件) + //允许工作 + EngineTypeGetOver_PLC_Work_two(OpName); + break; + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + Sendmessage("13", "1111", Opname); + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + if (S_EngineGetOver == true) + { + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("2", "1111", Opname); + SendMessage.ShowMoby(Opname); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(Opname); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + Opname + "|" + message); + } + InitAlarm(Opname); + } + + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/WorkIsOk.cs b/MisDataFunction/Function1055/OpcServer/WorkIsOk.cs new file mode 100644 index 0000000..08819e3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/WorkIsOk.cs @@ -0,0 +1,45 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工位合格标志 + /// + /// + /// + private void IsOk(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + //判断是否合格 + if (qualityMask == 1) + { + qualityMask = 1; + } else { + qualityMask = 0; + } + //通知WEB修改状态 + string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString(); + SendMessage.AsyncSendMessage(message); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/WorkStart.cs b/MisDataFunction/Function1055/OpcServer/WorkStart.cs new file mode 100644 index 0000000..a0905d5 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/WorkStart.cs @@ -0,0 +1,53 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStart, tagValue.ToString()); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + Thread.Sleep(500); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + MIS_BASE.Write_MatchingCompleted(OpName, false);// 匹配完成 + MIS_BASE.Write_Match(OpName, false);// 匹配结果 + MIS_BASE.WritePLC(77, OpName, "0"); ;// 托盘是否需要工作 1:需要工作 2:不需要工作 + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1055/OpcServer/vssver2.scc b/MisDataFunction/Function1055/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1055/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1055/Properties/AssemblyInfo.cs b/MisDataFunction/Function1055/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1055/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1055/Properties/vssver2.scc b/MisDataFunction/Function1055/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1055/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1055/app.config b/MisDataFunction/Function1055/app.config new file mode 100644 index 0000000..b4c4daf --- /dev/null +++ b/MisDataFunction/Function1055/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1055/mssccprj.scc b/MisDataFunction/Function1055/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1055/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1055/packages.config b/MisDataFunction/Function1055/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1055/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1055/vssver2.scc b/MisDataFunction/Function1055/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1055/vssver2.scc differ diff --git a/MisDataFunction/Function1056/DataAccess/DataAccess.cs b/MisDataFunction/Function1056/DataAccess/DataAccess.cs new file mode 100644 index 0000000..68cdca4 --- /dev/null +++ b/MisDataFunction/Function1056/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1056/DataAccess/vssver2.scc b/MisDataFunction/Function1056/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1056/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1056/Db.cs b/MisDataFunction/Function1056/Db.cs new file mode 100644 index 0000000..23ab541 --- /dev/null +++ b/MisDataFunction/Function1056/Db.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 合力_转线_A92判断工件状态 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OPA92_EngineGetOverCheckWorkType(string EngineID, out int MatchResult, out string MatchResultStr) + { + DataTable dt = new DataTable(); + MatchResult = 2;// 默认是报警 程序出错 + MatchResultStr = "默认是报警 程序出错";// 默认是报警 程序出错 + string produceName = "合力_转线_A92判断工件状态"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@轮毂总成号", EngineID); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["result"]); + MatchResultStr = dt.Rows[0]["msg"].ToString(); + return true; + } + } + return false; + } + + /// + /// 合力_转线_删除记录数据 同时保存 轮毂 桥壳 关系 + /// + /// + public static void OPA92_DeleteLineData(string EngineID_QiaoKe) + { + DataTable dt = new DataTable(); + string produceName = "合力_转线_删除记录数据"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID_QiaoKe); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + } + } +} diff --git a/MisDataFunction/Function1056/Function02.csproj.vspscc b/MisDataFunction/Function1056/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1056/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1056/Function1056.csproj b/MisDataFunction/Function1056/Function1056.csproj new file mode 100644 index 0000000..c153744 --- /dev/null +++ b/MisDataFunction/Function1056/Function1056.csproj @@ -0,0 +1,169 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {191419A0-CCEB-4816-BEDC-C39ABF2981A7} + Library + Properties + Function1056 + Function1056 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1056/MesServerFunction/Fun_1056.cs b/MisDataFunction/Function1056/MesServerFunction/Fun_1056.cs new file mode 100644 index 0000000..a6ed400 --- /dev/null +++ b/MisDataFunction/Function1056/MesServerFunction/Fun_1056.cs @@ -0,0 +1,223 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + // case "MES": + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "15": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + public void fun_WritePLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WritePLC, e); + } + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + } +} diff --git a/MisDataFunction/Function1056/MesServerFunction/vssver2.scc b/MisDataFunction/Function1056/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1056/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1056/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1056/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..bd32165 --- /dev/null +++ b/MisDataFunction/Function1056/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,109 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + DataTable dt; + dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + + MIS_BASE.Write_FixAllow(OpName, true); + + // 当A92 到位时表示当前一定是第二个件 先判断当前工件是否为已匹配的第二个工件 是的话是工作,不是报警 + Db.OPA92_EngineGetOverCheckWorkType(EngineID, out int MatchResult, out string MatchResultStr); + if (MatchResult == 1) + { + // 轮毂线 + MIS_BASE.Write_Match(OpName, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + + return; + } + else + { + // 将根据轮毂号 工位号 时间 报错内容 存储到数据库中供查询 + // 匹配结果不成功 + MIS_BASE.Write_Match(OpName, false);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + return; + } + + //if (MES_QualityMask == 2) + //{ + // //工作完成 + // //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + // //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + // //return; + //} + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + ////第四步,获取是否允许工作 + //BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + ////暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + //if (IsAllowWork == 1) + //{ + // //通知PLC允许工作,允许工作在保存完成时清空 + // MIS_BASE.Write_FixAllow(OpName, true); + //} + //else + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + //} + + + + } + + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1056/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1056/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1056/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1056/Methods/UDP.Send.cs b/MisDataFunction/Function1056/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1056/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1056/Methods/vssver2.scc b/MisDataFunction/Function1056/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1056/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1056/OpcServer/Barcode.cs b/MisDataFunction/Function1056/OpcServer/Barcode.cs new file mode 100644 index 0000000..10a0ee6 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/Barcode.cs @@ -0,0 +1,98 @@ +using System; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, OpName); + // return; + //} + //通知PLC允许工作,允许工作在保存完成时清空 + + //将机型信息传递给刷写站工控机 + + + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1056/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..06e6b33 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1056/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..c5b6d6f --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/EngineGetOver.cs @@ -0,0 +1,67 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/FalseGO.cs b/MisDataFunction/Function1056/OpcServer/FalseGO.cs new file mode 100644 index 0000000..4ad2665 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/FalseGO.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/HeartBeat.cs b/MisDataFunction/Function1056/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/MesRead.cs b/MisDataFunction/Function1056/OpcServer/MesRead.cs new file mode 100644 index 0000000..a577ea9 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/MesRead.cs @@ -0,0 +1,92 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + + //保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + //推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + + + //MIS_BASE.Write_FixAllow(OpName, false); + + //MIS_BASE.Write_ConfirmOkGo(OpName, false); + + + //MIS_BASE.Write_FixOver(OpName, false); + //MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + + //统计在线产量,在线节拍 + // SendMessage.SendActuallyCount(OpName, tagValue); + + // 判断050 工位是否有传递机型 有的话 允许050工作 同时删除记录表中轮毂号 + MIS_BASE.Read_EngineGetOver_PLC("OP050", out bool EngineGetOver_PLC_NextWorkStep); + if (EngineGetOver_PLC_NextWorkStep) + { + MIS_BASE.Write_FixAllow("OP050", true); + // 查询050 工位当前到位的工件编号 + MIS_BASE.Read_EngineID("OP050", out string OP050_EngineID); + // 绑定关系 同时 删除记录 + Db.OPA92_DeleteLineData(OP050_EngineID); + } + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/MesReadOver.cs b/MisDataFunction/Function1056/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1056/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..63c11b3 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/MesSaveNowData.cs @@ -0,0 +1,40 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Net.Mime.MediaTypeNames; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(OpName); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + OpName + "|" + message); + //SendMessageFun.SendMessageMESToWEB("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/WebSubmit.cs b/MisDataFunction/Function1056/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..6a088b5 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/WebSubmit.cs @@ -0,0 +1,294 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "WritePLC": + if (m_Value_length > 1) return; + fun_WritePLC(_e); + break; + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + Sendmessage("13", "1111", Opname); + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + if (S_EngineGetOver == true) + { + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("2", "1111", Opname); + SendMessage.ShowMoby(Opname); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(Opname); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + Opname + "|" + message); + } + InitAlarm(Opname); + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/WorkStart.cs b/MisDataFunction/Function1056/OpcServer/WorkStart.cs new file mode 100644 index 0000000..da1ef0a --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/WorkStart.cs @@ -0,0 +1,46 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + //后加,清空信号 + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/WritePLC.cs b/MisDataFunction/Function1056/OpcServer/WritePLC.cs new file mode 100644 index 0000000..83ede7c --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/WritePLC.cs @@ -0,0 +1,41 @@ +using System; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void WritePLC(object e) + { + + { + try + { + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/vssver2.scc b/MisDataFunction/Function1056/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1056/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1056/Properties/AssemblyInfo.cs b/MisDataFunction/Function1056/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1056/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1056/Properties/vssver2.scc b/MisDataFunction/Function1056/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1056/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1056/app.config b/MisDataFunction/Function1056/app.config new file mode 100644 index 0000000..b4c4daf --- /dev/null +++ b/MisDataFunction/Function1056/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1056/mssccprj.scc b/MisDataFunction/Function1056/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1056/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1056/packages.config b/MisDataFunction/Function1056/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1056/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1056/vssver2.scc b/MisDataFunction/Function1056/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1056/vssver2.scc differ diff --git a/MisDataFunction/Function1057/DataAccess/DataAccess.cs b/MisDataFunction/Function1057/DataAccess/DataAccess.cs new file mode 100644 index 0000000..574d619 --- /dev/null +++ b/MisDataFunction/Function1057/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1052 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1057/DataAccess/vssver2.scc b/MisDataFunction/Function1057/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1057/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1057/Db.cs b/MisDataFunction/Function1057/Db.cs new file mode 100644 index 0000000..0e1fdc9 --- /dev/null +++ b/MisDataFunction/Function1057/Db.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 合力_OPA90是否允许工作_判断 如果允许工作则将两个轮毂状态设为待匹配 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OP50_OPA90_MatchResult(int EngineTypeID, int EngineTypeID_QiaoKe, string EngineID, string OrderForm, out int MatchResult, out string MatchResultStr) + { + DataTable dt = new DataTable(); + MatchResult = 3;// 默认是报警 程序出错 + MatchResultStr = "默认是报警 程序出错";// 默认是报警 程序出错 + string produceName = "合力_OPA90是否允许工作_判断"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@轮毂机型", EngineTypeID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@轮毂总成号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@桥壳_机型", EngineTypeID_QiaoKe); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@订单号", OrderForm); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["最终结果"]); + MatchResultStr = dt.Rows[0]["最终结果说明"].ToString(); + return true; + } + } + return false; + } + + public static bool OP051_OP050_NeedWork(string EngineID, string opName, string orderForm, out int MatchResult) + { + DataTable dt = new DataTable(); + MatchResult = 0; + string produceName = "合力_OP050前停判断_下工位是否需要工作"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["是否需要工作"]); + return true; + } + } + return false; + } + } +} diff --git a/MisDataFunction/Function1057/Function02.csproj.vspscc b/MisDataFunction/Function1057/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1057/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1057/Function1057.csproj b/MisDataFunction/Function1057/Function1057.csproj new file mode 100644 index 0000000..f4ad2c8 --- /dev/null +++ b/MisDataFunction/Function1057/Function1057.csproj @@ -0,0 +1,167 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {9377BB04-B518-4E77-8B90-E56FE7980204} + Library + Properties + Function1057 + Function1057 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1057/MesServerFunction/Fun_1057.cs b/MisDataFunction/Function1057/MesServerFunction/Fun_1057.cs new file mode 100644 index 0000000..6a943b5 --- /dev/null +++ b/MisDataFunction/Function1057/MesServerFunction/Fun_1057.cs @@ -0,0 +1,206 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + } +} diff --git a/MisDataFunction/Function1057/MesServerFunction/vssver2.scc b/MisDataFunction/Function1057/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1057/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1057/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1057/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..edaa222 --- /dev/null +++ b/MisDataFunction/Function1057/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,98 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + DataTable dt; + dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + //提示机型发生变化 + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + //return; + } + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1057/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1057/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1057/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1057/Methods/UDP.Send.cs b/MisDataFunction/Function1057/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1057/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1057/Methods/vssver2.scc b/MisDataFunction/Function1057/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1057/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1057/OpcServer/Barcode.cs b/MisDataFunction/Function1057/OpcServer/Barcode.cs new file mode 100644 index 0000000..d9f59f8 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/Barcode.cs @@ -0,0 +1,228 @@ +using System; +using System.Threading; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + int Recipe1; + int Recipe2; + + bool IsNotRepeatedNumber = false; + //1:获得申请上线信息后,扫描条码才处理业务 + bool ispartload; + //(115) + int PTO; + //(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int NgearSwitch; + //(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int RgearSwitch; + //(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + int SpeedSensor; + //(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + string PartTypeMid; + //(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int Tcu_V; + + //判断是否开启线外上线 + if (!Convert.ToBoolean(MIS_BASE.ReadPLC(64, OpName))) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "若转线上线工件请在系统选择转线工件选项"); + return; + } + + //判断工件是否到位 + MIS_BASE.Read_WorkStart(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + return; + } + //判断设备是否申请上线 + MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + return; + } + // 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + // 选小机型 从北汽福田BOM中选 得先维护BOM + // 变速器序列号 '1333 050 062*16012023*30000001' + + //扫描完变速器序列号条码号 true + bool isGetOver_PLC = false; + //判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_PLC); + //如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + //否则按装配物料进行验证 + if (!isGetOver_PLC) + { + + if (barcode.Split('*').Length > 2) + { + //2: 判断是否重号, 从数据库获得机型、机型代码等信息 + string partSn = barcode; + EngineID = barcode; + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + + //IsRepeatedNumber true 不重号;false 重号; + IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + if (IsNotRepeatedNumber) + { + BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + + + BaseDataSystemMES.UpLoadPTO(EngineType, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + //PTO + MIS_BASE.WritePLC(115, OpName, PTO); + //空挡开关检测 + MIS_BASE.WritePLC(95, OpName, NgearSwitch); + //倒挡开关检测 + MIS_BASE.WritePLC(96, OpName, RgearSwitch); + //里程表检测 + MIS_BASE.WritePLC(97, OpName, SpeedSensor); + //大机型扩展 + MIS_BASE.WritePLC(98, OpName, PartTypeMid); + //TCU + MIS_BASE.WritePLC(122, OpName, Tcu_V); + string tagStartAdr;//= "DB411.10"; + + // 先查询配方号 根据工位号 去moby表查配方号 + // 根据配方号 去配方表查配方数据 + // 写入配方数据 + BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + ////将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm_MES, OrderForm); + + //通知web显示 + SendMessage.ShowMoby(OpName); + //在PLC传递机型后进行允许工作 + //MIS_BASE.Write_FixAllow(OpName, true); + SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码成功,请开始工作!"); + //SendMessageFun.SendMessage("1235", "1111", OpName); + + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + //Thread.Sleep(1000); + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + } + } + else//验证物料 + { + //物料号 + { + //读取PLC的传递机型信号 + bool tagValue; + MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + if (tagValue) + { + //验证物料 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + if (!IsSuccess)//???? + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + //判断物料是否验证完成 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + if (IsSuccess) + { + if (IsAllowWork == 1) + { + //移到允许保存信号中 + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + } + + } + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1057/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1057/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..06e6b33 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1057/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..fd4ae58 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/EngineGetOver.cs @@ -0,0 +1,79 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + //判断该订单数据是否已经工作过,有的话则在WEB跳出弹窗选择 并同时禁止工作 + //DataTable dt2 = BaseDataSystemMES.EngineIsTwoWork(OpName, OrderForm, EngineID); + //if (dt2.Rows[0]["result"].ToString() == "1") //已完成 + //{ + // //不允许工作 + // MIS_BASE.Write_FixAllow(OpName, false); + // //通知WEB校验重新工作还是跳过 点重新工作给允许工作,点跳过给工作完成 + // string message = "MES|Engine_Is_TwoWork|" + OpName + "|1"; + // SendMessage.AsyncSendMessage(message); + //} + //else + //{ + // EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + //} + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + + } +} diff --git a/MisDataFunction/Function1057/OpcServer/FalseGO.cs b/MisDataFunction/Function1057/OpcServer/FalseGO.cs new file mode 100644 index 0000000..4ad2665 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/FalseGO.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/HeartBeat.cs b/MisDataFunction/Function1057/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/MesRead.cs b/MisDataFunction/Function1057/OpcServer/MesRead.cs new file mode 100644 index 0000000..2496314 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/MesRead.cs @@ -0,0 +1,123 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + + //保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead_J07MA150(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + //推送质量数据到MES的页面d + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + string SLResult = MIS_BASE.ReadPLC(41, OpName).ToString(); //试漏结果 + int TurnLineWork = Convert.ToInt32(MIS_BASE.ReadPLC(64, OpName)); //是否转线 + // 保存150工位试漏结果 + BaseDataSystemMES.SLResult_Add( SLResult, EngineID, EngineType, EngineTypeID, TurnLineWork); + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + string awaitOpName = "OPA90"; + // 读取A90 是否在等待 + int isAwait = Convert.ToInt32(MIS_BASE.ReadPLC(29, awaitOpName)); + // 如果是OPA60 的话去再次判断工件匹配状态 + if (isAwait == 1) + { + MIS_BASE.Read_TagTypeID(201, awaitOpName, out string EngineTypeID_QiaoKe); + + string await_EngineID = MIS_BASE.ReadPLC(10, awaitOpName).ToString(); // 读取A90等待工件的工件编号 + int await_EngineTypeID = Convert.ToInt32(MIS_BASE.ReadPLC(9, awaitOpName)); // 读取A90等待工件的机型编号 + string await_OrderForm = MIS_BASE.ReadPLC(39, awaitOpName).ToString(); // 读取A90等待工件的订单号 + Db.OP50_OPA90_MatchResult(await_EngineTypeID, Convert.ToInt32(EngineTypeID_QiaoKe), await_EngineID, await_OrderForm, out int MatchResult, out string MatchResultStr); + if (MatchResult == 1) + { + // 轮毂线 + MIS_BASE.Write_Match(awaitOpName, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(awaitOpName, true);// 匹配完成 + MIS_BASE.Write_FixAllow(awaitOpName, true); // 允许工作 + MIS_BASE.WritePLC(29, awaitOpName, false); // 取消等待 + return; + } + } + + string awaitOpName2 = "OP051"; + // 读取A90 是否在等待 + int isAwait2 = Convert.ToInt32(MIS_BASE.ReadPLC(29, awaitOpName2)); + if (isAwait2 == 1 && OpName == "OPA60") + { + string await2_EngineID = MIS_BASE.ReadPLC(10, awaitOpName2).ToString(); // 读取051等待工件的工件编号 + string await2_OrderForm = MIS_BASE.ReadPLC(39, awaitOpName2).ToString(); // 读取051等待工件的订单号 + + + Db.OP051_OP050_NeedWork(await2_EngineID, awaitOpName2, await2_OrderForm, out int MatchResult); + + if (MatchResult == 1) //匹配 有需要装配的轮毂 + { + MIS_BASE.Write_Match(awaitOpName2, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(awaitOpName2, true);// 匹配完成 + MIS_BASE.WritePLC(77, awaitOpName2, "1");// 托盘是否需要工作 1:需要工作 2:不需要工作 + MIS_BASE.Write_FixAllow(awaitOpName2, true); // 允许工作 + MIS_BASE.WritePLC(29, awaitOpName2, false); // 取消等待 + } + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/MesReadOver.cs b/MisDataFunction/Function1057/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/WebSubmit.cs b/MisDataFunction/Function1057/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..fc79ae5 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/WebSubmit.cs @@ -0,0 +1,307 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "TurnLineWork"://150工位独有,转线上线标志 + SendMessage.AsyncSendMessage_Notice(OpName, "切换成功!"); + if (Convert.ToInt32(m_Value) == 1) //(0 正常工件 ,1 转线工件) + { + //写入转线标识点 (64)501.6 + MIS_BASE.WritePLC(64, OpName, true); + } + else + { + MIS_BASE.WritePLC(64, OpName, false); + } + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + try + { + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + Sendmessage("13", "1111", Opname); + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + + if (S_EngineGetOver == true) + { + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("2", "1111", Opname); + SendMessage.ShowMoby(Opname); + } + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + InitAlarm(Opname); + } + catch (Exception err) + { + + } + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/WorkStart.cs b/MisDataFunction/Function1057/OpcServer/WorkStart.cs new file mode 100644 index 0000000..5739456 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/WorkStart.cs @@ -0,0 +1,44 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1057/OpcServer/vssver2.scc b/MisDataFunction/Function1057/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1057/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1057/Properties/AssemblyInfo.cs b/MisDataFunction/Function1057/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1057/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1057/Properties/vssver2.scc b/MisDataFunction/Function1057/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1057/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1057/app.config b/MisDataFunction/Function1057/app.config new file mode 100644 index 0000000..b4c4daf --- /dev/null +++ b/MisDataFunction/Function1057/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1057/mssccprj.scc b/MisDataFunction/Function1057/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1057/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1057/packages.config b/MisDataFunction/Function1057/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1057/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1057/vssver2.scc b/MisDataFunction/Function1057/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1057/vssver2.scc differ diff --git a/MisDataFunction/Function1058/DataAccess/DataAccess.cs b/MisDataFunction/Function1058/DataAccess/DataAccess.cs new file mode 100644 index 0000000..a7f91fa --- /dev/null +++ b/MisDataFunction/Function1058/DataAccess/DataAccess.cs @@ -0,0 +1,16 @@ + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1058/DataAccess/vssver2.scc b/MisDataFunction/Function1058/DataAccess/vssver2.scc new file mode 100644 index 0000000..1083b3a Binary files /dev/null and b/MisDataFunction/Function1058/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1058/Db.cs b/MisDataFunction/Function1058/Db.cs new file mode 100644 index 0000000..64286ed --- /dev/null +++ b/MisDataFunction/Function1058/Db.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 北汽福田变速器序列号总线上线_获得机型信息 + /// + /// + /// + /// + /// + /// 0 不重号;1 重号;2:失败 + /// + public static bool GetEngineType(string partSn, out int EngineTypeID, out string EngineType, out string EngineID,out int IsRepeatedNumber) + { + DataTable dt = new DataTable(); + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + IsRepeatedNumber = 2; + string produceName = "北汽福田变速器序列号总线上线_获得机型信息"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms,out dt)) + { + if(dt.Rows.Count > 0) + { + IsRepeatedNumber = Convert.ToInt32( dt.Rows[0]["IsRepeatedNumber"]); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["EngineTypeID"]); + EngineType = dt.Rows[0]["EngineType"].ToString(); + EngineID = partSn; + return true; + } + } + return false; + } + /// + /// 北汽福田变速器序列号总线上线_增加 + /// + /// + /// + /// + /// + /// + public static bool UpLoadOpNameInsert(string partSn, int EngineTypeID, string EngineType, string OpName) + { + + string produceName = "北汽福田变速器序列号总线上线_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@基本型号代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@基本型号", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + // ALTER PROCEDURE[dbo].[北汽福田变速器序列号总线上线_增加] + // @变速器序列号 nvarchar(50)='1333 050 062 0001*146012023*12345678',--'1333 050 062 0001' + //@基本型号代码 int=1, + //@基本型号 nvarchar(50)='1333 050 062 0001', + //@工位号 nvarchar(50) = 'J05PA010' + } +} diff --git a/MisDataFunction/Function1058/Function08.csproj.vspscc b/MisDataFunction/Function1058/Function08.csproj.vspscc new file mode 100644 index 0000000..82c6db2 --- /dev/null +++ b/MisDataFunction/Function1058/Function08.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function08" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1058/Function1058.csproj b/MisDataFunction/Function1058/Function1058.csproj new file mode 100644 index 0000000..f4bb711 --- /dev/null +++ b/MisDataFunction/Function1058/Function1058.csproj @@ -0,0 +1,168 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {FC07F99C-0C97-4FEF-9A0E-CA4883400464} + Library + Properties + Function1058 + Function1058 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + AnyCPU + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1058/MesServerFunction/Function1058.cs b/MisDataFunction/Function1058/MesServerFunction/Function1058.cs new file mode 100644 index 0000000..1c5713d --- /dev/null +++ b/MisDataFunction/Function1058/MesServerFunction/Function1058.cs @@ -0,0 +1,253 @@ + +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e =new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + //{ + // //lock1 = new object(); + // //lock (lock1) + // { + // switch (e.TagTypeCodeID.ToString()) + // { + // //PLC 工件到位 + // case "2": + // fun_WorkStart(e); + // break; + // //PLC 允许保存质量数据 + // case "19": + // fun_MesRead(e); + // break; + // //MES 保存数据完成 + // case "20": + // fun_MesReadOver(e); + // break; + // //PLC 传递机型 + // case "44": + // fun_EngineTypeGetOverPLC(e); + // break; + // //MES 合格放行 + // case "51": + // fun_ConfirmOkGo(e); + // break; + // //MES 不合格放行 + // case "8": + // fun_FalseGo(e); + // break; + // //MES 扫描条码 + // case "Barcode": + // fun_Barcode(e); + // break; + // //WEB 处理页面传递过来的数据 + // case "WebSubmit": + // fun_WebSubmit(e); + // break; + // } + // } + + //} + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //2.MES判断是否扫描完成 + //3.若扫描完成,则MES给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + + /// + /// 保存完成 20 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 保存完成 19 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + public int fun_SubLineLoadPartCountMatch() + { + return SubLineLoadPartCountMatch; + } + + } +} diff --git a/MisDataFunction/Function1058/MesServerFunction/vssver2.scc b/MisDataFunction/Function1058/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..775bb6c Binary files /dev/null and b/MisDataFunction/Function1058/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1058/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1058/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..5c44814 --- /dev/null +++ b/MisDataFunction/Function1058/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,288 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 分线上总线的数量 + /// + public static int SubLineLoadPartCount = 2; + /// + /// 分线上总线已经匹配的数量 + /// + public static int SubLineLoadPartCountMatch = 0; + /// + /// 正常逻辑工作 + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //初始化物料临时表 + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + BaseDataSystemMES.MesServer_Process_EngineTypeOver_BQ_FirstOP(OpName); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(OpName); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(OpName); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(OpName); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(OpName); + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + // BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + //SendMessageFun.SendMessage("123", "111", OpName); + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + // 暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + + int isRepair; + int engineTypeID; + + string engineType = ""; + string engineID = ""; + string palletCode = ""; + string orderForm = ""; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + /// + /// 正常匹配分线和总线 + /// + /// + /// 总线工件号 + /// 总线工件机型代码 + /// 总线工件机型 + private void Match(string opName, string engineID, int engineTypeID, string engineType, int PartPallet_Code) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + int engineTypeID_SubLine; + int partPallet_Code_SubLine; + int PalletInfo = 1;//总线托盘状态 + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string AlarmStr; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //第一步:获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + //第二步:获取分线传递机型信号 + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine); + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //第三步:判断合格标志 + MIS_BASE.Read_PalletInfo(opName_SubLine, out PalletInfo); + if (PalletInfo == 2) return; //若不合格则返回不进行匹配 + string OrderForm; + //第四步:获取分线的信息,匹配验证 + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm); + //判断分线数据是否合格 + //if (!BaseDataSystemMES.QulityDataVerify(opName, engineID_SubLine, out AlarmStr) && !BaseDataSystemMES.QualityVerifyStatus_Hash_Read(opName)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, opName); + // return; + //} + + if (engineTypeID_SubLine == engineTypeID) + { + BaseDataSystemMES.SubLineLoadPartCountMatch_Select(opName, out SubLineLoadPartCountMatch); + SubLineLoadPartCountMatch = SubLineLoadPartCountMatch + 1; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + if(SubLineLoadPartCountMatch== SubLineLoadPartCount) + { + MIS_BASE.Write_FixAllow(opName, true); + SubLineLoadPartCountMatch = 0; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + } + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName); + sendmessage(opName, 1, "Match");//匹配结果 + } + else + { + MIS_BASE.Write_Match(opName, false);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成//68:1、取消返修;2、匹配成功 自己监控发送 MES|MatchingCompleted + + //发送匹配完成和匹配结果信息 + SendMessageFun.AsyncSendMessage_Notice(opName,"匹配失败,工件型号不匹配!"); + SendMessageFun.SendInfomation("MatchSuccess", "0", opName); + sendmessage(opName, 0, "Match");//匹配结果 + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog("Match:" + err.ToString()); + + } + } + + + + /// + /// 强制匹配分线和总线 + /// + /// + private void ForceMatch(string opName) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + bool m_EngineGetOver_PLC; + + int engineTypeID_SubLine; + int engineTypeID; + int partPallet_Code_SubLine; + int partPallet_Code; + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string engineID; + string engineType; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine);//1:读取分线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + MIS_BASE.Read_EngineGetOver_PLC(opName, out m_EngineGetOver_PLC);//2:读取总线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC) return;//必须工件同时到位才能进行匹配 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm);//获取分线的信息 + MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out partPallet_Code, out OrderForm); + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName);//界面显示匹配成功 + + MIS_BASE.Write_FixAllow(opName, true);//允许PLC工作 + + //发送匹配完成和匹配结果信息 + sendmessage(opName, 1, "MatchingComplete");//匹配完成 + sendmessage(opName, 1, "Match");//匹配结果 + } + catch + { + + } + } + } +} diff --git a/MisDataFunction/Function1058/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1058/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..8d84430 --- /dev/null +++ b/MisDataFunction/Function1058/Methods/SubmitToMisweb.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + + // /// + // /// 批量发送WEB消息(Value为BOOL值) + // /// + // /// 消息编号组合 + // /// 消息值组合 + // /// 工位号 + // void Sendmessage(string MessageNumm,string Value, string OpName) + //{ + // for (int i=0;i + // /// 选择发送给WEB的消息 + // /// + // /// 消息类型 + // /// 消息工位 + //void Sendmessage(char Num,string Value, string OpName) + //{ + // string SendMessage; + // switch (Num) + // { + // case '1': + // //1(直接在界面通过选择机型确认工序内容) + // SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '2': + // //2显示物料 + // SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '3': + + // //3显示操作指导图片 + // SendMessage = "MES|PicShow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '4': + // //3显示操作指导图片 + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '5': + // SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '6': + // SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + // AsyncSendMessage(SendMessage); + // break; + // case '7': + // SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '8': + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '9': + // SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'a': + // SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'b': + // SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'c': + // SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // } + //} + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + //void SendInfomation(string Command, string Value, string OpName) + //{ + + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + //} + + + ///// + ///// 发送在线产量、在线节拍 + ///// + ///// + ///// + //private void SendActuallyCount(string OpName, int tagValue) + //{ + // //当工件离开时,更新在线产量、在线节拍 + // if (tagValue == 0) + // { + // try + // { + // int opNameCount = 0;//在线产量 + // int opNameCountTime = 0;//在线节拍 + + // BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + // SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + // } + // } + //} + + + } +} diff --git a/MisDataFunction/Function1058/Methods/UDP.Send.cs b/MisDataFunction/Function1058/Methods/UDP.Send.cs new file mode 100644 index 0000000..26acece --- /dev/null +++ b/MisDataFunction/Function1058/Methods/UDP.Send.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MesServerWork; +//using BasicData; +using System.Collections; +using bizFacade; +//using SystemFramework; +using System.Data; +using System.Threading; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + ///// + ///// 发送信息到MES通讯服务器或者其他的 + ///// + ///// + //private void AsyncSendMessage(string Message) + //{ + // MIS_BASE.asyncSendMessage(Message); + //} + + /// + /// 发送提示消息 + /// + /// + //private void AsyncSendMessage_Notice(string opname, string notice) + //{ + // //通知Web界面 + // BaseDataSystemMES.Web_Notice_Insert(opname, notice); + // string SendMessage = "MES|Notice|" + opname + "|" + "1"; + // MIS_BASE.asyncSendMessage(SendMessage); + //} + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + + } +} diff --git a/MisDataFunction/Function1058/Methods/vssver2.scc b/MisDataFunction/Function1058/Methods/vssver2.scc new file mode 100644 index 0000000..7b1a830 Binary files /dev/null and b/MisDataFunction/Function1058/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1058/OpcServer/Barcode.cs b/MisDataFunction/Function1058/OpcServer/Barcode.cs new file mode 100644 index 0000000..f70a8bc --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/Barcode.cs @@ -0,0 +1,220 @@ +using System; +using System.Threading; +using System.Xml.Linq; +using bizFacade; + +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcode = new object(); + + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + lock(lockBarcode) + { + try + { + + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + int Recipe1; + int Recipe2; + + bool IsNotRepeatedNumber = false; + //1:获得申请上线信息后,扫描条码才处理业务 + bool ispartload; + //(115) + int PTO; + //(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int NgearSwitch; + //(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int RgearSwitch; + //(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + int SpeedSensor; + //(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + string PartTypeMid; + //(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int Tcu_V; + //判断工件是否到位 + MIS_BASE.Read_WorkStart(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + return; + } + //判断设备是否申请上线 + MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + return; + } + // 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + // 选小机型 从北汽福田BOM中选 得先维护BOM + // 变速器序列号 '1333 050 062*16012023*30000001' + + //扫描完变速器序列号条码号 true + bool isGetOver_MES = false; + //判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + //MIS_BASE.Read_EngineTypeGetOver_MES(OpName, out isGetOver_MES); + MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_MES); + //如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + //否则按装配物料进行验证 + if (!isGetOver_MES) + { + + if (barcode.Split(';').Length > 2 || barcode.Split('*').Length > 2) + { + + string partSn = barcode; + EngineID = barcode; + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + SendMessage.ShowMoby(OpName); + + //2: 判断是否重号 + //IsRepeatedNumber true 不重号;false 重号; + IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + if (IsNotRepeatedNumber) + { + // 从数据库获得机型、机型代码等信息 + BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + // 从数据库获得PTO等信息 + BaseDataSystemMES.UpLoadPTO(partSn, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + //PTO + MIS_BASE.WritePLC(115, OpName, PTO); + //空挡开关检测 + MIS_BASE.WritePLC(95, OpName, NgearSwitch); + //倒挡开关检测 + MIS_BASE.WritePLC(96, OpName, RgearSwitch); + //里程表检测 + MIS_BASE.WritePLC(97, OpName, SpeedSensor); + //大机型扩展 + MIS_BASE.WritePLC(98, OpName, PartTypeMid); + //TCU + MIS_BASE.WritePLC(122, OpName, Tcu_V); + // 先查询配方号 根据工位号 去moby表查配方号 + // 根据配方号 去配方表查配方数据 写入配方数据 + string tagStartAdr;//= "DB411.10"; + BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + // 将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + // 写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + SendMessage.ShowMoby(OpName); + + SendMessageFun.AsyncSendMessage_Notice(OpName, "总成码扫码完成,请扫描后壳码!"); + + + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + + //Thread.Sleep(1000); + //// 临时增加 清除MES的传递机型 + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + } + } + else//验证物料 + { + //物料号 + { + //读取PLC的传递机型信号 + bool tagValue; + MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + if (tagValue) + { + //验证物料 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + if (!IsSuccess)//???? + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + //判断物料是否验证完成 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + if (IsSuccess) + { + if (IsAllowWork == 1) + { + //移到允许保存信号中 + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + SendMessageFun.SendMessage("245", "111", OpName); + + // 写入到数据库的[北汽福田工位状态监控MOBY]表中 + SendMessage.ShowMoby(OpName); + + SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码完成,请开始工作!"); + + //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + } + + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:Barcode"); + } + } + + } + + + } +} diff --git a/MisDataFunction/Function1058/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1058/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..a978c1f --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,35 @@ +using System; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList","1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1058/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..db8fde9 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/EngineGetOver.cs @@ -0,0 +1,98 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcodeEngineTypeGetOver = new object(); + + + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + lock(lockBarcodeEngineTypeGetOver) + { + + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + SendMessageFun.SendInfomation("AskReset", "1", OpName); + return; + } + string OrderForm; + string OrderForm_MES; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + //判断PLC机型与MES机型是否一致 + if (EngineTypeID_MES == EngineTypeID & EngineID_MES == EngineID & EngineType_MES == EngineType) + { + // 如果机型改变的话 提示机型发生变化 + DataTable dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + return; + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "码块RFID机型与MES机型不匹配!"); + } + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + } + + + + } +} diff --git a/MisDataFunction/Function1058/OpcServer/FalseGO.cs b/MisDataFunction/Function1058/OpcServer/FalseGO.cs new file mode 100644 index 0000000..54c73c7 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/FalseGO.cs @@ -0,0 +1,37 @@ +using System; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + + /// + /// 返修放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList", "1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/HeartBeat.cs b/MisDataFunction/Function1058/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/MesRead.cs b/MisDataFunction/Function1058/OpcServer/MesRead.cs new file mode 100644 index 0000000..4705f0a --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/MesRead.cs @@ -0,0 +1,85 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockMesRead = new object (); + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + lock(lockMesRead) + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + if (Db.UpLoadOpNameInsert(EngineID, EngineTypeID, EngineType, OpName)) + { + //保存质量数据 + int qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //推送质量数据到MES的页面 + MIS_BASE.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, tagValue); + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + + //MisDataSaveDate. + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + SendMessage.SendActuallyCount(OpName, tagValue);//统计在线产量,在线节拍 + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!"); + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + + } + + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/MesReadOver.cs b/MisDataFunction/Function1058/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..9b637f2 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/MesReadOver.cs @@ -0,0 +1,37 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + try + { + //DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + + // BaseDataSystemMES.Material_Insert(OpName, tagValue); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/WebSubmit.cs b/MisDataFunction/Function1058/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..4bfd077 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/WebSubmit.cs @@ -0,0 +1,342 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string opName_SubLine = ""; + string engineID = "";//工件信息 + string[] dataArray = Content.Split('|'); + + if (dataArray.Length != 2) + return; + + + string m_Command = dataArray[0].ToString();//消息类型 + string m_Value = dataArray[1].ToString();//消息参数 + string[] m_Value_array = m_Value.Split('&');//消息参数数量 + int m_Value_length = m_Value_array.Length; //消息参数长度 + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //修改托盘状态 + + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + + break; + case "FixAllow"://重新拧紧 + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + MIS_BASE.Write_RepairUpline_MES(opName_SubLine, true); + //MIS_BASE.Write_PalletInfo(opName_SubLine, 4); + //MIS_BASE.Write_UpdatePalletOK(opName_SubLine, true); + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + } + else if (Convert.ToInt32(m_Value) == 0) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + break; + //强制匹配 + case "ForceMatch": + if (Convert.ToInt32(m_Value) == 1) + { + ForceMatch(OpName); + } + break; + case "PalletGO": + + if (Convert.ToInt32(m_Value) == 1) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + } + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + fun_EngineTypeGetOverPLC(_e); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WebSubmit"); + } + } + + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + bool S_WorkOn;//申请上线 DBX0.1 + bool S_WorkStart;//工件到位 DBX0.1 + bool S_EngineGetOver;//传递机型 DBX0.4 + bool S_FixAllow;//允许工作 DBX3.1 + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + + int IsCompleted = 0; + int S_Match = 0; + int PalletInfo_SubLine = 0;//显示分线托盘状态 + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "WorkStart_Subline"); + } + + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "EngineTypeGetOverMES_Subline"); + + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_EngineGetOver), "EngineTypeGetOverMES_Subline"); + } + + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + + //MIS_BASE.Read_MatchingCompleted(Opname, out IsCompleted); //DBX1.3 是否匹配 + //MIS_BASE.Read_Match(Opname, out S_Match); //DBX1.4 匹配结果 + + //if (IsCompleted == 1 && S_Match == 1)//发送匹配完成和匹配结果信息 + //{ + // SendMessageFun.SendInfomation("MatchingCompleted", "1", Opname); + // SendMessageFun.SendInfomation("Match", "1", Opname); + // SendMessageFun.SendInfomation("MatchSuccess", "1", Opname);//界面显示匹配成功 + //} + //else if (IsCompleted == 1 && S_Match == 0) + //{ + // SendMessageFun.SendInfomation("MatchSuccess", "0", Opname);//界面显示匹配失败 + //} + + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + //string Opname_SubLine = ""; + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(Opname)) + //{ + // Opname_SubLine = MIS_BASE.hashtable_OpNameRepair[Opname].ToString(); + //} + //if (Opname_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_PalletInfo(Opname, out PalletInfo_SubLine); + //sendmessage(Opname, PalletInfo_SubLine, "SubQualityMask"); + //SendMessageFun.SendInfomation("ShowMobySubLine", Opname_SubLine, Opname);//显示分线机型及流水号 + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/WorkStart.cs b/MisDataFunction/Function1058/OpcServer/WorkStart.cs new file mode 100644 index 0000000..0582e8e --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/WorkStart.cs @@ -0,0 +1,55 @@ +using System; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //线首显示订单信息 + + if (tagValue == 1) + { + MIS_BASE.Write_TagTypeID(115, OpName, 0); + MIS_BASE.Write_TagTypeID(95, OpName, 0); + MIS_BASE.Write_TagTypeID(96, OpName, 0); + MIS_BASE.Write_TagTypeID(97, OpName, 0); + MIS_BASE.Write_TagTypeID(98, OpName, ""); + //清空MOBY的产品流水号 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStart, tagValue.ToString()); + + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WorkStart"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/vssver2.scc b/MisDataFunction/Function1058/OpcServer/vssver2.scc new file mode 100644 index 0000000..e8dac03 Binary files /dev/null and b/MisDataFunction/Function1058/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1058/Properties/AssemblyInfo.cs b/MisDataFunction/Function1058/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3608c0 --- /dev/null +++ b/MisDataFunction/Function1058/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function08")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function08")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1058/Properties/vssver2.scc b/MisDataFunction/Function1058/Properties/vssver2.scc new file mode 100644 index 0000000..87eebff Binary files /dev/null and b/MisDataFunction/Function1058/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1058/app.config b/MisDataFunction/Function1058/app.config new file mode 100644 index 0000000..b4c4daf --- /dev/null +++ b/MisDataFunction/Function1058/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1058/mssccprj.scc b/MisDataFunction/Function1058/mssccprj.scc new file mode 100644 index 0000000..f184c61 --- /dev/null +++ b/MisDataFunction/Function1058/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function08.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function08", KRHAAAAA diff --git a/MisDataFunction/Function1058/packages.config b/MisDataFunction/Function1058/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1058/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1058/vssver2.scc b/MisDataFunction/Function1058/vssver2.scc new file mode 100644 index 0000000..93af295 Binary files /dev/null and b/MisDataFunction/Function1058/vssver2.scc differ diff --git a/MisDataFunction/Function1059/DataAccess/DataAccess.cs b/MisDataFunction/Function1059/DataAccess/DataAccess.cs new file mode 100644 index 0000000..a7f91fa --- /dev/null +++ b/MisDataFunction/Function1059/DataAccess/DataAccess.cs @@ -0,0 +1,16 @@ + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1059/Db.cs b/MisDataFunction/Function1059/Db.cs new file mode 100644 index 0000000..64286ed --- /dev/null +++ b/MisDataFunction/Function1059/Db.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 北汽福田变速器序列号总线上线_获得机型信息 + /// + /// + /// + /// + /// + /// 0 不重号;1 重号;2:失败 + /// + public static bool GetEngineType(string partSn, out int EngineTypeID, out string EngineType, out string EngineID,out int IsRepeatedNumber) + { + DataTable dt = new DataTable(); + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + IsRepeatedNumber = 2; + string produceName = "北汽福田变速器序列号总线上线_获得机型信息"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms,out dt)) + { + if(dt.Rows.Count > 0) + { + IsRepeatedNumber = Convert.ToInt32( dt.Rows[0]["IsRepeatedNumber"]); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["EngineTypeID"]); + EngineType = dt.Rows[0]["EngineType"].ToString(); + EngineID = partSn; + return true; + } + } + return false; + } + /// + /// 北汽福田变速器序列号总线上线_增加 + /// + /// + /// + /// + /// + /// + public static bool UpLoadOpNameInsert(string partSn, int EngineTypeID, string EngineType, string OpName) + { + + string produceName = "北汽福田变速器序列号总线上线_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@基本型号代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@基本型号", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + // ALTER PROCEDURE[dbo].[北汽福田变速器序列号总线上线_增加] + // @变速器序列号 nvarchar(50)='1333 050 062 0001*146012023*12345678',--'1333 050 062 0001' + //@基本型号代码 int=1, + //@基本型号 nvarchar(50)='1333 050 062 0001', + //@工位号 nvarchar(50) = 'J05PA010' + } +} diff --git a/MisDataFunction/Function1059/Function1059.csproj b/MisDataFunction/Function1059/Function1059.csproj new file mode 100644 index 0000000..e8b1c30 --- /dev/null +++ b/MisDataFunction/Function1059/Function1059.csproj @@ -0,0 +1,113 @@ + + + + + Debug + AnyCPU + {913CE3C1-7D16-4A19-A9B0-BBCDB6770B4B} + Library + Properties + Function1059 + Function1059 + v4.8 + 512 + true + + + + true + full + false + ..\..\..\dll_fun\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\MisData_3.0_2022.08.23.1622.LLX\DLL\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1059/MesServerFunction/Function1059.cs b/MisDataFunction/Function1059/MesServerFunction/Function1059.cs new file mode 100644 index 0000000..67c16df --- /dev/null +++ b/MisDataFunction/Function1059/MesServerFunction/Function1059.cs @@ -0,0 +1,270 @@ + +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e =new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "43": + PartLoad(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + //{ + // //lock1 = new object(); + // //lock (lock1) + // { + // switch (e.TagTypeCodeID.ToString()) + // { + // //PLC 工件到位 + // case "2": + // fun_WorkStart(e); + // break; + // //PLC 允许保存质量数据 + // case "19": + // fun_MesRead(e); + // break; + // //MES 保存数据完成 + // case "20": + // fun_MesReadOver(e); + // break; + // //PLC 传递机型 + // case "44": + // fun_EngineTypeGetOverPLC(e); + // break; + // //MES 合格放行 + // case "51": + // fun_ConfirmOkGo(e); + // break; + // //MES 不合格放行 + // case "8": + // fun_FalseGo(e); + // break; + // //MES 扫描条码 + // case "Barcode": + // fun_Barcode(e); + // break; + // //WEB 处理页面传递过来的数据 + // case "WebSubmit": + // fun_WebSubmit(e); + // break; + // } + // } + + //} + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //2.MES判断是否扫描完成 + //3.若扫描完成,则MES给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + + /// + /// 保存完成 20 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 保存完成 19 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + public int fun_SubLineLoadPartCountMatch() + { + return SubLineLoadPartCountMatch; + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + } +} diff --git a/MisDataFunction/Function1059/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1059/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..895f4c1 --- /dev/null +++ b/MisDataFunction/Function1059/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,279 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 分线上总线的数量 + /// + public static int SubLineLoadPartCount = 2; + /// + /// 分线上总线已经匹配的数量 + /// + public static int SubLineLoadPartCountMatch = 0; + /// + /// 正常逻辑工作 + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + //string OrderForm = "";//订单号 + //DataTable dt; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + // BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + //SendMessageFun.SendMessage("123", "111", OpName); + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + // 暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + + int isRepair; + int engineTypeID; + + string engineType = ""; + string engineID = ""; + string palletCode = ""; + string orderForm = ""; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + /// + /// 正常匹配分线和总线 + /// + /// + /// 总线工件号 + /// 总线工件机型代码 + /// 总线工件机型 + private void Match(string opName, string engineID, int engineTypeID, string engineType, int PartPallet_Code) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + int engineTypeID_SubLine; + int partPallet_Code_SubLine; + int PalletInfo = 1;//总线托盘状态 + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string AlarmStr; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //第一步:获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + //第二步:获取分线传递机型信号 + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine); + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //第三步:判断合格标志 + MIS_BASE.Read_PalletInfo(opName_SubLine, out PalletInfo); + if (PalletInfo == 2) return; //若不合格则返回不进行匹配 + string OrderForm; + //第四步:获取分线的信息,匹配验证 + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm); + //判断分线数据是否合格 + //if (!BaseDataSystemMES.QulityDataVerify(opName, engineID_SubLine, out AlarmStr) && !BaseDataSystemMES.QualityVerifyStatus_Hash_Read(opName)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, opName); + // return; + //} + + if (engineTypeID_SubLine == engineTypeID) + { + BaseDataSystemMES.SubLineLoadPartCountMatch_Select(opName, out SubLineLoadPartCountMatch); + SubLineLoadPartCountMatch = SubLineLoadPartCountMatch + 1; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + if(SubLineLoadPartCountMatch== SubLineLoadPartCount) + { + MIS_BASE.Write_FixAllow(opName, true); + SubLineLoadPartCountMatch = 0; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + } + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName); + sendmessage(opName, 1, "Match");//匹配结果 + } + else + { + MIS_BASE.Write_Match(opName, false);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成//68:1、取消返修;2、匹配成功 自己监控发送 MES|MatchingCompleted + + //发送匹配完成和匹配结果信息 + SendMessageFun.AsyncSendMessage_Notice(opName,"匹配失败,工件型号不匹配!"); + SendMessageFun.SendInfomation("MatchSuccess", "0", opName); + sendmessage(opName, 0, "Match");//匹配结果 + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog("Match:" + err.ToString()); + + } + } + + + + /// + /// 强制匹配分线和总线 + /// + /// + private void ForceMatch(string opName) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + bool m_EngineGetOver_PLC; + + int engineTypeID_SubLine; + int engineTypeID; + int partPallet_Code_SubLine; + int partPallet_Code; + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string engineID; + string engineType; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine);//1:读取分线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + MIS_BASE.Read_EngineGetOver_PLC(opName, out m_EngineGetOver_PLC);//2:读取总线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC) return;//必须工件同时到位才能进行匹配 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm);//获取分线的信息 + MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out partPallet_Code, out OrderForm); + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName);//界面显示匹配成功 + + MIS_BASE.Write_FixAllow(opName, true);//允许PLC工作 + + //发送匹配完成和匹配结果信息 + sendmessage(opName, 1, "MatchingComplete");//匹配完成 + sendmessage(opName, 1, "Match");//匹配结果 + } + catch + { + + } + } + } +} diff --git a/MisDataFunction/Function1059/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1059/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..8d84430 --- /dev/null +++ b/MisDataFunction/Function1059/Methods/SubmitToMisweb.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + + // /// + // /// 批量发送WEB消息(Value为BOOL值) + // /// + // /// 消息编号组合 + // /// 消息值组合 + // /// 工位号 + // void Sendmessage(string MessageNumm,string Value, string OpName) + //{ + // for (int i=0;i + // /// 选择发送给WEB的消息 + // /// + // /// 消息类型 + // /// 消息工位 + //void Sendmessage(char Num,string Value, string OpName) + //{ + // string SendMessage; + // switch (Num) + // { + // case '1': + // //1(直接在界面通过选择机型确认工序内容) + // SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '2': + // //2显示物料 + // SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '3': + + // //3显示操作指导图片 + // SendMessage = "MES|PicShow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '4': + // //3显示操作指导图片 + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '5': + // SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '6': + // SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + // AsyncSendMessage(SendMessage); + // break; + // case '7': + // SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '8': + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '9': + // SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'a': + // SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'b': + // SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'c': + // SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // } + //} + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + //void SendInfomation(string Command, string Value, string OpName) + //{ + + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + //} + + + ///// + ///// 发送在线产量、在线节拍 + ///// + ///// + ///// + //private void SendActuallyCount(string OpName, int tagValue) + //{ + // //当工件离开时,更新在线产量、在线节拍 + // if (tagValue == 0) + // { + // try + // { + // int opNameCount = 0;//在线产量 + // int opNameCountTime = 0;//在线节拍 + + // BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + // SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + // } + // } + //} + + + } +} diff --git a/MisDataFunction/Function1059/Methods/UDP.Send.cs b/MisDataFunction/Function1059/Methods/UDP.Send.cs new file mode 100644 index 0000000..26acece --- /dev/null +++ b/MisDataFunction/Function1059/Methods/UDP.Send.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MesServerWork; +//using BasicData; +using System.Collections; +using bizFacade; +//using SystemFramework; +using System.Data; +using System.Threading; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + ///// + ///// 发送信息到MES通讯服务器或者其他的 + ///// + ///// + //private void AsyncSendMessage(string Message) + //{ + // MIS_BASE.asyncSendMessage(Message); + //} + + /// + /// 发送提示消息 + /// + /// + //private void AsyncSendMessage_Notice(string opname, string notice) + //{ + // //通知Web界面 + // BaseDataSystemMES.Web_Notice_Insert(opname, notice); + // string SendMessage = "MES|Notice|" + opname + "|" + "1"; + // MIS_BASE.asyncSendMessage(SendMessage); + //} + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + + } +} diff --git a/MisDataFunction/Function1059/OpcServer/Barcode.cs b/MisDataFunction/Function1059/OpcServer/Barcode.cs new file mode 100644 index 0000000..f99b4a1 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/Barcode.cs @@ -0,0 +1,239 @@ +using System; +using System.Threading; +using System.Xml.Linq; +using bizFacade; + +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcode = new object(); + + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + lock(lockBarcode) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + //+*************DbName***************** + string DbName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + int Recipe1; + int Recipe2; + + bool IsNotRepeatedNumber = false; + //1:获得申请上线信息后,扫描条码才处理业务 + bool ispartload; + //(115) + int PTO; + //(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int NgearSwitch; + //(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int RgearSwitch; + //(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + int SpeedSensor; + //(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + string PartTypeMid; + //(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int Tcu_V; + //判断工件是否到位 + MIS_BASE.Read_WorkStart(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + return; + } + //判断设备是否申请上线 + //MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload); + //if (!ispartload) + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + // return; + //} + // 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + // 选小机型 从北汽福田BOM中选 得先维护BOM + // 变速器序列号 '1333 050 062*16012023*30000001' + + //扫描完变速器序列号条码号 true + bool isGetOver_MES = false; + //判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + MIS_BASE.Read_EngineTypeGetOver_MES(OpName, out isGetOver_MES); + + //如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + //否则按装配物料进行验证 + if (!isGetOver_MES) + { + + if (barcode.Split('*').Length > 2) + { + //2: 判断是否重号, 从数据库获得机型、机型代码等信息 + string partSn = barcode; + EngineID = barcode; + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + + //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + + //IsRepeatedNumber true 不重号;false 重号; + IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + if (IsNotRepeatedNumber) + { + BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + + //MIS_BASE.Write_EngineID_MES(OpName, EngineID); + //MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + //MIS_BASE.Write_EngineType_MES(OpName, EngineType); + //MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + + BaseDataSystemMES.UpLoadPTO(partSn, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + //PTO + MIS_BASE.WritePLC(115, OpName, PTO); + //空挡开关检测 + MIS_BASE.WritePLC(95, OpName, NgearSwitch); + //倒挡开关检测 + MIS_BASE.WritePLC(96, OpName, RgearSwitch); + //里程表检测 + MIS_BASE.WritePLC(97, OpName, SpeedSensor); + //大机型扩展 + MIS_BASE.WritePLC(98, OpName, PartTypeMid); + //TCU + MIS_BASE.WritePLC(122, OpName, PartTypeMid); + string tagStartAdr;//= "DB411.10"; + + // 先查询配方号 根据工位号 去moby表查配方号 + // 根据配方号 去配方表查配方数据 + // 写入配方数据 + BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + ////将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm_MES, OrderForm); + + + // 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号] + // [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES] + // [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + // [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + // [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码] + + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, "产品型号代码_MES", EngineTypeID.ToString()); + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, "发动机型号_MES", EngineType); + + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + + //Thread.Sleep(5000); + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + //等待PLC将数据写入RFID;写入PLC的DB块,通知MES验证RFID机型数据是否正确传递 + + //通知web显示 + SendMessage.ShowMoby(OpName); + //SendMessageFun.SendMessage("1235", "1111", OpName); + + SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码完成!"); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + } + } + else//验证物料 + { + //物料号 + { + //读取PLC的传递机型信号 + bool tagValue; + MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + if (tagValue) + { + //验证物料 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + if (!IsSuccess)//???? + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + //判断物料是否验证完成 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + if (IsSuccess) + { + if (IsAllowWork == 1) + { + //移到允许保存信号中 + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + } + + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:Barcode"); + } + } + + } + + + } +} diff --git a/MisDataFunction/Function1059/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1059/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..a978c1f --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,35 @@ +using System; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList","1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1059/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..5cf02f9 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/EngineGetOver.cs @@ -0,0 +1,108 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcodeEngineTypeGetOver = new object(); + + + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + lock(lockBarcodeEngineTypeGetOver) + { + + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + SendMessageFun.SendInfomation("AskReset", "1", OpName); + return; + } + string OrderForm; + string OrderForm_MES; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + // 测试的时候用的 plc读取订单号有问题 + // OrderForm = BaseDataSystemMES.GetOrderDataBySn(EngineID); + + if (EngineTypeID_MES == EngineTypeID & EngineID_MES == EngineID & EngineType_MES == EngineType & OrderForm_MES == OrderForm) + { + // + DataTable dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + // 提示机型发生变化 + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + return; + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "码块RFID机型与MES机型不匹配!"); + } + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + } + + + + } +} diff --git a/MisDataFunction/Function1059/OpcServer/FalseGO.cs b/MisDataFunction/Function1059/OpcServer/FalseGO.cs new file mode 100644 index 0000000..54c73c7 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/FalseGO.cs @@ -0,0 +1,37 @@ +using System; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + + /// + /// 返修放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList", "1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/HeartBeat.cs b/MisDataFunction/Function1059/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/MesRead.cs b/MisDataFunction/Function1059/OpcServer/MesRead.cs new file mode 100644 index 0000000..9bc056d --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/MesRead.cs @@ -0,0 +1,77 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockMesRead = new object (); + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + lock(lockMesRead) + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + if (Db.UpLoadOpNameInsert(EngineID, EngineTypeID, EngineType, OpName)) + { + // 保存质量数据 + int qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + // 推送质量数据到MES的页面 + MIS_BASE.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + // 保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, tagValue); + // 测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + SendMessage.SendActuallyCount(OpName, tagValue);//统计在线产量,在线节拍 + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + // MES工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!"); + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + + } + + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/MesReadOver.cs b/MisDataFunction/Function1059/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..9b637f2 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/MesReadOver.cs @@ -0,0 +1,37 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + try + { + //DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + + // BaseDataSystemMES.Material_Insert(OpName, tagValue); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1059/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..be4c8ce --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/MesSaveNowData.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + // 保存质量数据 + MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString(),true); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/PartLoad.cs b/MisDataFunction/Function1059/OpcServer/PartLoad.cs new file mode 100644 index 0000000..e221f64 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/PartLoad.cs @@ -0,0 +1,39 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线(针对上线工位) + /// + /// + /// + private void PartLoad(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描总成码"); + } + else + { + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/WebSubmit.cs b/MisDataFunction/Function1059/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..0272c32 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/WebSubmit.cs @@ -0,0 +1,343 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string opName_SubLine = ""; + string engineID = "";//工件信息 + string[] dataArray = Content.Split('|'); + + if (dataArray.Length != 2) + return; + + + string m_Command = dataArray[0].ToString();//消息类型 + string m_Value = dataArray[1].ToString();//消息参数 + string[] m_Value_array = m_Value.Split('&');//消息参数数量 + int m_Value_length = m_Value_array.Length; //消息参数长度 + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //修改托盘状态 + + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + + break; + case "FixAllow"://重新拧紧 + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + MIS_BASE.Write_RepairUpline_MES(opName_SubLine, true); + //MIS_BASE.Write_PalletInfo(opName_SubLine, 4); + //MIS_BASE.Write_UpdatePalletOK(opName_SubLine, true); + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + } + else if (Convert.ToInt32(m_Value) == 0) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + break; + //强制匹配 + case "ForceMatch": + if (Convert.ToInt32(m_Value) == 1) + { + ForceMatch(OpName); + } + break; + case "PalletGO": + + if (Convert.ToInt32(m_Value) == 1) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + } + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + fun_EngineTypeGetOverPLC(_e); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WebSubmit"); + } + } + + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + bool S_WorkStart;//工件到位 DBX0.1 + bool S_EngineGetOver;//传递机型 DBX0.4 + bool S_FixAllow;//允许工作 DBX3.1 + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + + int IsCompleted = 0; + int S_Match = 0; + int PalletInfo_SubLine = 0;//显示分线托盘状态 + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "WorkStart_Subline"); + } + + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "EngineTypeGetOverMES_Subline"); + + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_EngineGetOver), "EngineTypeGetOverMES_Subline"); + } + + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + + //MIS_BASE.Read_MatchingCompleted(Opname, out IsCompleted); //DBX1.3 是否匹配 + //MIS_BASE.Read_Match(Opname, out S_Match); //DBX1.4 匹配结果 + + //if (IsCompleted == 1 && S_Match == 1)//发送匹配完成和匹配结果信息 + //{ + // SendMessageFun.SendInfomation("MatchingCompleted", "1", Opname); + // SendMessageFun.SendInfomation("Match", "1", Opname); + // SendMessageFun.SendInfomation("MatchSuccess", "1", Opname);//界面显示匹配成功 + //} + //else if (IsCompleted == 1 && S_Match == 0) + //{ + // SendMessageFun.SendInfomation("MatchSuccess", "0", Opname);//界面显示匹配失败 + //} + + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + //string Opname_SubLine = ""; + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(Opname)) + //{ + // Opname_SubLine = MIS_BASE.hashtable_OpNameRepair[Opname].ToString(); + //} + //if (Opname_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_PalletInfo(Opname, out PalletInfo_SubLine); + //sendmessage(Opname, PalletInfo_SubLine, "SubQualityMask"); + //SendMessageFun.SendInfomation("ShowMobySubLine", Opname_SubLine, Opname);//显示分线机型及流水号 + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/WorkStart.cs b/MisDataFunction/Function1059/OpcServer/WorkStart.cs new file mode 100644 index 0000000..a16c909 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/WorkStart.cs @@ -0,0 +1,75 @@ +using System; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //线首显示订单信息 + + if (tagValue == 1) + { + MIS_BASE.Write_TagTypeID(115, OpName, 0); + MIS_BASE.Write_TagTypeID(95, OpName, 0); + MIS_BASE.Write_TagTypeID(96, OpName, 0); + MIS_BASE.Write_TagTypeID(97, OpName, 0); + MIS_BASE.Write_TagTypeID(98, OpName, ""); + //清空MOBY的产品流水号 + + // 北汽福田工位状态监控MOBY_增加 + // 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号] + // [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES] + // [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + // [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + // [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码] + //[到达时间],[离开时间],[持续时间] + + //初始化物料临时表 + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + BaseDataSystemMES.MesServer_Process_EngineTypeOver_BQ_FirstOP(OpName); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStart, tagValue.ToString()); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(OpName); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(OpName); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(OpName); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(OpName); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WorkStart"); + } + } + } +} diff --git a/MisDataFunction/Function1059/Properties/AssemblyInfo.cs b/MisDataFunction/Function1059/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5afe3c2 --- /dev/null +++ b/MisDataFunction/Function1059/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function1059")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Function1059")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("3dcc04c0-32bf-4573-91f6-c4e342a0cf2a")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1059/app.config b/MisDataFunction/Function1059/app.config new file mode 100644 index 0000000..b4c4daf --- /dev/null +++ b/MisDataFunction/Function1059/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1059/mssccprj.scc b/MisDataFunction/Function1059/mssccprj.scc new file mode 100644 index 0000000..f184c61 --- /dev/null +++ b/MisDataFunction/Function1059/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function08.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function08", KRHAAAAA diff --git a/MisDataFunction/Function1059/packages.config b/MisDataFunction/Function1059/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1059/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1060/DataAccess/DataAccess.cs b/MisDataFunction/Function1060/DataAccess/DataAccess.cs new file mode 100644 index 0000000..cd36930 --- /dev/null +++ b/MisDataFunction/Function1060/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1053 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1060/Db.cs b/MisDataFunction/Function1060/Db.cs new file mode 100644 index 0000000..64286ed --- /dev/null +++ b/MisDataFunction/Function1060/Db.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 北汽福田变速器序列号总线上线_获得机型信息 + /// + /// + /// + /// + /// + /// 0 不重号;1 重号;2:失败 + /// + public static bool GetEngineType(string partSn, out int EngineTypeID, out string EngineType, out string EngineID,out int IsRepeatedNumber) + { + DataTable dt = new DataTable(); + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + IsRepeatedNumber = 2; + string produceName = "北汽福田变速器序列号总线上线_获得机型信息"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms,out dt)) + { + if(dt.Rows.Count > 0) + { + IsRepeatedNumber = Convert.ToInt32( dt.Rows[0]["IsRepeatedNumber"]); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["EngineTypeID"]); + EngineType = dt.Rows[0]["EngineType"].ToString(); + EngineID = partSn; + return true; + } + } + return false; + } + /// + /// 北汽福田变速器序列号总线上线_增加 + /// + /// + /// + /// + /// + /// + public static bool UpLoadOpNameInsert(string partSn, int EngineTypeID, string EngineType, string OpName) + { + + string produceName = "北汽福田变速器序列号总线上线_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@基本型号代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@基本型号", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + // ALTER PROCEDURE[dbo].[北汽福田变速器序列号总线上线_增加] + // @变速器序列号 nvarchar(50)='1333 050 062 0001*146012023*12345678',--'1333 050 062 0001' + //@基本型号代码 int=1, + //@基本型号 nvarchar(50)='1333 050 062 0001', + //@工位号 nvarchar(50) = 'J05PA010' + } +} diff --git a/MisDataFunction/Function1060/Function1060.csproj b/MisDataFunction/Function1060/Function1060.csproj new file mode 100644 index 0000000..e7b4f94 --- /dev/null +++ b/MisDataFunction/Function1060/Function1060.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {D5DC93C7-91DD-4C82-9444-64180F15A9C9} + Library + Properties + Function1060 + Function1060 + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\MisDataFunDll\MisDataFunDll\bin\Debug\00.1Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1060/MesServerFunction/Fun_1060.cs b/MisDataFunction/Function1060/MesServerFunction/Fun_1060.cs new file mode 100644 index 0000000..48817f0 --- /dev/null +++ b/MisDataFunction/Function1060/MesServerFunction/Fun_1060.cs @@ -0,0 +1,217 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + } +} diff --git a/MisDataFunction/Function1060/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1060/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..a9dd932 --- /dev/null +++ b/MisDataFunction/Function1060/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,96 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + //string OrderForm = "";//订单号 + //DataTable dt; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("1235", "1111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + //// 工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + //return; + } + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1060/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1060/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1060/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1060/Methods/UDP.Send.cs b/MisDataFunction/Function1060/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1060/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/Barcode.cs b/MisDataFunction/Function1060/OpcServer/Barcode.cs new file mode 100644 index 0000000..5d80b2f --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/Barcode.cs @@ -0,0 +1,97 @@ +using System; +//using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, OpName); + // return; + //} + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1060/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1060/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..ac8affd --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + //Sendmessage("24", "11", OpName); + + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1060/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..db74c48 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/EngineGetOver.cs @@ -0,0 +1,90 @@ +using System; +using System.Data; +//using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + string OrderForm_MES; + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + // 测试的时候用的 plc读取订单号有问题 + // OrderForm = BaseDataSystemMES.GetOrderDataBySn(EngineID); + + if (EngineTypeID_MES == EngineTypeID & EngineID_MES == EngineID & EngineType_MES == EngineType) + { + DataTable dt; + dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + //提示机型发生变化 + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "PLC机型与MES机型不匹配!"); + } + + + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + + } +} diff --git a/MisDataFunction/Function1060/OpcServer/FalseGO.cs b/MisDataFunction/Function1060/OpcServer/FalseGO.cs new file mode 100644 index 0000000..e6d4179 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/FalseGO.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + //BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + //Sendmessage("24", "11", OpName); + + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/HeartBeat.cs b/MisDataFunction/Function1060/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/MesRead.cs b/MisDataFunction/Function1060/OpcServer/MesRead.cs new file mode 100644 index 0000000..2c468df --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/MesRead.cs @@ -0,0 +1,72 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + if (Db.UpLoadOpNameInsert(EngineID, EngineTypeID, EngineType, OpName)) + { + //保存质量数据 + int qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + //推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //MES工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!"); + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/MesReadOver.cs b/MisDataFunction/Function1060/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1060/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..11c9129 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/MesSaveNowData.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + // 保存质量数据 + MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/PartLoad.cs b/MisDataFunction/Function1060/OpcServer/PartLoad.cs new file mode 100644 index 0000000..75debe9 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/PartLoad.cs @@ -0,0 +1,23 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线 43 + /// + /// + /// + private void PartLoad(object e) + { + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/WebSubmit.cs b/MisDataFunction/Function1060/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..87548a3 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/WebSubmit.cs @@ -0,0 +1,334 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + bool S_WorkStart;//工件到位 DBX0.1 + bool S_EngineGetOver;//传递机型 DBX0.4 + bool S_FixAllow;//允许工作 DBX3.1 + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + + int IsCompleted = 0; + int S_Match = 0; + int PalletInfo_SubLine = 0;//显示分线托盘状态 + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "WorkStart_Subline"); + } + + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "EngineTypeGetOverMES_Subline"); + + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_EngineGetOver), "EngineTypeGetOverMES_Subline"); + } + + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + + //MIS_BASE.Read_MatchingCompleted(Opname, out IsCompleted); //DBX1.3 是否匹配 + //MIS_BASE.Read_Match(Opname, out S_Match); //DBX1.4 匹配结果 + + //if (IsCompleted == 1 && S_Match == 1)//发送匹配完成和匹配结果信息 + //{ + // SendMessageFun.SendInfomation("MatchingCompleted", "1", Opname); + // SendMessageFun.SendInfomation("Match", "1", Opname); + // SendMessageFun.SendInfomation("MatchSuccess", "1", Opname);//界面显示匹配成功 + //} + //else if (IsCompleted == 1 && S_Match == 0) + //{ + // SendMessageFun.SendInfomation("MatchSuccess", "0", Opname);//界面显示匹配失败 + //} + + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + //string Opname_SubLine = ""; + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(Opname)) + //{ + // Opname_SubLine = MIS_BASE.hashtable_OpNameRepair[Opname].ToString(); + //} + //if (Opname_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_PalletInfo(Opname, out PalletInfo_SubLine); + //sendmessage(Opname, PalletInfo_SubLine, "SubQualityMask"); + //SendMessageFun.SendInfomation("ShowMobySubLine", Opname_SubLine, Opname);//显示分线机型及流水号 + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/WorkStart.cs b/MisDataFunction/Function1060/OpcServer/WorkStart.cs new file mode 100644 index 0000000..904295e --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/WorkStart.cs @@ -0,0 +1,91 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Data; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + + int PLCRcipe; + + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + //北汽福田工位状态监控MOBY_查询_订单下达用 + DataTable dt; + dt = BaseDataSystemMES.DownOrderToOpNameMobyList(OpName); + if (dt != null) + { + //开始上线前清空交互区数据 + MIS_BASE.WritePLC(73, OpName, ""); + MIS_BASE.WritePLC(74, OpName, ""); + MIS_BASE.WritePLC(75, OpName, ""); + int workType = 0; + if (dt.Rows.Count > 0) + { + // 正常逻辑 获得机型信息、配方号、 + EngineTypeID = Convert.ToInt32(dt.Rows[0][MobyTagType.EngineTypeID_MES]); + EngineType = dt.Rows[0][MobyTagType.EngineType_MES].ToString(); + OrderForm = dt.Rows[0][MobyTagType.OrderForm_MES].ToString(); + PLCRcipe = Convert.ToInt32(dt.Rows[0][MobyTagType.PLCRcipe]); + EngineID = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("-", "").Replace(" ", "").Replace(":", ""); + EngineID = EngineID + "_" + EngineType; //拼接工件编号 按照唯一码加时间来拼接 + // 将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + // 获得配方数据 + BaseDataSystemMES.PLCRcipeByOpName(OpName, out byte[] bytes, out string tagStartAdr, PLCRcipe); + // 写入配方数据 + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + // MES传递机型 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + } + } + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + + } +} diff --git a/MisDataFunction/Function1060/Properties/AssemblyInfo.cs b/MisDataFunction/Function1060/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..36f4b02 --- /dev/null +++ b/MisDataFunction/Function1060/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function1060")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Function1060")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("58215063-87f5-4708-8dda-031524c70b54")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1060/app.config b/MisDataFunction/Function1060/app.config new file mode 100644 index 0000000..b4c4daf --- /dev/null +++ b/MisDataFunction/Function1060/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFunction/Function1060/packages.config b/MisDataFunction/Function1060/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1060/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dll_common/AsyncIO.dll b/dll_common/AsyncIO.dll new file mode 100644 index 0000000..5bfd21b Binary files /dev/null and b/dll_common/AsyncIO.dll differ diff --git a/dll_common/BasicData.dll b/dll_common/BasicData.dll new file mode 100644 index 0000000..8dfe09b Binary files /dev/null and b/dll_common/BasicData.dll differ diff --git a/dll_common/BouncyCastle.Crypto.dll b/dll_common/BouncyCastle.Crypto.dll new file mode 100644 index 0000000..0310983 Binary files /dev/null and b/dll_common/BouncyCastle.Crypto.dll differ diff --git a/dll_common/ConLink.dll b/dll_common/ConLink.dll new file mode 100644 index 0000000..fa95f29 Binary files /dev/null and b/dll_common/ConLink.dll differ diff --git a/dll_common/ConLink19.dll b/dll_common/ConLink19.dll new file mode 100644 index 0000000..0b665e4 Binary files /dev/null and b/dll_common/ConLink19.dll differ diff --git a/dll_common/DataLinkMesWork.dll b/dll_common/DataLinkMesWork.dll new file mode 100644 index 0000000..57fcd25 Binary files /dev/null and b/dll_common/DataLinkMesWork.dll differ diff --git a/dll_common/EnBaseM.dll b/dll_common/EnBaseM.dll new file mode 100644 index 0000000..ebdeaa2 Binary files /dev/null and b/dll_common/EnBaseM.dll differ diff --git a/dll_common/ICSharpCode.SharpZipLib.dll b/dll_common/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..84e8c68 Binary files /dev/null and b/dll_common/ICSharpCode.SharpZipLib.dll differ diff --git a/dll_common/MQTT.dll b/dll_common/MQTT.dll new file mode 100644 index 0000000..c61c4f0 Binary files /dev/null and b/dll_common/MQTT.dll differ diff --git a/dll_common/MQTTnet.Extensions.ManagedClient.dll b/dll_common/MQTTnet.Extensions.ManagedClient.dll new file mode 100644 index 0000000..99035f6 Binary files /dev/null and b/dll_common/MQTTnet.Extensions.ManagedClient.dll differ diff --git a/dll_common/MQTTnet.dll b/dll_common/MQTTnet.dll new file mode 100644 index 0000000..2951433 Binary files /dev/null and b/dll_common/MQTTnet.dll differ diff --git a/dll_common/MW_Log.dll b/dll_common/MW_Log.dll new file mode 100644 index 0000000..752820a Binary files /dev/null and b/dll_common/MW_Log.dll differ diff --git a/dll_common/MesControl.dll b/dll_common/MesControl.dll new file mode 100644 index 0000000..cd3960b Binary files /dev/null and b/dll_common/MesControl.dll differ diff --git a/dll_common/MesWork.DeviceDriver.dll b/dll_common/MesWork.DeviceDriver.dll new file mode 100644 index 0000000..186755c Binary files /dev/null and b/dll_common/MesWork.DeviceDriver.dll differ diff --git a/dll_common/MesWork.PLC.dll b/dll_common/MesWork.PLC.dll new file mode 100644 index 0000000..3399040 Binary files /dev/null and b/dll_common/MesWork.PLC.dll differ diff --git a/dll_common/Monitor.MesWork.dll b/dll_common/Monitor.MesWork.dll new file mode 100644 index 0000000..1874ca5 Binary files /dev/null and b/dll_common/Monitor.MesWork.dll differ diff --git a/dll_common/Monitor.MesWork.xml b/dll_common/Monitor.MesWork.xml new file mode 100644 index 0000000..f978604 --- /dev/null +++ b/dll_common/Monitor.MesWork.xml @@ -0,0 +1,2860 @@ + + + + Monitor.MesWork + + + + + AlarmListView 的摘要说明。 + + + + + 从OnDataChange发送int tagID, int tagValue到处理程序 + private void OnDataChange(int tagID, int tagValue) + + + + + + + 从OnDataChange发送int tagID, int tagValue到处理程序 + private void OnDataChange(int tagID, int tagValue) + + + + + 必需的设计器变量。 + + + + + 当时发生的报警总行数 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + 报警到达 + + + + + 报警到达 + + + + + 报警解除 + + + + + 报警解除 + + + + + 报警确认 + + + + + 报警确认 + + + + + 报警过滤条件 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警过滤条件 + + + + + 从系统获得 + =null 时,初始化时显示全部报警 + =AlarmItemSelect,初始化时显示AlarmItemSelect条件报警 + + + + + + + + + + 报警到达文字颜色 + + + + + 报警到达文本底色 + + + + + 报警解除文字颜色 + + + + + 报警解除文本底色 + + + + + 报警确认文字颜色 + + + + + 报警确认文本底色 + + + + + 初始化报警显示 + + + + + 报警控件,监控值变化时,图形重绘 + + + + + + 增加TagKey + + + + + =true,调Gif;false不调Gif + + + + + Gif图像 + + + + + Gif图像 + + + + + IsRotation =0不调用Gif;=1调用Gif TagValueType + + + + + IsRotation =0不调用Gif;=1调用Gif + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + + + + + + 绘制图形 + + + + + + 正常绘制 + + + + + + 显示Gif + + + + + + 增加TagKey + + + + + =true,调Gif;false不调Gif + + + + + Gif图像 + + + + + IsRotation =0不调用Gif;=1调用Gif TagValueType + + + + + IsRotation =0不调用Gif;=1调用Gif + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + + + + + + 绘制图形 + + + + + + 正常绘制 + + + + + + 显示Gif + + + + + + PlcLinkStatus 的摘要说明。 + + + + + 显示PLC连接状态 + + + + + + PLC连接正常时图形 + + + + + PLC连接正常时图形 + + + + + PLC连接不正常时图形 + + + + + PLC连接不正常时图形 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + PlcLinkStatusWork 的摘要说明。 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + + + + + + 根据变量是否正确,显示通讯状态 通讯数据交换 + + + + + + 通讯正常 + + + + + 通讯失败 + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + PlcLinkStatusWork 的摘要说明。 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + + + + + + 根据变量是否正确,显示通讯状态 通讯数据交换 + + + + + + 通讯正常 + + + + + 通讯失败 + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 变量类型 + + + + + 变量类型 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示机床状态 + + + + + + 绘制图形 + + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示机床状态 + + + + + + 绘制图形 + + + + + + 增加TagKey + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示到位信号 + + + + + + 绘制图形 + + + + + + 发动机工位在线显示 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 发动机号 + + + + + 发动机号 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + OpName + 工位名称 + + + + + 是否进行具体发动机号追踪 + + + + + 是否进行具体发动机号追踪 + + + + + 具体发动机号追踪发动机号 + 发动机号 + + + + + 具体发动机号追踪 + 发动机号 + + + + + 具体发动机号追踪 + Tag位置0时颜色 + + + + + 具体发动机号追踪 + Tag位置1时颜色 + + + + + + + + + + 发动机号的变化,给本控件的发动机号赋值 + 确定被追踪的发动机号 + + + + + + + 发动机号动态追踪设定 + + + + + + + 显示被追踪的发动机 + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 托盘到位 + + + + + + + 绘制图形 + + + + + + 发动机工位在线显示 + + + + + 当鼠标在上方时出现工件编号 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 发动机号 + + + + + 发动机号 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + OpName + 工位名称 + + + + + 是否进行具体发动机号追踪 + + + + + 是否进行具体发动机号追踪 + + + + + 具体发动机号追踪发动机号 + 发动机号 + + + + + 具体发动机号追踪 + 发动机号 + + + + + 具体发动机号追踪 + Tag位置0时颜色 + + + + + 具体发动机号追踪 + Tag位置1时颜色 + + + + + + + + + + 发动机号的变化,给本控件的发动机号赋值 + 确定被追踪的发动机号 + + + + + + + 发动机号动态追踪设定 + + + + + + + 显示被追踪的发动机 + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 托盘到位 + + + + + + + 绘制图形 + + + + + + UserControlButton 的摘要说明。 + + + + + 发动机号 + + + + + 发动机号 + + + + + 当鼠标在上方时出现发动机号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 机床状态 + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + 变量值 + + + + + 变量值 + + + + + 变量类型 + + + + + 变量类型 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + TagNameID名称 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + 发动机号 + + + + + 发动机号 + + + + + 当鼠标在上方时出现发动机号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示心跳控件 + + + + + + 绘制图形 + + + + + + 增加TagKey + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 绘制图形 + + + + + + 水平方式显示工件编号。 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + 垂直方式显示工件编号。 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + 变量值 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + Button 文本颜色代码 + + + + + + + + + + 显示工件编号 + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + 变量值 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + Button 文本颜色代码 + + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + 增加TagKey + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 绘制图形 + + + + + + 一个强类型的资源类,用于查找本地化的字符串等。 + + + + + 返回此类使用的缓存的 ResourceManager 实例。 + + + + + 重写当前线程的 CurrentUICulture 属性 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + diff --git a/dll_common/NPOI.OOXML.dll b/dll_common/NPOI.OOXML.dll new file mode 100644 index 0000000..031d41d Binary files /dev/null and b/dll_common/NPOI.OOXML.dll differ diff --git a/dll_common/NPOI.OpenXml4Net.dll b/dll_common/NPOI.OpenXml4Net.dll new file mode 100644 index 0000000..8da4ac2 Binary files /dev/null and b/dll_common/NPOI.OpenXml4Net.dll differ diff --git a/dll_common/NPOI.OpenXmlFormats.dll b/dll_common/NPOI.OpenXmlFormats.dll new file mode 100644 index 0000000..4a8f87b Binary files /dev/null and b/dll_common/NPOI.OpenXmlFormats.dll differ diff --git a/dll_common/NPOI.dll b/dll_common/NPOI.dll new file mode 100644 index 0000000..1a500e9 Binary files /dev/null and b/dll_common/NPOI.dll differ diff --git a/dll_common/NetMQ.dll b/dll_common/NetMQ.dll new file mode 100644 index 0000000..e649c0e Binary files /dev/null and b/dll_common/NetMQ.dll differ diff --git a/dll_common/Newtonsoft.Json.dll b/dll_common/Newtonsoft.Json.dll new file mode 100644 index 0000000..7af125a Binary files /dev/null and b/dll_common/Newtonsoft.Json.dll differ diff --git a/dll_common/Opc.Ua.Client.dll b/dll_common/Opc.Ua.Client.dll new file mode 100644 index 0000000..8874d8f Binary files /dev/null and b/dll_common/Opc.Ua.Client.dll differ diff --git a/dll_common/Opc.Ua.Configuration.dll b/dll_common/Opc.Ua.Configuration.dll new file mode 100644 index 0000000..b3f3970 Binary files /dev/null and b/dll_common/Opc.Ua.Configuration.dll differ diff --git a/dll_common/Opc.Ua.Core.dll b/dll_common/Opc.Ua.Core.dll new file mode 100644 index 0000000..ee01d0d Binary files /dev/null and b/dll_common/Opc.Ua.Core.dll differ diff --git a/dll_common/OpcUaHelper.dll b/dll_common/OpcUaHelper.dll new file mode 100644 index 0000000..e95e509 Binary files /dev/null and b/dll_common/OpcUaHelper.dll differ diff --git a/dll_common/SqlCmd.dll b/dll_common/SqlCmd.dll new file mode 100644 index 0000000..b6b25f9 Binary files /dev/null and b/dll_common/SqlCmd.dll differ diff --git a/dll_common/System.Net.Http.Formatting.dll b/dll_common/System.Net.Http.Formatting.dll new file mode 100644 index 0000000..e9e80be Binary files /dev/null and b/dll_common/System.Net.Http.Formatting.dll differ diff --git a/dll_common/System.Net.Http.dll b/dll_common/System.Net.Http.dll new file mode 100644 index 0000000..1c5c6fd Binary files /dev/null and b/dll_common/System.Net.Http.dll differ diff --git a/dll_common/System.Runtime.InteropServices.RuntimeInformation.dll b/dll_common/System.Runtime.InteropServices.RuntimeInformation.dll new file mode 100644 index 0000000..360e92a Binary files /dev/null and b/dll_common/System.Runtime.InteropServices.RuntimeInformation.dll differ diff --git a/dll_common/System.Web.Cors.dll b/dll_common/System.Web.Cors.dll new file mode 100644 index 0000000..6f3da24 Binary files /dev/null and b/dll_common/System.Web.Cors.dll differ diff --git a/dll_common/System.Web.Http.Cors.dll b/dll_common/System.Web.Http.Cors.dll new file mode 100644 index 0000000..fd0b539 Binary files /dev/null and b/dll_common/System.Web.Http.Cors.dll differ diff --git a/dll_common/System.Web.Http.SelfHost.dll b/dll_common/System.Web.Http.SelfHost.dll new file mode 100644 index 0000000..852728e Binary files /dev/null and b/dll_common/System.Web.Http.SelfHost.dll differ diff --git a/dll_common/System.Web.Http.dll b/dll_common/System.Web.Http.dll new file mode 100644 index 0000000..7e3bd30 Binary files /dev/null and b/dll_common/System.Web.Http.dll differ diff --git a/dll_common/log4net.dll b/dll_common/log4net.dll new file mode 100644 index 0000000..8646b6f Binary files /dev/null and b/dll_common/log4net.dll differ diff --git a/icon/断开状态.png b/icon/断开状态.png new file mode 100644 index 0000000..0ae6189 Binary files /dev/null and b/icon/断开状态.png differ diff --git a/icon/连接状态.png b/icon/连接状态.png new file mode 100644 index 0000000..fcf9db7 Binary files /dev/null and b/icon/连接状态.png differ