1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- using HslCommunication.LogNet;
- using SqlSugar;
- namespace MainForm
- {
- public class SQLHelper
- {
- public static string DBDir = GlobalContext.DBDir;
- //用于数据库日志记录
- private static ILogNet logNet = new LogNetDateTime(GlobalContext.SQLLogDir, GenerateMode.ByEveryDay);
- /// <summary>
- /// 使用锁防止多线程同时操作数据库表
- /// </summary>
- private static readonly object sqlLock = new object();
- public class ResponseMessage
- {
- public bool result { get; set; }
- public string text { get; set; }
- }
- /// <summary>
- /// SQL连接
- /// </summary>
- private static SqlConnection connection = null;
- public static string connString = "";
- public static SqlSugarClient Db
- {
- get { return _db; }
- }
- public static void DatabaseConnection()
- {
- _db = new SqlSugarClient(new ConnectionConfig
- {
- ConnectionString = connString, // 请确保connString在此作用域内已定义或作为参数传递进来
- DbType = SqlSugar.DbType.SqlServer,
- IsAutoCloseConnection = true,
- InitKeyType = InitKeyType.Attribute
- });
- }
- //连接本地数据库
- public static SqlSugarClient _db = new SqlSugarClient(new ConnectionConfig
- {
- ConnectionString = connString, // 连接到 SqlServer(不指定数据库)
- DbType = SqlSugar.DbType.SqlServer, // 数据库类型:SqlServer
- IsAutoCloseConnection = true, // 自动关闭连接
- InitKeyType = InitKeyType.Attribute // 使用实体类属性来初始化表结构
- });
- public static void DBInitWork()
- {
- //以月为单位存
- string subDir = DateTime.Now.ToString("yyyyMM");
- string dataBaseName = "Db" + subDir;
- connString =
- @"server= " + GlobalContext.Server +
- ";database= " + dataBaseName +
- ";uid=" + GlobalContext.User +
- ";pwd=" + GlobalContext.PassWord;
- //判断路径是否存在,不存在则创建路径
- if (!Directory.Exists(DBDir + subDir)) Directory.CreateDirectory(DBDir + subDir);
- DatabaseConnection();
- //创建数据库和表
- SQLHelper.CreateDataBase(DBDir, subDir, dataBaseName);
- SQLHelper.CreateDataBase();
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="SQLString"></param>
- /// <param name="cmdParms"></param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public static DataSet Query(string SQLString, List<SqlParameter> cmdParms, string connectionString)
- {
- using (SqlConnection connection = new SqlConnection(connectionString))
- {
- SqlCommand cmd = new SqlCommand();
- PrepareCommand(cmd, connection, null, SQLString, cmdParms);
- using (SqlDataAdapter da = new SqlDataAdapter(cmd))
- {
- DataSet ds = new DataSet();
- try
- {
- da.Fill(ds, "ds");
- cmd.Parameters.Clear();
- }
- catch (System.Data.SqlClient.SqlException ex)
- {
- throw new Exception(ex.Message);
- }
- return ds;
- }
- }
- }
- /// <summary>
- /// 执行SQL语句,返回影响的记录数
- /// </summary>
- /// <param name="SQLString">SQL语句</param>
- /// <returns>影响的记录数</returns>
- public static int ExecuteSQL(string SQLString, List<SqlParameter> cmdParms, string connectionString)
- {
- using (SqlConnection connection = new SqlConnection(connectionString))
- {
- using (SqlCommand cmd = new SqlCommand())
- {
- try
- {
- PrepareCommand(cmd, connection, null, SQLString, cmdParms);
- int rows = cmd.ExecuteNonQuery();
- cmd.Parameters.Clear();
- return rows;
- }
- catch (System.Data.SqlClient.SqlException e)
- {
- throw e;
- }
- }
- }
- }
- private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, string cmdText, List<SqlParameter> cmdParms)
- {
- if (conn.State != ConnectionState.Open)
- conn.Open();
- cmd.Connection = conn;
- cmd.CommandText = cmdText;
- if (trans != null)
- cmd.Transaction = trans;
- cmd.CommandType = CommandType.Text;//cmdType;
- if (cmdParms != null)
- {
- foreach (SqlParameter parameter in cmdParms)
- {
- if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
- (parameter.Value == null))
- {
- parameter.Value = DBNull.Value;
- }
- cmd.Parameters.Add(parameter);
- }
- }
- }
- /// <summary>
- /// 创建SQL连接属性
- /// </summary>
- public static SqlConnection Connection
- {
- get
- {
- //DBInitWork();
- try
- {
- if (connection == null)//如果没有创建连接,则先创建
- {
- //从配置文件中获取SQL连接字段
- //string connStr = ConfigurationManager.ConnectionStrings["ConnetcionNmae"].ToString();
- connection = new SqlConnection(connString);//创建连接
- connection.Open();//打开连接
- }
- else if (connection.State == ConnectionState.Broken)//如果连接中断,则重现打开
- {
- connection.Close();
- connection.Open();
- }
- else if (connection.State == ConnectionState.Closed)//如果关闭,则打开
- {
- connection.Open();
- }
- return connection;
- }
- catch (Exception ex)
- {
- if (connection != null)
- {
- connection.Close();
- connection.Dispose();
- }
- logNet.WriteError(ex.Message.ToString());
- return null;
- }
- }
- }
- /// <summary>
- /// 重置连接
- /// </summary>
- public static void ResetConnection()
- {
- if (connection != null)
- {
- connection.Close();
- connection.Dispose();
- connection = null;
- }
- }
- /// <summary>
- /// 获取数据集
- /// </summary>
- /// <param name="str">执行字符串</param>
- /// <returns></returns>
- public static DataSet GetDataSet(string str)
- {
- lock (sqlLock)
- {
- try
- {
- SqlDataAdapter sda = new SqlDataAdapter(str, Connection);
- DataSet ds = new DataSet();
- sda.Fill(ds);
- return ds;
- }
- catch (Exception ex)
- {
- ResetConnection();
- logNet.WriteError(ex.Message.ToString());
- return null;
- }
- }
- }
- /// <summary>
- /// 获取表格
- /// </summary>
- /// <param name="str">执行字符串</param>
- /// <returns></returns>
- public static DataTable GetDataTable(string str)
- {
- return GetDataSet(str).Tables[0] ?? null;
- }
- /// <summary>
- /// 执行SQL语句
- /// </summary>
- /// <param name="str"></param>
- public static string ExecuteNonQuery(string str)
- {
- string ret = string.Empty;
- try
- {
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = Connection;
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = str;
- cmd.ExecuteNonQuery();
- ret = "成功";
- }
- catch (Exception ex)
- {
- ret = ex.Message.ToString();
- logNet.WriteError(ex.Message.ToString());
- }
- return ret;
- }
- /////////////////////////////////////////////////////////////////////////
- ///创建数据库和表
- /////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 判断数据库是否存在
- /// </summary>
- /// <param name="Db">数据库名称</param>
- /// <returns></returns>
- public static bool IsDBExist(string Db)
- {
- string createDbStr = " select * from master.dbo.sysdatabases where name " + "= '" + Db + "'";
- DataTable dt = GetDataTable(createDbStr);
- if (dt?.Rows.Count > 0)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 判断数据库中指定表格是否存在
- /// </summary>
- /// <param name="Db"></param>
- /// <param name="tb"></param>
- /// <returns></returns>
- public static bool IsTableExist(string Db, string tb)
- {
- string createTbStr = "USE " + Db + " select 1 from sysobjects where id =object_id('" + tb + "') and type = 'U'";
- DataTable dt = GetDataTable(createTbStr);
- if (dt?.Rows.Count > 0)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 判断数据库中指定表格是否存在
- /// </summary>
- /// <param name="Db"></param>
- /// <param name="tb"></param>
- /// <returns></returns>
- public static bool IsTableExist(string Db, string tb, string connString)
- {
- string createTbStr = "USE " + Db + " select 1 from sysobjects where id =object_id('" + tb + "') and type = 'U'";
- DataSet ds = Query(createTbStr, null, connString);
- if (ds?.Tables["ds"]?.Rows.Count > 0)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 创建数据库表
- /// </summary>
- /// <param name="Db">数据库名</param>
- /// <param name="tb">表名</param>
- public static void CreateDataTable(string Db, string tb, string content)
- {
- if (IsDBExist(Db) == false)
- {
- throw new Exception("数据库不存在!");
- }
- if (IsTableExist(Db, tb))
- {
- throw new Exception("数据库表已经存在!");
- }
- else
- {
- string createTableStr = "USE " + Db + " Create table " + tb + "(" + content + ")";
- ExecuteNonQuery(createTableStr);
- }
- }
- public static void CreateDataBase(string dbDir, string subDir, string dataBaseName)
- {
- string fileMDF = dbDir + subDir + @"\" + dataBaseName + @".mdf";
- string fileLDF = dbDir + subDir + @"\" + dataBaseName + @".ldf";
- if ((!File.Exists(fileMDF)) && (!File.Exists(fileLDF)))
- {
- SqlConnection myConn = new SqlConnection("Server=" + GlobalContext.Server
- + ";Integrated security=SSPI;database=master");
- String strSQL;
- strSQL = @"CREATE DATABASE " + dataBaseName +
- " ON PRIMARY " +
- "(NAME = " + dataBaseName + "_Data, " +
- "FILENAME = '" + fileMDF + "', " +
- "SIZE = 64MB, " +
- "MAXSIZE = UNLIMITED," +
- "FILEGROWTH = 64MB)" +
- "LOG ON (NAME = " + dataBaseName + "_Log, " +
- "FILENAME = '" + fileLDF + "', " +
- "SIZE = 64MB, " +
- "MAXSIZE = UNLIMITED, " +
- "FILEGROWTH = 64MB)";
- SqlCommand myCommand = new SqlCommand(strSQL, myConn);
- try
- {
- myConn.Open();
- myCommand.ExecuteNonQuery();
- logNet.WriteInfo("DataBase is Created Successfully");
- //创建StationIn表
- string content = @"[GUID] [nvarchar](36) NOT NULL,
- [Workorder_code] [nvarchar](50) NOT NULL,
- [Mtltmrk] [nvarchar](50) NOT NULL,
- [Sn] [nvarchar](64) NOT NULL,
- [StationIn_body] [nvarchar](MAX) NOT NULL,
- [StationInReturn_body] [nvarchar](MAX) NULL,
- [Parameter_values] [nvarchar](MAX) NULL,
- [Write_user] [nvarchar](20) NOT NULL,
- [Test_time] [varchar](23) NOT NULL,
- [Upload] [nvarchar](10) NOT NULL";
- CreateDataTable(dataBaseName, "StationIn", content);
- //创建ProcessData表
- content = @"[ID] [nvarchar](50) NOT NULL,
- [Equipment_code] [nvarchar](50) NOT NULL,
- [Workorder_code] [nvarchar](50) NOT NULL,
- [Batch_number] [nvarchar](32) NULL,
- [Sn] [nvarchar](64) NULL,
- [Testitem] [varchar](50) NULL,
- [Parameter_values] [nvarchar](MAX) NOT NULL,
- [StationOut_body] [nvarchar](MAX) NULL,
- [StationOutReturn_body] [nvarchar](MAX) NULL,
- [Write_user] [nvarchar](20) NOT NULL,
- [Test_time] [varchar](23) NOT NULL,
- [Upload] [nvarchar](10) NOT NULL";
- CreateDataTable(dataBaseName, "ProcessData", content);
- //创建OneCheckData表
- content = @" [ID] [nvarchar](50) NOT NULL,
- [Line_code] [nvarchar](50) NOT NULL,
- [Line_name] [nvarchar](50) NOT NULL,
- [Equipment_code] [nvarchar](50) NOT NULL,
- [Equipment_name] [nvarchar](50) NOT NULL,
- [Workorder_code] [nvarchar](50) NOT NULL,
- [Procedure_code] [nvarchar](32) NOT NULL,
- [Procedure_name] [nvarchar](32) NOT NULL,
- [Oneckeck_values] [nvarchar](MAX) NOT NULL,
- [Onecheck_empcode] [nvarchar](32) NULL,
- [Onecheck_empname] [nvarchar](32) NULL,
- [Onecheck_time] [varchar](20) NOT NULL,
- [Upload] [nvarchar](10) NOT NULL";
- CreateDataTable(dataBaseName, "OneCheckData", content);
- //创建WorkingData表-单机
- content = @"
- [Date] [nvarchar](10) NOT NULL,
- [Equipment_code] [nvarchar](32) NOT NULL,
- [BootTime] [varchar](20) NOT NULL,
- [Bootmoment] [nvarchar](20) NOT NULL,
- [RunTime] [varchar](20) NOT NULL,
- [WoringTime] [varchar](20) NOT NULL,
- [RepairTime] [varchar](20) NOT NULL,
- [StopTime] [varchar](20) NOT NULL,
- [WoringNum] [nvarchar](20) NOT NULL,
- [NeedTime] [varchar](20) NOT NULL,
- [PlanStopMoment] [nvarchar](20) NOT NULL,
- [Equipment_status] [nvarchar](20) NOT NULL,
- [WorkingQty] [nchvarcharar](20) NOT NULL,
- [QualifiedQty] [nvarchar](20) NOT NULL,
- [TotalQty] [nvarchar](20) NOT NULL,
- [NGset] [nvarchar](20) NOT NULL,
- [QualifiedRateSet] [nvarchar](20) NOT NULL,
- [RhySet] [nvarchar](20) NOT NULL,
- [Update_time] [varchar](20) NOT NULL";
- CreateDataTable(dataBaseName, "WorkingData", content);
- //创建LineWorkingData表-整线
- content = @" [GUID] [nvarchar](36) NOT NULL,
- [LineName] [nvarchar](36) NOT NULL,
- [BootTimeLong] [float] NULL,
- [NormalTimeLong] [float] NULL,
- [StandbyTimeLong] [float] NULL,
- [FaultTimeLong] [float] NULL,
- [MaterialShortageTimeLong] [float] NULL,
- [MaintenanceTimeLong] [float] NULL,
- [FaultNumber] [int] NULL,
- [OutputNumber] [int] NULL,
- [QualifiedNumber] [int] NULL,
- [QualifiedRate] [float] NULL,
- [DesignRhythm] [float] NULL,
- [RealityRhythm] [float] NULL,
- [CreateTime] [datetime] NULL";
- CreateDataTable(dataBaseName, "LineWorkingData", content);
- //创建AlarmData表
- content = @" [GUID] [nvarchar](36) NOT NULL,
- [LineName] [nvarchar](36) NOT NULL,
- [AlarmType] [nvarchar](36) NOT NULL,
- [AlarmDesc] [nvarchar](64) NOT NULL,
- [StartTime] [datetime] NOT NULL,
- [EndTime] [datetime] NULL,
- [PersistTime] [int] NULL";
- CreateDataTable(dataBaseName, "AlarmData", content);
- }
- catch (System.Exception ex)
- {
- logNet.WriteError(ex.Message.ToString());
- }
- finally
- {
- if (myConn.State == ConnectionState.Open)
- {
- myConn.Close();
- }
- }
- }
- }
- #region
- /// <summary>
- /// 检验并创建工单信息表
- /// </summary>
- public static void CreateDataBase_DBMain()
- {
- try
- {
- // 数据库链接
- string connString =
- "server=" + GlobalContext.Server +
- ";database=DBMain" +
- ";uid=" + GlobalContext.User +
- ";pwd=" + GlobalContext.PassWord;
- // 创建OrderTable表
- if (!IsTableExist("DBMain", "OrderTable", connString))
- {
- string content =
- @"
- CREATE TABLE [dbo].[OrderTable](
- [WorkOrderNum] [nvarchar](150) NOT NULL,
- [WorkOrderStatus] [nvarchar](32) NOT NULL,
- [BatchNumber] [nvarchar](36) NULL,
- [ProductMtltmrk] [nvarchar](32) NULL,
- [ProductNo] [nvarchar](32) NULL,
- [ProductName] [nvarchar](32) NULL,
- [SupplierCode] [nvarchar](32) NULL,
- [PlannedQuantity] [nvarchar](32) NULL,
- [CompletedQuantity] [int] NULL,
- [Plnsign] [nvarchar](32) NULL,
- [Soreqdat] [nvarchar](32) NULL,
- [Process] [nvarchar](32) NULL,
- [CreatedTime] [datetime] NOT NULL,
- CONSTRAINT [PK__OrderTab__33E32040C02E055A] PRIMARY KEY CLUSTERED
- (
- [WorkOrderNum] ASC
- )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
- ) ON [PRIMARY]
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'车间订单号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'WorkOrderNum'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'WorkOrderStatus'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批次号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'BatchNumber'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'产品型号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'ProductMtltmrk'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'产品代号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'ProductNo'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'产品名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'ProductName'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'SupplierCode'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'计划数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'PlannedQuantity'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'已完成数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'CompletedQuantity'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'计划标记' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'Plnsign'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'需求日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'Soreqdat'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属流程' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'Process'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable', @level2type=N'COLUMN',@level2name=N'CreatedTime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OrderTable'";
- ExecuteSQL(content, null, connString);
- }
- }
- catch (System.Exception ex)
- {
- logNet.WriteError(ex.Message.ToString());
- }
- }
- #endregion
- #region 进出站相关数据记录
- // 提供静态属性来访问 SqlSugarClient 实例
- //连网数据库
- public static SqlSugarClient dbmain = new SqlSugarClient(new ConnectionConfig
- {
- ConnectionString = "server=" + GlobalContext.Server +
- ";database=DBMain" +
- ";uid=" + GlobalContext.User +
- ";pwd=" + GlobalContext.PassWord, // 连接到 SqlServer(不指定数据库)
- DbType = SqlSugar.DbType.SqlServer, // 数据库类型:SqlServer
- IsAutoCloseConnection = true, // 自动关闭连接
- InitKeyType = InitKeyType.Attribute // 使用实体类属性来初始化表结构
- });
- // 判断表格是否存在
- public static bool CheckTableExists(SqlSugarClient Db, string tableName)
- {
- //判断表是否存在
- var result = Db.Ado.SqlQuery<int>($@"
- SELECT COUNT(*)
- FROM INFORMATION_SCHEMA.TABLES
- WHERE TABLE_NAME = @tableName", new { tableName }).FirstOrDefault() > 0;
- return result;
- }
- //创建 载具绑定物料码表、物料码绑定部件码表、PLC返回MES数据记录表
- public static void CreateDataBase()
- {
- try
- {
- // 3. 判断并创建表格
- if (!CheckTableExists(Db, "carrierbind"))
- {
- CreateTables<CarrierBind>(Db);
- }
- if (!CheckTableExists(Db, "productbind"))
- {
- CreateTables<ProductBind>(Db);
- }
- if (!CheckTableExists(Db, "testdata"))
- {
- CreateTables<TestData>(Db);
- }
- logNet.WriteInfo("表格已创建或已存在。");
- }
- catch (Exception ex)
- {
- logNet.WriteError("表格创建失败,错误原因:" + ex.Message);
- MessageBox.Show("表格创建失败,错误码:" + ex.Message);
- }
- }
- public static void CreateTables<T>(SqlSugarClient Db) where T : class, new()
- {
- Db.CodeFirst.InitTables<T>(); // 根据传入的实体类类型来创建表格
- logNet.WriteInfo($"表格 {typeof(T).Name} 已创建。");
- }
- //获取载具绑定的产品码
- public static string GetProductBarcodeByCarrierCode(string carrierCode)
- {
- try
- {
- var Carrierdt = Db.Queryable<CarrierBind>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderByDescending(x => x.ID)
- .Take(1)
- .ToList();
- if (Carrierdt != null && Carrierdt.Count > 0)
- {
- return Carrierdt.First().ProductBarcode;
- }
- else
- {
- return string.Empty;
- }
- }
- catch (Exception ex)
- {
- return string.Empty;
- }
- }
- //获取载具绑定的PCB码
- public static string GetPCBBarcodeByCarrierCode(string carrierCode)
- {
- try
- {
- var Carrierdt = Db.Queryable<CarrierBind>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderByDescending(x => x.ID)
- .Take(1)
- .ToList();
- if (Carrierdt != null && Carrierdt.Count > 0)
- {
- return Carrierdt.First().PCBBarcode;
- }
- else
- {
- return string.Empty;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"获取载具绑定的PCB码报错:{ex.Message}");
- return string.Empty;
- }
- }
- //载具码和产品码解除绑定关系
- public static ResponseMessage DelCarrierBind(string carrierCode)
- {
- // 检查记录是否已经存在
- var CarrierBind_exists = Db.Queryable<CarrierBind>().Where(x => x.CarrierCode == carrierCode);
- try
- {
- Db.Deleteable<CarrierBind>().Where(x => x.CarrierCode == carrierCode).ExecuteCommand();
- logNet.WriteInfo($"载具码与产品码解绑成功。");
- return new ResponseMessage { result = true, text = "载具码与产品码解绑成功" };
- }
- catch (Exception ex)
- {
- logNet.WriteError($"载具码与产品码解绑成功,错误" + ex.Message);
- return new ResponseMessage { result = false, text = "载具码与产品码解绑成功,错误" + ex.Message };
- }
- #endregion
- }
- //载具码和产品码绑定关系
- public static ResponseMessage InsertCarrierBind(string carrierCode, string productBarcode)
- {
- carrierCode = carrierCode.Replace("\r", "");
- productBarcode = productBarcode.Replace("\r", "");
- #region 新建CarrierBind实体,并将数据插入carrierBind表格
- // 创建 CarrierBind 实体,并通过传入的参数设置字段值
- var CarrierBind_sumRecord = new CarrierBind
- {
- CarrierCode = carrierCode,
- ProductBarcode = productBarcode
- };
- // 检查记录是否已经存在
- var CarrierBind_exists = Db.Queryable<CarrierBind>().Where(x => x.CarrierCode == carrierCode);
- try
- {
- if (CarrierBind_exists != null)
- {
- Db.Deleteable<CarrierBind>().Where(x => x.CarrierCode == carrierCode).ExecuteCommand();
- logNet.WriteInfo($"载具码与产品码已存在绑定关系,先解绑。");
- }
- // 插入数据
- Db.Insertable(CarrierBind_sumRecord).ExecuteCommand();
- logNet.WriteInfo($"载具码与产品码绑定成功。");
- return new ResponseMessage { result = true, text = "载具码与产品码绑定成功" };
- }
- catch (Exception ex)
- {
- logNet.WriteError($"载具码与产品码绑定失败,错误" + ex.Message);
- return new ResponseMessage { result = false, text = "载具码与产品码绑定失败,错误" + ex.Message };
- }
- #endregion
- }
- //载具码和产品码绑定关系
- public static ResponseMessage PCBCarrierBind(string carrierCode, string pcbBarcode)
- {
- pcbBarcode = pcbBarcode.Replace("\r", "");
- // 检查记录是否已经存在
- var CarrierBind_exists = Db.Queryable<CarrierBind>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderByDescending(x => x.CreateTime)
- .Take(1)
- .First();
- try
- {
- if (CarrierBind_exists != null)
- {
- Db.Updateable<CarrierBind>()
- .SetColumns(x=>x.PCBBarcode== pcbBarcode)
- .Where(x => x.ID == CarrierBind_exists.ID)
- .ExecuteCommand();
- logNet.WriteInfo($"载具码{carrierCode}与PCB码{pcbBarcode}绑定成功");
- }
- else {
- return new ResponseMessage { result = true, text = "载具码与PCB码绑定失败!载具码["+ carrierCode + "]没有绑定记录"};
- }
- // 插入数据
- return new ResponseMessage { result = true, text = "载具码与PCB码绑定成功" };
- }
- catch (Exception ex)
- {
- logNet.WriteError($"载具码与产品码绑定失败,错误" + ex.Message);
- return new ResponseMessage { result = false, text = "载具码与产品码绑定失败,错误" + ex.Message };
- }
- }
- public static ResponseMessage InsertOp10Data(string carrierCode, string productBarcode, int bindOrder,
- int throwingAmount, float cleaningPressure, float cleaningSpeed,
- float airKnifeHeight, float cleaningTime, int cleaningCount, int remainCount)
- {
- // 检查记录是否已经存在
- bool OP10_exists = Db.Queryable<CarrierBind>().Any(x => x.CarrierCode == carrierCode &&
- x.ProductBarcode == productBarcode);
- if (OP10_exists)
- {
- var maxBindOrder = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode &&
- x.ProductBarcode == productBarcode)
- .Max(x => x.BindOrder); ;
- bindOrder = maxBindOrder + 1;
- }
- #region 将OP10数据插入testdata表格
- // 创建 Op10 实体,并通过传入的参数设置字段值
- var op10 = new TestData
- {
- CarrierCode = carrierCode, // 载具码
- ProductBarcode = productBarcode, // 产品码
- BindOrder = bindOrder, // 绑定顺序
- OP10_ThrowingAmount = throwingAmount, // 抛料数量
- OP10_CleaningPressure = cleaningPressure, // 清洗气压
- OP10_CleaningSpeed = cleaningSpeed, // 清洗速度
- OP10_AirKnifeHeight = airKnifeHeight, // 风刀高度
- OP10_CleaningTime = cleaningTime, // 清洗时间
- OP10_CleaningCount = cleaningCount, // 清洗次数
- OP10_RemainCount = remainCount // 清洗次数
- };
- try
- {
- Db.Insertable(op10).ExecuteCommand();
- logNet.WriteError("OP10记录插入成功!");
- return new ResponseMessage { result = true, text = "OP10记录插入成功" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP10记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP10记录插入出错!错误码:" + ex.Message };
- }
- #endregion
- }
- // op20绑定部件码
- public static ResponseMessage InsertOp20Product(string carrierCode, string productBarcode, string topCover_Barcode)
- {
- int bindOrder = 1;
- try
- {
- // 检查记录是否已经存在
- bool Product_exists = Db.Queryable<ProductBind>().Any(x => x.CarrierCode == carrierCode &&
- x.ProductBarcode == productBarcode);
- if (Product_exists)
- {
- var maxBindOrder = Db.Queryable<ProductBind>()
- .Where(x => x.CarrierCode == carrierCode &&
- x.ProductBarcode == productBarcode)
- .Max(x => x.BindOrder); ;
- bindOrder = maxBindOrder + 1;
- }
- #region 新建ProductBind实体,并将数据插入productBind表格
- // 创建 ProductBind 实体,并通过传入的参数设置字段值
- var ProductBind_sumRecord = new ProductBind
- {
- CarrierCode = carrierCode,//载具码
- ProductBarcode = productBarcode, // 产品条码
- BindOrder = bindOrder, // 绑定顺序
- TopCover_Barcode = topCover_Barcode, //部件码
- };
- // 插入数据
- Db.Insertable(ProductBind_sumRecord).ExecuteCommand();
- return new ResponseMessage { result = true, text = "OP20-产品码绑定部件码成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP20-产品码绑定部件码出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP20-产品码绑定部件码出错!错误码:" + ex.Message };
- }
- #endregion
- }
- // op20向testdata表格插入数据
- public static ResponseMessage InsertOp20Data(string carrierCode, string productBarcode, int throwCount, int remainCount)
- {
- ////// 检查上一次插入的记录是否存在
- ////var lastRecord = Db.Queryable<TestData>()
- //// .Where(x => x.CarrierCode== carrierCode && x.ProductBarcode == productBarcode &&
- //// (x.OP10_ThrowingAmount != 0 ||
- //// x.OP10_CleaningPressure != 0.0f ||
- //// x.OP10_CleaningSpeed != 0.0f ||
- //// x.OP10_AirKnifeHeight != 0.0f ||
- //// x.OP10_CleaningTime != 0.0f ||
- //// x.OP10_CleaningCount != 0 ||
- //// x.OP10_RemainCount != 0)) // 看上一次有无记录数据
- //// .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- //// .Take(1) // 只取一条记录
- //// .First(); // 获取第一条记录,若没有则返回null
- ////if (lastRecord == null)
- ////{
- //// logNet.WriteError("OP20错误:OP10未插入数据!");
- ////}
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP20记录插入出错:MES主数据未成功创建,无法插入OP20数据!");
- return new ResponseMessage { result = false, text = "OP20错误:MES主数据未成功创建,无法插入OP20数据!" };
- }
- //if (lastRecord.OP20_ThrowCount != 0 || lastRecord.OP20_RemainCount != 0)
- //{
- // logNet.WriteError("OP20记录插入出错:即将插入的行数据已存在,插入失败!");
- // return new ResponseMessage { result = false, text = "OP20记录插入出错:即将插入的行数据已存在,插入失败!" };
- //}
- lastRecord.OP20_ThrowCount = throwCount;
- lastRecord.OP20_RemainCount = remainCount;
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new { x.OP20_ThrowCount, x.OP20_RemainCount })
- .ExecuteCommand();
- logNet.WriteError("OP20记录插入成功!");
- return new ResponseMessage { result = true, text = "OP20记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP20记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP20记录插入出错!错误码:" + ex.Message };
- }
- }
- // op301向testdata表格插入数据
- public static ResponseMessage InsertOp301Data(string carrierCode, string productBarcode, float gluingSpeed, float pressureAB, float pressureDifferenceAB,
- string productHeightInfo, string periodicWeightData, string remainingGlueAmount)
- {
- ////// 检查上一次插入的记录是否存在
- ////var lastRecord = Db.Queryable<TestData>()
- //// .Where(x => x.CarrierCode == carrierCode && x.ProductBarcode == productBarcode &&
- //// (x.OP20_ThrowCount != 0 || x.OP20_RemainCount != 0)) // 只查找有效插入的数据
- //// .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- //// .Take(1) // 只取一条记录
- //// .First(); // 获取第一条记录,若没有则返回null
- ////if (lastRecord == null)
- ////{
- //// logNet.WriteError("OP301错误:OP20插入的记录存在值为空!");
- //// return new ResponseMessage { result = false, text = "OP301错误:OP20插入的记录存在值为空!" };
- ////}
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP301错误:MES主数据未成功创建,无法插入OP301数据!");
- return new ResponseMessage { result = false, text = "OP301错误:MES主数据未成功创建,无法插入OP301数据!" };
- }
- //if (lastRecord.OP301_GluingSpeed != 0.0f || lastRecord.OP301_PressureAB != 0.0f ||
- //lastRecord.OP301_PressureDifferenceAB != 0.0f || lastRecord.OP301_ProductHeightInfo != 0.0f ||
- //lastRecord.OP301_PeriodicWeightData != 0.0f || lastRecord.OP301_RemainingGlueAmount != 0.0f)
- //{
- // logNet.WriteError("OP301记录插入出错:即将插入的行数据已存在,插入失败!");
- // return new ResponseMessage { result = false, text = "OP301记录插入出错:即将插入的行数据已存在,插入失败!" };
- //}
- lastRecord.OP301_GluingSpeed = gluingSpeed; // 供胶速度
- lastRecord.OP301_PressureAB = pressureAB; // AB管气压
- lastRecord.OP301_PressureDifferenceAB = pressureDifferenceAB; // AB管气压差
- lastRecord.OP301_ProductHeightInfo = productHeightInfo; // 产品测高信息
- lastRecord.OP301_PeriodicWeightData = periodicWeightData; // 定期称重数据
- lastRecord.OP301_RemainingGlueAmount = remainingGlueAmount; // 剩余胶量
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP301_GluingSpeed,
- x.OP301_PressureAB,
- x.OP301_PressureDifferenceAB,
- x.OP301_ProductHeightInfo,
- x.OP301_PeriodicWeightData,
- x.OP301_RemainingGlueAmount
- }).ExecuteCommand();
- logNet.WriteError("OP301记录插入成功!");
- return new ResponseMessage { result = true, text = "OP301记录插入成功" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP301记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP301记录插入出错!错误码:" + ex.Message };
- }
- }
- // op302向testdata表格插入数据
- public static ResponseMessage InsertOp302Data(string carrierCode, string productBarcode, float gluingSpeed, float pressureAB, float pressureDifferenceAB,
- string productHeightInfo, string periodicWeightData, string remainingGlueAmount)
- {
- ////// 检查上一次插入的记录是否存在
- ////var lastRecord = Db.Queryable<TestData>()
- //// .Where(x => x.OP301_GluingSpeed != 0.0f && x.OP301_PressureA != 0.0f && x.OP301_PressureB != 0.0f &&
- //// x.OP301_PressureDifferenceAB != 0.0f && x.OP301_ProductHeightInfo != 0.0f &&
- //// x.OP301_PeriodicWeightData != 0.0f && x.OP301_RemainingGlueAmount != 0.0f) // 只查找有效插入的数据
- //// .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- //// .Take(1) // 只取一条记录
- //// .First(); // 获取第一条记录,若没有则返回null
- ////if (lastRecord == null)
- ////{
- //// logNet.WriteError("OP302错误:OP301插入的记录存在值为空!");
- //// return new ResponseMessage { result = false, text = "OP302错误:OP301插入的记录存在值为空!" };
- ////}
- ///
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP302记录插入错误:MES主数据未成功创建,无法插入OP302数据!");
- return new ResponseMessage { result = false, text = "OP302记录插入错误:MES主数据未成功创建,无法插入OP302数据!" };
- }
- //if (lastRecord.OP302_GluingSpeed != 0.0f || lastRecord.OP302_PressureAB != 0.0f ||
- // lastRecord.OP302_PressureDifferenceAB != 0.0f || lastRecord.OP302_ProductHeightInfo != "" ||
- // lastRecord.OP302_PeriodicWeightData !="" || lastRecord.OP302_RemainingGlueAmount != "")
- //{
- // logNet.WriteError("OP302记录插入出错:即将插入的行数据已存在,插入失败!");
- // return new ResponseMessage { result = false, text = "OP302记录插入出错:即将插入的行数据已存在,插入失败!" };
- //}
- lastRecord.OP302_GluingSpeed = gluingSpeed; // 供胶速度
- lastRecord.OP302_PressureAB = pressureAB; // AB管气压
- lastRecord.OP302_PressureDifferenceAB = pressureDifferenceAB; // AB管气压差
- lastRecord.OP302_ProductHeightInfo = productHeightInfo; // 产品测高信息
- lastRecord.OP302_PeriodicWeightData = periodicWeightData; // 定期称重数据
- lastRecord.OP302_RemainingGlueAmount = remainingGlueAmount; // 剩余胶量
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP302_GluingSpeed,
- x.OP302_PressureAB,
- x.OP302_PressureDifferenceAB,
- x.OP302_ProductHeightInfo,
- x.OP302_PeriodicWeightData,
- x.OP302_RemainingGlueAmount
- }).ExecuteCommand();
- logNet.WriteError("OP302记录插入成功!");
- return new ResponseMessage { result = true, text = "OP302记录插入成功" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP302记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP302错误:即将插入的数据存在值不为空,插入失败,请按标准操作!" };
- }
- }
- // op40向testdata表格插入数据
- public static ResponseMessage InsertOp40Data(string carrierCode, string productBarcode, string gluePosx, string gluePosy, string glueLineArea,
- string glueLineHeight, int result, string inspectionImagePath)
- {
- //// 检查上一次插入的记录是否存在
- //var lastRecord = Db.Queryable<TestData>()
- // .Where(x => x.OP302_GluingSpeed != 0.0f && x.OP302_PressureAB != 0.0f &&
- // x.OP302_PressureDifferenceAB != 0.0f && x.OP302_ProductHeightInfo != 0.0f &&
- // x.OP302_PeriodicWeightData != 0.0f && x.OP302_RemainingGlueAmount != 0.0f) // 只查找有效插入的数据
- // .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- // .Take(1) // 只取一条记录
- // .First(); // 获取第一条记录,若没有则返回null
- //if (lastRecord == null)
- //{
- // logNet.WriteError("OP40错误:OP302插入的记录存在值为空!");
- // return new ResponseMessage { result = false, text = "OP40错误:OP302插入的记录存在值为空!" };
- //}
- //if (lastRecord.OP40_GluePosition != "" || lastRecord.OP40_GlueLineArea != 0.0f ||
- // lastRecord.OP40_GlueLineHeight != 0.0f || lastRecord.OP40_InspectionImagePath != "")
- //{
- // logNet.WriteError("OP40错误:即将插入的数据存在值不为空,插入失败,请按标准操作!");
- // return new ResponseMessage { result = false, text = "OP40错误:即将插入的数据存在值不为空,插入失败,请按标准操作!" };
- //}
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP40记录插入错误:MES主数据未成功创建,无法插入OP40数据!");
- return new ResponseMessage { result = false, text = "OP40记录插入错误:MES主数据未成功创建,无法插入OP40数据!" };
- }
- ////if (lastRecord.OP40_GluePosX != "" || lastRecord.OP40_GluePosY != "" || lastRecord.OP40_GlueLineArea != "" ||
- //// lastRecord.OP40_GlueLineHeight != "" || lastRecord.OP40_Result != 0 || lastRecord.OP40_InspectionImagePath != "")
- ////{
- //// logNet.WriteError("OP40记录插入出错:即将插入的行数据已存在,插入失败!");
- //// return new ResponseMessage { result = false, text = "OP40记录插入出错:即将插入的行数据已存在,插入失败!" };
- ////}
- lastRecord.OP40_GluePosX = gluePosx; // 胶线位置X偏差
- lastRecord.OP40_GluePosY = gluePosy; // 胶线位置Y偏差
- lastRecord.OP40_GlueLineArea = glueLineArea; // 胶线面积
- lastRecord.OP40_GlueLineHeight = glueLineHeight; // 胶线高度
- lastRecord.OP40_Result = result.ToString(); // 胶线检测结果
- lastRecord.OP40_InspectionImagePath = inspectionImagePath; // 检测图片路径
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP40_GluePosX,
- x.OP40_GluePosY,
- x.OP40_GlueLineArea,
- x.OP40_GlueLineHeight,
- x.OP40_Result,
- x.OP40_InspectionImagePath
- }).ExecuteCommand();
- logNet.WriteError("OP40记录插入成功!");
- return new ResponseMessage { result = true, text = "OP40记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP40记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = true, text = "OP40记录插入出错!错误码:" + ex.Message };
- }
- }
- //OP50 往product塞数据
- public static ResponseMessage InsertOp50Product(string carrierCode, string productBarcode, string addPCB_Barcode)
- {
- #region 往productBind表格中插入addPCB_Barcode数据
- // 检查上一次插入的记录是否存在
- try
- {
- var productBind_lastRecord = Db.Queryable<ProductBind>()
- .Where(x => x.CarrierCode == carrierCode && x.ProductBarcode == productBarcode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (productBind_lastRecord == null)
- {
- logNet.WriteError("OP50-错误:ProductBind表数据为空!");
- return new ResponseMessage { result = false, text = "OP50-错误:ProductBind表数据为空!" };
- }
- //if (productBind_lastRecord.AddPCB_Barcode != "")
- //{
- // logNet.WriteError("OP50-错误:即将插入ProductBind的数据存在值不为空,插入失败,请按标准操作!");
- // return new ResponseMessage { result = false, text = "OP50-错误:即将插入ProductBind的数据存在值不为空,插入失败,请按标准操作!" };
- //}
- productBind_lastRecord.AddPCB_Barcode = addPCB_Barcode;
- Db.Updateable(productBind_lastRecord)
- .UpdateColumns(x => new
- {
- x.AddPCB_Barcode
- }).ExecuteCommand();
- logNet.WriteError("OP50部件码绑定产品码成功!");
- return new ResponseMessage { result = false, text = "OP50部件码绑定产品码成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP50部件码绑定产品码失败!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP50部件码绑定产品码失败!错误码:" + ex.Message };
- }
- #endregion
- }
- // op50向testdata表格插入数据
- public static ResponseMessage InsertOp50Data(string carrierCode, string productBarcode, int assemblyStatus,
- int addBoardStatus, float addBoardPressure, int remainCount, string reinspectionImagePath)
- {
- // 检查上一次插入的记录是否存在
- //var lastRecord = Db.Queryable<TestData>()
- // .Where(x => x.CarrierCode == CarrierCode && x.ProductBarcode == ProductBarcode && x.OP40_GluePosition != "" && x.OP40_GlueLineArea != 0.0f &&
- // x.OP40_GlueLineHeight != 0.0f && x.OP40_InspectionImagePath != "") // 只查找有效插入的数据
- // .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- // .Take(1) // 只取一条记录
- // .First(); // 获取第一条记录,若没有则返回null
- //if (lastRecord == null)
- //{
- // logNet.WriteError("OP50错误:OP40插入的记录存在值为空!");
- // return new ResponseMessage { result = false, text = "OP50错误:OP40插入的记录存在值为空!!" };
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP50记录插入错误:MES主数据未成功创建,无法插入OP50数据!");
- return new ResponseMessage { result = false, text = "OP50记录插入错误:MES主数据未成功创建,无法插入OP50数据!" };
- }
- ////if ( lastRecord.OP50_AssemblyStatus != 2 || lastRecord.OP50_ReinspectionImagePath != "" ||
- //// lastRecord.OP50_AddBoardStatus != 2 || lastRecord.OP50_AddBoardPressure != 0.0f)
- ////{
- //// logNet.WriteError("OP50记录插入错误:即将插入的数据存在值不为空,插入失败,请按标准操作!");
- //// return new ResponseMessage { result = false, text = "OP50记录插入错误:即将插入的数据存在值不为空,插入失败,请按标准操作!" };
- ////}
- lastRecord.OP50_AssemblyStatus = assemblyStatus; // 组装是否到位
- lastRecord.OP50_AddBoardStatus = addBoardStatus; // ADD板有无
- lastRecord.OP50_AddBoardPressure = addBoardPressure; // ADD板压合压力
- lastRecord.OP50_RemainCount = remainCount; // ADD板余料数
- lastRecord.OP50_ReinspectionImagePath = reinspectionImagePath; // ADD板余料数
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP50_AssemblyStatus,
- x.OP50_AddBoardStatus,
- x.OP50_AddBoardPressure,
- x.OP50_RemainCount,
- x.OP50_ReinspectionImagePath
- }).ExecuteCommand();
- logNet.WriteError("OP50记录插入成功!");
- return new ResponseMessage { result = true, text = "OP50记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP50记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP50记录插入出错!错误码:" + ex.Message };
- }
- }
- // op60向testdata表格插入数据
- public static ResponseMessage InsertOp60Data(string carrierCode, string productBarcode, int assemblyStatus,
- int topCoverStatus, float topCoverPressure, string reinspectionImagePath)
- {
- // 检查上一次插入的记录是否存在
- //var lastRecord = Db.Queryable<TestData>()
- // .Where(x => x.CarrierCode == CarrierCode && x.ProductBarcode == ProductBarcode && x.AddPCB_Barcode != "" && x.OP50_AssemblyStatus != 2 && x.OP50_ReinspectionImagePath != "" &&
- // x.OP50_AddBoardStatus != 2 && x.OP50_AddBoardPressure != 0.0f) // 只查找有效插入的数据
- // .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- // .Take(1) // 只取一条记录
- // .First(); // 获取第一条记录,若没有则返回null
- //if (lastRecord == null)
- //{
- // logNet.WriteError("OP60错误:OP50插入的记录存在值为空!");
- // return new ResponseMessage { result = false, text = "OP60错误:OP50插入的记录存在值为空!" };
- // }
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP60记录插入错误:MES主数据未成功创建,无法插入OP60数据!");
- return new ResponseMessage { result = false, text = "OP60记录插入错误:MES主数据未成功创建,无法插入OP60数据!" };
- }
- //if (lastRecord.OP60_AssemblyStatus != 0 || lastRecord.OP60_ReinspectionImagePath != "" ||
- // lastRecord.OP60_TopCoverStatus != 0 || lastRecord.OP60_TopCoverPressure != 0.0f)
- //{
- // logNet.WriteError("OP50记录插入错误:即将插入的数据存在值不为空,插入失败,请按标准操作!");
- // return new ResponseMessage { result = false, text = "OP50记录插入错误:即将插入的数据存在值不为空,插入失败,请按标准操作!" };
- //}
- lastRecord.OP60_AssemblyStatus = assemblyStatus; // 组装是否到位
- lastRecord.OP60_TopCoverStatus = topCoverStatus; // 上盖板有无
- lastRecord.OP60_TopCoverPressure = topCoverPressure; // 上盖板压合压力
- lastRecord.OP60_ReinspectionImagePath = reinspectionImagePath; // 设备复检图片路径
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP60_AssemblyStatus,
- x.OP60_ReinspectionImagePath,
- x.OP60_TopCoverStatus,
- x.OP60_TopCoverPressure
- }).ExecuteCommand();
- logNet.WriteError("OP60记录插入成功!");
- return new ResponseMessage { result = true, text = "OP60记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP60记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP60记录插入出错!错误码:" + ex.Message };
- }
- }
- // op701向testdata表格插入数据
- public static ResponseMessage InsertOp701Data(string carrierCode, string productBarcode, string lockTime, string lockOrder, string lockResult, int remainCount)
- {
- // 检查上一次插入的记录是否存在
- //var lastRecord = Db.Queryable<TestData>()
- // .Where(x => x.CarrierCode == CarrierCode && x.ProductBarcode == ProductBarcode && x.OP60_AssemblyStatus != 2 && x.OP60_ReinspectionImagePath != "" &&
- // x.OP60_TopCoverStatus != 2 && x.OP60_TopCoverPressure != 0.0f) // 只查找有效插入的数据
- // .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- // .Take(1) // 只取一条记录
- // .First(); // 获取第一条记录,若没有则返回null
- //if (lastRecord == null)
- //{
- // logNet.WriteError("OP701错误:OP60插入的记录存在值为空!");
- // return new ResponseMessage { result = false, text = "OP701错误:OP60插入的记录存在值为空!" };
- //}
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP701记录插入错误:MES主数据未成功创建,无法插入OP701数据!");
- return new ResponseMessage { result = false, text = "OP701记录插入错误:MES主数据未成功创建,无法插入OP701数据!" };
- }
- //if (lastRecord.OP701_LockTime != "" || lastRecord.OP701_LockOrder != "" || lastRecord.OP701_LockResult != "")
- //{
- // logNet.WriteError("OP701错误:即将插入的数据存在值不为空,插入失败,请按标准操作!");
- // return new ResponseMessage { result = false, text = "OP701错误:即将插入的数据存在值不为空,插入失败,请按标准操作!" };
- //}
- lastRecord.OP701_LockTime = lockTime;
- lastRecord.OP701_LockOrder = lockOrder;
- lastRecord.OP701_LockResult = lockResult;
- lastRecord.OP701_RemainCount = remainCount;
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP701_LockTime,
- x.OP701_LockOrder,
- x.OP701_LockResult,
- x.OP701_RemainCount
- }).ExecuteCommand();
- logNet.WriteError("OP701记录插入成功!");
- return new ResponseMessage { result = true, text = "OP701记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP701记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP701记录插入出错!错误码:" + ex.Message };
- }
- }
- // op702向testdata表格插入数据
- public static ResponseMessage InsertOp702Data(string carrierCode, string productBarcode, string lockTime, string lockOrder, string lockResult, int remainCount)
- {
- //// 检查上一次插入的记录是否存在
- //var lastRecord = Db.Queryable<TestData>()
- // .Where(x => x.CarrierCode == CarrierCode && x.ProductBarcode == ProductBarcode && x.OP701_TorqueCurveDataPath != "" && x.OP701_ScrewPressure != 0.0f &&
- // x.OP701_Turns != 0 && x.OP701_LockTime != 0 && x.OP701_LockOrder != "" &&
- // x.OP701_LockResult != "") // 只查找有效插入的数据
- // .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- // .Take(1) // 只取一条记录
- // .First(); // 获取第一条记录,若没有则返回null
- //if (lastRecord == null)
- //{
- // logNet.WriteError("OP702错误:OP701插入的记录存在值为空!");
- // return new ResponseMessage { result = false, text = "OP702错误:OP701插入的记录存在值为空!" };
- //}
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP702记录插入错误:MES主数据未成功创建,无法插入OP702数据!");
- return new ResponseMessage { result = false, text = "OP702记录插入错误:MES主数据未成功创建,无法插入OP702数据!" };
- }
- lastRecord.OP702_LockTime = lockTime;
- lastRecord.OP702_LockOrder = lockOrder;
- lastRecord.OP702_LockResult = lockResult;
- lastRecord.OP702_RemainCount = remainCount;
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP702_LockTime,
- x.OP702_LockOrder,
- x.OP702_LockResult,
- x.OP702_RemainCount
- }).ExecuteCommand();
- logNet.WriteError("OP702记录插入成功!");
- return new ResponseMessage { result = true, text = "OP702记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP702记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP702记录插入出错!错误码:" + ex.Message };
- }
- }
- // op80向testdata表格插入数据
- public static ResponseMessage InsertOp80Data(string carrierCode, string productBarcode, string screwHeights,
- string screwResults)
- {
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP80记录插入错误:MES主数据未成功创建,无法插入OP80数据!");
- return new ResponseMessage { result = false, text = "OP80记录插入错误:MES主数据未成功创建,无法插入OP80数据!" };
- }
- lastRecord.OP80_ScrewHeights = screwHeights;
- lastRecord.OP80_ScrewResults = screwResults;
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP80_ScrewHeights,
- x.OP80_ScrewResults
- }).ExecuteCommand();
- logNet.WriteError("OP80记录插入成功!");
- return new ResponseMessage { result = true, text = "OP80记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP80记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP80记录插入出错!错误码:" + ex.Message };
- }
- }
- // op90向testdata表格插入数据
- public static ResponseMessage InsertOp90Data(string carrierCode, string productBarcode, int throwCount,
- int remainCount)
- {
- try
- {
- var lastRecord = Db.Queryable<TestData>()
- .Where(x => x.CarrierCode == carrierCode)
- .OrderBy(x => x.ID, OrderByType.Desc) // 按照ID降序查找最新记录
- .Take(1) // 只取一条记录
- .First(); // 获取第一条记录,若没有则返回null
- if (lastRecord == null)
- {
- logNet.WriteError("OP90记录插入错误:MES主数据未成功创建,无法插入OP90数据!");
- return new ResponseMessage { result = false, text = "OP90记录插入错误:MES主数据未成功创建,无法插入OP90数据!" };
- }
- lastRecord.OP90_ThrowCount = throwCount;
- lastRecord.OP90_RemainCount = remainCount;
- Db.Updateable(lastRecord)
- .UpdateColumns(x => new
- {
- x.OP80_ScrewHeights,
- x.OP80_ScrewResults
- }).ExecuteCommand();
- logNet.WriteError("OP90记录插入成功!");
- return new ResponseMessage { result = true, text = "OP90记录插入成功!" };
- }
- catch (Exception ex)
- {
- logNet.WriteError("OP80记录插入出错!错误码:" + ex.Message);
- return new ResponseMessage { result = false, text = "OP90记录插入出错!错误码:" + ex.Message };
- }
- }
- #region 实体
- // 定义实体类(对应数据库表)载具绑定表
- public class CarrierBind
- {
- // 主键ID,设置为自增且非空
- [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
- public int ID { get; set; } // 主键ID
- // 其他列
- public string CarrierCode { get; set; } = ""; // 载具码
- public string ProductBarcode { get; set; } = ""; // 产品码
- public string PCBBarcode { get; set; } = ""; // 产品码
- public DateTime CreateTime { get; set; } = DateTime.Now; // 创建时间
- }
- // 定义ProductBind实体类,表示表格结构
- public class ProductBind
- {
- // 主键ID,设置为自增且非空
- [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
- public int ID { get; set; } // 主键ID
- // 其他列
- public DateTime CreateTime { get; set; } = DateTime.Now; // 创建时间
- public string CarrierCode { get; set; } = ""; // 载具码
- public string ProductBarcode { get; set; } = ""; // 产品条码
- public string TopCover_Barcode { get; set; } = ""; // 上盖板条码
- public string AddPCB_Barcode { get; set; } = ""; // ADD板条码
- public int BindOrder { get; set; } = 0; // 绑定顺序
- }
- // 定义TestData实体类,表示表格TestData结构
- public class TestData
- {
- // 主键ID,设置为自增且非空
- [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
- public int ID { get; set; } // 主键ID
- // 其他列
- public DateTime CreateTime { get; set; } = DateTime.Now; // 创建时间
- public string CarrierCode { get; set; } = ""; // 载具码
- public string ProductBarcode { get; set; } = ""; // 产品条码
- public int BindOrder { get; set; } = 0; // 绑定顺序
- //op10
- public int OP10_ThrowingAmount { get; set; } = 0; // 抛料数量 // 清洗功率
- public float OP10_CleaningPressure { get; set; } = 0.0f; // 清洗气压
- public float OP10_CleaningSpeed { get; set; } = 0.0f; // 清洗速度
- public float OP10_AirKnifeHeight { get; set; } = 0.0f; // 风刀高度
- public float OP10_CleaningTime { get; set; } = 0.0f; // 清洗时间
- public int OP10_CleaningCount { get; set; } = 0; // 清洗次数
- public int OP10_RemainCount { get; set; } = 0; // 外壳体余料数
- //op20
- public int OP20_ThrowCount { get; set; } = 0; // 抛料数量
- public int OP20_RemainCount { get; set; } = 0; // 上盖余料数
- //op301
- public float OP301_GluingSpeed { get; set; } = 0.0f; // 供胶速度
- public float OP301_PressureAB { get; set; } = 0.0f; // A管气压
- public float OP301_PressureDifferenceAB { get; set; } = 0.0f; // AB管气压差
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP301_ProductHeightInfo { get; set; } = ""; // 产品测高信息
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP301_PeriodicWeightData { get; set; } = ""; // 定期称重数据
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP301_RemainingGlueAmount { get; set; } = ""; // 剩余胶量
- //op302
- public float OP302_GluingSpeed { get; set; } = 0.0f; // 供胶速度
- public float OP302_PressureAB { get; set; } = 0.0f; // A管气压
- public float OP302_PressureDifferenceAB { get; set; } = 0.0f; // AB管气压差
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP302_ProductHeightInfo { get; set; } = ""; // 产品测高信息
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP302_PeriodicWeightData { get; set; } = ""; // 定期称重数据
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP302_RemainingGlueAmount { get; set; } = ""; // 剩余胶量
- //op40
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP40_GluePosX { get; set; } = ""; // 胶线位置X偏差
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP40_GluePosY { get; set; } = ""; // 胶线位置Y偏差
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP40_GlueLineArea { get; set; } = ""; // 胶线面积
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP40_GlueLineHeight { get; set; } = ""; // 胶线高度
- public string OP40_Result { get; set; } = ""; // 胶线检测结果 1:OK 非1:NG
- public string OP40_InspectionImagePath { get; set; } = ""; // 检测图片路径
- //op50
- public int OP50_AssemblyStatus { get; set; } = 0; // 组装是否到位
- public string OP50_ReinspectionImagePath { get; set; } = ""; // 设备复检图片路径
- public int OP50_AddBoardStatus { get; set; } = 0; // ADD板有无
- public int OP50_RemainCount { get; set; } = 0; // ADD板余料数
- public float OP50_AddBoardPressure { get; set; } = 0.0f; // ADD板压合压力
- //op60
- public int OP60_AssemblyStatus { get; set; } = 0; // 组装是否到位
- public int OP60_TopCoverStatus { get; set; } = 0; // 上盖板有无
- public float OP60_TopCoverPressure { get; set; } = 0.0f; // 上盖板压合压力
- public string OP60_ReinspectionImagePath { get; set; } = ""; // 设备复检图片路径
- //op701
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP701_LockTime { get; set; } = ""; // 锁附时间
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP701_LockOrder { get; set; } = ""; // 锁附顺序
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP701_LockResult { get; set; } = ""; // 锁附结果
- public int OP701_RemainCount { get; set; } = 0; // 螺丝余料数
- //op702
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP702_LockTime { get; set; } = ""; // 锁附时间
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP702_LockOrder { get; set; } = ""; // 锁附顺序
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP702_LockResult { get; set; } = ""; // 锁附结果
- public int OP702_RemainCount { get; set; } = 0; // 螺丝余料数
- //op80
- [SqlSugar.SugarColumn(ColumnDataType = "varchar(500)")]
- public string OP80_ScrewHeights { get; set; } = ""; // 螺丝高度
- public string OP80_ScrewResults { get; set; } = ""; // 螺丝检测结果
- //op90
- public int OP90_ThrowCount { get; set; } = 0; // 抛料次数
- public int OP90_RemainCount { get; set; } = 0; // 料箱余料数
- }
- #endregion
- }
- }
|