|
|
using System;
|
|
|
using System.IO;
|
|
|
using System.Reflection;
|
|
|
using System.Xml;
|
|
|
using System.Data;
|
|
|
using Mesnac.Equips;
|
|
|
using Mesnac.Action.Feeding.ProducingPlan;
|
|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Codd.Session;
|
|
|
using Mesnac.Basic;
|
|
|
using System.Xml.Serialization;
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.BasicInfo
|
|
|
{
|
|
|
public class RecipeData
|
|
|
{
|
|
|
#region 基本函数
|
|
|
/// <summary>
|
|
|
/// 获取本地连接
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private DbHelper getLocalHelper()
|
|
|
{
|
|
|
return new DatabaseAction().NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取网络连接
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private DbHelper getServerHelper()
|
|
|
{
|
|
|
return new DatabaseAction().NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// Xml序列化DataTable
|
|
|
/// </summary>
|
|
|
/// <param name="dt"></param>
|
|
|
/// <returns></returns>
|
|
|
private string SerializeDataTable(DataTable dt)
|
|
|
{
|
|
|
StringWriter strWriter = new StringWriter();
|
|
|
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));
|
|
|
serializer.Serialize(strWriter, dt);
|
|
|
return strWriter.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 基本类型
|
|
|
/// <summary>
|
|
|
/// 称量类型
|
|
|
/// </summary>
|
|
|
public enum WeightType
|
|
|
{
|
|
|
炭黑 = 0,
|
|
|
油 = 1,
|
|
|
胶料 = 2,
|
|
|
粉料 = 3,
|
|
|
小料 = 4,
|
|
|
}
|
|
|
public class PptPlanInfo
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 计划号
|
|
|
/// </summary>
|
|
|
public string PlanID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 生产日期
|
|
|
/// </summary>
|
|
|
public string PlanDate { get; set; }
|
|
|
/// <summary>
|
|
|
/// 机台代码
|
|
|
/// </summary>
|
|
|
public string RecipeEquipCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 物料代码
|
|
|
/// </summary>
|
|
|
public string RecipeMaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方名称
|
|
|
/// </summary>
|
|
|
public string RecipeMaterialName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方版本号
|
|
|
/// </summary>
|
|
|
public string RecipeVersionID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 用户配方版本号
|
|
|
/// </summary>
|
|
|
public string RecipeUserVersion { get; set; }
|
|
|
/// <summary>
|
|
|
/// 生产班次
|
|
|
/// </summary>
|
|
|
public string ShiftID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 生产班组
|
|
|
/// </summary>
|
|
|
public string ClassID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 顺序号
|
|
|
/// </summary>
|
|
|
public string SerialNum { get; set; }
|
|
|
/// <summary>
|
|
|
/// 优先级
|
|
|
/// </summary>
|
|
|
public string PriLevel { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方别名
|
|
|
/// </summary>
|
|
|
public string RecipeName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方类型
|
|
|
/// </summary>
|
|
|
public string RecipeType { get; set; }
|
|
|
/// <summary>
|
|
|
/// 运行方式
|
|
|
/// </summary>
|
|
|
public string RunType { get; set; }
|
|
|
/// <summary>
|
|
|
/// 打印方式
|
|
|
/// </summary>
|
|
|
public string PrintType { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划来源
|
|
|
/// </summary>
|
|
|
public string PlanSource { get; set; }
|
|
|
/// <summary>
|
|
|
/// 每车重量
|
|
|
/// </summary>
|
|
|
public string TotalWeight { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计数
|
|
|
/// </summary>
|
|
|
public int PlanNum { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划重量
|
|
|
/// </summary>
|
|
|
public string PlanWeight { get; set; }
|
|
|
/// <summary>
|
|
|
/// 完成数量
|
|
|
/// </summary>
|
|
|
public string RealNum { get; set; }
|
|
|
/// <summary>
|
|
|
/// 完成重量
|
|
|
/// </summary>
|
|
|
public string RealWeight { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划紧急状态
|
|
|
/// </summary>
|
|
|
public string UrgencyState { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划状态
|
|
|
/// </summary>
|
|
|
public string PlanState { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划编制日期
|
|
|
/// </summary>
|
|
|
public string OperDatetime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划结束日期
|
|
|
/// </summary>
|
|
|
public string PlanEndTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 实际开始日期
|
|
|
/// </summary>
|
|
|
public string RealStartTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 实际结束日期
|
|
|
/// </summary>
|
|
|
public string RealEndtime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 计划制定者
|
|
|
/// </summary>
|
|
|
public string OperCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 接收标志
|
|
|
/// </summary>
|
|
|
public string ReviseSgn { get; set; }
|
|
|
/// <summary>
|
|
|
/// 小料计划已生成
|
|
|
/// </summary>
|
|
|
public string Smallcreate { get; set; }
|
|
|
/// <summary>
|
|
|
/// 平均车时间
|
|
|
/// </summary>
|
|
|
public string AvgTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 备注
|
|
|
/// </summary>
|
|
|
public string Remark { get; set; }
|
|
|
/// <summary>
|
|
|
/// 删除标志
|
|
|
/// </summary>
|
|
|
public string DeleteFlag { get; set; }
|
|
|
/// <summary>
|
|
|
/// 生成计划标志
|
|
|
/// </summary>
|
|
|
public string CreatePlanFlag { get; set; }
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 配方信息
|
|
|
/// </summary>
|
|
|
public class RecipeInfo
|
|
|
{
|
|
|
/// <summary>
|
|
|
///编号
|
|
|
/// </summary>
|
|
|
public int ObjID { get; set; }
|
|
|
/// <summary>
|
|
|
///机台编码
|
|
|
/// </summary>
|
|
|
public string RecipeEquipCode { get; set; }
|
|
|
/// <summary>
|
|
|
///物料编码
|
|
|
/// </summary>
|
|
|
public string RecipeMaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
///版本号
|
|
|
/// </summary>
|
|
|
public string RecipeVersionID { get; set; }
|
|
|
/// <summary>
|
|
|
///配方名称
|
|
|
/// </summary>
|
|
|
public string RecipeName { get; set; }
|
|
|
/// <summary>
|
|
|
///配方类型
|
|
|
/// </summary>
|
|
|
public int RecipeType { get; set; }
|
|
|
/// <summary>
|
|
|
///物料名称
|
|
|
/// </summary>
|
|
|
public string RecipeMaterialName { get; set; }
|
|
|
/// <summary>
|
|
|
///用户配方版本
|
|
|
/// </summary>
|
|
|
public int RecipeUserVersion { get; set; }
|
|
|
/// <summary>
|
|
|
///配方状态
|
|
|
/// </summary>
|
|
|
public int RecipeState { get; set; }
|
|
|
/// <summary>
|
|
|
///配方创建时间
|
|
|
/// </summary>
|
|
|
public int RecipeDefineDate { get; set; }
|
|
|
/// <summary>
|
|
|
///最后一次修改日期
|
|
|
/// </summary>
|
|
|
public int RecipeModifyTime { get; set; }
|
|
|
/// <summary>
|
|
|
///每车时间
|
|
|
/// </summary>
|
|
|
public int LotDoneTime { get; set; }
|
|
|
/// <summary>
|
|
|
///每架车数
|
|
|
/// </summary>
|
|
|
public int ShelfLotCount { get; set; }
|
|
|
/// <summary>
|
|
|
///每车重量
|
|
|
/// </summary>
|
|
|
public int LotTotalWeight { get; set; }
|
|
|
/// <summary>
|
|
|
///炭黑回收方式
|
|
|
/// </summary>
|
|
|
public int CarbonRecycleType { get; set; }
|
|
|
/// <summary>
|
|
|
///炭黑回收时间
|
|
|
/// </summary>
|
|
|
public int CarbonRecycleTime { get; set; }
|
|
|
/// <summary>
|
|
|
///超温排胶最短时间
|
|
|
/// </summary>
|
|
|
public int OverTempMinTime { get; set; }
|
|
|
/// <summary>
|
|
|
///超时排胶时间
|
|
|
/// </summary>
|
|
|
public int OverTimeSetTime { get; set; }
|
|
|
/// <summary>
|
|
|
///超温排胶温度
|
|
|
/// </summary>
|
|
|
public int OverTempSetTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///最高进料温度
|
|
|
/// </summary>
|
|
|
public int InPolyMaxTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///最低进胶温度
|
|
|
/// </summary>
|
|
|
public int InPolyMinTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///加胶时间
|
|
|
/// </summary>
|
|
|
public int InPolySetTime { get; set; }
|
|
|
/// <summary>
|
|
|
///加炭黑时间
|
|
|
/// </summary>
|
|
|
public int InCarbonSetTime { get; set; }
|
|
|
/// <summary>
|
|
|
///加油时间
|
|
|
/// </summary>
|
|
|
public int InOilSetTime { get; set; }
|
|
|
/// <summary>
|
|
|
///加粉料时间
|
|
|
/// </summary>
|
|
|
public int InPowderSetTime { get; set; }
|
|
|
/// <summary>
|
|
|
///转速允许偏差
|
|
|
/// </summary>
|
|
|
public int RollSpeedDiff { get; set; }
|
|
|
/// <summary>
|
|
|
///上顶栓压力允许偏差
|
|
|
/// </summary>
|
|
|
public int RamPressDiff { get; set; }
|
|
|
/// <summary>
|
|
|
///是否使用三区温度
|
|
|
/// </summary>
|
|
|
public int IsUseAreaTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///侧壁温度
|
|
|
/// </summary>
|
|
|
public int SideTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///侧壁温度偏差
|
|
|
/// </summary>
|
|
|
public int SideTempDiff { get; set; }
|
|
|
/// <summary>
|
|
|
///转子温度
|
|
|
/// </summary>
|
|
|
public int RollTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///转子温度偏差
|
|
|
/// </summary>
|
|
|
public int RollTempDiff { get; set; }
|
|
|
/// <summary>
|
|
|
///卸料门温度
|
|
|
/// </summary>
|
|
|
public int DdoorTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///卸料门温度偏差
|
|
|
/// </summary>
|
|
|
public int DdoorTempDiff { get; set; }
|
|
|
/// <summary>
|
|
|
///操作者
|
|
|
/// </summary>
|
|
|
public int OperCode { get; set; }
|
|
|
/// <summary>
|
|
|
///备注
|
|
|
/// </summary>
|
|
|
public int Remark { get; set; }
|
|
|
/// <summary>
|
|
|
///开始使用时间
|
|
|
/// </summary>
|
|
|
public int StartDatetime { get; set; }
|
|
|
/// <summary>
|
|
|
///结束使用时间
|
|
|
/// </summary>
|
|
|
public int EndDatetime { get; set; }
|
|
|
/// <summary>
|
|
|
///审核人
|
|
|
/// </summary>
|
|
|
public int AuditUser { get; set; }
|
|
|
/// <summary>
|
|
|
///审核日期
|
|
|
/// </summary>
|
|
|
public int AuditDateTime { get; set; }
|
|
|
/// <summary>
|
|
|
///工艺指导说明
|
|
|
/// </summary>
|
|
|
public int RecipeDic { get; set; }
|
|
|
/// <summary>
|
|
|
///工艺停放时间要求
|
|
|
/// </summary>
|
|
|
public int StayTimeSpand { get; set; }
|
|
|
/// <summary>
|
|
|
///研发版本号
|
|
|
/// </summary>
|
|
|
public int RearchCode { get; set; }
|
|
|
/// <summary>
|
|
|
///补偿温度
|
|
|
/// </summary>
|
|
|
public int MakeUpTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///最新标识
|
|
|
/// </summary>
|
|
|
public int NewFlag { get; set; }
|
|
|
/// <summary>
|
|
|
///计划数量
|
|
|
/// </summary>
|
|
|
public int SetNumber { get; set; }
|
|
|
/// <summary>
|
|
|
///超能量排胶最短时间
|
|
|
/// </summary>
|
|
|
public int OverEnergySetTime { get; set; }
|
|
|
/// <summary>
|
|
|
///超能量排胶能量
|
|
|
/// </summary>
|
|
|
public int OverEnergySetEnergy { get; set; }
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 密炼信息
|
|
|
/// </summary>
|
|
|
public class RecipeMixingInfo
|
|
|
{
|
|
|
/// <summary>
|
|
|
///编号
|
|
|
/// </summary>
|
|
|
public int ObjID { get; set; }
|
|
|
/// <summary>
|
|
|
///配方编号
|
|
|
/// </summary>
|
|
|
public int RecipeObjID { get; set; }
|
|
|
/// <summary>
|
|
|
///物料编码
|
|
|
/// </summary>
|
|
|
public int RecipeMaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
///版本号
|
|
|
/// </summary>
|
|
|
public int RecipeVersionID { get; set; }
|
|
|
/// <summary>
|
|
|
///密炼序号
|
|
|
/// </summary>
|
|
|
public int MixingStep { get; set; }
|
|
|
/// <summary>
|
|
|
///条件代码
|
|
|
/// </summary>
|
|
|
public string TermCode { get; set; }
|
|
|
/// <summary>
|
|
|
///条件名称
|
|
|
/// </summary>
|
|
|
public string TermName { get; set; }
|
|
|
/// <summary>
|
|
|
///条件地址
|
|
|
/// </summary>
|
|
|
public int TermCodeAddress { get; set; }
|
|
|
/// <summary>
|
|
|
///时间
|
|
|
/// </summary>
|
|
|
public int MixingTime { get; set; }
|
|
|
/// <summary>
|
|
|
///温度
|
|
|
/// </summary>
|
|
|
public int MixingTemp { get; set; }
|
|
|
/// <summary>
|
|
|
///能量
|
|
|
/// </summary>
|
|
|
public int MixingEnergy { get; set; }
|
|
|
/// <summary>
|
|
|
///功率
|
|
|
/// </summary>
|
|
|
public int MixingPower { get; set; }
|
|
|
/// <summary>
|
|
|
///压力
|
|
|
/// </summary>
|
|
|
public int MixingPress { get; set; }
|
|
|
/// <summary>
|
|
|
///转速
|
|
|
/// </summary>
|
|
|
public int MixingSpeed { get; set; }
|
|
|
/// <summary>
|
|
|
///动作代码
|
|
|
/// </summary>
|
|
|
public string ActionCode { get; set; }
|
|
|
/// <summary>
|
|
|
///动作地址
|
|
|
/// </summary>
|
|
|
public int ActionCodeAddress { get; set; }
|
|
|
|
|
|
#region 同步执行的密炼信息集合,包括当前步骤
|
|
|
|
|
|
private List<RecipeMixingInfo> _synchMixingInfos = new List<RecipeMixingInfo>();
|
|
|
/// <summary>
|
|
|
/// 同步执行的密炼信息集合,包括当前步骤
|
|
|
/// </summary>
|
|
|
public List<RecipeMixingInfo> SynchMixingInfos
|
|
|
{
|
|
|
get { return _synchMixingInfos; }
|
|
|
set { _synchMixingInfos = value; }
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 称量信息
|
|
|
/// </summary>
|
|
|
public class RecipeWeightInfo
|
|
|
{
|
|
|
/// <summary>
|
|
|
///编号
|
|
|
/// </summary>
|
|
|
public int ObjID { get; set; }
|
|
|
/// <summary>
|
|
|
///料仓编号
|
|
|
/// </summary>
|
|
|
public int JarNum { get; set; }
|
|
|
/// <summary>
|
|
|
///配方编号
|
|
|
/// </summary>
|
|
|
public int RecipeObjID { get; set; }
|
|
|
/// <summary>
|
|
|
///物料编码
|
|
|
/// </summary>
|
|
|
public int RecipeMaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
///版本号
|
|
|
/// </summary>
|
|
|
public int RecipeVersionID { get; set; }
|
|
|
/// <summary>
|
|
|
///称量序号
|
|
|
/// </summary>
|
|
|
public int WeightID { get; set; }
|
|
|
/// <summary>
|
|
|
///称量类型
|
|
|
/// </summary>
|
|
|
public int WeightType { get; set; }
|
|
|
/// <summary>
|
|
|
///称编号
|
|
|
/// </summary>
|
|
|
public int ScaleID { get; set; }
|
|
|
/// <summary>
|
|
|
///称量动作
|
|
|
/// </summary>
|
|
|
public int ActCode { get; set; }
|
|
|
/// <summary>
|
|
|
///称量物料代码
|
|
|
/// </summary>
|
|
|
public string MaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
///称量物料名称
|
|
|
/// </summary>
|
|
|
public string MaterialName { get; set; }
|
|
|
/// <summary>
|
|
|
///设定重量
|
|
|
/// </summary>
|
|
|
public double SetWeight { get; set; }
|
|
|
/// <summary>
|
|
|
///原定重量
|
|
|
/// </summary>
|
|
|
public double OldSetWeight { get; set; }
|
|
|
/// <summary>
|
|
|
///允许误差
|
|
|
/// </summary>
|
|
|
public double ErrorAllow { get; set; }
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计划信息
|
|
|
/// <summary>
|
|
|
/// 计划数量
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public int GetPlansCount()
|
|
|
{
|
|
|
PlanLog log = PlanCommon.PlanLog;
|
|
|
int result = 0;
|
|
|
if (log != null)
|
|
|
{
|
|
|
result = PlanCommon.GetPlanCount(Basic.DataSourceFactory.MCDbType.Local, new BaseAction().CurrEquipCode, log.LastSelectDate, log.LastSelectShiftID);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行的计划索引
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public int GetCurrentPlanIndex()
|
|
|
{
|
|
|
PlanLog log = PlanCommon.PlanLog;
|
|
|
int iResult = 0;
|
|
|
if (log != null)
|
|
|
{
|
|
|
iResult = PlanCommon.GetCurrentPlanIndex(Basic.DataSourceFactory.MCDbType.Local, log.LastPlanID);
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前计划号
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public string GetCurrentPlanID()
|
|
|
{
|
|
|
PlanLog log = PlanCommon.PlanLog;
|
|
|
if (log != null)
|
|
|
{
|
|
|
return log.LastPlanID;
|
|
|
}
|
|
|
return string.Empty;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取计划车数
|
|
|
/// </summary>
|
|
|
/// <param name="planid"></param>
|
|
|
/// <returns></returns>
|
|
|
public int GetPlanLotCount(string planid)
|
|
|
{
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.CommandText = "SELECT plan_num FROM ppt_plan where plan_id = @PlanID";
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanID", planid);
|
|
|
object obj = dbHelper.ToScalar();
|
|
|
int iResult = 0;
|
|
|
if (obj != null
|
|
|
&& obj != DBNull.Value
|
|
|
&& int.TryParse(obj.ToString(), out iResult))
|
|
|
{
|
|
|
return iResult;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前计划车数
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public int GetCurrentPlanLotCount()
|
|
|
{
|
|
|
string planid = GetCurrentPlanID();
|
|
|
return GetPlanLotCount(planid);
|
|
|
}
|
|
|
|
|
|
#region 获取当前计划信息
|
|
|
/// <summary>
|
|
|
/// 获取当前计划信息
|
|
|
/// </summary>
|
|
|
/// <returns>返回计划对象</returns>
|
|
|
public PptPlanInfo GetCurrentPptPlanInfo()
|
|
|
{
|
|
|
PptPlanInfo plan = new PptPlanInfo();
|
|
|
string planid = GetCurrentPlanID();
|
|
|
DataRow row = PlanCommon.GetPlanData(Basic.DataSourceFactory.MCDbType.Local, planid);
|
|
|
if (row != null)
|
|
|
{
|
|
|
plan.PlanID = DataProcessor.RowValue(row, "PlanID", string.Empty);
|
|
|
plan.PlanDate = DataProcessor.RowValue(row, "PlanDate", string.Empty);
|
|
|
plan.RecipeEquipCode = DataProcessor.RowValue(row, "RecipeEquipCode", string.Empty);
|
|
|
plan.RecipeMaterialCode = DataProcessor.RowValue(row, "RecipeMaterialCode", string.Empty);
|
|
|
plan.RecipeMaterialName = DataProcessor.RowValue(row, "RecipeMaterialName", string.Empty);
|
|
|
plan.RecipeVersionID = DataProcessor.RowValue(row, "RecipeVersionID", string.Empty);
|
|
|
//plan.RecipeUserVersion = DataProcessor.RowValue(row, "RecipeUserVersion", string.Empty);
|
|
|
plan.ShiftID = DataProcessor.RowValue(row, "ShiftID", string.Empty);
|
|
|
plan.ClassID = DataProcessor.RowValue(row, "ClassID", string.Empty);
|
|
|
//plan.SerialNum = DataProcessor.RowValue(row, "SerialNum", string.Empty);
|
|
|
plan.PriLevel = DataProcessor.RowValue(row, "PriLevel", string.Empty);
|
|
|
//plan.RecipeName = DataProcessor.RowValue(row, "RecipeName", string.Empty);
|
|
|
//plan.RecipeType = DataProcessor.RowValue(row, "RecipeType", string.Empty);
|
|
|
//plan.RunType = DataProcessor.RowValue(row, "RunType", string.Empty);
|
|
|
//plan.PrintType = DataProcessor.RowValue(row, "PrintType", string.Empty);
|
|
|
//plan.PlanSource = DataProcessor.RowValue(row, "PlanSource", string.Empty);
|
|
|
plan.TotalWeight = DataProcessor.RowValue(row, "TotalWeight", string.Empty);
|
|
|
plan.PlanNum = DataProcessor.RowValue(row, "PlanNum", 1);
|
|
|
plan.PlanWeight = DataProcessor.RowValue(row, "PlanWeight", string.Empty);
|
|
|
plan.RealNum = DataProcessor.RowValue(row, "RealNum", string.Empty);
|
|
|
plan.RealWeight = DataProcessor.RowValue(row, "RealWeight", string.Empty);
|
|
|
//plan.UrgencyState = DataProcessor.RowValue(row, "UrgencyState", string.Empty);
|
|
|
plan.PlanState = DataProcessor.RowValue(row, "PlanState", string.Empty);
|
|
|
plan.OperDatetime = DataProcessor.RowValue(row, "OperDatetime", string.Empty);
|
|
|
//plan.PlanEndTime = DataProcessor.RowValue(row, "PlanEndTime", string.Empty);
|
|
|
//plan.RealStartTime = DataProcessor.RowValue(row, "RealStartTime", string.Empty);
|
|
|
plan.RealEndtime = DataProcessor.RowValue(row, "RealEndtime", string.Empty);
|
|
|
plan.OperCode = DataProcessor.RowValue(row, "OperCode", string.Empty);
|
|
|
plan.ReviseSgn = DataProcessor.RowValue(row, "ReviseSgn", string.Empty);
|
|
|
//plan.Smallcreate = DataProcessor.RowValue(row, "Smallcreate", string.Empty);
|
|
|
//plan.AvgTime = DataProcessor.RowValue(row, "AvgTime", string.Empty);
|
|
|
//plan.Remark = DataProcessor.RowValue(row, "Remark", string.Empty);
|
|
|
//plan.DeleteFlag = DataProcessor.RowValue(row, "DeleteFlag", string.Empty);
|
|
|
//plan.CreatePlanFlag = DataProcessor.RowValue(row, "CreatePlanFlag", string.Empty);
|
|
|
}
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 配方信息
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取配方号
|
|
|
/// </summary>
|
|
|
/// <param name="planid">计划号</param>
|
|
|
/// <returns>返回对应计划的配方号,如果没有对应则返回0</returns>
|
|
|
public string GetRecipeID(string planid)
|
|
|
{
|
|
|
string Result = string.Empty;
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.CommandText = @"SELECT t2.ObjID FROM dbo.ppt_plan t1
|
|
|
INNER JOIN dbo.pmt_recipe t2 ON substring(t1.equip_code,4,2)=t2.equip_code
|
|
|
AND t1.mater_code=t2.mater_code AND t1.edt_code=t2.edt_code
|
|
|
WHERE t1.plan_id=@PlanID";
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanID", planid);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
return result.ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "0";
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前配方号
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public string GetCurrentRecipeID()
|
|
|
{
|
|
|
string planid = GetCurrentPlanID();
|
|
|
return GetRecipeID(planid);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 设置当前配方号
|
|
|
/// </summary>
|
|
|
public void SetCurrentRecipeID()
|
|
|
{
|
|
|
string recipeid = GetCurrentRecipeID();
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.CommandText = "UPDATE SysKeyValue SET ssValue=@RecipeID WHERE ssKey='RecipeID'";
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeID", recipeid);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
dbHelper.CommandText = "UPDATE SysKeyValue SET ssValue = t.mater_name FROM pmt_recipe t WHERE ssKey='RecipeMixingName' AND t.ObjID=@RecipeID";
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeID", recipeid);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
dbHelper.CommandText = "SELECT ssRemark FROM SysKeyValue WHERE ssKey='RecipeMixing'";
|
|
|
string sqlstr = dbHelper.ToScalar().ToString();
|
|
|
sqlstr = string.Format(sqlstr, recipeid);
|
|
|
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
|
dt.TableName = "tableName";
|
|
|
string xml = SerializeDataTable(dt);
|
|
|
|
|
|
dbHelper.CommandText = "INSERT INTO dbo.PmtRecipeMixingXml(RecipeID, DataXml) VALUES (@RecipeID,@DataXml);SELECT SCOPE_IDENTITY();";
|
|
|
dbHelper.AddParameter("@RecipeID", recipeid);
|
|
|
dbHelper.AddParameter("@DataXml", xml);
|
|
|
sqlstr = dbHelper.ToScalar().ToString();
|
|
|
|
|
|
dbHelper.CommandText = "UPDATE SysKeyValue SET ssValue =@ssValue WHERE ssKey='RecipeMixing'";
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@ssValue", sqlstr);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取配方主信息
|
|
|
/// </summary>
|
|
|
/// <param name="recipeid"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetRecipeData(string recipeid)
|
|
|
{
|
|
|
DataTable dt_recipe = new DataTable();
|
|
|
string sqlstr = @"select ObjID,mater_code as RecipeMaterialCode,mater_name as RecipeMaterialName,equip_code as RecipeEquipCode,edt_code as RecipeVersionID,recipe_code as RecipeName,recipe_state as RecipeState,oper_code as OperCode,total_weight as LotTotalWeight,ever_used as EverUsed,black_reuse as CarbonRecycleType,reuse_time as CarbonRecycleTime,mini_time as OverTimeSetTime,max_temp as InPloyMaxTemp,mini_temp as InPloyMinTemp,over_temp as OverTempSetTemp,fill_coef as MakeUpTemp,shelf_num as ShelfLotCount,mem_note as Remark,define_date as RecipeDefineDate,sds_temp as SideTemp,zz_temp as RollTemp,xlm_temp as DdoorTemp,if_not as IsUseAreaTemp,expire_time as OverTempMinTime,OverEnergy,MinEnergyTime,FlagJP,RecipeType as RecipeType from pmt_recipe WHERE ObjID = @RecipeID";
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeID", recipeid);
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dt_recipe = dbHelper.ToDataTable();
|
|
|
return dt_recipe;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前配方主信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetCurrentRecipeData()
|
|
|
{
|
|
|
string recipeid = GetCurrentRecipeID();
|
|
|
return GetRecipeData(recipeid);
|
|
|
}
|
|
|
#region 获取配方主信息
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化填充配方主信息
|
|
|
/// </summary>
|
|
|
/// <param name="recipeData"></param>
|
|
|
/// <returns></returns>
|
|
|
public RecipeInfo FillRecipeInfo(DataTable dt_recipe)
|
|
|
{
|
|
|
RecipeInfo recipe = new RecipeInfo();
|
|
|
if (dt_recipe.Rows.Count == 0)
|
|
|
{
|
|
|
return recipe;
|
|
|
}
|
|
|
recipe.ObjID = DataProcessor.RowValue(dt_recipe.Rows[0], "ObjID", 0);
|
|
|
recipe.RecipeEquipCode = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeEquipCode", string.Empty);
|
|
|
recipe.RecipeMaterialCode = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeMaterialCode", string.Empty);
|
|
|
recipe.RecipeVersionID = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeVersionID", string.Empty);
|
|
|
recipe.RecipeName = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeName", string.Empty);
|
|
|
recipe.RecipeType = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeType", 0);
|
|
|
recipe.RecipeMaterialName = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeMaterialName", string.Empty);
|
|
|
//recipe.RecipeUserVersion = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeUserVersion", 0);
|
|
|
recipe.RecipeState = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeState", 0);
|
|
|
recipe.RecipeDefineDate = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeDefineDate", 0);
|
|
|
//recipe.RecipeModifyTime = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeModifyTime", 0);
|
|
|
//recipe.LotDoneTime = DataProcessor.RowValue(dt_recipe.Rows[0], "LotDoneTime", 0);
|
|
|
recipe.ShelfLotCount = DataProcessor.RowValue(dt_recipe.Rows[0], "ShelfLotCount", 3);
|
|
|
recipe.LotTotalWeight = DataProcessor.RowValue(dt_recipe.Rows[0], "LotTotalWeight", 0);
|
|
|
recipe.CarbonRecycleType = DataProcessor.RowValue(dt_recipe.Rows[0], "CarbonRecycleType", 0);
|
|
|
recipe.CarbonRecycleTime = DataProcessor.RowValue(dt_recipe.Rows[0], "CarbonRecycleTime", 0);
|
|
|
recipe.OverTempMinTime = DataProcessor.RowValue(dt_recipe.Rows[0], "OverTempMinTime", 0);
|
|
|
recipe.OverTimeSetTime = DataProcessor.RowValue(dt_recipe.Rows[0], "OverTimeSetTime", 0);
|
|
|
recipe.OverTempSetTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "OverTempSetTemp", 0);
|
|
|
//recipe.InPolyMaxTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "InPolyMaxTemp", 0);
|
|
|
//recipe.InPolyMinTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "InPolyMinTemp", 0);
|
|
|
//recipe.InPolySetTime = DataProcessor.RowValue(dt_recipe.Rows[0], "InPolySetTime", 0);
|
|
|
//recipe.InCarbonSetTime = DataProcessor.RowValue(dt_recipe.Rows[0], "InCarbonSetTime", 0);
|
|
|
//recipe.InOilSetTime = DataProcessor.RowValue(dt_recipe.Rows[0], "InOilSetTime", 0);
|
|
|
//recipe.InPowderSetTime = DataProcessor.RowValue(dt_recipe.Rows[0], "InPowderSetTime", 0);
|
|
|
//recipe.RollSpeedDiff = DataProcessor.RowValue(dt_recipe.Rows[0], "RollSpeedDiff", 0);
|
|
|
//recipe.RamPressDiff = DataProcessor.RowValue(dt_recipe.Rows[0], "RamPressDiff", 0);
|
|
|
recipe.IsUseAreaTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "IsUseAreaTemp", 0);
|
|
|
recipe.SideTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "SideTemp", 0);
|
|
|
//recipe.SideTempDiff = DataProcessor.RowValue(dt_recipe.Rows[0], "SideTempDiff", 0);
|
|
|
recipe.RollTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "RollTemp", 0);
|
|
|
//recipe.RollTempDiff = DataProcessor.RowValue(dt_recipe.Rows[0], "RollTempDiff", 0);
|
|
|
recipe.DdoorTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "DdoorTemp", 0);
|
|
|
//recipe.DdoorTempDiff = DataProcessor.RowValue(dt_recipe.Rows[0], "DdoorTempDiff", 0);
|
|
|
recipe.OperCode = DataProcessor.RowValue(dt_recipe.Rows[0], "OperCode", 0);
|
|
|
recipe.Remark = DataProcessor.RowValue(dt_recipe.Rows[0], "Remark", 0);
|
|
|
//recipe.StartDatetime = DataProcessor.RowValue(dt_recipe.Rows[0], "StartDatetime", 0);
|
|
|
//recipe.EndDatetime = DataProcessor.RowValue(dt_recipe.Rows[0], "EndDatetime", 0);
|
|
|
//recipe.AuditUser = DataProcessor.RowValue(dt_recipe.Rows[0], "AuditUser", 0);
|
|
|
//recipe.AuditDateTime = DataProcessor.RowValue(dt_recipe.Rows[0], "AuditDateTime", 0);
|
|
|
//recipe.RecipeDic = DataProcessor.RowValue(dt_recipe.Rows[0], "RecipeDic", 0);
|
|
|
//recipe.StayTimeSpand = DataProcessor.RowValue(dt_recipe.Rows[0], "StayTimeSpand", 0);
|
|
|
//recipe.RearchCode = DataProcessor.RowValue(dt_recipe.Rows[0], "RearchCode", 0);
|
|
|
recipe.MakeUpTemp = DataProcessor.RowValue(dt_recipe.Rows[0], "MakeUpTemp", 0);
|
|
|
//recipe.NewFlag = DataProcessor.RowValue(dt_recipe.Rows[0], "NewFlag", 0);
|
|
|
//recipe.OverEnergySetEnergy = DataProcessor.RowValue(dt_recipe.Rows[0], "OverEnergySetEnergy", 0);
|
|
|
//recipe.OverEnergySetTime = DataProcessor.RowValue(dt_recipe.Rows[0], "OverEnergySetTime", 0);
|
|
|
if (recipe.IsUseAreaTemp == 0)
|
|
|
{
|
|
|
recipe.SideTemp = 0;
|
|
|
recipe.RollTemp = 0;
|
|
|
recipe.DdoorTemp = 0;
|
|
|
}
|
|
|
return recipe;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前配方主信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public RecipeInfo GetCurrentRecipeInfo()
|
|
|
{
|
|
|
DataTable dt = GetCurrentRecipeData();
|
|
|
return FillRecipeInfo(dt);
|
|
|
}
|
|
|
#endregion
|
|
|
/// <summary>
|
|
|
/// 获取配方密炼信息
|
|
|
/// </summary>
|
|
|
/// <param name="recipeid"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetRecipeMixingData(string recipeid)
|
|
|
{
|
|
|
DataTable dt_mixing = new DataTable();
|
|
|
string sqlstr = @"SELECT t1.ObjID,t1.RecipeObjID,t1.father_code as RecipeMaterialCode,t1.edt_code as RecipeVersionID,t1.mix_id as MixingStep,t1.term_code as TermCode,t1.set_time as MixingTime,t1.set_temp as MixingTemp,t1.set_ener as MixingEnergy,t1.set_power as MixingPower,t1.set_pres as MixingPress,t1.set_rota as MixingSpeed,t1.act_code as ActionCode,t2.ActionAddress,t3.TermAddress FROM pmt_mix t1
|
|
|
LEFT JOIN dbo.PmtAction t2 ON t1.act_code=t2.ActionCode
|
|
|
LEFT JOIN dbo.PmtTerm t3 ON t1.term_code=t3.TermCode WHERE t1.RecipeObjID = @RecipeID order by t1.mix_id";
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeID", recipeid);
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dt_mixing = dbHelper.ToDataTable();
|
|
|
return dt_mixing;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前配方密炼信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetCurrentRecipeMixingData()
|
|
|
{
|
|
|
string recipeid = GetCurrentRecipeID();
|
|
|
return GetRecipeMixingData(recipeid);
|
|
|
}
|
|
|
#region 获取配方密炼步骤信息
|
|
|
/// <summary>
|
|
|
/// 将密炼信息填充至类
|
|
|
/// </summary>
|
|
|
/// <param name="dt_mixing"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<RecipeMixingInfo> FillRecipeMixingInfo(DataTable dt_mixing)
|
|
|
{
|
|
|
//DbHelper dbHelper = getLocalHelper();
|
|
|
//DataTable dt_termaddress = new DataTable();
|
|
|
//dbHelper.CommandType = CommandType.Text;
|
|
|
//dbHelper.CommandText = "SELECT * FROM dbo.PmtTerm";
|
|
|
//dt_termaddress = dbHelper.ToDataTable();
|
|
|
//DataTable dt_actionaddress = new DataTable();
|
|
|
//dbHelper.CommandType = CommandType.Text;
|
|
|
//dbHelper.CommandText = "SELECT * FROM dbo.PmtAction";
|
|
|
//dt_actionaddress = dbHelper.ToDataTable();
|
|
|
List<RecipeMixingInfo> mixinglst = new List<RecipeMixingInfo>(); //要下传的密炼信息集合
|
|
|
|
|
|
foreach (DataRow row in dt_mixing.Rows)
|
|
|
{
|
|
|
RecipeMixingInfo mixing = new RecipeMixingInfo();
|
|
|
|
|
|
mixing.ActionCode = DataProcessor.RowValue(row, "ActionCode", string.Empty);
|
|
|
mixing.ActionCodeAddress = DataProcessor.RowValue(row, "ActionAddress", 0);
|
|
|
//foreach (DataRow _dr in dt_actionaddress.Rows)
|
|
|
//{
|
|
|
// if (_dr["ActionCode"].ToString().Trim().Equals(mixing.ActionCode, StringComparison.CurrentCultureIgnoreCase))
|
|
|
// {
|
|
|
// mixing.ActionCodeAddress = DataProcessor.RowValue(_dr, "ActionAddress", 0);
|
|
|
// break;
|
|
|
// }
|
|
|
//}
|
|
|
mixing.TermCode = DataProcessor.RowValue(row, "TermCode", string.Empty);
|
|
|
mixing.TermCodeAddress = DataProcessor.RowValue(row, "TermAddress", 0);
|
|
|
//foreach (DataRow _dr in dt_termaddress.Rows)
|
|
|
//{
|
|
|
// if (_dr["TermCode"].ToString().Trim().Equals(mixing.TermCode.Trim(), StringComparison.CurrentCultureIgnoreCase))
|
|
|
// {
|
|
|
// mixing.TermCodeAddress = DataProcessor.RowValue(_dr, "TermAddress", 0);
|
|
|
// mixing.TermName = DataProcessor.RowValue(_dr, "ShowName", string.Empty);
|
|
|
// break;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
#region 保存同步执行的密炼信息和当前密炼信息
|
|
|
|
|
|
RecipeMixingInfo sychnMixing = new RecipeMixingInfo();
|
|
|
sychnMixing.ObjID = DataProcessor.RowValue(row, "ObjID", 0);
|
|
|
sychnMixing.RecipeObjID = DataProcessor.RowValue(row, "RecipeObjID", 0);
|
|
|
sychnMixing.RecipeMaterialCode = DataProcessor.RowValue(row, "RecipeMaterialCode", 0);
|
|
|
sychnMixing.RecipeVersionID = DataProcessor.RowValue(row, "RecipeVersionID", 0);
|
|
|
sychnMixing.TermCode = mixing.TermCode;
|
|
|
sychnMixing.TermCodeAddress = mixing.TermCodeAddress;
|
|
|
sychnMixing.TermName = mixing.TermName;
|
|
|
sychnMixing.MixingStep = DataProcessor.RowValue(row, "MixingStep", 0);
|
|
|
sychnMixing.MixingTime = DataProcessor.RowValue(row, "MixingTime", 0);
|
|
|
sychnMixing.MixingTemp = DataProcessor.RowValue(row, "MixingTemp", 0);
|
|
|
sychnMixing.MixingEnergy = DataProcessor.RowValue(row, "MixingEnergy", 0);
|
|
|
sychnMixing.MixingPower = DataProcessor.RowValue(row, "MixingPower", 0);
|
|
|
sychnMixing.ActionCode = mixing.ActionCode;
|
|
|
sychnMixing.ActionCodeAddress = mixing.ActionCodeAddress;
|
|
|
sychnMixing.MixingPress = DataProcessor.RowValue(row, "MixingPress", 0);
|
|
|
sychnMixing.MixingSpeed = DataProcessor.RowValue(row, "MixingSpeed", 0);
|
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrEmpty(mixing.TermName) && mixing.TermName.Trim() == "同时执行")
|
|
|
{
|
|
|
mixinglst[mixinglst.Count - 1].ActionCodeAddress += mixing.ActionCodeAddress;
|
|
|
mixinglst[mixinglst.Count - 1].SynchMixingInfos.Add(sychnMixing); //合并同步执行的密炼步骤信息
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
mixing.ObjID = DataProcessor.RowValue(row, "ObjID", 0);
|
|
|
mixing.RecipeObjID = DataProcessor.RowValue(row, "RecipeObjID", 0);
|
|
|
mixing.RecipeMaterialCode = DataProcessor.RowValue(row, "RecipeMaterialCode", 0);
|
|
|
mixing.RecipeVersionID = DataProcessor.RowValue(row, "RecipeVersionID", 0);
|
|
|
mixing.MixingStep = DataProcessor.RowValue(row, "MixingStep", 0);
|
|
|
mixing.MixingTime = DataProcessor.RowValue(row, "MixingTime", 0);
|
|
|
mixing.MixingTemp = DataProcessor.RowValue(row, "MixingTemp", 0);
|
|
|
mixing.MixingEnergy = DataProcessor.RowValue(row, "MixingEnergy", 0);
|
|
|
mixing.MixingPower = DataProcessor.RowValue(row, "MixingPower", 0);
|
|
|
mixing.MixingPress = DataProcessor.RowValue(row, "MixingPress", 0);
|
|
|
mixing.MixingSpeed = DataProcessor.RowValue(row, "MixingSpeed", 0);
|
|
|
mixing.SynchMixingInfos.Add(sychnMixing);
|
|
|
mixinglst.Add(mixing);
|
|
|
}
|
|
|
return mixinglst;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前密炼信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<RecipeMixingInfo> GetCurrentRecipeMixingInfo()
|
|
|
{
|
|
|
DataTable dt = GetCurrentRecipeMixingData();
|
|
|
return FillRecipeMixingInfo(dt);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
private string ToString(object obj)
|
|
|
{
|
|
|
if (obj == null || obj == DBNull.Value)
|
|
|
{
|
|
|
return string.Empty;
|
|
|
}
|
|
|
return obj.ToString().Trim();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 称量动作信息转义
|
|
|
/// </summary>
|
|
|
/// <param name="row"></param>
|
|
|
/// <returns></returns>
|
|
|
private int WeightAction(DataRow row)
|
|
|
{
|
|
|
int iresult = 0;
|
|
|
int.TryParse(ToString(row["ActCode"]), out iresult);
|
|
|
return iresult;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取配方称量信息
|
|
|
/// </summary>
|
|
|
/// <param name="recipeid"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetRecipeWeigthData(string recipeid)
|
|
|
{
|
|
|
DataTable dt_weight = new DataTable();
|
|
|
// string sqlstr = @"SELECT t1.ObjID,t1.RecipeObjID,t1.weight_id as WeightID,t1.father_code as RecipeMaterialCode,t1.equip_code as RecipeEquipCode,t1.edt_code as RecipeVersionID,t1.weigh_type as WeightType,t1.act_code as ActCode,t1.child_code as MaterialCode,t1.child_name as MaterialName,t1.set_weight as SetWeight,t1.error_allow as ErrorAllow,t3.JarSerial
|
|
|
// FROM pmt_weigh t1
|
|
|
// LEFT JOIN pmt_material t2 ON t1.child_code=t2.mater_code
|
|
|
// LEFT JOIN SytJar t3 ON t2.mater_name=t3.MaterialName and JarUsed = '使用'
|
|
|
// WHERE t1.RecipeObjID = @RecipeID order by t1.weigh_type,t1.weight_id";
|
|
|
// string sqlstr = @"SELECT t1.ObjID,t1.RecipeObjID,t1.weight_id as WeightID,t1.father_code as RecipeMaterialCode,t1.equip_code as RecipeEquipCode,t1.edt_code as RecipeVersionID,t1.weigh_type as WeightType,t1.act_code as ActCode,t1.child_code as MaterialCode,t1.child_name as MaterialName,t1.set_weight as SetWeight,t1.error_allow as ErrorAllow,t3.JarSerial,t1.Auto_ploy
|
|
|
// FROM pmt_weigh t1
|
|
|
// LEFT JOIN pmt_material t2 ON t1.child_code=t2.mater_code
|
|
|
// LEFT JOIN (select jartype,MaterialName,jarused,deleteflag,maxcapacity,mincapacity,curvalue,curstate,min(jarserial) as jarserial from SytJar where JarUsed = '使用' group by jartype,MaterialName,jarused,deleteflag,maxcapacity,mincapacity,curvalue,curstate) t3 ON t2.mater_name=t3.MaterialName and JarUsed = '使用'
|
|
|
// WHERE t1.RecipeObjID = @RecipeID order by t1.weigh_type,t1.weight_id";
|
|
|
//语句中增加了罐的类型
|
|
|
string sqlstr = @"SELECT t1.ObjID,t1.RecipeObjID,t1.weight_id as WeightID,t1.father_code as RecipeMaterialCode,t1.equip_code as RecipeEquipCode,t1.edt_code as RecipeVersionID,t1.weigh_type as WeightType,t1.act_code as ActCode,t1.child_code as MaterialCode,t1.child_name as MaterialName,t1.set_weight as SetWeight,t1.error_allow as ErrorAllow,t3.JarSerial,t1.Auto_ploy
|
|
|
FROM pmt_weigh t1
|
|
|
LEFT JOIN pmt_material t2 ON t1.child_code=t2.mater_code
|
|
|
LEFT JOIN (select jartype,MaterialName,jarused,deleteflag,maxcapacity,mincapacity,curvalue,curstate,min(jarserial) as jarserial from SytJar where JarUsed = '使用' group by jartype,MaterialName,jarused,deleteflag,maxcapacity,mincapacity,curvalue,curstate) t3 ON t2.mater_type=t3.JarType and t2.mater_name=t3.MaterialName and JarUsed = '使用'
|
|
|
WHERE t1.RecipeObjID = @RecipeID order by t1.weigh_type,t1.weight_id";
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeID", recipeid);
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dt_weight = dbHelper.ToDataTable();
|
|
|
foreach (DataRow row in dt_weight.Rows)
|
|
|
{
|
|
|
//数据库ActCode为0:称量,1:称道,2:卸料;PLC为1:称量,2:称道,3:卸料;因此要为ActCode加1
|
|
|
row["ActCode"] = WeightAction(row) + 1;
|
|
|
//if (!string.IsNullOrEmpty(row["MaterialCode"].ToString()) && row["WeightType"].ToString() == "2")//如果是胶料特殊处理
|
|
|
//{
|
|
|
// if (Convert.ToInt32(row["MaterialCode"].ToString().Substring(0, 1)) < 3)
|
|
|
// row["ActCode"] = 0;
|
|
|
// else
|
|
|
// row["ActCode"] = 1;
|
|
|
//}
|
|
|
//row["ActCode"] = WeightAction(row);
|
|
|
}
|
|
|
dt_weight.TableName = recipeid;
|
|
|
return dt_weight;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前配方称量信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetCurrentRecipeWeigthData()
|
|
|
{
|
|
|
string recipeid = GetCurrentRecipeID();
|
|
|
return GetRecipeWeigthData(recipeid);
|
|
|
}
|
|
|
#region 获取配方称量信息
|
|
|
/// <summary>
|
|
|
/// 获取当前物料的罐号
|
|
|
/// </summary>
|
|
|
/// <param name="weightType">称量类型</param>
|
|
|
/// <param name="materCode">物料代码</param>
|
|
|
/// <returns>成功返回对应的罐号,失败返回0</returns>
|
|
|
private int GetJarNum(int weightType, string materCode)
|
|
|
{
|
|
|
// string sqlstr = @"SELECT t1.JarSerial FROM SytJar t1
|
|
|
// INNER JOIN pmt_material t2 ON t1.MaterialName=t2.mater_name
|
|
|
// WHERE t2.mater_code=@MaterialCode and t1.JarUsed = '使用'";
|
|
|
string sqlstr = @"SELECT t1.JarSerial FROM SytJar t1
|
|
|
INNER JOIN pmt_material t2 ON t1.MaterialName=t2.mater_name and t1.JarType = t2.mater_Type
|
|
|
WHERE t1.JarType=@JarType and t2.mater_code=@MaterialCode and t1.JarUsed = '使用'";
|
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@JarType", Global.GetJarTypeByWeightType(weightType.ToString()));
|
|
|
dbHelper.AddParameter("@MaterialCode", materCode);
|
|
|
object obj = dbHelper.ToScalar();
|
|
|
if (obj != null && obj != DBNull.Value)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
if (int.TryParse(obj.ToString(), out iResult))
|
|
|
{
|
|
|
return iResult;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 将称量转化为类信息
|
|
|
/// </summary>
|
|
|
/// <param name="dt_weight"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<RecipeWeightInfo> FillRecipeWeightInfo(DataTable dt_weight)
|
|
|
{
|
|
|
List<RecipeWeightInfo> weightlst = new List<RecipeWeightInfo>();
|
|
|
foreach (DataRow row in dt_weight.Rows)
|
|
|
{
|
|
|
RecipeWeightInfo weight = new RecipeWeightInfo();
|
|
|
weight.ObjID = DataProcessor.RowValue(row, "ObjID", 0);
|
|
|
weight.RecipeObjID = DataProcessor.RowValue(row, "RecipeObjID", 0);
|
|
|
weight.RecipeMaterialCode = DataProcessor.RowValue(row, "RecipeMaterialCode", 0);
|
|
|
weight.RecipeVersionID = DataProcessor.RowValue(row, "RecipeVersionID", 0);
|
|
|
weight.WeightID = DataProcessor.RowValue(row, "WeightID", 0);
|
|
|
weight.WeightType = DataProcessor.RowValue(row, "WeightType", 0);
|
|
|
//weight.ScaleID = DataProcessor.RowValue(row, "ScaleID", 0);
|
|
|
weight.ActCode = DataProcessor.RowValue(row, "ActCode", 0);
|
|
|
weight.MaterialCode = DataProcessor.RowValue(row, "MaterialCode", string.Empty);
|
|
|
weight.MaterialName = DataProcessor.RowValue(row, "MaterialName", string.Empty);
|
|
|
weight.SetWeight = DataProcessor.RowValue(row, "SetWeight", 0.00);
|
|
|
//weight.OldSetWeight = DataProcessor.RowValue(row, "OldSetWeight", 0.00);
|
|
|
weight.ErrorAllow = DataProcessor.RowValue(row, "ErrorAllow", 0.00);
|
|
|
weight.JarNum = GetJarNum(weight.WeightType, weight.MaterialCode);
|
|
|
weightlst.Add(weight);
|
|
|
}
|
|
|
return weightlst;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前配方称量类信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<RecipeWeightInfo> GetCurrentRecipeWeightInfo()
|
|
|
{
|
|
|
DataTable dt = GetCurrentRecipeWeigthData();
|
|
|
return FillRecipeWeightInfo(dt);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取下一个计划编号
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public string GetNextPlanID()
|
|
|
{
|
|
|
string result = string.Empty;
|
|
|
PlanLog planLog = PlanCommon.PlanLog;
|
|
|
result = PlanCommon.GetNextPlanID(planLog.LastPlanID, new BaseAction().CurrEquipCode, planLog.LastSelectDate, planLog.LastSelectShiftID);
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
#endregion
|
|
|
}
|
|
|
}
|