|
|
@@ -1,4 +1,5 @@
|
|
|
-using LocalhostMES.Models;
|
|
|
+using LocalhostMES.Core;
|
|
|
+using LocalhostMES.Models;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
@@ -15,7 +16,7 @@ namespace LocalhostMES.DataBase
|
|
|
public static SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
|
|
|
{
|
|
|
//192.168.1.100
|
|
|
- ConnectionString = "Database=LingPaoProject; Data Source=Localhost; Port=3306;User Id=root; Password=root;Charset=utf8;TreatTinyAsBoolean=false;",//连接符字串
|
|
|
+ ConnectionString = "Database=LingPaoProject; Data Source=192.168.1.26; Port=3306;User Id=root; Password=root;Charset=utf8;TreatTinyAsBoolean=false;",//连接符字串
|
|
|
DbType = SqlSugar.DbType.MySql,//数据库类型
|
|
|
IsAutoCloseConnection = true //不设成true要手动close
|
|
|
},
|
|
|
@@ -36,7 +37,21 @@ namespace LocalhostMES.DataBase
|
|
|
Db.CodeFirst.InitTables<SnInfo>();
|
|
|
Db.CodeFirst.InitTables<BindRecord>();
|
|
|
Db.CodeFirst.InitTables<ProcessRecord>();
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int GetProductProductionRecords(string sn)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return Db.Queryable<ProductionToStation>().Where(it => it.SN == sn).ToList().Count;
|
|
|
+ }
|
|
|
+ catch ( Exception ex )
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("获取一条产品的生产记录至数据库时出错!", ex);
|
|
|
+
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
}
|
|
|
public static List<WorkOrderInfo> SelectWorkOrderInfo(string workOrderNo = null)
|
|
|
{
|
|
|
@@ -47,24 +62,23 @@ namespace LocalhostMES.DataBase
|
|
|
else
|
|
|
{
|
|
|
return Db.Queryable<WorkOrderInfo>().ToList();
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- public static bool InsertWorkOrderInfo(WorkOrderInfo info)
|
|
|
+
|
|
|
+ public static bool InsertWorkOrderInfo(WorkOrderInfo info)
|
|
|
{
|
|
|
|
|
|
- if( Db.Storageable(info).ExecuteCommand() == 1 )
|
|
|
+ if ( Db.Storageable(info).ExecuteCommand() == 1 )
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
public static bool UpdateWorkOrderInfo(WorkOrderInfo info)
|
|
|
{
|
|
|
|
|
|
- if ( Db.Updateable(info).Where(it=>it.WorkOrderNo==info.WorkOrderNo) .ExecuteCommand() == 1 )
|
|
|
+ if ( Db.Updateable(info).Where(it => it.WorkOrderNo == info.WorkOrderNo).ExecuteCommand() == 1 )
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
@@ -80,7 +94,7 @@ namespace LocalhostMES.DataBase
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- public static List<SnInfo> SelectSnInfo(string workOrderNo = null, bool needused = false,bool isused=false)
|
|
|
+ public static List<SnInfo> SelectSnInfo(string workOrderNo = null, bool needused = false, bool isused = false)
|
|
|
{
|
|
|
if ( workOrderNo != null )
|
|
|
{
|
|
|
@@ -88,7 +102,7 @@ namespace LocalhostMES.DataBase
|
|
|
{
|
|
|
return Db.Queryable<SnInfo>().Where(it => it.WorkOrderNo == workOrderNo && it.IsUsed == isused).ToList();
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
return Db.Queryable<SnInfo>().Where(it => it.WorkOrderNo == workOrderNo).ToList();
|
|
|
}
|
|
|
@@ -96,7 +110,6 @@ namespace LocalhostMES.DataBase
|
|
|
else
|
|
|
{
|
|
|
return Db.Queryable<SnInfo>().ToList();
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
public static bool InsertSnInfo(SnInfo info)
|
|
|
@@ -171,7 +184,7 @@ namespace LocalhostMES.DataBase
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public static bool DeleteBindRecord(string sn=null)
|
|
|
+ public static bool DeleteBindRecord(string sn = null)
|
|
|
{
|
|
|
if ( sn != null )
|
|
|
{
|
|
|
@@ -180,9 +193,9 @@ namespace LocalhostMES.DataBase
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
- if ( Db.Deleteable<BindRecord>().ExecuteCommand()!=0)
|
|
|
+ if ( Db.Deleteable<BindRecord>().ExecuteCommand() != 0 )
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
@@ -200,7 +213,7 @@ namespace LocalhostMES.DataBase
|
|
|
query = query.Where(it => it.Sn == Sn);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if ( !string.IsNullOrWhiteSpace(StationCode) )
|
|
|
{
|
|
|
@@ -230,7 +243,7 @@ namespace LocalhostMES.DataBase
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public static bool DeleteProcessRecord(string sn=null)
|
|
|
+ public static bool DeleteProcessRecord(string sn = null)
|
|
|
{
|
|
|
|
|
|
if ( Db.Deleteable<ProcessRecord>().Where(it => it.Sn == sn).ExecuteCommand() == 1 )
|
|
|
@@ -239,7 +252,7 @@ namespace LocalhostMES.DataBase
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|