|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Mesnac.Basic;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using Mesnac.Compressor.Entity;
|
|
|
|
|
using Mesnac.Compressor.Unity;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Compressor.Data
|
|
|
|
|
{
|
|
|
|
|
public class DataBHandler
|
|
|
|
|
{
|
|
|
|
|
public DbHelper dbHelper;
|
|
|
|
|
private DataSourceFactory dsFactory=DataSourceFactory.Instance;
|
|
|
|
|
public DataBHandler()
|
|
|
|
|
{
|
|
|
|
|
dbHelper = dsFactory.GetDbHelper("DataSource1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConnectShow()
|
|
|
|
|
{
|
|
|
|
|
Common.Instance.LocalConnect = false;
|
|
|
|
|
FrmConnnectFlag frm = new FrmConnnectFlag();
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
dbHelper = null;
|
|
|
|
|
}
|
|
|
|
|
#region 查询
|
|
|
|
|
public bool TrayIsNull(string Rfid)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("select * from T_RP_WorkTrayRealTimeInfo where state!=0 and RFIDNum='").Append(Rfid).Append("'");
|
|
|
|
|
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
|
|
|
if (dt.Rows.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取产品是否合格
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Rfid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public WorkTray GetProductQuality(string Rfid)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Fatal("查询本地数据库");
|
|
|
|
|
WorkTray tray = new WorkTray();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("select * from T_RP_WorkTrayRealTimeInfo where RFIDNum='").Append(Rfid).Append("'");
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Debug("sql语句:"+sb.ToString());
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
|
|
|
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
tray.RfidNum = dt.Rows[0]["RFIDNum"].ToString();
|
|
|
|
|
tray.MainBarcode = dt.Rows[0]["barCode"].ToString();
|
|
|
|
|
tray.SemiBarcode = dt.Rows[0]["SemiBarcode"].ToString();
|
|
|
|
|
string Okng= dt.Rows[0]["State"].ToString();
|
|
|
|
|
tray.InsertTime = dt.Rows[0]["updateTime"].ToString();
|
|
|
|
|
int outvalue = 0;
|
|
|
|
|
//调试用
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Debug(dt.Rows[0]["RFIDNum"].ToString() + " barcode:" + dt.Rows[0]["barcode"].ToString() + " SemiBarcode:" + dt.Rows[0]["SemiBarcode"].ToString() + " State:" + dt.Rows[0]["State"].ToString() + " CurrentStation:" + dt.Rows[0]["CurrentStation"].ToString());
|
|
|
|
|
//调试完成
|
|
|
|
|
if (int.TryParse(Okng.Trim(), out outvalue))
|
|
|
|
|
{
|
|
|
|
|
tray.OKNG = outvalue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//质量转换错误,默认为1
|
|
|
|
|
ICSharpCode.Core.LoggingService.Info("质量转换错误,默认为1");
|
|
|
|
|
tray.OKNG = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(e.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
return tray;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="semiBarcode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetMainBacodeBySemiBarcode(string semiBarcode)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null|| !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("SELECT SemiBarcode FROM dbo.T_RP_WorkTrayRealTimeInfo WHERE RFIDNum='");
|
|
|
|
|
sb.Append(semiBarcode).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Rfid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool GetPreWorkInfo(string Rfid,string stationid)
|
|
|
|
|
{
|
|
|
|
|
//根据当前工位获取前一工位数据
|
|
|
|
|
//然后获取前一工位信息
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
sb.Append("SELECT StationID FROM dbo.T_BD_SubStation a LEFT JOIN dbo.T_RP_WorkTrayRealTimeInfo b ON a.PreStationID=b.CurrentStation WHERE b.RFIDNum='").Append(Rfid).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
|
|
|
if (dt.Rows.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
string currentStation = dt.Rows[0]["StationID"].ToString();
|
|
|
|
|
if (stationid == currentStation)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 这个好像没用
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="TableName"></param>
|
|
|
|
|
/// <param name="objectArray"></param>
|
|
|
|
|
public void Insert(string TableName,object[] objectArray)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("insert into ").Append(TableName).Append(" values(");
|
|
|
|
|
//sb.Append("'',").Append();
|
|
|
|
|
foreach (object ob in objectArray)
|
|
|
|
|
{
|
|
|
|
|
sb.Append("'").Append(ob.ToString()).Append("'");
|
|
|
|
|
}
|
|
|
|
|
sb.Append(")");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ExecSql(string sql)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("Insert语句错误:" + e.ToString());
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetLastMainBarcode(string code)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "NoConnect0001";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("EXEC SP_Pro_GetNewMainBarcode '");
|
|
|
|
|
sb.Append(code).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
return "Error0001";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetLastSemiBarcode(string code)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "NoConnect0001";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("EXEC SP_Pro_GetNewSemiBarcode '");
|
|
|
|
|
sb.Append(code).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
return "Error0001";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stationID"></param>
|
|
|
|
|
/// <param name="RFID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool CurrentStationHaveWork(string stationID,string RFID)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_CurruntState @RFID,@stationID";
|
|
|
|
|
dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
dbHelper.AddParameter("@stationID", stationID);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
var obj=dbHelper.ToScalar();
|
|
|
|
|
int result = Convert.ToInt32(obj);
|
|
|
|
|
if (result < 1)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前工位质量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="MainBarcode"></param>
|
|
|
|
|
/// <param name="SemiBarcode"></param>
|
|
|
|
|
/// <param name="StationName"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool GetCurrentStationState(string MainBarcode,string SemiBarcode,string StationName,string tableName)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string TableName = tableName;
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append(" SELECT Barcode FROM ").Append(TableName);
|
|
|
|
|
sb.Append(" WHERE Barcode='").Append(MainBarcode).Append("' AND SemiBarcode='").Append(SemiBarcode).Append("' AND State='1'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
|
|
|
return dt.Rows.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建新的系统条码**************888
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="MainBarcode"></param>
|
|
|
|
|
/// <param name="SemiBarcode"></param>
|
|
|
|
|
public void CreatNewProduct(string MainBarcode,string SemiBarcode)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("INSERT INTO dbo.T_SY_TraceState(barcode,SemiBarcode_A1)VALUES('");
|
|
|
|
|
sb.Append(MainBarcode).Append("','").Append(SemiBarcode).Append("')");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新托盘状态************************
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tray"></param>
|
|
|
|
|
/// <param name="stationid"></param>
|
|
|
|
|
public void UpdateTray(WorkTray tray,string stationid,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("UPDATE dbo.T_RP_WorkTrayRealTimeInfo SET ");
|
|
|
|
|
sb.Append("barCode='").Append(tray.MainBarcode).Append("',");
|
|
|
|
|
sb.Append("SemiBarcode='").Append(tray.SemiBarcode).Append("',");
|
|
|
|
|
sb.Append("CurrentStation='").Append(stationid).Append("',");
|
|
|
|
|
sb.Append("State='").Append(tray.OKNG.ToString()).Append("',");
|
|
|
|
|
sb.Append("UploadFlag='").Append(flag.ToString()).Append("',");
|
|
|
|
|
sb.Append("updateTime='").Append(tray.InsertTime).Append("' ");
|
|
|
|
|
sb.Append("WHERE RFIDNum='").Append(tray.RfidNum).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Info("更新托盘信息:" + sb.ToString());
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//互换托盘,不是换线。******************************
|
|
|
|
|
public void ChangeTray(string RFID,int state,string SemiType, string stationID,string Semibarcode)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_changeTray @RFID,@State,@stationID,@semibarcode,@semiType";
|
|
|
|
|
dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
dbHelper.AddParameter("@State", state);
|
|
|
|
|
dbHelper.AddParameter("@semibarcode", Semibarcode);
|
|
|
|
|
dbHelper.AddParameter("@semiType", SemiType);
|
|
|
|
|
dbHelper.AddParameter("@stationID", stationID);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetSemiBarcode(string RFID)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("SELECT SemiBarcode FROM dbo.T_RP_WorkTrayRealTimeInfo WHERE RFIDNum='");
|
|
|
|
|
sb.Append(RFID).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetMainBarcode(string RFID)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("SELECT barCode FROM dbo.T_RP_WorkTrayRealTimeInfo WHERE RFIDNum='");
|
|
|
|
|
sb.Append(RFID).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入部件条码到部件表*******************************
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="barcode"></param>
|
|
|
|
|
public void InsertSemiBarcode(string barcode,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("INSERT INTO [dbo].[T_RP_SemiProInfo](SemiBarcode,UploadFlag)VALUES('");
|
|
|
|
|
sb.Append(barcode).Append("','").Append(flag.ToString()).Append("')");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入trace表*********************
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="barcode"></param>
|
|
|
|
|
/// <param name="SemiACode"></param>
|
|
|
|
|
public void InsertTrace(string barcode, string SemiACode,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
|
|
|
|
|
string sql = "EXEC SP_Pro_InsertTraceStation @semiBarcode,@mainBarcode,@flag";
|
|
|
|
|
dbHelper.AddParameter("@semiBarcode", SemiACode);
|
|
|
|
|
dbHelper.AddParameter("@mainBarcode", barcode);
|
|
|
|
|
dbHelper.AddParameter("@flag", flag);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 第一工位更新trace********************************
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="barcode"></param>
|
|
|
|
|
/// <param name="SemiACode"></param>
|
|
|
|
|
/// <param name="MachineID"></param>
|
|
|
|
|
public void InsertMainBacode(string barcode,string SemiACode,string MachineID)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("INSERT INTO [dbo].[T_SY_TraceState](Barcode,SemiBarcode_A,ProductID)VALUES('");
|
|
|
|
|
sb.Append(barcode).Append("','").Append(SemiACode).Append("','").Append(MachineID).Append("')");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新主表,追踪**************************
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdateTrace(string Column,string MainCode,string SemiCode,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("UPDATE [dbo].[T_SY_TraceState] SET ");
|
|
|
|
|
//这里还需要加上,拆解不为1
|
|
|
|
|
sb.Append(Column).Append("='").Append(SemiCode).Append("', UploadFlag='").Append(flag.ToString()).Append("' where Barcode='").Append(MainCode).Append("'");
|
|
|
|
|
sb.Append(" and ISDis=0");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Info("更新Trace:" + sb.ToString());
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ChangeLine(string RFID,string Semibarcode,string stationid,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_ChangeLine @RFID,@Semibarcode,@stationid,@flag";
|
|
|
|
|
dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
dbHelper.AddParameter("@Semibarcode", Semibarcode);
|
|
|
|
|
dbHelper.AddParameter("@stationid", stationid);
|
|
|
|
|
dbHelper.AddParameter("@flag", flag);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
int result = Convert.ToInt32(dbHelper.ToScalar());
|
|
|
|
|
return result == 1 ? true : false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateTraceStation(string RFID,int state,string SemiType, string stationID,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_UpdateTraceStation @RFID,@State,@stationID,@semiType,@flag";
|
|
|
|
|
dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
dbHelper.AddParameter("@State", state);
|
|
|
|
|
dbHelper.AddParameter("@semiType", SemiType);
|
|
|
|
|
dbHelper.AddParameter("@stationID", stationID);
|
|
|
|
|
dbHelper.AddParameter("@flag", flag);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Info("更新生产信息:" + sql);
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
//测试
|
|
|
|
|
//GetProductQuality(RFID);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前机种信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetCurrentMachineInfo()
|
|
|
|
|
{
|
|
|
|
|
//MachineInfo Minfo = new MachineInfo();
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
//return Minfo;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_ChangeProduct";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入报警信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="WorkName">电脑名字</param>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
public void InsertAlarmInfo(string WorkName,AlarmInfo info)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("INSERT INTO dbo.T_BD_UniteAlarmInfo(ComputerName,UniteID,AlarmInfo,AlarmIndex,RecordTime )VALUES ('");
|
|
|
|
|
sb.Append(WorkName).Append("','");
|
|
|
|
|
sb.Append(info.AlarmUnit.ToString()).Append("','");
|
|
|
|
|
sb.Append(info.AlarmString).Append("','");
|
|
|
|
|
sb.Append(info.AlarmIndex.ToString()).Append("',");
|
|
|
|
|
sb.Append("GETDATE()").Append(")");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region ActionDb
|
|
|
|
|
public DataTable SelectAlarmInfo(string ComputerName)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("select 序号 = row_number() over(order by RecordTime desc),AlarmIndex as '报警单元',AlarmInfo as '报警信息 (一小时)' ,RecordTime as '报警时间' from dbo.T_BD_UniteAlarmInfo where ComputerName= '");
|
|
|
|
|
sb.Append(ComputerName).Append("'");
|
|
|
|
|
sb.Append(" AND RecordTime>=DATEADD(HH,-1,GETDATE())");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
DataTable dt= dbHelper.ToDataTable();
|
|
|
|
|
return dt;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//工作完成
|
|
|
|
|
public void WorkFinish(string RFID,string bigcode,string serialnum,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
//string sql = "Exec SP_Pro_ProductionInfo @RFID,@bigCode,@serialNum";
|
|
|
|
|
//dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
//dbHelper.AddParameter("@bigCode", bigcode);
|
|
|
|
|
//dbHelper.AddParameter("@serialNum", serialnum);
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("Exec SP_Pro_ProductionInfo '").Append(RFID).Append("','");
|
|
|
|
|
sb.Append(bigcode).Append("','");
|
|
|
|
|
sb.Append(serialnum).Append("','");
|
|
|
|
|
sb.Append(flag.ToString()).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Info(string.Format(sb.ToString()));
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TrayTemInsert(string RFID)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_D4insert @RFID";
|
|
|
|
|
dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
return Convert.ToInt32(dbHelper.ToScalar());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string GetTrayTemID(int key)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "SELECT Semibarcode FROM [T_tem_D4] WHERE serialID='"+key.ToString()+"'";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取最新交接班信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ShiftInfo GetShiftInfo()
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "SELECT TOP(1)ShiftNo,GroupID,a.ShiftID, b.ShiftName,a.CarryTime FROM dbo.T_RP_ShiftInfo a LEFT JOIN dbo.T_HR_Shift b ON a.ShiftID=b.ShiftID ORDER BY CarryTime DESC ";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
DataTable dt= dbHelper.ToDataTable();
|
|
|
|
|
|
|
|
|
|
ShiftInfo shift = new ShiftInfo();
|
|
|
|
|
shift.carryTime = dt.Rows[0]["CarryTime"].ToString();
|
|
|
|
|
shift.shiftNo = dt.Rows[0]["ShiftNo"].ToString();
|
|
|
|
|
shift.shiftID = dt.Rows[0]["ShiftID"].ToString();
|
|
|
|
|
shift.groupID = dt.Rows[0]["GroupID"].ToString();
|
|
|
|
|
shift.shiftName = dt.Rows[0]["ShiftName"].ToString();
|
|
|
|
|
return shift;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetCurrentMachine()
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "SELECT TOP(1) ProductChangingID FROM dbo.T_RP_ProductChangeLog ORDER BY ChangeTime DESC ";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
return Convert.ToInt32(dbHelper.ToScalar());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前机种
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="MachineID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataTable GetCurrentMachine(int MachineID)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = " SELECT * FROM dbo.T_BD_ProductInfo WHERE ProductID='" + MachineID.ToString()+"'";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
return dbHelper.ToDataTable();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前产品的投产时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name=""></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetProductBeginTime(string mainbarcode)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = " SELECT top(1) BeginTime FROM dbo.T_SY_TraceState WHERE Barcode='" + mainbarcode + "'";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存每个线尾要换线的托盘信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="MachineID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public void SaveChangeLineInfo(string RFID,int flag)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null || !Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "Exec SP_Pro_SaveLastStation @RFID,@flag";
|
|
|
|
|
dbHelper.AddParameter("@RFID", RFID);
|
|
|
|
|
dbHelper.AddParameter("@flag", flag);
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
|
|
|
|
|
//ConnectShow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float GetD8Weight(string SemiBarcode)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("SELECT top(1) Para1 FROM dbo.T_RP_StationPara_D8d2 WHERE SemiBarcode='");
|
|
|
|
|
sb.Append(SemiBarcode).Append("'");
|
|
|
|
|
dbHelper.CommandText = sb.ToString();
|
|
|
|
|
return Convert.ToSingle(dbHelper.ToScalar());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|