|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Basic;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.Technology
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工艺日志辅助类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class RecipeLogHelper
|
|
|
|
|
{
|
|
|
|
|
#region 单例实现
|
|
|
|
|
|
|
|
|
|
private static RecipeLogHelper _instance = null;
|
|
|
|
|
|
|
|
|
|
private RecipeLogHelper() { }
|
|
|
|
|
|
|
|
|
|
public static RecipeLogHelper Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_instance == null)
|
|
|
|
|
{
|
|
|
|
|
_instance = new RecipeLogHelper();
|
|
|
|
|
}
|
|
|
|
|
return _instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private StringBuilder _pmtRecipeOld = new StringBuilder();
|
|
|
|
|
private StringBuilder _pmtWeighOld = new StringBuilder();
|
|
|
|
|
private StringBuilder _pmtMixOld = new StringBuilder();
|
|
|
|
|
private StringBuilder _pmtRecipeNow = new StringBuilder();
|
|
|
|
|
private StringBuilder _pmtWeighNow = new StringBuilder();
|
|
|
|
|
private StringBuilder _pmtMixNow = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
private bool _isBegin = false;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性定义
|
|
|
|
|
|
|
|
|
|
public StringBuilder PmtRecipeOld
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtRecipeOld; }
|
|
|
|
|
set { _pmtRecipeOld = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StringBuilder PmtWeighOld
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtWeighOld; }
|
|
|
|
|
set { _pmtWeighOld = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StringBuilder PmtMixOld
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtMixOld; }
|
|
|
|
|
set { _pmtMixOld = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StringBuilder PmtRecipeNow
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtRecipeNow; }
|
|
|
|
|
set { _pmtRecipeNow = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StringBuilder PmtWeighNow
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtWeighNow; }
|
|
|
|
|
set { _pmtWeighNow = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StringBuilder PmtMixNow
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtMixNow; }
|
|
|
|
|
set { _pmtMixNow = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsBegin
|
|
|
|
|
{
|
|
|
|
|
get { return _isBegin; }
|
|
|
|
|
set { _isBegin = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存工艺日志
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存工艺日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">物料编码</param>
|
|
|
|
|
/// <param name="edtCode">版本号</param>
|
|
|
|
|
public void SaveRecipeLog(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (this._isBegin == true)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Info("保存工艺日志...");
|
|
|
|
|
RecipeLog recipeLog = new RecipeLog();
|
|
|
|
|
FeedingAction action = new FeedingAction();
|
|
|
|
|
recipeLog.EquipCode = action.CurrEquipCode;
|
|
|
|
|
recipeLog.MaterCode = materCode;
|
|
|
|
|
recipeLog.EdtCode = edtCode;
|
|
|
|
|
recipeLog.PmtRecipeOld = this._pmtRecipeOld.Append("/").ToString();
|
|
|
|
|
recipeLog.PmtWeighOld = this._pmtWeighOld.ToString();
|
|
|
|
|
recipeLog.PmtMixOld = this._pmtMixOld.ToString();
|
|
|
|
|
recipeLog.PmtRecipeNow = this._pmtRecipeNow.Append("/").ToString();
|
|
|
|
|
recipeLog.PmtWeighNow = this._pmtWeighNow.ToString();
|
|
|
|
|
recipeLog.PmtMixNow = this._pmtMixNow.ToString();
|
|
|
|
|
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
if (localHelper == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-保存配方日志失败:获取本地数据连接失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string oper_Timer = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
|
|
|
|
|
string strSql1 = "insert into Pmt_recipeLogLocal(Oper_time,Equip_code,Mater_code,Edt_code,Pmt_recipeold,Pmt_weighold,Pmt_mixold,Pmt_recipenow,Pmt_weighnow,Pmt_mixnow,Oper_person,IsUpFlag)";
|
|
|
|
|
strSql1 += " values(@Oper_time,@Equip_code,@Mater_code,@Edt_code,@Pmt_recipeold,@Pmt_weighold,@Pmt_mixold,@Pmt_recipenow,@Pmt_weighnow,@Pmt_mixnow,@Oper_person,@IsUpFlag);SELECT SCOPE_IDENTITY();";
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = strSql1;
|
|
|
|
|
localHelper.AddParameter("@Oper_time", oper_Timer);
|
|
|
|
|
localHelper.AddParameter("@Equip_code", action.CurrEquipCode);
|
|
|
|
|
localHelper.AddParameter("@Mater_code", materCode);
|
|
|
|
|
localHelper.AddParameter("@Edt_code", edtCode);
|
|
|
|
|
localHelper.AddParameter("@Pmt_recipeold", recipeLog.PmtRecipeOld);
|
|
|
|
|
localHelper.AddParameter("@Pmt_weighold", recipeLog.PmtWeighOld);
|
|
|
|
|
localHelper.AddParameter("@Pmt_mixold", recipeLog.PmtMixOld);
|
|
|
|
|
localHelper.AddParameter("@Pmt_recipenow", recipeLog.PmtRecipeNow);
|
|
|
|
|
localHelper.AddParameter("@Pmt_weighnow", recipeLog.PmtWeighNow);
|
|
|
|
|
localHelper.AddParameter("@Pmt_mixnow", recipeLog.PmtMixNow);
|
|
|
|
|
localHelper.AddParameter("@Oper_person", Mesnac.Basic.UserInfo.Instance.UserName);
|
|
|
|
|
localHelper.AddParameter("@IsUpFlag", 0);
|
|
|
|
|
object objId = localHelper.ToScalar();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (action.NetType == Base.BaseAction.NetTypes.Net)
|
|
|
|
|
{
|
|
|
|
|
DbHelper serverHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
|
|
|
|
|
if (serverHelper == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-网络保存配方日志失败:获取网络数据连接失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string strSql2 = "insert into Pmt_recipeLogLocal(Oper_time,Equip_code,Mater_code,Edt_code,Pmt_recipeold,Pmt_weighold,Pmt_mixold,Pmt_recipenow,Pmt_weighnow,Pmt_mixnow,Oper_person)";
|
|
|
|
|
strSql2 += " values(@Oper_time,@Equip_code,@Mater_code,@Edt_code,@Pmt_recipeold,@Pmt_weighold,@Pmt_mixold,@Pmt_recipenow,@Pmt_weighnow,@Pmt_mixnow,@Oper_person)";
|
|
|
|
|
serverHelper.CommandType = CommandType.Text;
|
|
|
|
|
serverHelper.ClearParameter();
|
|
|
|
|
serverHelper.CommandText = strSql2;
|
|
|
|
|
serverHelper.AddParameter("@Oper_time", oper_Timer);
|
|
|
|
|
serverHelper.AddParameter("@Equip_code", action.CurrEquipCode);
|
|
|
|
|
serverHelper.AddParameter("@Mater_code", materCode);
|
|
|
|
|
serverHelper.AddParameter("@Edt_code", edtCode);
|
|
|
|
|
serverHelper.AddParameter("@Pmt_recipeold", recipeLog.PmtRecipeOld);
|
|
|
|
|
serverHelper.AddParameter("@Pmt_weighold", recipeLog.PmtWeighOld);
|
|
|
|
|
serverHelper.AddParameter("@Pmt_mixold", recipeLog.PmtMixOld);
|
|
|
|
|
serverHelper.AddParameter("@Pmt_recipenow", recipeLog.PmtRecipeNow);
|
|
|
|
|
serverHelper.AddParameter("@Pmt_weighnow", recipeLog.PmtWeighNow);
|
|
|
|
|
serverHelper.AddParameter("@Pmt_mixnow", recipeLog.PmtMixNow);
|
|
|
|
|
serverHelper.AddParameter("@Oper_person", Mesnac.Basic.UserInfo.Instance.UserName);
|
|
|
|
|
serverHelper.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
string strSql3 = "update Pmt_recipeLogLocal set IsUpFlag = 1 where Oper_time=@Oper_time and Equip_code=@Equip_code and Mater_code=@Mater_code and Edt_code=@Edt_code";
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = strSql3;
|
|
|
|
|
localHelper.AddParameter("@Oper_time", oper_Timer);
|
|
|
|
|
localHelper.AddParameter("@Equip_code", action.CurrEquipCode);
|
|
|
|
|
localHelper.AddParameter("@Mater_code", materCode);
|
|
|
|
|
localHelper.AddParameter("@Edt_code", edtCode);
|
|
|
|
|
localHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-网络库保存配方日志失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._isBegin = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-保存配方日志失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 工艺日志辅助方法
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 清空字符串生成器
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void ClearStringBuilder()
|
|
|
|
|
{
|
|
|
|
|
this._pmtRecipeOld.Clear();
|
|
|
|
|
this._pmtWeighOld.Clear();
|
|
|
|
|
this._pmtMixOld.Clear();
|
|
|
|
|
this._pmtRecipeNow.Clear();
|
|
|
|
|
this._pmtWeighNow.Clear();
|
|
|
|
|
this._pmtMixNow.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成旧版本的配方称量信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方物料编码</param>
|
|
|
|
|
/// <param name="edtCode">配方版本号</param>
|
|
|
|
|
/// <returns>返回旧版本的配方称量信息字符串生成器</returns>
|
|
|
|
|
public StringBuilder GenerateRecipeWeighOld(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
return GenerateRecipeWeigh(this._pmtWeighOld, materCode, edtCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成新版本的配方称量信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方物料编码</param>
|
|
|
|
|
/// <param name="edtCode">配方版本号</param>
|
|
|
|
|
/// <returns>返回新版本的配方称量信息字符串生成器</returns>
|
|
|
|
|
public StringBuilder GenerateRecipeWeighNow(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
return GenerateRecipeWeigh(this._pmtWeighNow, materCode, edtCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生成配方称量信息字符串
|
|
|
|
|
|
|
|
|
|
private StringBuilder GenerateRecipeWeigh(StringBuilder sb, string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
FeedingAction action = new FeedingAction();
|
|
|
|
|
DataTable weighTable = this.GetWeighDataTable(materCode, edtCode);
|
|
|
|
|
if (weighTable != null && weighTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
double setWeight = 0.0;
|
|
|
|
|
double errorAllow = 0.0;
|
|
|
|
|
//炭黑
|
|
|
|
|
foreach (DataRow row in weighTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
int weightType = DataProcessor.RowValue(row, "weigh_type", -1);
|
|
|
|
|
if (weightType == 0)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "weight_id", 0)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "ActionName", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_name", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_code", String.Empty)));
|
|
|
|
|
setWeight = DataProcessor.RowValue(row, "set_weight", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setWeight == 0 ? String.Empty : setWeight.ToString()));
|
|
|
|
|
errorAllow = DataProcessor.RowValue(row, "error_allow", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", errorAllow == 0 ? String.Empty : errorAllow.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("/");
|
|
|
|
|
//油料
|
|
|
|
|
foreach (DataRow row in weighTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
int weightType = DataProcessor.RowValue(row, "weigh_type", -1);
|
|
|
|
|
if (weightType == 1 || weightType == 5)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "weight_id", 0)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "ActionName", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_name", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_code", String.Empty)));
|
|
|
|
|
setWeight = DataProcessor.RowValue(row, "set_weight", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setWeight == 0 ? String.Empty : setWeight.ToString()));
|
|
|
|
|
errorAllow = DataProcessor.RowValue(row, "error_allow", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", errorAllow == 0 ? String.Empty : errorAllow.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("/");
|
|
|
|
|
//胶料
|
|
|
|
|
foreach (DataRow row in weighTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
int weightType = DataProcessor.RowValue(row, "weigh_type", -1);
|
|
|
|
|
if (weightType == 2)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "weight_id", 0)));
|
|
|
|
|
//sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "ActionName", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_name", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_code", String.Empty)));
|
|
|
|
|
setWeight = DataProcessor.RowValue(row, "set_weight", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setWeight == 0 ? String.Empty : setWeight.ToString()));
|
|
|
|
|
errorAllow = DataProcessor.RowValue(row, "error_allow", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", errorAllow == 0 ? String.Empty : errorAllow.ToString()));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "AutoPloyName", "无")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("/");
|
|
|
|
|
//粉料
|
|
|
|
|
foreach (DataRow row in weighTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
int weightType = DataProcessor.RowValue(row, "weigh_type", -1);
|
|
|
|
|
if (weightType == 3)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "weight_id", 0)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "ActionName", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_name", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_code", String.Empty)));
|
|
|
|
|
setWeight = DataProcessor.RowValue(row, "set_weight", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setWeight == 0 ? String.Empty : setWeight.ToString()));
|
|
|
|
|
errorAllow = DataProcessor.RowValue(row, "error_allow", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", errorAllow == 0 ? String.Empty : errorAllow.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("/");
|
|
|
|
|
//小料
|
|
|
|
|
foreach (DataRow row in weighTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
int weightType = DataProcessor.RowValue(row, "weigh_type", -1);
|
|
|
|
|
if (weightType == 4)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "weight_id", 0)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "ActionName", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_name", String.Empty)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "child_code", String.Empty)));
|
|
|
|
|
setWeight = DataProcessor.RowValue(row, "set_weight", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setWeight == 0 ? String.Empty : setWeight.ToString()));
|
|
|
|
|
errorAllow = DataProcessor.RowValue(row, "error_allow", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", errorAllow == 0 ? String.Empty : errorAllow.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("/");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append("/////");
|
|
|
|
|
}
|
|
|
|
|
return sb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成旧版本的配方混炼信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方物料代码</param>
|
|
|
|
|
/// <param name="edtCode">配方版本号</param>
|
|
|
|
|
/// <returns>返回对应旧版本的配方混炼信息字符串生成器</returns>
|
|
|
|
|
public StringBuilder GenerateRecipeMixOld(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
return GenerateRecipeMix(this._pmtMixOld, materCode, edtCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成新版本的配方混炼信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方物料代码</param>
|
|
|
|
|
/// <param name="edtCode">配方版本号</param>
|
|
|
|
|
/// <returns>返回对应旧版本的配方混炼信息字符串生成器</returns>
|
|
|
|
|
public StringBuilder GenerateRecipeMixNow(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
return GenerateRecipeMix(this._pmtMixNow, materCode, edtCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生成配方混炼信息字符串
|
|
|
|
|
|
|
|
|
|
private StringBuilder GenerateRecipeMix(StringBuilder sb, string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
FeedingAction action = new FeedingAction();
|
|
|
|
|
DataTable mixTable = this.GetMixDataTable(materCode, edtCode);
|
|
|
|
|
if (mixTable != null && mixTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow row in mixTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "mix_id", 0)));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "TermName", String.Empty)));
|
|
|
|
|
int setTime = DataProcessor.RowValue(row, "set_time", 0);
|
|
|
|
|
sb.Append(String.Format("{0},", setTime == 0 ? String.Empty : setTime.ToString()));
|
|
|
|
|
int setTemp = DataProcessor.RowValue(row, "set_temp", 0);
|
|
|
|
|
sb.Append(String.Format("{0},", setTemp == 0 ? String.Empty : setTemp.ToString()));
|
|
|
|
|
double setPower = DataProcessor.RowValue(row, "set_power", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setPower == 0 ? String.Empty : setPower.ToString()));
|
|
|
|
|
double setEner = DataProcessor.RowValue(row, "set_ener", 0.0);
|
|
|
|
|
sb.Append(String.Format("{0},", setEner == 0 ? String.Empty : setEner.ToString()));
|
|
|
|
|
sb.Append(String.Format("{0},", DataProcessor.RowValue(row, "ActName", String.Empty)));
|
|
|
|
|
double setPres = DataProcessor.RowValue(row, "set_pres", 0);
|
|
|
|
|
sb.Append(String.Format("{0},", setPres == 0 ? String.Empty : setPres.ToString()));
|
|
|
|
|
int setRota = DataProcessor.RowValue(row, "set_rota", 0);
|
|
|
|
|
sb.Append(String.Format("{0},/", setRota == 0 ? String.Empty : setRota.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 配方辅助方法
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取配方数据行
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方物料编码</param>
|
|
|
|
|
/// <param name="edtCode">版本号</param>
|
|
|
|
|
/// <returns>返回对应配方的数据行</returns>
|
|
|
|
|
public DataRow GetRecipeDataRow(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FeedingAction action = new FeedingAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
if (localHelper == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-获取配方数据行失败:获取本地数据连接失败!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = "select top 1 * from pmt_recipe where equip_code = @equipCode and mater_code=@materCode and edt_code=@edtCode";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@equipCode", action.CurrEquipCode.Substring(3, 2));
|
|
|
|
|
localHelper.AddParameter("@materCode", materCode);
|
|
|
|
|
localHelper.AddParameter("@edtCode", edtCode);
|
|
|
|
|
DataTable table = localHelper.ToDataTable();
|
|
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return table.Rows[0];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-获取配方数据行失败:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取配方称量数据表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方物料代码</param>
|
|
|
|
|
/// <param name="edtCode">版本号</param>
|
|
|
|
|
/// <returns>返回对应配方的称量数据表</returns>
|
|
|
|
|
public DataTable GetWeighDataTable(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FeedingAction action = new FeedingAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
if (localHelper == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-获取配方称量数据表失败:获取本地数据连接失败!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
//string strSql = "select * from pmt_weigh where equip_code = @equipCode and father_code=@materCode and edt_code=@edtCode order by weight_id";
|
|
|
|
|
string strSql = @"SELECT [ObjID]
|
|
|
|
|
,[RecipeObjID]
|
|
|
|
|
,[weight_id]
|
|
|
|
|
,[father_code]
|
|
|
|
|
,[equip_code]
|
|
|
|
|
,[edt_code]
|
|
|
|
|
,[weigh_type]
|
|
|
|
|
,[act_code]
|
|
|
|
|
,[child_code]
|
|
|
|
|
,[child_name]
|
|
|
|
|
,[set_weight]
|
|
|
|
|
,[error_allow]
|
|
|
|
|
,[unit_name]
|
|
|
|
|
,[mem_note]
|
|
|
|
|
,[ChanYong_Flag]
|
|
|
|
|
,[Auto_ploy]
|
|
|
|
|
,sc1.[ItemName] as [WeightTypeName]
|
|
|
|
|
,sc2.[ItemName] as [ActionName]
|
|
|
|
|
,sc3.[ItemName] as [AutoPloyName]
|
|
|
|
|
FROM [pmt_weigh]
|
|
|
|
|
left join [SysCode] sc1 on sc1.[TypeID]='WeightType' and sc1.[ItemCode] = [pmt_weigh].[weigh_type]
|
|
|
|
|
left join [SysCode] sc2 on sc2.[TypeID]='WeightAction' and sc2.[ItemCode] = [pmt_weigh].[act_code]
|
|
|
|
|
left join [SysCode] sc3 on sc3.[TypeID]='AutoPloy' and sc3.[ItemCode] = [pmt_weigh].[Auto_ploy]
|
|
|
|
|
where [pmt_weigh].[equip_code] = @equipCode and [pmt_weigh].[father_code]=@materCode and [pmt_weigh].[edt_code]=@edtCode order by [pmt_weigh].[weigh_type],[pmt_weigh].[weight_id]";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@equipCode", action.CurrEquipCode.Substring(3, 2));
|
|
|
|
|
localHelper.AddParameter("@materCode", materCode);
|
|
|
|
|
localHelper.AddParameter("@edtCode", edtCode);
|
|
|
|
|
DataTable table = localHelper.ToDataTable();
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-获取配方称量数据表失败:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取配方混炼数据表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">配方编码</param>
|
|
|
|
|
/// <param name="edtCode">版本号</param>
|
|
|
|
|
/// <returns>返回对应配方的混炼数据表</returns>
|
|
|
|
|
public DataTable GetMixDataTable(string materCode, string edtCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FeedingAction action = new FeedingAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
if (localHelper == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-获取配方混炼数据表失败:获取本地数据连接失败!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
//string strSql = "select * from pmt_mix where equip_code = @equipCode and father_code=@materCode and edt_code=@edtCode order by mix_id";
|
|
|
|
|
string strSql = @"select [pmt_mix].[ObjID]
|
|
|
|
|
,[RecipeObjID]
|
|
|
|
|
,[father_code]
|
|
|
|
|
,[equip_code]
|
|
|
|
|
,[rub_code]
|
|
|
|
|
,[edt_code]
|
|
|
|
|
,[term_code]
|
|
|
|
|
,[set_time]
|
|
|
|
|
,[set_temp]
|
|
|
|
|
,[set_ener]
|
|
|
|
|
,[set_power]
|
|
|
|
|
,[act_code]
|
|
|
|
|
,[set_pres]
|
|
|
|
|
,[set_rota]
|
|
|
|
|
,[steel_kind]
|
|
|
|
|
,[switch_mete]
|
|
|
|
|
,[mix_id],[PmtTerm].[ShowName] as [TermName],[PmtAction].[ShowName] as [ActName] from [pmt_mix] left join [PmtTerm]
|
|
|
|
|
on [pmt_mix].[term_code] = [PmtTerm].[TermCode]
|
|
|
|
|
left join [PmtAction] on [pmt_mix].[act_code] = [PmtAction].[ActionCode]
|
|
|
|
|
where [pmt_mix].[equip_code] = @equipCode and [pmt_mix].[father_code]=@materCode and [pmt_mix].[edt_code]=@edtCode order by [pmt_mix].[mix_id]";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@equipCode", action.CurrEquipCode.Substring(3, 2));
|
|
|
|
|
localHelper.AddParameter("@materCode", materCode);
|
|
|
|
|
localHelper.AddParameter("@edtCode", edtCode);
|
|
|
|
|
DataTable table = localHelper.ToDataTable();
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志-获取配方混炼数据表失败:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 工艺日志实体类
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工艺日志实体类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class RecipeLog
|
|
|
|
|
{
|
|
|
|
|
#region 定义字段
|
|
|
|
|
|
|
|
|
|
private long _objId;
|
|
|
|
|
private string _equipCode;
|
|
|
|
|
private string _materCode;
|
|
|
|
|
private string _edtCode;
|
|
|
|
|
private string _pmtRecipeOld;
|
|
|
|
|
private string _pmtWeighOld;
|
|
|
|
|
private string _pmtMixOld;
|
|
|
|
|
private string _pmtRecipeNow;
|
|
|
|
|
private string _pmtWeighNow;
|
|
|
|
|
private string _pmtMixNow;
|
|
|
|
|
private string _operPerson;
|
|
|
|
|
private int _isUpFlag;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 定义属性
|
|
|
|
|
|
|
|
|
|
public long ObjId
|
|
|
|
|
{
|
|
|
|
|
get { return _objId; }
|
|
|
|
|
set { _objId = value; }
|
|
|
|
|
}
|
|
|
|
|
public string EquipCode
|
|
|
|
|
{
|
|
|
|
|
get { return _equipCode; }
|
|
|
|
|
set { _equipCode = value; }
|
|
|
|
|
}
|
|
|
|
|
public string MaterCode
|
|
|
|
|
{
|
|
|
|
|
get { return _materCode; }
|
|
|
|
|
set { _materCode = value; }
|
|
|
|
|
}
|
|
|
|
|
public string EdtCode
|
|
|
|
|
{
|
|
|
|
|
get { return _edtCode; }
|
|
|
|
|
set { _edtCode = value; }
|
|
|
|
|
}
|
|
|
|
|
public string PmtRecipeOld
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtRecipeOld; }
|
|
|
|
|
set { _pmtRecipeOld = value; }
|
|
|
|
|
}
|
|
|
|
|
public string PmtWeighOld
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtWeighOld; }
|
|
|
|
|
set { _pmtWeighOld = value; }
|
|
|
|
|
}
|
|
|
|
|
public string PmtMixOld
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtMixOld; }
|
|
|
|
|
set { _pmtMixOld = value; }
|
|
|
|
|
}
|
|
|
|
|
public string PmtRecipeNow
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtRecipeNow; }
|
|
|
|
|
set { _pmtRecipeNow = value; }
|
|
|
|
|
}
|
|
|
|
|
public string PmtWeighNow
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtWeighNow; }
|
|
|
|
|
set { _pmtWeighNow = value; }
|
|
|
|
|
}
|
|
|
|
|
public string PmtMixNow
|
|
|
|
|
{
|
|
|
|
|
get { return _pmtMixNow; }
|
|
|
|
|
set { _pmtMixNow = value; }
|
|
|
|
|
}
|
|
|
|
|
public string OperPerson
|
|
|
|
|
{
|
|
|
|
|
get { return _operPerson; }
|
|
|
|
|
set { _operPerson = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int IsUpFlag
|
|
|
|
|
{
|
|
|
|
|
get { return _isUpFlag; }
|
|
|
|
|
set { _isUpFlag = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|