|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Data;
|
|
|
using ICSharpCode.Core;
|
|
|
using Mesnac.Codd.Session;
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity.material;
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity.PptPlan;
|
|
|
using DevExpress.DataProcessing.InMemoryDataProcessor.Executors;
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Product.XlPlan
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 计划业务辅助类
|
|
|
/// </summary>
|
|
|
public class PlanHelper
|
|
|
{
|
|
|
#region 静态字段定义
|
|
|
|
|
|
private static bool _isInit = false; //当班计划是否已初始化
|
|
|
private static string _execDate; //执行日期
|
|
|
private static string _execShift; //执行班次
|
|
|
private static string _execClass; //执行班组
|
|
|
private static bool _isShift = false; //是否交接班标志
|
|
|
private static PlanLog _planLog = null; //计划日志
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 静态属性定义
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否正在初始化计划标志
|
|
|
/// </summary>
|
|
|
public static bool IsInit
|
|
|
{
|
|
|
get { return _isInit; }
|
|
|
set { lock (String.Empty) { _isInit = value; } }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行日期
|
|
|
/// </summary>
|
|
|
public static string ExecDate
|
|
|
{
|
|
|
get { return _execDate; }
|
|
|
set { lock (String.Empty) { _execDate = value; } }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行班次
|
|
|
/// </summary>
|
|
|
public static string ExecShift
|
|
|
{
|
|
|
get { return _execShift; }
|
|
|
set { lock (String.Empty) { _execShift = value; } }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行班组
|
|
|
/// </summary>
|
|
|
public static string ExecClass
|
|
|
{
|
|
|
get { return _execClass; }
|
|
|
set { lock (String.Empty) { _execClass = value; } }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 是否交接班标记
|
|
|
/// </summary>
|
|
|
public static bool IsShift
|
|
|
{
|
|
|
get { return _isShift; }
|
|
|
set { lock (String.Empty) { _isShift = value; } }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 计划日志对象
|
|
|
/// </summary>
|
|
|
public static PlanLog PlanLog
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
if (_planLog == null)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
_planLog = new PlanLog();
|
|
|
string currentPlanDate = BaseDataHelper.GetSysValue("PlanLog.CurrentPlanDate"); //获取当前计划日期
|
|
|
string currentPlanId = BaseDataHelper.GetSysValue("PlanLog.CurrentPlanID"); //获取当前计划号
|
|
|
string currentShiftID = BaseDataHelper.GetSysValue("PlanLog.CurrentShiftID"); //获取当前班次
|
|
|
string currentShiftName = BaseDataHelper.GetSysValue("PlanLog.CurrentShiftName"); //获取当前班次名称
|
|
|
string currentClassID = BaseDataHelper.GetSysValue("PlanLog.CurrentClassID"); //获取当前班组
|
|
|
string currentClassName = BaseDataHelper.GetSysValue("PlanLog.CurrentClassName"); //获取当前班组名称
|
|
|
if (!String.IsNullOrEmpty(currentPlanDate))
|
|
|
{
|
|
|
_planLog.LastDate = Convert.ToDateTime(currentPlanDate);
|
|
|
}
|
|
|
if (!String.IsNullOrEmpty(currentShiftID))
|
|
|
{
|
|
|
_planLog.LastShiftID = Convert.ToInt32(currentShiftID);
|
|
|
}
|
|
|
if (!String.IsNullOrEmpty(currentClassID))
|
|
|
{
|
|
|
_planLog.LastClassID = Convert.ToInt32(currentClassID);
|
|
|
}
|
|
|
if (!String.IsNullOrEmpty(currentPlanId))
|
|
|
{
|
|
|
_planLog.LastPlanID = currentPlanId.Trim();
|
|
|
}
|
|
|
_planLog.LastShiftName = currentShiftName;
|
|
|
_planLog.LastClassName = currentClassName;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("从SysKeyValue中获取计划日志失败:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
return _planLog;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_planLog = value;
|
|
|
try
|
|
|
{
|
|
|
if (_planLog != null)
|
|
|
{
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentPlanDate", String.Format("{0:yyyy-MM-dd}", _planLog.LastDate));
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentPlanID", _planLog.LastPlanID);
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentShiftID", _planLog.LastShiftID.ToString());
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentShiftName", _planLog.LastShiftName);
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentClassID", _planLog.LastClassID.ToString());
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentClassName", _planLog.LastClassName);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentPlanDate", String.Format("{0:yyyy-MM-dd}", DateTime.Now));
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentPlanID", String.Empty);
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentShiftID", String.Empty);
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentShiftName", String.Empty);
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentClassID", String.Empty);
|
|
|
BaseDataHelper.UpdateSysValue("PlanLog.CurrentClassName", String.Empty);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("保存计划日志到SysKeyValue表中失败:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 静态方法定义
|
|
|
|
|
|
#region 计划网格控件样式设置方法
|
|
|
|
|
|
#region 设置(网格控件)的表头、字体和行样式
|
|
|
/// <summary>
|
|
|
/// 设置(网格控件)的表头、字体和行样式
|
|
|
/// </summary>
|
|
|
/// <param name="grid"></param>
|
|
|
public static void SetDataGridViewStyle(DataGridView grid)
|
|
|
{
|
|
|
lock (String.Empty)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (grid == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Warn("设置计划背景色失败:网格控件为null");
|
|
|
return;
|
|
|
}
|
|
|
grid.RowTemplate.Height = 28;
|
|
|
grid.DefaultCellStyle.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
grid.ColumnHeadersHeight = 28;
|
|
|
grid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
grid.RowHeadersVisible = false;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("【当班计划】设置(网格控件)的表头、字体和行样式SetDataGridViewStyle失败:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 设置(网格控件)的表头、字体和行样式
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置(网格控件)的表头、字体和行样式
|
|
|
/// </summary>
|
|
|
/// <param name="grid"></param>
|
|
|
public static void SetDataGridViewStyle48(DataGridView grid)
|
|
|
{
|
|
|
lock (String.Empty)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (grid == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Warn("设置计划背景色失败:网格控件为null");
|
|
|
return;
|
|
|
}
|
|
|
grid.RowTemplate.Height = 60;
|
|
|
grid.DefaultCellStyle.Font = new System.Drawing.Font("宋体", 32F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
grid.ColumnHeadersHeight = 70;
|
|
|
grid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
grid.RowHeadersVisible = false;
|
|
|
grid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //列头居中
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("【当班计划】设置(网格控件)的表头、字体和行样式SetDataGridViewStyle48失败:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 设置(网格控件)计划状态背景色
|
|
|
/// <summary>
|
|
|
/// 设置计划状态背景色
|
|
|
/// </summary>
|
|
|
/// <param name="grid"></param>
|
|
|
public static void SetBackColor(DataGridView grid)
|
|
|
{
|
|
|
lock (String.Empty)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (grid == null || grid.Visible == false)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Warn("设置计划背景色失败:网格控件为null或不可见");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
string lastPlanID = String.Empty;
|
|
|
PlanLog log = PlanLog;
|
|
|
if (log != null)
|
|
|
{
|
|
|
lastPlanID = log.LastPlanID;
|
|
|
}
|
|
|
grid.ClearSelection(); //清空选中行
|
|
|
grid.ColumnHeadersHeight = 25;
|
|
|
grid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
grid.RowHeadersVisible = false;
|
|
|
grid.RowTemplate.Height = 28;
|
|
|
grid.RowsDefaultCellStyle.Font = new System.Drawing.Font("宋体", 12, System.Drawing.FontStyle.Bold);
|
|
|
foreach (DataGridViewRow row in grid.Rows)
|
|
|
{
|
|
|
int planState = 0;
|
|
|
planState = StateToValue(row.Cells["Plan_StateText"].Value.ToString());
|
|
|
|
|
|
switch (planState)
|
|
|
{
|
|
|
case (int)PlanState.Download: //已下传
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(255, 204, 204);
|
|
|
break;
|
|
|
case (int)PlanState.UnStart: //未启动
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(255, 255, 204);
|
|
|
break;
|
|
|
case (int)PlanState.Producting: //正在运行
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.GreenYellow; //绿色
|
|
|
break;
|
|
|
case (int)PlanState.Terminated: //已终止
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(220, 220, 120); //灰色
|
|
|
break;
|
|
|
case (int)PlanState.Completed: //已完成
|
|
|
int realNum = 0;
|
|
|
realNum = Convert.ToInt32(row.Cells["Real_Num"].Value);
|
|
|
if (realNum < Convert.ToInt32(row.Cells["Plan_Num"].Value))
|
|
|
{
|
|
|
//停止计划
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(220, 220, 120); //灰色
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//完成计划
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(220, 220, 220); //灰色
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("设置计划背景色失败:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 判断某个计划是否存在(LR_Plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断某个计划是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
public static bool LRPlanExists(string planID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select count(Plan_Id) from LR_plan where Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != DBNull.Value && Convert.ToInt32(result) > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 判断某个计划是否存在(xl_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断某个计划是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
public static bool PlanExists(string planID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select count(Plan_Id) from xl_plan where Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != DBNull.Value && Convert.ToInt32(result) > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断某个计划是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="recipeName">配方名称</param>
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
public static bool PlanExistsRecipeName(string recipeID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select count(Plan_Id) from xl_plan where Recipe_ID = @Recipe_ID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@Recipe_ID", recipeID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != DBNull.Value && Convert.ToInt32(result) > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断某个计划是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>存在返回true,不存在返回false</returns>
|
|
|
public static bool PlanExists(DateTime planDate, int shiftID, string planID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select count(Plan_Id) from xl_plan where Convert(varchar,Plan_Date,112) = @PlanDate and Shift_Id = @ShiftID and Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != DBNull.Value && Convert.ToInt32(result) > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GetNextSerialNum 获取下一个可用的序号SerialNum 规则:同机台、同日期、同班次 计划号最后2位的最大值加1
|
|
|
/// <summary>
|
|
|
/// 获取下一个可用的序号
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <returns>返回可用的序号</returns>
|
|
|
public static int GetNextSerialNum()
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT MAX(Plan_Serial) FROM xl_plan";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result == null || result == System.DBNull.Value)
|
|
|
{
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Convert.ToInt32(result) + 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GetNextSerialNumFromLRPlan 获取下一个可用的序号SerialNum 规则:同机台、同日期、同班次 计划号最后2位的最大值加1(xl_plan)
|
|
|
/// <summary>
|
|
|
/// 获取下一个可用的序号
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <returns>返回可用的序号</returns>
|
|
|
public static int GetNextSerialNumFromLRPlan(DateTime planDate)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT MAX(RIGHT(Plan_Id,2)) FROM LR_plan WHERE LEFT(Plan_Id,8) = @PlanDate";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result == null || result == System.DBNull.Value)
|
|
|
{
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Convert.ToInt32(result) + 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GenerateNextPlanID 获取下一个可用的计划号 (6位日期、2位机台、1位班次、1位网络/本机、2位流水)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下一个可用的计划号 (6位日期、2位机台、1位班次、1位网络/本机、2位流水)
|
|
|
/// </summary>
|
|
|
/// <param name="equipCode">机台号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回生成的12位计划号</returns>
|
|
|
public static string GenerateNextPlanID(string equipCode, DateTime planDate, int shiftID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT Max(Plan_Id) FROM xl_plan WHERE LEFT(Plan_Id,8) = @PlanDate";
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result == null || result == System.DBNull.Value)
|
|
|
{
|
|
|
//string code = equipCode.Substring(3, 2); //获取机台后2位
|
|
|
string code = "01";
|
|
|
return String.Format("{0:yyyyMMdd}{1}{2}01", planDate, code, shiftID);
|
|
|
}
|
|
|
string lastTwo = result.ToString().Substring(11, 2); //截取最后2位
|
|
|
int newValue = Convert.ToInt32(lastTwo) + 1;
|
|
|
string nextPlanID = result.ToString().Substring(0, 11) + Mesnac.Basic.DataProcessor.FillZero(newValue.ToString(), 2);
|
|
|
return nextPlanID;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GenerateNextPlanIDNew 获取下一个可用的计划号 (6位日期、2位机台、1位班次、1位网络/本机、2位流水)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下一个可用的计划号 (6位日期、2位机台、1位班次、1位网络/本机、2位流水)
|
|
|
/// </summary>
|
|
|
/// <param name="equipCode">机台号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回生成的12位计划号</returns>
|
|
|
public static string GenerateNextPlanIDNew(DateTime planDate, int shiftID,int sNum)
|
|
|
{
|
|
|
string code = "01";
|
|
|
return String.Format("{0:yyyyMMdd}{1}{2}", planDate, code, shiftID) + Mesnac.Basic.DataProcessor.FillZero(sNum.ToString(), 2);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取某条生产计划(计划号)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取某条生产计划(计划号)
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>返回对应计划的DataRow</returns>
|
|
|
public static DataRow GetPlanData(string planID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT * FROM xl_plan WHERE Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count == 1)
|
|
|
{
|
|
|
return table.Rows[0];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取某条生产计划(计划序号、日期)
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>返回对应计划的DataRow</returns>
|
|
|
public static DataRow GetPlanData(int planSerial)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT * FROM xl_plan WHERE Plan_Serial = @Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@Plan_Serial", planSerial);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count == 1)
|
|
|
{
|
|
|
return table.Rows[0];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取某条生产计划(计划号)
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>返回对应计划实体对象</returns>
|
|
|
public static Entity.xl_plan GetPlanDataEntity(string planID)
|
|
|
{
|
|
|
DataRow dr = GetPlanData(planID);
|
|
|
if (dr != null)
|
|
|
{
|
|
|
Entity.xl_plan plan = ConvertDataRowToPptPlan(dr);
|
|
|
return plan;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取某条生产计划(计划序号、日期)
|
|
|
/// </summary>
|
|
|
/// <param name="planSerial">计划序号</param>
|
|
|
/// <param name="planDate">计划日期</param>
|
|
|
/// <returns>返回对应计划实体对象</returns>
|
|
|
public static Entity.xl_plan GetPlanDataEntity(int planSerial)
|
|
|
{
|
|
|
DataRow dr = GetPlanData(planSerial);
|
|
|
if (dr != null)
|
|
|
{
|
|
|
Entity.xl_plan plan = ConvertDataRowToPptPlan(dr);
|
|
|
return plan;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 实体类复制
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将一个实体类复制到另一个实体类
|
|
|
/// </summary>
|
|
|
/// <param name="objectsrc">源实体类</param>
|
|
|
/// <param name="objectdest">复制到的实体类</param>
|
|
|
public static void EntityToEntity(object objectsrc, object objectdest)
|
|
|
{
|
|
|
var sourceType = objectsrc.GetType();
|
|
|
var destType = objectdest.GetType();
|
|
|
foreach (var source in sourceType.GetProperties())
|
|
|
{
|
|
|
foreach (var dest in destType.GetProperties())
|
|
|
{
|
|
|
if (dest.Name == source.Name)
|
|
|
{
|
|
|
dest.SetValue(objectdest, source.GetValue(objectsrc));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当班未执行计划列表
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当班未执行计划列表
|
|
|
/// </summary>
|
|
|
/// <param name="limit">限定返回结果的行数</param>
|
|
|
/// <returns>返回符合条件的计划列表</returns>
|
|
|
public static List<Entity.xl_plan> GetUnExePlanEntityList(int limit)
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT top {0} * FROM xl_plan WHERE Plan_State = 5 ORDER BY Plan_Date,Plan_Serial";
|
|
|
strSql = String.Format(strSql, limit);
|
|
|
dbHelper.CommandText = strSql;
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach(DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当班正在执行及未执行的计划列表
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当班正在执行及未执行的计划列表
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <param name="limit">限定返回结果的行数</param>
|
|
|
/// <returns>返回符合条件的计划列表</returns>
|
|
|
public static List<Entity.xl_plan> GetPlanEntityListByNum(int limit)
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
DateTime planDate = PlanHelper.PlanLog.LastDate;
|
|
|
int shiftID = PlanHelper.PlanLog.LastShiftID;
|
|
|
string msg = String.Empty;
|
|
|
string strPlanDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
|
|
|
|
|
|
//bool result = ProductHelper.PlanDateVerify(out planDate, out shiftID, strPlanDate, shiftID, out msg);
|
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT top {0} * FROM xl_plan WHERE LEFT(Plan_Id,8) = @PlanDate AND Plan_State <= 5 ORDER BY Plan_Serial";
|
|
|
strSql = String.Format(strSql, limit);
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
//dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当班大于某序号的正在执行及未执行的计划列表
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当班大于某序号的正在执行及未执行的计划列表
|
|
|
/// </summary>
|
|
|
/// <param name="planSerial">计划序号</param>
|
|
|
/// <returns>返回符合条件的计划列表</returns>
|
|
|
public static List<Entity.xl_plan> GetPlanListAfterPlanSerial(int planSerial)
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
DateTime planDate = PlanHelper.PlanLog.LastDate;
|
|
|
int shiftID = PlanHelper.PlanLog.LastShiftID;
|
|
|
string msg = String.Empty;
|
|
|
string strPlanDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
|
|
|
|
|
|
//bool result = ProductHelper.PlanDateVerify(out planDate, out shiftID, strPlanDate, shiftID, out msg);
|
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT * FROM xl_plan WHERE LEFT(Plan_Id,8) = @PlanDate AND Shift_Id = @ShiftID AND Plan_State <= 5 AND Plan_Serial > @Plan_Serial ORDER BY Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
dbHelper.AddParameter("@Plan_Serial", planSerial);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当班某序号未执行的计划(下移使用)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当班某序号未执行的计划
|
|
|
/// </summary>
|
|
|
/// <param name="planSerial">计划序号</param>
|
|
|
/// <returns>返回符合条件的计划列表</returns>
|
|
|
public static Entity.xl_plan GetPlanBySerialDown(int planSerial)
|
|
|
{
|
|
|
Entity.xl_plan reRtPlan = null;
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
string planDate = DateTime.Now.ToShortDateString();
|
|
|
//int shiftID = PlanHelper.PlanLog.LastShiftID;
|
|
|
string msg = String.Empty;
|
|
|
string strPlanDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
|
|
|
|
|
|
//bool result = ProductHelper.PlanDateVerify(out planDate, out shiftID, strPlanDate, shiftID, out msg);
|
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT top 1 * FROM xl_plan WHERE Plan_Date = @PlanDate AND Plan_State <= 5 AND Plan_State >3 AND Plan_Serial > @Plan_Serial ORDER BY Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanDate", planDate);
|
|
|
//dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
dbHelper.AddParameter("@Plan_Serial", planSerial);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
reRtPlan = ConvertDataRowToPptPlan(dr);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return reRtPlan;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当班某序号未执行的计划(上移使用)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当班某序号未执行的计划
|
|
|
/// </summary>
|
|
|
/// <param name="planSerial">计划序号</param>
|
|
|
/// <returns>返回符合条件的计划列表</returns>
|
|
|
public static Entity.xl_plan GetPlanBySerialUp(int planSerial)
|
|
|
{
|
|
|
Entity.xl_plan reRtPlan = null;
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
string planDate = DateTime.Now.ToShortDateString();
|
|
|
//int shiftID = PlanHelper.PlanLog.LastShiftID;
|
|
|
string msg = String.Empty;
|
|
|
string strPlanDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
|
|
|
|
|
|
//bool result = ProductHelper.PlanDateVerify(out planDate, out shiftID, strPlanDate, shiftID, out msg);
|
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT top 1 * FROM xl_plan WHERE Plan_Date = @PlanDate AND Plan_State <= 5 AND Plan_State >3 AND Plan_Serial < @Plan_Serial ORDER BY Plan_Serial DESC";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@PlanDate", planDate);
|
|
|
//dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
dbHelper.AddParameter("@Plan_Serial", planSerial);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
reRtPlan = ConvertDataRowToPptPlan(dr);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return reRtPlan;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取未执行的计划数(xl_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取未执行的计划数
|
|
|
/// </summary>
|
|
|
public static int GetUnExePlanNum()
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
|
|
|
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 strSql = "SELECT * FROM xl_plan WHERE Plan_State = 5";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst.Count;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取正在执行的计划数(xl_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取正在执行的计划数
|
|
|
/// </summary>
|
|
|
public static int GetRunningPlanNum()
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
|
|
|
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 strSql = "SELECT * FROM xl_plan WHERE Plan_State = 3";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst.Count;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取已经下传的计划数(xl_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取已经下传的计划数
|
|
|
/// </summary>
|
|
|
public static int GetDownPlanNum()
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
|
|
|
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 strSql = "SELECT * FROM xl_plan WHERE Plan_State = 4";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst.Count;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 清空计划列表(xl_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 清空计划列表
|
|
|
/// </summary>
|
|
|
public static void ClearRT_Plan()
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "Delete FROM xl_plan WHERE Plan_State <> 3 And Plan_State <> 5";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据配方id获取物料信息列表
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据配方id获取物料信息列表
|
|
|
/// </summary>
|
|
|
/// <param name="recipeId">配方ID</param>
|
|
|
/// <returns>返回符合条件的计划列表</returns>
|
|
|
public static List<xl_weigh> Getxl_weighList(string recipeId)
|
|
|
{
|
|
|
List<xl_weigh> lst = new List<xl_weigh>();
|
|
|
|
|
|
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 strSql = "SELECT * FROM xl_weigh where Recipe_ID = @Recipe_ID order by Weight_Id";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Recipe_ID", recipeId);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
xl_weigh entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtweigh(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取下一条生产计划
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下一条生产计划
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回符合条件的计划</returns>
|
|
|
public static xl_plan GetNextPlan(int planSerial)
|
|
|
{
|
|
|
xl_plan reRtPLan = new xl_plan();
|
|
|
|
|
|
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 strSql = "SELECT top 1 * FROM xl_plan WHERE Plan_State = 5 AND Plan_Serial > @Plan_Serial ORDER BY Plan_Date,Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Plan_Serial", planSerial);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
reRtPLan = ConvertDataRowToPptPlan(dr);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return reRtPLan;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据物料id获取Pmt_Bin
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据物料id获取Pmt_Bin
|
|
|
/// </summary>
|
|
|
/// <param name="recipeId">物料id</param>
|
|
|
/// <returns>返回符合条件Pmt_Bin</returns>
|
|
|
public static Pmt_Bin GetPmt_Bin(string materialID)
|
|
|
{
|
|
|
Pmt_Bin rePmt_Bin = new Pmt_Bin();
|
|
|
|
|
|
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 strSql = "SELECT * FROM Pmt_Bin where Material_ID = @Material_ID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Material_ID", materialID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Pmt_Bin entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtBin(dr);
|
|
|
rePmt_Bin = entity;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return rePmt_Bin;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取所有Pmt_Bin
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取所有Pmt_Bin
|
|
|
/// </summary>
|
|
|
public static List<Pmt_Bin> GetAllPmt_Bin()
|
|
|
{
|
|
|
List<Pmt_Bin> rePmt_BinList = new List<Pmt_Bin>();
|
|
|
|
|
|
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 strSql = "SELECT * FROM Pmt_Bin";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Pmt_Bin entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtBin(dr);
|
|
|
rePmt_BinList.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return rePmt_BinList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据物料id获取料仓号
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据物料id获取料仓号
|
|
|
/// </summary>
|
|
|
/// <param name="recipeId">物料id</param>
|
|
|
/// <returns>返回符合条件Pmt_Bin</returns>
|
|
|
public static int GetPmt_BinSerial(string materialID)
|
|
|
{
|
|
|
Pmt_Bin rePmt_Bin = new Pmt_Bin();
|
|
|
|
|
|
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 strSql = "SELECT * FROM Pmt_Bin where Material_ID = @Material_ID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Material_ID", materialID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Pmt_Bin entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtBin(dr);
|
|
|
rePmt_Bin = entity;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
return (int)rePmt_Bin.Bin_Serial;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取所有xl_material
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取所有Pmt_material
|
|
|
/// </summary>
|
|
|
public static List<xl_material> GetAllMaterial()
|
|
|
{
|
|
|
List<xl_material> rePmt_materialList = new List<xl_material>();
|
|
|
|
|
|
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 strSql = "SELECT distinct m.* FROM xl_material m inner join Pmt_Bin b on m.ID=b.Material_ID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
xl_material entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtMaterial(dr);
|
|
|
rePmt_materialList.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return rePmt_materialList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据物料id获取Pmt_material
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据物料id获取Pmt_material
|
|
|
/// </summary>
|
|
|
/// <param name="recipeId">物料id</param>
|
|
|
/// <returns>返回符合条件Pmt_Bin</returns>
|
|
|
public static xl_material GetPmt_material(string materialID)
|
|
|
{
|
|
|
xl_material rePmt_material = null;
|
|
|
|
|
|
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 strSql = "SELECT * FROM xl_material where ID = @Material_ID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Material_ID", materialID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
xl_material entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtMaterial(dr);
|
|
|
rePmt_material = entity;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return rePmt_material;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据物料名称获取物料的ID
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据物料名称获取物料的ID
|
|
|
/// </summary>
|
|
|
/// <param name="materialCode">物料名称</param>
|
|
|
/// <returns>返回符合条件materialID</returns>
|
|
|
public static string GetPmt_materialID(string materialCode)
|
|
|
{
|
|
|
xl_material rePmt_material = null;
|
|
|
|
|
|
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 strSql = "SELECT * FROM xl_material where Material_code = @Material_code";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Material_code", materialCode);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
xl_material entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPmtMaterial(dr);
|
|
|
rePmt_material = entity;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
return rePmt_material.ID;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取某条计划的状态
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取某条计划的状态
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>返回计划状态</returns>
|
|
|
public static PlanState GetPlanState(string planID)
|
|
|
{
|
|
|
DataRow row = GetPlanData(planID);
|
|
|
if (row != null)
|
|
|
{
|
|
|
int planState = Mesnac.Basic.DataProcessor.RowValue(row, "PlanState", 0); //获取计划状态
|
|
|
int planNum = Mesnac.Basic.DataProcessor.RowValue(row, "PlanNum", 0); //获取计划数
|
|
|
int realNum = Mesnac.Basic.DataProcessor.RowValue(row, "RealNum", 0); //获取完成数
|
|
|
if (realNum >= planNum)
|
|
|
{
|
|
|
return PlanState.Completed;
|
|
|
}
|
|
|
return (PlanState)planState;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return PlanState.UnKnow;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取某条计划的开炼状态
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取某条计划的开炼状态
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>返回计划开炼状态</returns>
|
|
|
public static PlanState GetMillPlanState(string planID)
|
|
|
{
|
|
|
DataRow row = GetPlanData(planID);
|
|
|
if (row != null)
|
|
|
{
|
|
|
int planState = Mesnac.Basic.DataProcessor.RowValue(row, "MillPlanState", 0); //获取计划状态
|
|
|
int planNum = Mesnac.Basic.DataProcessor.RowValue(row, "PlanNum", 0); //获取计划数
|
|
|
int realNum = Mesnac.Basic.DataProcessor.RowValue(row, "MillRealNum", 0); //获取完成数
|
|
|
if (realNum >= planNum)
|
|
|
{
|
|
|
return PlanState.Completed;
|
|
|
}
|
|
|
return (PlanState)planState;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return PlanState.UnKnow;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据计划号获取配方GUID
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取配方GUID
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>成功返回配方GUID,失败返回String.Empty</returns>
|
|
|
public static string GetRecipeGUID(string planID)
|
|
|
{
|
|
|
DataRow row = GetPlanData(planID);
|
|
|
if (row != null)
|
|
|
{
|
|
|
string recipeGUID = Mesnac.Basic.DataProcessor.RowValue(row, "RecipeGUID", String.Empty);
|
|
|
return recipeGUID;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return String.Empty;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取本机台、日期、班次的计划数据
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取本机台、日期、班次的计划数据 2023-06-28
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回符合条件的计划数据</returns>
|
|
|
public static DataTable GetPlanData(DateTime planDate, int shiftID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT Plan_Serial,Recipe_Name,Equip_Code,Version,Plan_Id,Plan_Num,Real_Num,Plan_StateText,Start_Date,End_Date FROM xl_plan WHERE LEFT(Plan_Id,8) = @PlanDate AND Shift_id = @ShiftID ORDER BY Plan_State,Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
return table;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取本机台、日期的计划数据
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <returns>返回符合条件的计划数据</returns>
|
|
|
public static DataTable GetPlanData(DateTime planDate)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT Plan_Serial,Recipe_Name,Equip_Code,Version,Plan_Id,Plan_Num,Real_Num,Plan_StateText,Start_Date,End_Date FROM xl_plan WHERE LEFT(Plan_Id,8) = @PlanDate ORDER BY Plan_State,Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
return table;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取本机台、日期的计划数据
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <returns>返回符合条件的计划对象列表</returns>
|
|
|
public static List<Entity.xl_plan> GetPlanDataEntity(DateTime planDate)
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
DataTable dt = GetPlanData(planDate);
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取本机台、日期、班次的计划数据
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回符合条件的计划对象列表</returns>
|
|
|
public static List<Entity.xl_plan> GetPlanDataEntity(DateTime planDate, int shiftID)
|
|
|
{
|
|
|
List<Entity.xl_plan> lst = new List<Entity.xl_plan>();
|
|
|
DataTable dt = GetPlanData(planDate, shiftID);
|
|
|
Entity.xl_plan entity = null;
|
|
|
foreach(DataRow dr in dt.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPptPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GetFirstPlanID 获取对应计划日期,班次的第一条未生产的计划
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取对应计划日期,班次的第一条未生产的计划
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回符合条件的计划ID,失败返回null或String.Empty</returns>
|
|
|
public static string GetFirstPlanID(DateTime planDate, int shiftID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select top 1 PlanID from xl_plan where left(PlanID,6) = right(@PlanDate,6) and ShiftID = @ShiftID and PlanState = '3' and RealNum = 0 order by ActionOrder";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
return result as string;
|
|
|
}
|
|
|
return String.Empty;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GetFirstUnAllExecPlanID 获取对应计划日期,班次的第一条未完全生产的计划
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取对应计划日期,班次的第一条未完全生产(密炼未执行或开炼未执行)的计划
|
|
|
/// </summary>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次ID</param>
|
|
|
/// <returns>返回符合条件的计划ID,失败返回null或String.Empty</returns>
|
|
|
public static string GetFirstUnAllExecPlanID(DateTime planDate, int shiftID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select top 1 PlanID from xl_plan where left(PlanID,6) = right(@PlanDate,6) and ShiftID = @ShiftID and (PlanState = '3' or MillPlanState='3') and RealNum = 0 and MillRealNum = 0 order by ActionOrder";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
return result as string;
|
|
|
}
|
|
|
return String.Empty;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GetPrevPlanID 获取当前计划的前一个计划号,用户计划排序
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当前计划的前一个计划号,用户计划排序
|
|
|
/// </summary>
|
|
|
/// <param name="currPlanID">当前计划号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns>返回当前计划的前一个计划号</returns>
|
|
|
public static string GetPrevPlanID(string currPlanID, DateTime planDate, int shiftID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select top 1 PlanID from xl_plan where ActionOrder < (select ActionOrder from xl_plan where PlanID = @PlanID) and left(PlanID,6) = right(@PlanDate,6) and ShiftID = @ShiftID order by ActionOrder desc";
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
dbHelper.AddParameter("@PlanID", currPlanID);
|
|
|
dbHelper.CommandText = strSql;
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result == null || result == System.DBNull.Value)
|
|
|
{
|
|
|
return String.Empty;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return result as string;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region GetNextPlanID 获取当前计划的下一个计划号,用于计划排序
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当前计划的下一个计划号,用于计划排序
|
|
|
/// </summary>
|
|
|
/// <param name="currPlanID">当前计划号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次</param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetNextPlanID(string currPlanID, DateTime planDate, int shiftID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string sqlStr = "select top 1 PlanID from xl_plan where ActionOrder > (select ActionOrder from xl_plan where PlanID = @PlanID) and left(PlanID,6) = right(@PlanDate,6) and ShiftID = @ShiftID order by ActionOrder asc";
|
|
|
dbHelper.AddParameter("@PlanID", currPlanID);
|
|
|
dbHelper.AddParameter("@PlanDate", String.Format("{0:yyyyMMdd}", planDate));
|
|
|
dbHelper.AddParameter("@ShiftID", shiftID);
|
|
|
dbHelper.CommandText = sqlStr;
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result == null || result == System.DBNull.Value)
|
|
|
{
|
|
|
return String.Empty;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return result as string;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据计划号获取对应的配方总重TotalWeight
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取对应的配方总重TotalWeight
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <returns>获取成功返回对应的值,失败返回0</returns>
|
|
|
public static double GetTotalWeightByPlanID(string planID)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
string strSql = @"select LotTotalWeight from PmtRecipe where GUID = (select RecipeGUID from xl_plan where PlanID = @PlanID)";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
return Convert.ToDouble(result.ToString());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 添加生产计划(xl_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加生产计划
|
|
|
/// </summary>
|
|
|
/// <param name="equipCode">5位机台号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次ID</param>
|
|
|
/// <param name="classID">班组ID</param>
|
|
|
/// <param name="recipeGUID">配方GUID</param>
|
|
|
/// <param name="planNum">计划数</param>
|
|
|
/// <returns>返回新加计划的计划号</returns>
|
|
|
public static string AddPlan(string equipCode, DateTime planDate, int shiftID, string recipeGUID, int planNum)
|
|
|
{
|
|
|
return AddPlan(equipCode, planDate, shiftID, recipeGUID, 0, planNum, String.Empty);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加生产计划
|
|
|
/// </summary>
|
|
|
/// <param name="equipCode">5位机台号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次ID</param>
|
|
|
/// <param name="classID">班组ID</param>
|
|
|
/// <param name="recipeGUID">配方GUID</param>
|
|
|
/// <param name="planNum">计划数</param>
|
|
|
/// <param name="remark">备注</param>
|
|
|
/// <returns>返回新加计划的计划号</returns>
|
|
|
public static string AddPlan(string equipCode, DateTime planDate, int shiftID, string recipeGUID, int planNum, string remark)
|
|
|
{
|
|
|
return AddPlan(equipCode, planDate, shiftID, recipeGUID, 0, planNum, remark);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加生产计划
|
|
|
/// </summary>
|
|
|
/// <param name="equipCode">5位机台号</param>
|
|
|
/// <param name="planDate">计划生产日期</param>
|
|
|
/// <param name="shiftID">班次ID</param>
|
|
|
/// <param name="classID">班组ID</param>
|
|
|
/// <param name="recipeGUID">配方GUID</param>
|
|
|
/// <param name="recipeVersion">配方版本号</param>
|
|
|
/// <param name="planNum">计划数</param>
|
|
|
/// <param name="remark">备注</param>
|
|
|
/// <returns>返回新加计划的计划号</returns>
|
|
|
public static string AddPlan(string equipCode, DateTime planDate, int shiftID, string recipeGUID, int recipeVersion, int planNum, string remark)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
//查询配方数据
|
|
|
Entity.xl_recipe recipe = null;
|
|
|
if (recipeVersion ==0)
|
|
|
{
|
|
|
recipe = Technical.XlRecipe.RecipeHelper.GetRecipeEntityByGUID(recipeGUID);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
recipe = Technical.XlRecipe.RecipeHelper.GetRecipeEntityByGUID(recipeGUID, recipeVersion.ToString());
|
|
|
}
|
|
|
if (recipe != null)
|
|
|
{
|
|
|
string strRecipeVersion = recipe.Version; //配方版本号
|
|
|
string recipeCode = recipe.Recipe_Code;
|
|
|
string recipeName = recipe.Recipe_Name; //配方名称
|
|
|
string recipeType = recipe.Recipe_type.ToString(); //配方类型
|
|
|
decimal? totalWeight = recipe.Total_Weight; //每车重量
|
|
|
|
|
|
#region 从两张表中获取最大的serialNum
|
|
|
|
|
|
int serialNum = 0;
|
|
|
int rtPlanSNum = GetNextSerialNum(); //xl_plan序号
|
|
|
int lrPlanSNum = GetNextSerialNumFromLRPlan(planDate); //LR_Plan序号
|
|
|
if(rtPlanSNum >= lrPlanSNum)
|
|
|
{
|
|
|
serialNum = rtPlanSNum;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
serialNum = lrPlanSNum;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 组合获取planID
|
|
|
string planID = GenerateNextPlanIDNew(planDate, shiftID, serialNum); //计划号
|
|
|
#endregion
|
|
|
|
|
|
//int serialNum = GetNextSerialNum(planDate);
|
|
|
//string planID = GenerateNextPlanID(equipCode, planDate, shiftID); //计划号
|
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
//添加计划的SQL语句
|
|
|
string strSql3 = @"INSERT INTO xl_plan(Dosing_Id,Plan_Id,Equip_Code,Plan_Serial,Recipe_ID,Recipe_Code,Recipe_Name,Version,Mixer_Line,Recipe_Type,Shift_Id,Shift_Class,Plan_Num,Real_Num,Duration_Time,Start_Date,End_Date,Weight_Man,Stock_Man,Plan_Batch,Plan_State,Plan_StateText,Plan_Date,IF_FLAG)
|
|
|
VALUES(@Dosing_Id,@Plan_Id,@Equip_Code,@Plan_Serial,@Recipe_ID,@Recipe_Code,@Recipe_Name,@Version,@Mixer_Line,@Recipe_Type,@Shift_Id,@Shift_Class,@Plan_Num,@Real_Num,@Duration_Time,@Start_Date,@End_Date,@Weight_Man,@Stock_Man,@Plan_Batch,@Plan_State,@Plan_StateText,@Plan_Date,@IF_FLAG)";
|
|
|
dbHelper.CommandText = strSql3;
|
|
|
|
|
|
dbHelper.AddParameter("@Dosing_Id", 0);
|
|
|
dbHelper.AddParameter("@Plan_Id", planID); //计划号
|
|
|
dbHelper.AddParameter("@Equip_Code", equipCode); //机台号
|
|
|
dbHelper.AddParameter("@Plan_Serial", serialNum); //排序字段(优先级,在此与ActionOrder相同)
|
|
|
dbHelper.AddParameter("@Recipe_ID", recipeGUID); //配方GUID
|
|
|
dbHelper.AddParameter("@Recipe_Code", recipeCode); //配方编码
|
|
|
dbHelper.AddParameter("@Recipe_Name", recipeName); //配方别名
|
|
|
dbHelper.AddParameter("@Version", strRecipeVersion); //配方版本号
|
|
|
dbHelper.AddParameter("@Mixer_Line", recipe.Mixer_line); //配方版本号
|
|
|
dbHelper.AddParameter("@Recipe_Type", recipeType); //配方类型
|
|
|
dbHelper.AddParameter("@Shift_Id", shiftID); //班次ID
|
|
|
dbHelper.AddParameter("@Shift_Class", 0); //班组ID
|
|
|
dbHelper.AddParameter("@Plan_Num", planNum); //计划数
|
|
|
dbHelper.AddParameter("@Real_Num", 0); //完成数量
|
|
|
dbHelper.AddParameter("@Duration_Time", 0); //持续时间
|
|
|
dbHelper.AddParameter("@Start_Date", String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now)); //开始时间
|
|
|
dbHelper.AddParameter("@End_Date", null); //结束时间
|
|
|
dbHelper.AddParameter("@Weight_Man", null); //称量工
|
|
|
dbHelper.AddParameter("@Stock_Man", null); //投料工
|
|
|
dbHelper.AddParameter("@Plan_Batch", null); //批次号,不同的现场有不同的命令规则。
|
|
|
dbHelper.AddParameter("@Plan_State", (int)PlanState.UnStart); //计划状态
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow((int)PlanState.UnStart)); //计划日期
|
|
|
dbHelper.AddParameter("@Plan_Date", String.Format("{0:yyyy-MM-dd}", DateTime.Now)); //计划日期
|
|
|
dbHelper.AddParameter("@IF_FLAG", 1); //MES计划变更标志位
|
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
return planID;
|
|
|
}
|
|
|
return String.Empty;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 添加生产计划(LR_plan)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加生产计划
|
|
|
/// </summary>
|
|
|
/// <param name="lrPlan">LR_plan实体类</param>
|
|
|
/// <returns>返回新加计划的计划号</returns>
|
|
|
public static string LRAddPlan(LR_plan lrPlan)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
|
//添加计划的SQL语句
|
|
|
string strSql3 = @"INSERT INTO LR_plan(Dosing_Id,Plan_Id,Equip_Code,Plan_Serial,Recipe_Code,Recipe_Name,Version,Recipe_Type,Shift_Id,Shift_Class,Plan_Num,Real_Num,Duration_Time,Start_Date,End_Date,Weight_Man,Stock_Man,Plan_Batch,Plan_State,Plan_Date,IF_FLAG)
|
|
|
VALUES(@Dosing_Id,@Plan_Id,@Equip_Code,@Plan_Serial,@Recipe_Code,@Recipe_Name,@Version,@Recipe_Type,@Shift_Id,@Shift_Class,@Plan_Num,@Real_Num,@Duration_Time,@Start_Date,@End_Date,@Weight_Man,@Stock_Man,@Plan_Batch,@Plan_State,@Plan_Date,@IF_FLAG)";
|
|
|
dbHelper.CommandText = strSql3;
|
|
|
|
|
|
dbHelper.AddParameter("@Dosing_Id", 0);
|
|
|
dbHelper.AddParameter("@Plan_Id", lrPlan.Plan_Id); //计划号
|
|
|
dbHelper.AddParameter("@Equip_Code", lrPlan.Equip_Code); //机台号
|
|
|
dbHelper.AddParameter("@Plan_Serial", lrPlan.Plan_Serial); //排序字段(优先级,在此与ActionOrder相同)
|
|
|
dbHelper.AddParameter("@Recipe_Code", lrPlan.Recipe_Code); //配方编码
|
|
|
dbHelper.AddParameter("@Recipe_Name", lrPlan.Recipe_Name); //配方别名
|
|
|
dbHelper.AddParameter("@Version", lrPlan.Version); //配方版本号
|
|
|
//dbHelper.AddParameter("@Mixer_Line", lrPlan.Mixer_Line); //配方版本号
|
|
|
dbHelper.AddParameter("@Recipe_Type", lrPlan.Recipe_Type); //配方类型
|
|
|
dbHelper.AddParameter("@Shift_Id", lrPlan.Shift_Id); //班次ID
|
|
|
dbHelper.AddParameter("@Shift_Class", 0); //班组ID
|
|
|
dbHelper.AddParameter("@Plan_Num", lrPlan.Plan_Num); //计划数
|
|
|
dbHelper.AddParameter("@Real_Num", lrPlan.Real_Num); //完成数量
|
|
|
dbHelper.AddParameter("@Duration_Time", lrPlan.Duration_Time); //持续时间
|
|
|
dbHelper.AddParameter("@Start_Date", lrPlan.Start_Date); //开始时间
|
|
|
dbHelper.AddParameter("@End_Date", lrPlan.End_Date); //结束时间
|
|
|
dbHelper.AddParameter("@Weight_Man", lrPlan.Weight_Man); //称量工
|
|
|
dbHelper.AddParameter("@Stock_Man", lrPlan.Stock_Man); //投料工
|
|
|
dbHelper.AddParameter("@Plan_Batch", lrPlan.Plan_Batch); //批次号,不同的现场有不同的命令规则。
|
|
|
dbHelper.AddParameter("@Plan_State", lrPlan.Plan_State); //计划状态
|
|
|
dbHelper.AddParameter("@Plan_Date", lrPlan.Plan_Date); //计划日期
|
|
|
dbHelper.AddParameter("@IF_FLAG", lrPlan.IF_FLAG); //暂时无用
|
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
return lrPlan.Plan_Id;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 添加(LR_recipe)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加(LR_recipe)
|
|
|
/// </summary>
|
|
|
/// <param name="lrPlan">LR_recipe实体类</param>
|
|
|
/// <returns>返回新加计划的计划号</returns>
|
|
|
public static string AddLR_recipe(LR_recipe lrRecipe)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
|
//添加计划的SQL语句
|
|
|
string strSql3 = @"INSERT INTO LR_recipe(Plan_id,Equip_code,Weight_ID,Material_Code,Material_Name,Set_Weight,Set_Error,CPK_Error,Batch_number,remark)
|
|
|
VALUES(@Plan_id,@Equip_code,@Weight_ID,@Material_Code,@Material_Name,@Set_Weight,@Set_Error,@CPK_Error,@Batch_number,@remark)";
|
|
|
dbHelper.CommandText = strSql3;
|
|
|
|
|
|
dbHelper.AddParameter("@Plan_id", lrRecipe.Plan_id);
|
|
|
dbHelper.AddParameter("@Equip_code", lrRecipe.Equip_Code);
|
|
|
dbHelper.AddParameter("@Weight_ID", lrRecipe.Weight_ID);
|
|
|
dbHelper.AddParameter("@Material_Code", lrRecipe.Material_Code);
|
|
|
dbHelper.AddParameter("@Material_Name", lrRecipe.Material_Name);
|
|
|
dbHelper.AddParameter("@Set_Weight", lrRecipe.Set_Weight);
|
|
|
dbHelper.AddParameter("@Set_Error", lrRecipe.Set_Error);
|
|
|
dbHelper.AddParameter("@CPK_Error", lrRecipe.CPK_Error);
|
|
|
dbHelper.AddParameter("@Batch_number", lrRecipe.Batch_number);
|
|
|
dbHelper.AddParameter("@remark", lrRecipe.remark);
|
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
return lrRecipe.Plan_id;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划的序号
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划的序号
|
|
|
/// </summary>
|
|
|
/// <param name="rtPlanList">要更新的计划列表</param>
|
|
|
public static void UpdatePlanSerial(xl_plan rtPlan)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "UPDATE xl_plan SET Plan_Serial = @Plan_Serial WHERE Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@Plan_Serial", rtPlan.Plan_Serial);
|
|
|
dbHelper.AddParameter("@PlanID", rtPlan.Plan_Id);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划设定数异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划设定数
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划设定数
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <param name="planNum">设定数</param>
|
|
|
public static void UpdatePlanNum(string planID, int planNum)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "UPDATE xl_plan SET Plan_Num = @PlanNum, IF_FLAG = @IfFlag WHERE Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanNum", planNum);
|
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划设定数异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划完成数
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划完成数UpdateRealNum
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划编号</param>
|
|
|
/// <param name="realNum">完成数</param>
|
|
|
public static void UpdateRealNum(string planID, int realNum)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "UPDATE xl_plan SET RealNum = @RealNum, IsUpFlag = 0 WHERE PlanID = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@RealNum", realNum);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划完成数异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划状态(xl_plan)——小料
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划状态(xl_plan)
|
|
|
/// </summary>
|
|
|
/// <param name="planID">要更新的计划号</param>
|
|
|
/// <param name="planState">新的计划状态</param>
|
|
|
public static void UpdatePlanState(string planID, int planState)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Plan_State = @PlanState, Plan_StateText = @Plan_StateText, IF_FLAG = @IfFlag where Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanState", planState);
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow(planState));
|
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划状态异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新计划状态(xl_plan)——手动下发执行
|
|
|
/// </summary>
|
|
|
/// <param name="planID">要更新的计划号</param>
|
|
|
/// <param name="planState">新的计划状态</param>
|
|
|
public static void UpdateStartPlanState(string planID, int planState,int shifId,string shiftClass)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Plan_State = @PlanState, Plan_StateText = @Plan_StateText,Shift_Id=@Shift_Id,Shift_Class=@Shift_Class,Start_Date=@Start_Date,IF_FLAG = @IfFlag where Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanState", planState);
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow(planState));
|
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.AddParameter("@Shift_Id", shifId);
|
|
|
dbHelper.AddParameter("@Shift_Class", shiftClass);
|
|
|
dbHelper.AddParameter("@Start_Date", DateTime.Now.ToString());
|
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划状态异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划状态(xl_plan)
|
|
|
/// </summary>
|
|
|
/// <param name="planSerial">查询条件:要更新的计划的序号</param>
|
|
|
/// <param name="planDate">查询条件:要更新的计划的日期</param>
|
|
|
/// <param name="planState">新的计划状态</param>
|
|
|
/// <param name="planNum">新的计划数</param>
|
|
|
/// <param name="planComNum">更新完成数量</param>
|
|
|
public static void UpdatePlanInfo(int planSerial, int planState, int planNum, int planComNum)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Plan_State = @PlanState, Plan_StateText = @Plan_StateText, Plan_Num = @planNum, Real_Num = @planComNum, IF_FLAG = @IfFlag where Plan_Serial = @planSerial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanState", planState);
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow(planState));
|
|
|
dbHelper.AddParameter("@planNum", planNum);
|
|
|
dbHelper.AddParameter("@planComNum", planComNum);
|
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
|
dbHelper.AddParameter("@planSerial", planSerial);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划状态异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划状态(xl_plan)
|
|
|
/// </summary>
|
|
|
/// <param name="planSerial">查询条件:要更新的计划的序号</param>
|
|
|
/// <param name="planDate">查询条件:要更新的计划的日期</param>
|
|
|
/// <param name="planState">新的计划状态</param>
|
|
|
/// <param name="planNum">新的计划数</param>
|
|
|
/// <param name="planComNum">更新完成数量</param>
|
|
|
public static void UpdatePlanInfo(int planSerial, int planState, int planNum, int planComNum, string endDateTime)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Plan_State = @PlanState, Plan_StateText = @Plan_StateText, Plan_Num = @planNum, Real_Num = @planComNum,End_Date = @endDateTime, IF_FLAG = @IfFlag where Plan_Serial = @planSerial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanState", planState);
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow(planState));
|
|
|
dbHelper.AddParameter("@planNum", planNum);
|
|
|
dbHelper.AddParameter("@planComNum", planComNum);
|
|
|
dbHelper.AddParameter("@endDateTime", endDateTime);
|
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
|
dbHelper.AddParameter("@planSerial", planSerial);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划状态异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划状态和计划终止时间
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划状态和计划执行时间
|
|
|
/// </summary>
|
|
|
/// <param name="dbType">数据库类型,网络库、本地库</param>
|
|
|
/// <param name="planID">计划号</param>
|
|
|
/// <param name="planState">计划状态</param>
|
|
|
/// <param name="realStartTime">实际计划开始时间</param>
|
|
|
public static void UpdatedPlanStateAndRealEndTime(string planID, int planState, DateTime realEndTime)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set PlanState = @PlanState, IsUpFlag=0 where PlanID = @PlanID"; //如果单机运行,则把计划上传标志IsUpFlag设置为0
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanState", planState);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划状态和计划终止时间异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划表中的单车总重
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新计划表中的单车总重
|
|
|
/// </summary>
|
|
|
/// <param name="planID">计划ID</param>
|
|
|
/// <param name="totalWeight">设定总重</param>
|
|
|
public static void UpdateTotalWeight(string planID, double totalWeight)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
string strSql = @"update xl_plan set TotalWeight = @TotalWeight, IsUpFlag = 0 where PlanID = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@TotalWeight", totalWeight);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划表中的单车总重异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 按计划号删除计划
|
|
|
|
|
|
/// <summary>
|
|
|
/// 按计划号删除计划
|
|
|
/// </summary>
|
|
|
/// <param name="planId">要删除计划对应的计划号</param>
|
|
|
/// <returns>成功返回true,失败返回false</returns>
|
|
|
public static void DeletePlan(string planId)
|
|
|
{
|
|
|
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;
|
|
|
dbHelper.ClearParameter();
|
|
|
string strSql = "DELETE FROM xl_plan WHERE Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanID", planId);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 下传计划列表至PLC(带班次)
|
|
|
|
|
|
/// <summary>
|
|
|
/// 下传计划列表至PLC(未生成的前10条计划)
|
|
|
/// </summary>
|
|
|
/// <param name="planDatestr">传入的计划日期</param>
|
|
|
/// <param name="shiftID">传入的班次ID</param>
|
|
|
/// <param name="msg">输出错误信息</param>
|
|
|
/// <returns>成功返回true,失败返回false</returns>
|
|
|
public static bool DownloadPlanInfo(string planDatestr, int shiftID, out string msg)
|
|
|
{
|
|
|
#region 检查日期班次是否设置正确,不正确则给出提示
|
|
|
|
|
|
//DateTime plandate = DateTime.Now;
|
|
|
//int shiftitem = 0;
|
|
|
//if (!ProductHelper.PlanDateVerify(out plandate, out shiftitem, planDatestr, shiftID, out msg))
|
|
|
//{
|
|
|
// ICSharpCode.Core.LoggingService<RefreshAction>.Debug(String.Format("刷新计划-下传计划列表PLC,操作取消,因为界面选择的日期、班次不是当班班次:选择计划日期:{0},选择班次:{1},当班日期:{2:yyyy-MM-dd},当班班次:{3}", planDatestr, shiftID, plandate, shiftitem));
|
|
|
// return false;
|
|
|
//}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
List<string> msgList = new List<string>();
|
|
|
bool result = ChemicalWeighingPlc.PlcPlanHelper.DownloadPlanData(msgList);
|
|
|
if (!result)
|
|
|
{
|
|
|
msg = Mesnac.Basic.DataProcessor.CombineMsgList(msgList);
|
|
|
ICSharpCode.Core.LoggingService<RefreshAction>.Error("计划列表下传失败:" + msg);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg = "计划列表下传成功";
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 计划辅助方法
|
|
|
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为计划实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr">要转换的数据行</param>
|
|
|
/// <returns>返回转换后的计划实体对象</returns>
|
|
|
public static Entity.xl_plan ConvertDataRowToPptPlan(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
Entity.xl_plan plan = new Entity.xl_plan();
|
|
|
plan.Dosing_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Dosing_Id", 0);
|
|
|
plan.Plan_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Id", String.Empty);
|
|
|
plan.Equip_Code = Mesnac.Basic.DataProcessor.RowValue(dr, "Equip_Code", String.Empty);
|
|
|
plan.Plan_Serial = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Serial", 0);
|
|
|
plan.Recipe_ID = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_ID", String.Empty);
|
|
|
plan.Recipe_Code = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_Code", String.Empty);
|
|
|
plan.Recipe_Name = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_Name", String.Empty);
|
|
|
plan.Version = Mesnac.Basic.DataProcessor.RowValue(dr, "Version", String.Empty);
|
|
|
plan.Mixer_Line = Mesnac.Basic.DataProcessor.RowValue(dr, "Mixer_Line", String.Empty);
|
|
|
plan.Recipe_Type = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_Type", 0);
|
|
|
plan.Shift_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_Id", String.Empty);
|
|
|
plan.Shift_Class = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_Class", String.Empty);
|
|
|
plan.Plan_Num = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Num", 0);
|
|
|
plan.Real_Num = Mesnac.Basic.DataProcessor.RowValue(dr, "Real_Num", 0);
|
|
|
plan.Duration_Time = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Id", 0);
|
|
|
plan.Start_Date = Mesnac.Basic.DataProcessor.RowValue(dr, "Start_Date", String.Empty);
|
|
|
plan.End_Date = Mesnac.Basic.DataProcessor.RowValue(dr, "End_Date", String.Empty);
|
|
|
plan.Weight_Man = Mesnac.Basic.DataProcessor.RowValue(dr, "Weight_Man", String.Empty);
|
|
|
plan.Stock_Man = Mesnac.Basic.DataProcessor.RowValue(dr, "Stock_Man", String.Empty);
|
|
|
plan.Plan_Batch = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Batch", String.Empty);
|
|
|
plan.Plan_State = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_State", 0);
|
|
|
plan.Plan_StateText = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_StateText", String.Empty);
|
|
|
plan.Plan_Date = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Date", String.Empty);
|
|
|
plan.IF_FLAG = Mesnac.Basic.DataProcessor.RowValue(dr, "IF_FLAG", 0);
|
|
|
|
|
|
return plan;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为xl_weigh实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr">要转换的数据行</param>
|
|
|
/// <returns>返回转换后的计划实体对象</returns>
|
|
|
public static xl_weigh ConvertDataRowToPmtweigh(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
xl_weigh plan = new xl_weigh();
|
|
|
plan.ID = Mesnac.Basic.DataProcessor.RowValue(dr, "ID", 0);
|
|
|
plan.Equip_Code = Mesnac.Basic.DataProcessor.RowValue(dr, "Equip_Code", String.Empty);
|
|
|
plan.Recipe_ID = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_ID", String.Empty);
|
|
|
plan.Weight_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Weight_Id", 0);
|
|
|
plan.Material_ID = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_ID", String.Empty);
|
|
|
plan.Station = Mesnac.Basic.DataProcessor.RowValue(dr, "Station", 0);
|
|
|
plan.Set_Weight =Convert.ToDecimal(Mesnac.Basic.DataProcessor.RowValue(dr, "Set_Weight", String.Empty));
|
|
|
plan.Set_Error = Convert.ToDecimal(Mesnac.Basic.DataProcessor.RowValue(dr, "Set_Error", String.Empty));
|
|
|
plan.Cpk_Error = Convert.ToDecimal(Mesnac.Basic.DataProcessor.RowValue(dr, "Cpk_Error", String.Empty));
|
|
|
|
|
|
return plan;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为Pmt_Bin实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr">要转换的数据行</param>
|
|
|
/// <returns>返回转换后的计划实体对象</returns>
|
|
|
public static Pmt_Bin ConvertDataRowToPmtBin(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
Pmt_Bin pmtBin = new Pmt_Bin();
|
|
|
pmtBin.Equip_Code = Mesnac.Basic.DataProcessor.RowValue(dr, "Equip_Code", String.Empty);
|
|
|
pmtBin.Bin_Serial = Mesnac.Basic.DataProcessor.RowValue(dr, "Bin_Serial", 0);
|
|
|
pmtBin.Dosing_ID = Mesnac.Basic.DataProcessor.RowValue(dr, "Dosing_ID", 0);
|
|
|
pmtBin.Material_ID = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_ID", String.Empty);
|
|
|
pmtBin.Bin_Capacity = Mesnac.Basic.DataProcessor.RowValue(dr, "Bin_Capacity", 0);
|
|
|
pmtBin.Bin_Baseline = Mesnac.Basic.DataProcessor.RowValue(dr, "Bin_Baseline", 0);
|
|
|
pmtBin.Bin_Residua = Mesnac.Basic.DataProcessor.RowValue(dr, "Bin_Residua", 0);
|
|
|
pmtBin.Bin_UseFlag = Mesnac.Basic.DataProcessor.RowValue(dr, "Bin_UseFlag", 0);
|
|
|
pmtBin.IF_FLAG = Mesnac.Basic.DataProcessor.RowValue(dr, "IF_FLAG", 0);
|
|
|
|
|
|
return pmtBin;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为Pmt_material实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr">要转换的数据行</param>
|
|
|
/// <returns>返回转换后的计划实体对象</returns>
|
|
|
public static xl_material ConvertDataRowToPmtMaterial(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
xl_material pmtMaterial = new xl_material();
|
|
|
pmtMaterial.ID = Mesnac.Basic.DataProcessor.RowValue(dr, "ID", String.Empty);
|
|
|
pmtMaterial.Material_code = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_code", String.Empty);
|
|
|
pmtMaterial.Material_name = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_name", String.Empty);
|
|
|
pmtMaterial.Remark = Mesnac.Basic.DataProcessor.RowValue(dr, "Remark", String.Empty);
|
|
|
pmtMaterial.Batch_number = Mesnac.Basic.DataProcessor.RowValue(dr, "Batch_number", String.Empty);
|
|
|
pmtMaterial.Barcode1 = Mesnac.Basic.DataProcessor.RowValue(dr, "Barcode1", String.Empty);
|
|
|
pmtMaterial.Barcode2 = Mesnac.Basic.DataProcessor.RowValue(dr, "Barcode2", String.Empty);
|
|
|
pmtMaterial.Barcode3 = Mesnac.Basic.DataProcessor.RowValue(dr, "Barcode3", String.Empty);
|
|
|
|
|
|
return pmtMaterial;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 将计划运行状态转换为文字进行显示
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将计划运行状态转换为文字进行显示
|
|
|
/// </summary>
|
|
|
/// <param name="stateNum">计划状态代码</param>
|
|
|
/// <returns>显示的文字信息</returns>
|
|
|
public static string StateToShow(int stateNum)
|
|
|
{
|
|
|
string reStr = null;
|
|
|
|
|
|
if (stateNum == 3)
|
|
|
{
|
|
|
reStr = "正在运行";
|
|
|
}
|
|
|
else if (stateNum == 4)
|
|
|
{
|
|
|
reStr = "已下传";
|
|
|
}
|
|
|
else if (stateNum == 5)
|
|
|
{
|
|
|
reStr = "未启动";
|
|
|
}
|
|
|
else if (stateNum == 7)
|
|
|
{
|
|
|
reStr = "已终止";
|
|
|
}
|
|
|
else if (stateNum == 8)
|
|
|
{
|
|
|
reStr = "已完成";
|
|
|
}
|
|
|
|
|
|
return reStr;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 将计划运行状态文字转换为代码
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将计划运行状态文字转换为代码
|
|
|
/// </summary>
|
|
|
/// <param name="stateInfo">计划状态代码</param>
|
|
|
/// <returns>显示的文字信息</returns>
|
|
|
public static Int32 StateToValue(string stateInfo)
|
|
|
{
|
|
|
Int32 reStateNum = 0;
|
|
|
|
|
|
if (stateInfo == "正在运行")
|
|
|
{
|
|
|
reStateNum = 3;
|
|
|
}
|
|
|
else if (stateInfo == "已下传")
|
|
|
{
|
|
|
reStateNum = 4;
|
|
|
}
|
|
|
else if (stateInfo == "未启动")
|
|
|
{
|
|
|
reStateNum = 5;
|
|
|
}
|
|
|
else if (stateInfo == "已终止")
|
|
|
{
|
|
|
reStateNum = 7;
|
|
|
}
|
|
|
else if (stateInfo == "已完成")
|
|
|
{
|
|
|
reStateNum = 8;
|
|
|
}
|
|
|
|
|
|
return reStateNum;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据物料id获取Pmt_material
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据物料id获取Pmt_material
|
|
|
/// </summary>
|
|
|
/// <param name="recipeId">物料id</param>
|
|
|
/// <returns>返回符合条件Pmt_Bin</returns>
|
|
|
public static DataTable GetXl_material(string materialID)
|
|
|
{
|
|
|
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 strSql = "SELECT m.Material_name,w.Set_Weight,w.Set_Error,b.Bin_Name FROM xl_weigh w inner join xl_material m on m.ID=w.Material_ID inner join Pmt_Bin b on w.Material_ID=b.Material_ID where w.Recipe_ID= @Material_ID order by Weight_Id";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Material_ID", materialID);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
return table;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 小料 2023-06-29
|
|
|
|
|
|
#region 重传计划状态
|
|
|
/// <summary>
|
|
|
/// 重传计划状态(xl_plan)
|
|
|
/// </summary>
|
|
|
/// <param name="planID">要更新的计划号</param>
|
|
|
/// <param name="planState">新的计划状态</param>
|
|
|
public static void UpdatePlanState(string planID, int planState, int isRetransmission, int retransmissionNum)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Plan_State = @PlanState, Plan_StateText = @Plan_StateText,Real_Num=0,Start_Date=@Start_Date,IsRetransmission=1,IF_FLAG = @IfFlag where Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@Start_Date", DateTime.Now.ToString());
|
|
|
dbHelper.AddParameter("@IsRetransmission", isRetransmission);
|
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<PlanHelper>.Error("更新计划状态异常:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 根据计划号获取下发计划任务
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取下发计划任务
|
|
|
/// </summary>
|
|
|
/// <param name="planId"></param>
|
|
|
/// <param name="recipeId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static List<Xl_DowLoadPlan> GetXlPlan(string planId)
|
|
|
{
|
|
|
List<Xl_DowLoadPlan> lst = new List<Xl_DowLoadPlan>();
|
|
|
|
|
|
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 strSql = @"select p.Dosing_Id,p.Plan_Id,p.Plan_Serial,p.Recipe_ID,p.Recipe_Name,p.Version,p.Plan_Num,p.Real_Num,p.Shift_Id,p.Shift_Class,p.Plan_State,p.Plan_StateText,p.Plan_TotalWeight,p.Plan_TotalError,
|
|
|
r.Total_Weight,r.Total_Error,m.ID as MaterialID,m.Material_name,b.Bin_Serial as Station,b.Bin_Name as StationName,w.Set_Weight,w.Set_Error,p.IsRetransmission,p.Retransmission_Num
|
|
|
from xl_plan p left join xl_recipe r on p.Recipe_ID=r.ID left join xl_weigh w on r.ID=w.Recipe_ID
|
|
|
left join xl_material m on w.Material_ID=m.ID
|
|
|
left join Pmt_Bin b on m.ID=b.Material_ID
|
|
|
where p.Plan_State=5 and p.Plan_Id=@Plan_Id ORDER BY Plan_Serial";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Plan_Id", planId);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Xl_DowLoadPlan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取下发计划任务
|
|
|
/// </summary>
|
|
|
/// <param name="planId"></param>
|
|
|
/// <param name="recipeId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static List<Xl_DowLoadPlan> GetXlPlan2(string planId)
|
|
|
{
|
|
|
List<Xl_DowLoadPlan> lst = new List<Xl_DowLoadPlan>();
|
|
|
|
|
|
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 strSql = @"
|
|
|
select pp.Dosing_Id,pp.Plan_Id,pp.Plan_Serial,pp.Recipe_ID,pp.Recipe_Name,pp.Version,pp.Plan_Num,pp.Real_Num,pp.Shift_Id,pp.Shift_Class,pp.Plan_State,pp.Plan_StateText,pp.Plan_TotalWeight,pp.Plan_TotalError,
|
|
|
pp.Total_Weight,pp.Total_Error,pp.MaterialID,pp.Material_name,b.Bin_Serial as Station,b.Bin_Name as StationName,pp.Set_Weight,pp.Set_Error,pp.IsRetransmission,pp.Retransmission_Num
|
|
|
from Pmt_Bin b left join ( select p.Dosing_Id,p.Plan_Id,p.Plan_Serial,p.Recipe_ID,p.Recipe_Name,p.Version,p.Plan_Num,p.Real_Num,p.Shift_Id,p.Shift_Class,p.Plan_State,p.Plan_StateText,p.Plan_TotalWeight,p.Plan_TotalError,
|
|
|
r.Total_Weight,r.Total_Error,m.ID as MaterialID,m.Material_name,b.Bin_Serial as Station,w.Set_Weight,w.Set_Error,p.IsRetransmission,p.Retransmission_Num
|
|
|
from xl_plan p left join xl_recipe r on p.Recipe_ID=r.ID left join xl_weigh w on r.ID=w.Recipe_ID
|
|
|
left join xl_material m on w.Material_ID=m.ID
|
|
|
left join Pmt_Bin b on m.ID=b.Material_ID
|
|
|
where p.Plan_State=5 and p.Plan_Id=@Plan_Id) pp on b.Bin_Serial=pp.Station ORDER BY Station";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Plan_Id", planId);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Xl_DowLoadPlan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 获取下一个计划任务
|
|
|
/// <summary>
|
|
|
/// 获取下一个计划任务
|
|
|
/// </summary>
|
|
|
/// <returns>下一个计划任务物料集合</returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static List<Xl_DowLoadPlan> GetNextXlPlan()
|
|
|
{
|
|
|
List<Xl_DowLoadPlan> lst = new List<Xl_DowLoadPlan>();
|
|
|
|
|
|
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 strSql = @"select p.Dosing_Id,p.Plan_Id,p.Plan_Serial,p.Recipe_ID,p.Recipe_Name,p.Version,p.Plan_Num,p.Real_Num,p.Shift_Id,p.Shift_Class,p.Plan_State,p.Plan_StateText,p.Plan_TotalWeight,p.Plan_TotalError,
|
|
|
r.Total_Weight,r.Total_Error,m.ID as MaterialID,m.Material_name,b.Bin_Serial as Station,b.Bin_Name as StationName,w.Set_Weight,w.Set_Error,p.IsRetransmission,p.Retransmission_Num
|
|
|
from (select top 1 * from xl_plan where Plan_State=5 and Plan_Num<>Real_Num ORDER BY Plan_Serial) p
|
|
|
left join xl_recipe r on p.Recipe_ID=r.ID
|
|
|
left join xl_weigh w on r.ID=w.Recipe_ID
|
|
|
left join xl_material m on w.Material_ID=m.ID
|
|
|
left join Pmt_Bin b on m.ID=b.Material_ID";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Xl_DowLoadPlan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据计划号 查看计划是否完成
|
|
|
/// <summary>
|
|
|
/// 根据计划号 查看计划是否完成
|
|
|
/// </summary>
|
|
|
/// <param name="planId">计划号</param>
|
|
|
/// <param name="realNum">处理次数</param>
|
|
|
/// <returns>true:已完成;false:还未完成</returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static bool GetXlPlanState(string planNo, int realNum)
|
|
|
{
|
|
|
List<xl_plan> lst = new List<xl_plan>();
|
|
|
|
|
|
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 strSql = @"select top 1 * from xl_plan where Plan_Id=@Plan_Id and Plan_State=3 ORDER BY Plan_Serial";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Plan_Id", planNo);
|
|
|
//dbHelper.AddParameter("@Real_Num", realNum);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取本机台全部的计划数据
|
|
|
/// <summary>
|
|
|
/// 获取本机台全部的计划数据
|
|
|
/// </summary>
|
|
|
/// <returns>返回符合条件的计划数据表</returns>
|
|
|
public static DataTable GetPlanData()
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "SELECT Plan_Serial,Recipe_ID,Recipe_Name,Equip_Code,Version,Plan_Id,Plan_Num,Real_Num,Plan_State,Plan_StateText,Start_Date,End_Date,Plan_Date FROM xl_plan ORDER BY Plan_State,left(Plan_Id,8),Plan_Serial";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
return table;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 根据计划号 查看计划是否完成
|
|
|
/// <summary>
|
|
|
/// 根据计划号 查看计划是否完成
|
|
|
/// </summary>
|
|
|
/// <param name="planId">计划号</param>
|
|
|
/// <returns>true:存在;false:未完成</returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static bool GetXlPlanState(string planId)
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "select count(Plan_Id) from xl_plan where Plan_Id = @PlanID and Plan_State=3";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanID", planId);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != DBNull.Value && Convert.ToInt32(result) > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 根据计划号获取当前正在执行的计划任务
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取当前正在执行的计划任务
|
|
|
/// </summary>
|
|
|
/// <param name="planId"></param>
|
|
|
/// <param name="recipeId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static List<Xl_DowLoadPlan> GetExecPlan(int serial)
|
|
|
{
|
|
|
List<Xl_DowLoadPlan> lst = new List<Xl_DowLoadPlan>();
|
|
|
|
|
|
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 strSql = @"select p.Dosing_Id,p.Plan_Id,p.Plan_Serial,p.Recipe_ID,p.Recipe_Name,p.Version,p.Plan_Num,p.Real_Num,p.Shift_Id,p.Shift_Class,p.Plan_State,p.Plan_StateText,p.Plan_TotalWeight,p.Plan_TotalError,
|
|
|
r.Total_Weight,r.Total_Error,m.ID as MaterialID,m.Material_name,b.Bin_Serial as Station,b.Bin_Name as StationName,w.Set_Weight,w.Set_Error,p.IsRetransmission,p.Retransmission_Num
|
|
|
from xl_plan p left join xl_recipe r on p.Recipe_ID=r.ID left join xl_weigh w on r.ID=w.Recipe_ID left join xl_material m on w.Material_ID=m.ID left join Pmt_Bin b on m.ID=b.Material_ID where p.Plan_State=3 and
|
|
|
Plan_Serial=@Plan_Serial and w.Station is not null ORDER BY p.Plan_Serial";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Plan_Serial", serial);
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Xl_DowLoadPlan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当前正在执行的计划任务
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取当前正在执行的计划任务
|
|
|
/// </summary>
|
|
|
/// <param name="planId"></param>
|
|
|
/// <param name="recipeId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static List<Xl_DowLoadPlan> GetExecPlan()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
List<Xl_DowLoadPlan> lst = new List<Xl_DowLoadPlan>();
|
|
|
|
|
|
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 strSql = @"select p.Dosing_Id,p.Plan_Id,p.Plan_Serial,p.Recipe_ID,p.Recipe_Name,p.Version,p.Plan_Num,p.Real_Num,p.Shift_Id,p.Shift_Class,p.Plan_State,p.Plan_StateText,p.Plan_TotalWeight,p.Plan_TotalError,
|
|
|
r.Total_Weight,r.Total_Error,m.ID as MaterialID,m.Material_name,b.Bin_Serial as Station,b.Bin_Name as StationName,w.Set_Weight,w.Set_Error,p.IsRetransmission,p.Retransmission_Num
|
|
|
from xl_plan p
|
|
|
left join xl_recipe r on p.Recipe_ID=r.ID
|
|
|
left join xl_weigh w on r.ID=w.Recipe_ID
|
|
|
left join xl_material m on w.Material_ID=m.ID
|
|
|
left join Pmt_Bin b on m.ID=b.Material_ID where p.Plan_State=3 and w.Station is not null ORDER BY p.Plan_Serial";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
Xl_DowLoadPlan entity = null;
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
entity = ConvertDataRowToPlan(dr);
|
|
|
lst.Add(entity);
|
|
|
}
|
|
|
}
|
|
|
return lst;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当前正在执行的计划任务
|
|
|
/// <summary>
|
|
|
/// 根据计划号获取当前正在执行的计划任务
|
|
|
/// </summary>
|
|
|
/// <param name="planId"></param>
|
|
|
/// <param name="recipeId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static DataTable GetExecPlanDataTable()
|
|
|
{
|
|
|
List<Xl_DowLoadPlan> lst = new List<Xl_DowLoadPlan>();
|
|
|
|
|
|
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 strSql = @"select p.Plan_Id,p.Plan_Num,p.Real_Num,p.Plan_Serial,p.Plan_TotalWeight,p.Plan_TotalError,p.Plan_State,p.Plan_Date,p.Plan_StateText,r.ID as RecipeID,r.Recipe_Name,r.Recipe_Verify,r.Total_Weight,r.Total_Error,
|
|
|
m.ID as MaterialID,m.Material_name,b.Bin_Serial as Station,b.Bin_Name as StationName,w.Set_Weight,w.Set_Error
|
|
|
from xl_plan p
|
|
|
left join xl_recipe r on p.Recipe_ID=r.ID
|
|
|
left join xl_weigh w on r.ID=w.Recipe_ID
|
|
|
left join xl_material m on w.Material_ID=m.ID
|
|
|
left join Pmt_Bin b on m.ID=b.Material_ID where p.Plan_State=3 and w.Station is not null ORDER BY p.Plan_Serial";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
return table;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 将数据保存到报表中
|
|
|
/// <summary>
|
|
|
/// 将数据保存到报表中
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public static bool SaveDataToDB(Hw_PlanCompletion plan)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
|
|
|
string sqlstr = @"insert into Hw_PlanCompletion(PlanId,Recipe_ID,Material_ID,Plan_Serial,Version,Real_Num,Material_Weight,Material_Error)
|
|
|
values(@PlanId,@Recipe_ID,@Material_ID,@Plan_Serial,@Version,@Real_Num,@Material_Weight,@Material_Error)";
|
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.AddParameter("@PlanId", plan.PlanId);
|
|
|
dbHelper.AddParameter("@Recipe_ID", plan.Recipe_ID);
|
|
|
dbHelper.AddParameter("@Material_ID", plan.Material_ID);
|
|
|
dbHelper.AddParameter("@Plan_Serial", plan.Plan_Serial);
|
|
|
dbHelper.AddParameter("@Version", plan.Version);
|
|
|
dbHelper.AddParameter("@Real_Num", plan.Real_Num);
|
|
|
dbHelper.AddParameter("@Material_Weight", plan.Material_Weight);
|
|
|
dbHelper.AddParameter("@Material_Error", plan.Material_Error);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划状态
|
|
|
/// <summary>
|
|
|
/// 更新计划状态
|
|
|
/// </summary>
|
|
|
/// <param name="planId">计划号</param>
|
|
|
/// <param name="state">任务状态 3:正在运行;4:已下传;5:未启动;7:已终止;8:已完成</param>
|
|
|
/// <param name="IfFlag">是否完成</param>
|
|
|
/// <returns></returns>
|
|
|
public static bool UpdatePlanState(string planId, int state, int IfFlag)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Plan_State = @PlanState, Plan_StateText = @Plan_StateText, IF_FLAG = @IfFlag where Plan_Id = @PlanID";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanState", state);
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow(state));
|
|
|
dbHelper.AddParameter("@IfFlag", IfFlag);
|
|
|
dbHelper.AddParameter("@PlanID", planId);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划数
|
|
|
/// <summary>
|
|
|
/// 更新计划完成数量
|
|
|
/// </summary>
|
|
|
/// <param name="planId">计划号</param>
|
|
|
/// <param name="quantity">完成数量</param>
|
|
|
/// <returns></returns>
|
|
|
public static bool UpdatePlanCompletedQuantity(string planId, int quantity, double totalWeight, double totalError)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Real_Num = @Real_Num,Plan_TotalWeight=@Plan_TotalWeight,Plan_TotalError=@Plan_TotalError, where Plan_Id = @Plan_Id";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@Real_Num", quantity);
|
|
|
dbHelper.AddParameter("@Plan_Id", planId);
|
|
|
dbHelper.AddParameter("@Plan_TotalWeight", totalWeight);
|
|
|
dbHelper.AddParameter("@Plan_TotalError", totalError);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新计划数-完成
|
|
|
/// <summary>
|
|
|
/// 更新计划完成数量-完成
|
|
|
/// </summary>
|
|
|
/// <param name="planId">计划号</param>
|
|
|
/// <param name="quantity">完成数量</param>
|
|
|
/// <returns></returns>
|
|
|
public static bool UpdatePlanCompletedQuantity(string planId, int quantity,int state, DateTime date, double totalWeight, double totalError)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "update xl_plan set Real_Num = @Real_Num,Plan_TotalWeight=@Plan_TotalWeight,Plan_TotalError=@Plan_TotalError,Plan_State=@PlanState,Plan_StateText=@Plan_StateText,End_Date=@End_Date where Plan_Id = @Plan_Id";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@Real_Num", quantity);
|
|
|
dbHelper.AddParameter("@End_Date", date);
|
|
|
dbHelper.AddParameter("@PlanState", state);
|
|
|
dbHelper.AddParameter("@Plan_TotalWeight", totalWeight);
|
|
|
dbHelper.AddParameter("@Plan_TotalError", totalError);
|
|
|
dbHelper.AddParameter("@Plan_StateText", StateToShow(state));
|
|
|
dbHelper.AddParameter("@Plan_Id", planId);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 添加计划报表-完成
|
|
|
/// <summary>
|
|
|
/// 更新计划完成数量-完成
|
|
|
/// </summary>
|
|
|
/// <param name="planId">计划号</param>
|
|
|
/// <param name="quantity">完成数量</param>
|
|
|
/// <returns></returns>
|
|
|
public static bool AddPlanReport(Xl_DowLoadPlan down,int Plan_Serial, int quantity, double totalWeight, double totalError)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
string strSql = "INSERT INTO Hw_PlanCompletion (PlanId,Recipe_ID,Material_ID,Version,Real_Num ,Material_Weight,Material_Error,CreateDateTime)VALUES(@PlanId,@Recipe_ID,@Material_ID,@Version,@Real_Num,@Material_Weight,@Material_Error,@CreateDateTime)";
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@PlanId", down.Plan_Id);
|
|
|
dbHelper.AddParameter("@Recipe_ID", down.Recipe_ID);
|
|
|
dbHelper.AddParameter("@Material_ID", down.MaterialID);
|
|
|
dbHelper.AddParameter("@Version", down.Version);
|
|
|
dbHelper.AddParameter("@Real_Num", quantity);
|
|
|
dbHelper.AddParameter("@Material_Weight", totalWeight);
|
|
|
dbHelper.AddParameter("@Material_Error", totalError);
|
|
|
dbHelper.AddParameter("@CreateDateTime", DateTime.Now);
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取当前班组
|
|
|
/// <summary>
|
|
|
/// 获取当前班组
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
public static Pmt_Shiftime GetShiftClass()
|
|
|
{
|
|
|
Pmt_Shiftime pmt_Shiftime = new Pmt_Shiftime();
|
|
|
|
|
|
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 strSql = @"select top 1, * from Pmt_Shiftime where Shift_st<=@Shift_st and Shift_et>=@Shift_et";
|
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@Shift_st", DateTime.Now.ToString("HH:mm:ss"));
|
|
|
dbHelper.AddParameter("@Shift_et", DateTime.Now.ToString("HH:mm:ss"));
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow dr in table.Rows)
|
|
|
{
|
|
|
pmt_Shiftime = ConvertDataRowToPptShiftimen(dr);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return pmt_Shiftime;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 把DataRow数据行转换为物料实体对象
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr">要转换的数据行</param>
|
|
|
/// <returns>返回转换后的计划实体对象</returns>
|
|
|
public static xl_material ConvertDataRowToXlMaterial(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
xl_material pmtMaterial = new xl_material();
|
|
|
pmtMaterial.ID = Mesnac.Basic.DataProcessor.RowValue(dr, "ID", String.Empty);
|
|
|
pmtMaterial.Material_code = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_code", String.Empty);
|
|
|
pmtMaterial.Material_name = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_name", String.Empty);
|
|
|
pmtMaterial.Remark = Mesnac.Basic.DataProcessor.RowValue(dr, "Remark", String.Empty);
|
|
|
pmtMaterial.Batch_number = Mesnac.Basic.DataProcessor.RowValue(dr, "Batch_number", String.Empty);
|
|
|
pmtMaterial.Barcode1 = Mesnac.Basic.DataProcessor.RowValue(dr, "Barcode1", String.Empty);
|
|
|
pmtMaterial.Barcode2 = Mesnac.Basic.DataProcessor.RowValue(dr, "Barcode2", String.Empty);
|
|
|
pmtMaterial.Barcode3 = Mesnac.Basic.DataProcessor.RowValue(dr, "Barcode3", String.Empty);
|
|
|
|
|
|
return pmtMaterial;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 把DataRow数据行转换为计划实体对象
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr">要转换的数据行</param>
|
|
|
/// <returns>返回转换后的计划实体对象</returns>
|
|
|
public static Xl_DowLoadPlan ConvertDataRowToPlan(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
Xl_DowLoadPlan plan = new Xl_DowLoadPlan();
|
|
|
plan.Dosing_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Dosing_Id", String.Empty);
|
|
|
plan.Plan_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Id", String.Empty);
|
|
|
plan.Plan_Serial = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Serial", 0);
|
|
|
plan.Recipe_ID = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_ID", String.Empty);
|
|
|
plan.Recipe_Name = Mesnac.Basic.DataProcessor.RowValue(dr, "Recipe_Name", String.Empty);
|
|
|
plan.Version = Mesnac.Basic.DataProcessor.RowValue(dr, "Version", 0);
|
|
|
plan.Plan_Num = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_Num", 0);
|
|
|
plan.Real_Num = Mesnac.Basic.DataProcessor.RowValue(dr, "Real_Num", 0);
|
|
|
plan.Shift_Id = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_Id", 0);
|
|
|
plan.Shift_Class = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_Class", String.Empty);
|
|
|
plan.Plan_State = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_State", 0);
|
|
|
plan.Plan_StateText = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_StateText", String.Empty);
|
|
|
plan.Plan_TotalWeight = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_TotalWeight", 0.000);
|
|
|
plan.Plan_TotalError = Mesnac.Basic.DataProcessor.RowValue(dr, "Plan_TotalError", 0.000);
|
|
|
plan.Total_Weight = Mesnac.Basic.DataProcessor.RowValue(dr, "Total_Weight", 0.000);
|
|
|
plan.Total_Error = Mesnac.Basic.DataProcessor.RowValue(dr, "Total_Error", 0.000);
|
|
|
plan.MaterialID = Mesnac.Basic.DataProcessor.RowValue(dr, "MaterialID", String.Empty);
|
|
|
plan.Material_name = Mesnac.Basic.DataProcessor.RowValue(dr, "Material_name", String.Empty);
|
|
|
plan.Station = Mesnac.Basic.DataProcessor.RowValue(dr, "Station", 0);
|
|
|
plan.StationName = Mesnac.Basic.DataProcessor.RowValue(dr, "StationName", String.Empty);
|
|
|
plan.Set_Weight =Convert.ToDecimal(Mesnac.Basic.DataProcessor.RowValue(dr, "Set_Weight", 0.000).ToString());
|
|
|
plan.Set_Error = Convert.ToDecimal(Mesnac.Basic.DataProcessor.RowValue(dr, "Set_Error", 0.000).ToString());
|
|
|
plan.IsRetransmission = Mesnac.Basic.DataProcessor.RowValue(dr, "IsRetransmission", 0);
|
|
|
plan.Retransmission_Num = Mesnac.Basic.DataProcessor.RowValue(dr, "Retransmission_Num", 0);
|
|
|
|
|
|
return plan;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 把DataRow数据行转换为班组实体对象
|
|
|
/// <summary>
|
|
|
/// 把DataRow数据行转换为班组实体对象
|
|
|
/// </summary>
|
|
|
/// <param name="dr"></param>
|
|
|
/// <returns></returns>
|
|
|
public static Pmt_Shiftime ConvertDataRowToPptShiftimen(DataRow dr)
|
|
|
{
|
|
|
if (dr != null)
|
|
|
{
|
|
|
Pmt_Shiftime shiftime = new Pmt_Shiftime();
|
|
|
shiftime.Shift_id = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_id", 0);
|
|
|
shiftime.Shift_name = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_name", String.Empty);
|
|
|
shiftime.Shift_st = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_st", String.Empty);
|
|
|
shiftime.Shift_et = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_et", String.Empty);
|
|
|
shiftime.Shift_class = Mesnac.Basic.DataProcessor.RowValue(dr, "Shift_class", 0);
|
|
|
|
|
|
return shiftime;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
}
|