|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Data;
|
|
|
using Mesnac.Basic;
|
|
|
using Mesnac.Codd.Session;
|
|
|
using System.Configuration;
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 数据存盘辅助类
|
|
|
/// </summary>
|
|
|
public class LotSaveHelper
|
|
|
{
|
|
|
#region 数据验证方法
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断车条码对应的数据是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="barcode">车条码</param>
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
public static bool Exists(string barcode)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string sqlstr = "select COUNT(Barcode) from PptLotData where Barcode=@Barcode";
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Barcode", barcode);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
int intResult = 0;
|
|
|
int.TryParse(result.ToString(), out intResult);
|
|
|
if (intResult > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<LotSaveHelper>.Error(ex.Message, ex);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 数据查询
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 报表存盘基础信息数据追加
|
|
|
|
|
|
/// <summary>
|
|
|
/// 追加报表存盘基础信息数据至数据库
|
|
|
/// </summary>
|
|
|
/// <param name="lotData">报表头数据对象</param>
|
|
|
public static void InsertLRLotData(Entity.LR_lot lotData)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string sqlstr = @"insert into LR_lot(Dosing_id,Plan_id,Equip_code,Serial_Num,Prd_date,Real_weight,Real_Error,Waste_Time,Warning_sgn,Net_Weight,Ng_sgn,ResetFlag,ResetStationNo,Lot_Barcode)
|
|
|
values(@Dosing_id,@Plan_id,@Equip_code,@Serial_Num,@Prd_date,@Real_weight,@Real_Error,@Waste_Time,@Warning_sgn,@Net_Weight,@Ng_sgn,@ResetFlag,@ResetStationNo,@Lot_Barcode)";
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Dosing_id", 0);
|
|
|
dbHelper.AddParameter("@Plan_id", lotData.Plan_id);
|
|
|
dbHelper.AddParameter("@Equip_code", ConfigurationManager.AppSettings["EquipCode"]);
|
|
|
dbHelper.AddParameter("@Serial_Num", lotData.Serial_Num);
|
|
|
dbHelper.AddParameter("@Prd_date", lotData.Prd_date);
|
|
|
dbHelper.AddParameter("@Real_weight", lotData.Real_weight / 1000);
|
|
|
dbHelper.AddParameter("@Real_Error", lotData.Real_Error / 1000);
|
|
|
dbHelper.AddParameter("@Waste_Time", lotData.Waste_Time);
|
|
|
dbHelper.AddParameter("@Warning_sgn", lotData.Warning_sgn);
|
|
|
dbHelper.AddParameter("@Net_Weight", lotData.Net_Weight / 1000);
|
|
|
dbHelper.AddParameter("@Ng_sgn", lotData.Ng_sgn);
|
|
|
dbHelper.AddParameter("@ResetFlag", 0);
|
|
|
dbHelper.AddParameter("@ResetStationNo", 0);
|
|
|
dbHelper.AddParameter("@Lot_Barcode", null);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<LotSaveHelper>.Error("车报表数据保存异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 报表存盘物料信息数据追加
|
|
|
|
|
|
/// <summary>
|
|
|
/// 追加报表存盘基础信息数据至数据库
|
|
|
/// </summary>
|
|
|
/// <param name="lotData">报表头数据对象</param>
|
|
|
public static void InsertLRweighData(Entity.LR_weigh weighData)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string sqlstr = @"insert into LR_weigh(Dosing_id,Plan_id,Equip_code,Serial_Num,Weight_ID,Material_Code,Real_Weight,Real_Error,Over_Weight,Over_Error,Waste_Time,Warning_Sign,Weight_Time,Batch_Number,Recipe_code)
|
|
|
values(@Dosing_id,@Plan_id,@Equip_code,@Serial_Num,@Weight_ID,@Material_Code,@Real_Weight,@Real_Error,@Over_Weight,@Over_Error,@Waste_Time,@Warning_Sign,@Weight_Time,@Batch_Number,@Recipe_code)";
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
|
if (weighData.Real_Error > 32767)
|
|
|
{
|
|
|
weighData.Real_Error = weighData.Real_Error - 65536;
|
|
|
}
|
|
|
|
|
|
dbHelper.AddParameter("@Dosing_id", weighData.Dosing_id);
|
|
|
dbHelper.AddParameter("@Plan_id", weighData.Plan_id);
|
|
|
dbHelper.AddParameter("@Equip_code", ConfigurationManager.AppSettings["EquipCode"]);
|
|
|
dbHelper.AddParameter("@Serial_Num", weighData.Serial_Num);
|
|
|
dbHelper.AddParameter("@Weight_ID", weighData.Weight_ID);
|
|
|
dbHelper.AddParameter("@Material_Code", weighData.Material_Code);
|
|
|
dbHelper.AddParameter("@Real_Weight", weighData.Real_Weight / 1000);
|
|
|
dbHelper.AddParameter("@Real_Error", weighData.Real_Error / 1000);
|
|
|
dbHelper.AddParameter("@Over_Weight", weighData.Over_Weight / 1000);
|
|
|
dbHelper.AddParameter("@Over_Error", weighData.Over_Error / 1000);
|
|
|
dbHelper.AddParameter("@Waste_Time", weighData.Waste_Time);
|
|
|
dbHelper.AddParameter("@Warning_Sign", weighData.Warning_sgn);
|
|
|
dbHelper.AddParameter("@Weight_Time", weighData.Weight_Time);
|
|
|
dbHelper.AddParameter("@Batch_Number", null);
|
|
|
dbHelper.AddParameter("@Recipe_code", null);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<LotSaveHelper>.Error("车报表数据保存异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 数据更新
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 冠合项目存盘数据
|
|
|
public static void InsertGHSaveData(Entity.RecordSaveDataInfo recordSaveDataInfo)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string sqlstr = @"insert into Record_SaveDataInfo(PlanId,SaveCode,SaveFinishedNum,SaveRow,SaveCol,SaveVCCSet,SaveVCCAct,SaveGFASet,SaveGFAAct,Save3thSet,Save3thAct,SaveLevel,SaveFillTime,SaveSpeed1,SaveSpeed2,SaveTime,Record_Time,SaveVCC2thSet,SaveVCC2thAct,SaveGFA2thSet,SaveGFA2thAct)
|
|
|
values(@PlanId,@SaveCode,@SaveFinishedNum,@SaveRow,@SaveCol,@SaveVCCSet,@SaveVCCAct,@SaveGFASet,@SaveGFAAct,@Save3thSet,@Save3thAct,@SaveLevel,@SaveFillTime,@SaveSpeed1,@SaveSpeed2,@SaveTime,@Record_Time,@SaveVCC2thSet,@SaveVCC2thAct,@SaveGFA2thSet,@SaveGFA2thAct)";
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanId", recordSaveDataInfo.PlanId);
|
|
|
dbHelper.AddParameter("@SaveCode", recordSaveDataInfo.SaveCode);
|
|
|
dbHelper.AddParameter("@SaveFinishedNum", recordSaveDataInfo.SaveFinishedNum);
|
|
|
dbHelper.AddParameter("@SaveRow", recordSaveDataInfo.SaveRow);
|
|
|
dbHelper.AddParameter("@SaveCol", recordSaveDataInfo.SaveCol);
|
|
|
dbHelper.AddParameter("@SaveVCCSet", recordSaveDataInfo.SaveVCCSet);
|
|
|
dbHelper.AddParameter("@SaveVCCAct", recordSaveDataInfo.SaveVCCAct);
|
|
|
dbHelper.AddParameter("@SaveGFASet", recordSaveDataInfo.SaveGFASet);
|
|
|
dbHelper.AddParameter("@SaveGFAAct", recordSaveDataInfo.SaveGFAAct);
|
|
|
dbHelper.AddParameter("@Save3thSet", recordSaveDataInfo.Save3thSet);
|
|
|
dbHelper.AddParameter("@Save3thAct", recordSaveDataInfo.Save3thAct);
|
|
|
dbHelper.AddParameter("@SaveLevel", recordSaveDataInfo.SaveLevel);
|
|
|
dbHelper.AddParameter("@SaveFillTime", recordSaveDataInfo.SaveFillTime);
|
|
|
dbHelper.AddParameter("@SaveSpeed1", recordSaveDataInfo.SaveSpeed1);
|
|
|
dbHelper.AddParameter("@SaveSpeed2", recordSaveDataInfo.SaveSpeed2);
|
|
|
dbHelper.AddParameter("@SaveTime", recordSaveDataInfo.SaveTime);
|
|
|
dbHelper.AddParameter("@Record_Time", recordSaveDataInfo.RecordTime);
|
|
|
dbHelper.AddParameter("@SaveVCC2thSet", recordSaveDataInfo.SaveVCC2thSet);
|
|
|
dbHelper.AddParameter("@SaveVCC2thAct", recordSaveDataInfo.SaveVCC2thAct);
|
|
|
dbHelper.AddParameter("@SaveGFA2thSet", recordSaveDataInfo.SaveGFA2thSet);
|
|
|
dbHelper.AddParameter("@SaveGFA2thAct", recordSaveDataInfo.SaveGFA2thAct);
|
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<LotSaveHelper>.Error("冠合存盘数据保存异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
}
|