|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Product.PptPlan.entity;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移动计划抽象业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class AbstractMoveAction : ChemicalWeighingAction
|
|
|
|
|
{
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移动计划事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler OnMovePlan;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移动计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="runtime">运行时参数</param>
|
|
|
|
|
/// <param name="msg">移动计划提示信息</param>
|
|
|
|
|
/// <param name="moveType">移动类型,Up上移,Down下移</param>
|
|
|
|
|
public void MovePlan(RuntimeParameter runtime, string msg, MoveType moveType)
|
|
|
|
|
{
|
|
|
|
|
List<string> errorList = new List<string>();
|
|
|
|
|
|
|
|
|
|
//DbMCControl planDateControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[RT_plan].[Plan_Date]").FirstOrDefault();
|
|
|
|
|
//DbMCControl pptShiftControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Shiftime").FirstOrDefault();
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_PlanInfo").FirstOrDefault(); //获取本机台计划网格控件
|
|
|
|
|
|
|
|
|
|
//if (planDateControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<InsertAction>.Error("{当班计划-移动计划} 缺少日期选择控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (pptShiftControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<InsertAction>.Error("{当班计划-移动计划} 缺少班次组合框控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<AbstractMoveAction>.Error("{当班计划——移动计划}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string planIds = String.Empty;
|
|
|
|
|
DataGridView clientGridView = clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
|
|
|
|
|
if (clientGridView.SelectedRows.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
DateTime ctlPlanDate = DateTime.Now;
|
|
|
|
|
int ctlShift = Global.PublicVar.Instance.globalShiftID;
|
|
|
|
|
//DateTime.TryParse(planDateControl.BaseControl.MCValue.ToString(), out ctlPlanDate);
|
|
|
|
|
//int.TryParse(pptShiftControl.BaseControl.MCValue.ToString(), out ctlShift);
|
|
|
|
|
|
|
|
|
|
string planId = clientGridView.SelectedRows[0].Cells["plan_id"].Value.ToString();
|
|
|
|
|
string plandate = clientGridView.SelectedRows[0].Cells["create_time"].Value.ToString();
|
|
|
|
|
int planOrder = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["plan_order"].Value);
|
|
|
|
|
if (!plandate.Substring(0,10).Equals(ctlPlanDate.ToShortDateString()))
|
|
|
|
|
{
|
|
|
|
|
string msg1 = "不可移动非当前日期的计划!!";
|
|
|
|
|
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 验证(PLC中读取过来的planid对应的数据库中的计划必须是存在的)
|
|
|
|
|
|
|
|
|
|
//RT_Plan currentRT_Plan = Product.PptPlan.PlanHelper.GetPlanDataEntity(planId);
|
|
|
|
|
|
|
|
|
|
//if (currentRT_Plan == null)
|
|
|
|
|
//{
|
|
|
|
|
// MessageBox.Show("删除异常,要删除的计划在数据库中丢失");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (moveType == MoveType.Up)
|
|
|
|
|
{
|
|
|
|
|
#region 获取交换位置对象并判断是否可以上移(条件:在该条计划前,是否有一条未运行中的计划)并执行上移
|
|
|
|
|
|
|
|
|
|
//int swagPlanSerial = (int)currentRT_Plan.Plan_Serial;
|
|
|
|
|
//RT_Plan swagRtPLan = Product.PptPlan.PlanHelper.GetPlanBySerialUp(swagPlanSerial);
|
|
|
|
|
//if (swagRtPLan == null)
|
|
|
|
|
//{
|
|
|
|
|
// MessageBox.Show("不能上移");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// currentRT_Plan.Plan_Serial = swagRtPLan.Plan_Serial;
|
|
|
|
|
// swagRtPLan.Plan_Serial = swagPlanSerial;
|
|
|
|
|
// Product.PptPlan.PlanHelper.UpdatePlanSerial(currentRT_Plan);
|
|
|
|
|
// Product.PptPlan.PlanHelper.UpdatePlanSerial(swagRtPLan);
|
|
|
|
|
|
|
|
|
|
// #region 重新下传计划列表
|
|
|
|
|
|
|
|
|
|
// //ChemicalWeighingPlc.PlcPlanHelper.PlanListReDown();
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if(planOrder == 1)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("不能上移");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改计划序号 根据计划编号修改
|
|
|
|
|
//先获取计划信息 根据计划编号
|
|
|
|
|
Base_PlanInfo lastPlanInfo = PlanHelper.getLastPlanInfoByPlanOrder(planOrder);
|
|
|
|
|
|
|
|
|
|
//修改计划序号
|
|
|
|
|
PlanHelper.UpdatePlanOrderByPlanId(new Base_PlanInfo()
|
|
|
|
|
{
|
|
|
|
|
plan_Id = lastPlanInfo.plan_Id,
|
|
|
|
|
plan_order = planOrder
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
PlanHelper.UpdatePlanOrderByPlanId(new Base_PlanInfo()
|
|
|
|
|
{
|
|
|
|
|
plan_Id = planId,
|
|
|
|
|
plan_order = lastPlanInfo.plan_order
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (moveType == MoveType.Down)
|
|
|
|
|
{
|
|
|
|
|
#region 获取交换位置对象并判断是否可以下移(条件:在该条计划后,是否有一条未运行中的计划)并执行下移
|
|
|
|
|
|
|
|
|
|
//int swagPlanSerial = (int)currentRT_Plan.Plan_Serial;
|
|
|
|
|
//RT_Plan swagRtPLan = Product.PptPlan.PlanHelper.GetPlanBySerialDown(swagPlanSerial);
|
|
|
|
|
//if (swagRtPLan == null)
|
|
|
|
|
//{
|
|
|
|
|
// MessageBox.Show("不能下移");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// currentRT_Plan.Plan_Serial = swagRtPLan.Plan_Serial;
|
|
|
|
|
// swagRtPLan.Plan_Serial = swagPlanSerial;
|
|
|
|
|
// Product.PptPlan.PlanHelper.UpdatePlanSerial(currentRT_Plan);
|
|
|
|
|
// Product.PptPlan.PlanHelper.UpdatePlanSerial(swagRtPLan);
|
|
|
|
|
|
|
|
|
|
// #region 重新下传计划列表
|
|
|
|
|
|
|
|
|
|
// //ChemicalWeighingPlc.PlcPlanHelper.PlanListReDown();
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (planOrder == clientGridView.RowCount)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("不能下移");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Base_PlanInfo nextPlanInfo = PlanHelper.getNextPlanInfoByPlanOrder(planOrder);
|
|
|
|
|
|
|
|
|
|
//修改计划序号
|
|
|
|
|
PlanHelper.UpdatePlanOrderByPlanId(new Base_PlanInfo()
|
|
|
|
|
{
|
|
|
|
|
plan_Id = nextPlanInfo.plan_Id,
|
|
|
|
|
plan_order = planOrder
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlanHelper.UpdatePlanOrderByPlanId(new Base_PlanInfo()
|
|
|
|
|
{
|
|
|
|
|
plan_Id = planId,
|
|
|
|
|
plan_order = nextPlanInfo.plan_order
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 触发移动计划事件,在本机台网格控件中显示本机台计划
|
|
|
|
|
|
|
|
|
|
if (OnMovePlan != null)
|
|
|
|
|
{
|
|
|
|
|
OnMovePlan(runtime, System.EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|