You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.4 KiB
C#
111 lines
4.4 KiB
C#
using ICSharpCode.Core;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe.entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
|
|
{
|
|
class ProductionBudgetAction : ChemicalWeighingAction, IAction
|
|
{
|
|
#region 字段定义
|
|
private RuntimeParameter _runtime;
|
|
//public static event EventHandler ReloadPlan;
|
|
private DbMCControl _clientGridControl = null; //网格计划控件
|
|
|
|
private string selectedPlanId = null;//选中计划号
|
|
private string selectedPlanState = null;
|
|
#endregion
|
|
|
|
#region IAction接口实现
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime);
|
|
this._runtime = runtime;
|
|
ICSharpCode.Core.LoggingService<ReloadPlanInfo>.Debug("重传计划信息...");
|
|
//获取界面控件
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_PlanInfo").FirstOrDefault();
|
|
if (clientGridControl == null)
|
|
{
|
|
ICSharpCode.Core.LoggingService<ReloadPlanInfo>.Error("{生产计划-重传计划信息} 缺少计划列表网格控件...");
|
|
return;
|
|
}
|
|
this._clientGridControl = clientGridControl;
|
|
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
|
|
|
|
if (clientGridView.SelectedRows.Count != 1)
|
|
{
|
|
string msg1_1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_ModifyPlanNumAction_msg1_1")); //请选择
|
|
MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this._runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
//获取选中的计划号
|
|
this.selectedPlanId = clientGridView.SelectedRows[0].Cells["plan_Id"].Value as string;
|
|
this.selectedPlanState = clientGridView.SelectedRows[0].Cells["plan_state"].Value as string;
|
|
if (this.selectedPlanState == "执行中")
|
|
{
|
|
//获取当前选中计划
|
|
entity.Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(this.selectedPlanId);
|
|
//调试时注释
|
|
//if (WriteRecipeInfoToPLC(planInfo))
|
|
if(true)
|
|
{
|
|
ICSharpCode.Core.LoggingService<StopAction>.Debug("{生产计划-计划下传} 计划重传成功...");
|
|
//planInfo.plan_beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
//Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(planInfo);
|
|
MessageBox.Show("计划重传成功!");
|
|
return;
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("计划重传失败!");
|
|
return;
|
|
}
|
|
#region 触发事件
|
|
|
|
//if (ReloadPlan != null)
|
|
//{
|
|
// ReloadPlan(runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
//}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("仅限重传执行中的计划", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 下发PLC计划信息
|
|
/// </summary>
|
|
/// <param name="base_PlanInfo"></param>
|
|
/// <returns></returns>
|
|
public static bool WriteRecipeInfoToPLC(Product.PptPlan.entity.Base_PlanInfo base_PlanInfo)
|
|
{
|
|
try
|
|
{
|
|
Base_RecipeInfo info = Technical.PmtRecipe.RecipeHelper.GetRecipeById(base_PlanInfo.recipe_Id);
|
|
//编号
|
|
var plan_Id = Convert.ToInt32(base_PlanInfo.plan_Id);
|
|
|
|
object[] recipeidArray = Mesnac.Basic.DataProcessor.ToSiemensPLCDataArray(plan_Id);
|
|
|
|
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|