using com.steering.mes.zgmil.entity;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.ZGMil.Common;
using Core.StlMes.Client.ZGMil.Entity;
using Core.StlMes.Client.ZGMil.NodeResultQuery;
using Core.StlMes.Client.ZGMil.Popup;
using Core.StlMes.Client.ZGMil.ResultConrtrol;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Core.StlMes.Client.ZGMil.Result
{
public partial class FrmFeedLoadResult : FrmBase
{
private string departm = "";
private string plineCode = "";
private string user = "";
private string bc = "";
private string bz = "";
private string Shift = "";
private string Group = "";
private string[] pCode;
private string[] arr;
FeedRowPlan Feedplan = new FeedRowPlan();
private string proPlanId = null;//轧管订单编号
private string gxPlanNo = null;//工序排产序号
private string lotNo = null;//生产批号
private string Departm = "";//部门
private string PlineCode = "";//产线
private string _UserName = ""; //签名 姓名
private string _Url = ""; //签名 Url
private string _UserID = ""; //签名 签名ID
//private string plineCode = "";
public FrmFeedLoadResult()
{
InitializeComponent();
this.IsLoadUserView = true;
//NativeMethodNew na = new NativeMethodNew(this.ob);
//departm = UserInfo.GetDepartment();
//PlineCode = na.GetPCode(departm); //获取 用户 对应的产线
StartTime.Value = DateTime.Parse(DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd"));
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
doQuery();
break;
//case "Add":
// add();
// break;
//case "Delete":
// delete();
// break;
case "DoTryRollingMaterial":
DoTryRollingMaterial();
break;
case "DoUpdateDate":
UpdateDatePlan();
break;
case "Node":
node();
break;
case "NodeBack":
nodeBack();
break;
case "DoSign":
Sign();
break;
case "DoPrint":
DoPrint();
break;
case "Close":
this.Close();
break;
}
}
#region 方法
///
/// 页面开启事件
///
///
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
Sign();
}
///
/// 签名
///
private void Sign()
{
ColUserName col = new ColUserName();
col.StationId = "13";
col.PlineCode = PlineCode;
col.ColGroup = Group;
col.Ob = this.ob;
col.ShowDialog();
_UserID = col.getUserId();
_UserName = col.getUserName();
}
private void DoPrint()
{
this.ultraGrid1.UpdateData();
string plineCode = "";
UltraGridRow uRow = ultraGrid1.ActiveRow;
if (uRow == null)
{
MessageUtil.ShowTips("请选择需要打印的炉信息!");
return;
}
plineCode = uRow.Cells["PLINE_CODE"].Value.ToString();
string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilLoad.cpt&op=view&PLINE_CODE=" + plineCode;
FrmExcel fre = new FrmExcel(this.ob, strurl);
fre.AutoSize = true;
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.WindowState = FormWindowState.Maximized;
fre.Show();
}
///
/// 更改girdRow颜色
///
public void ChangeGridColor()
{
if (ultraGrid1.Rows.Count > 0)
{
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
if (int.Parse(ugr.Cells["REAL_INDOUBLE_NUM"].Value.ToString()) > 0)
{
ugr.Appearance.BackColor = Color.YellowGreen;
}
}
}
}
///
/// 上料支都到了投料库Grid1变颜色
///
//public void ChangeGrid1Color()
//{
// int a = 0;
// int b = 0;
// string tlk = "";
// switch (PlineCode)
// {
// case "C008":
// tlk = "250投料库";
// break;
// case "C009":
// tlk = "258投料库";
// break;
// case "C010":
// tlk = "168投料库";
// break;
// case "C017":
// tlk = "460投料库";
// break;
// }
// if (ultraGrid2.Rows.Count > 0)
// {
// foreach (UltraGridRow uRow in ultraGrid2.Rows)
// {
// a += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) ;
// }
// }
// if (ultraGrid5.Rows.Count > 0)
// {
// foreach (UltraGridRow uRow in ultraGrid5.Rows)
// {
// if (tlk == uRow.Cells["STORAGE_NO"].Value.ToString())
// {
// b += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3());
// }
// }
// }
// if (a == b)
// {
// ultraGrid1.ActiveRow.Appearance.BackColor = Color.LimeGreen;
// }
//}
///
/// 数据同步
///
public void UpdateDatePlan()
{
SyncPro frm = new SyncPro(this.ob, plineCode);
frm.ShowDialog();
//int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.GetSQLDate.getPlanQuery", new object[] { }, this.ob);
//MessageBox.Show("计划同步完成!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
doQuery();
}
///
/// 试轧料
///
private void DoTryRollingMaterial()
{
string Shift = UserInfo.GetUserOrder();
string Group = UserInfo.GetUserGroup();
FrmTryRollingMaterial FrmBS = new FrmTryRollingMaterial(Shift, Shift, _UserName, this.ob, PlineCode, arr, pCode);
FrmBS.ShowDialog();
doQuery();
}
///
/// 上料回退
///
private void nodeBack()
{
ArrayList parm = new ArrayList();
ArrayList parm2 = new ArrayList();
UltraGridRow ugr = ultraGrid1.ActiveRow;
IQueryable uGrid = ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
if (uGrid.Count() == 0)
{
MessageUtil.ShowTips("请选择要上料回退的数据!");
return;
}
if (ultraGrid2.Rows.Count > 0)
{
foreach (UltraGridRow uRow in uGrid)
{
if (int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) > int.Parse(uRow.Cells["REAL_INDOUBLE_NUM"].Value.ToString3()))
{
MessageUtil.ShowTips("输入的支数不能大于已上料支数!");
return;
}
if (!StringUtil.IsInt(uRow.Cells["ACT_COUNT"].Value.ToString3()))
{
MessageUtil.ShowTips("输入的操作支不为整数,请重新输入!");
return;
}
ArrayList list = new ArrayList();
list.Add(uRow.Cells["JUDGE_STOVE_NO"].Value.ToString());
list.Add(uRow.Cells["JUGDE_APPLY_CODE"].Value.ToString());
list.Add(uRow.Cells["REAL_INDOUBLE_NUM"].Text.ToString3()); //已上料支
list.Add(uRow.Cells["CUT_NUM_GP"].Value.ToString3());
list.Add(ugr.Cells["PRO_PLAN_ID"].Value.ToString());
list.Add(ugr.Cells["GX_PLAN_NO"].Value.ToString());
list.Add(uRow.Cells["FEED_LENGTH"].Value.ToString3());
list.Add(uRow.Cells["CUT_TARGET"].Value.ToString()); //切损去向
list.Add(uRow.Cells["CUT_LENGTH"].Value.ToString3()); //切损长度
list.Add(uRow.Cells["CUT_WEIGHT"].Value.ToString3()); //切损重量
parm.Add(list);
}
}
else
{
MessageUtil.ShowTips("没有可上料回退的数据!");
return;
}
if (int.Parse(ugr.Cells["REAL_INDOUBLE_NUM"].Value.ToString()) == 0)
{
MessageUtil.ShowTips("此炉未上料,不能上料回退!");
return;
}
parm2.Add(ugr.Cells["FEED_HEAT_NO"].Value.ToString());
parm2.Add(ugr.Cells["PRO_PLAN_ID"].Value.ToString());
parm2.Add(ugr.Cells["GX_PLAN_NO"].Value.ToString());
parm2.Add(ugr.Cells["PLINE_CODE"].Value.ToString());
parm2.Add(ugr.Cells["HEAT_PLAN_NO"].Value.ToString());
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.zgmil.coup.FrmFeedLoad";
ccp.MethodName = "nodeBack";
ccp.ServerParams = new object[] { parm, parm2 };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnInfo == "上料回退成功!")
{
MessageUtil.ShowTips("上料回退成功!");
doQuery();
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
///
/// 上料确认
///
private void node()
{
ArrayList parm = new ArrayList();
ArrayList parm2 = new ArrayList();
UltraGridRow ultragrid = ultraGrid1.ActiveRow;
if (ultragrid.Cells["INWL_DESC"].Value.ToString() == "" || ultragrid.Cells["OUTWL_DESC"].Value.ToString() == "")
{
MessageUtil.ShowTips("缺少物料码,请联系计划员重新做计划!");
return;
}
IQueryable uGrid = ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
if (uGrid.Count() == 0)
{
MessageUtil.ShowTips("请选择要上料的数据!");
return;
}
IQueryable uGrid2 = ultraGrid2.Rows.AsQueryable().Where(" CHK = 'False'");
if (uGrid2.Count() > 0)
{
MessageUtil.ShowTips("有上料行没有打勾,请联系计划删除不用上料的计划行!");
return;
}
if (ultraGrid2.Rows.Count > 0)
{
int a = 0;
double b = 0.0;
foreach (UltraGridRow uRow in uGrid)
{
if (int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) > int.Parse(uRow.Cells["PLAN_INDOUBLE_NUM"].Value.ToString3()))
{
MessageUtil.ShowTips("输入的上料支不能大于计划上料支!");
return;
}
if (!StringUtil.IsInt(uRow.Cells["ACT_COUNT"].Value.ToString3()))
{
MessageUtil.ShowTips("输入的上料支不为整数,请重新输入!");
return;
}
if (int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) < 1)
{
MessageUtil.ShowTips("存在不上料的计划行,请通知计划重新下计划!");
return;
}
//if(!uRow.Cells["STORAGE_NO"].Text.ToString3().Contains("投料库"))
//{
// MessageUtil.ShowTips("还有管坯未到投料库,不能上料!");
// return;
//}
a += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) * int.Parse(uRow.Cells["CUT_NUM_GP"].Value.ToString3());
if (int.Parse(uRow.Cells["PLAN_INDOUBLE_NUM"].Value.ToString3()) == int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()))
{
b += double.Parse(uRow.Cells["PLAN_INDOUBLE_WT"].Value.ToString3());
}
else
{
b += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) * double.Parse(uRow.Cells["WEIGHT_M"].Value.ToString3());
}
ArrayList list = new ArrayList();
list.Add(uRow.Cells["JUDGE_STOVE_NO"].Value.ToString());
list.Add(uRow.Cells["JUGDE_APPLY_CODE"].Text.ToString());
list.Add(uRow.Cells["ACT_COUNT"].Value.ToString3()); //实绩上料支
list.Add(uRow.Cells["CUT_NUM_GP"].Value.ToString3());
list.Add(ultragrid.Cells["PRO_PLAN_ID"].Value.ToString());
list.Add(ultragrid.Cells["GX_PLAN_NO"].Value.ToString());
list.Add(uRow.Cells["FEED_LENGTH"].Value.ToString3());
list.Add(uRow.Cells["HEAT_PLAN_SQE"].Value.ToString()); //上料行ID
list.Add(uRow.Cells["CUT_TARGET"].Value.ToString()); //切损去向
list.Add(uRow.Cells["CUT_LENGTH"].Value.ToString3()); //切损长度
list.Add(uRow.Cells["CUT_WEIGHT"].Value.ToString3()); //切损重量
list.Add(uRow.Cells["PLAN_INDOUBLE_NUM"].Value.ToString()); //计划上料支
parm.Add(list);
}
actualNum.Value = a;
actualWeight.Value = b;
}
else {
MessageUtil.ShowTips("没有可上料的数据!");
return;
}
UltraGridRow ugr = ultraGrid1.ActiveRow;
if (int.Parse(ugr.Cells["REAL_INDOUBLE_NUM"].Value.ToString()) > 0)
{
MessageUtil.ShowTips("此炉已上料!");
return;
}
parm2.Add(ugr.Cells["FEED_HEAT_NO"].Value.ToString());
parm2.Add(ugr.Cells["PRO_PLAN_ID"].Value.ToString());
parm2.Add(ugr.Cells["GX_PLAN_NO"].Value.ToString());
parm2.Add(ugr.Cells["PLINE_CODE"].Value.ToString());
parm2.Add(Shift);
parm2.Add(Group);
parm2.Add(_UserName);
parm2.Add(_UserID);
parm2.Add(actualNum.Value.ToString());
parm2.Add(actualWeight.Value.ToString());
parm2.Add(ugr.Cells["HEAT_PLAN_NO"].Value.ToString());
Feedplan.ResultNo = ugr.Cells["HEAT_PLAN_NO"].Value.ToString();
Feedplan.LotNo = ugr.Cells["ZY_BATCH_ID"].Value.ToString();
Feedplan.JudgeStoveNo = ugr.Cells["FEED_HEAT_NO"].Value.ToString() + "-01";
Feedplan.StoveNo = "";
Feedplan.PlineCode = ugr.Cells["PLINE_CODE"].Value.ToString();
Feedplan.ProPlanId = ugr.Cells["PRO_PLAN_ID"].Value.ToString();
Feedplan.GxPlanNo = ugr.Cells["GX_PLAN_NO"].Value.ToString();
Feedplan.CutTarget = ugr.Cells["DECISION"].Value.ToString();//判定字头A B C
string[] arr = BaseMethod.WarehousePermissionsStore( this.ValidDataPurviewIds, this.ob);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.zgmil.coup.FrmFeedLoad";
ccp.MethodName = "node";
ccp.ServerParams = new object[] { parm, parm2, arr, Feedplan };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnInfo == "上料确认成功!")
{
MessageUtil.ShowTips("上料确认成功!");
doQuery();
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
///
/// 查询
///
private void doQuery()
{
string JudgeStoveNo = "";
string FeedHeatNo = "";
string LotNo = "";
string IsLoad = "0";
string startTime = "";
string endTime = "";
if (chkJudgeStoveNo.Checked)
{
if (uteJudgeStoveNo.Text.Trim() == "")
{
JudgeStoveNo = "";
}
else
{
JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
}
}
if (chkFEED_HEAT_NO.Checked)
{
if (ultraFEED_HEAT_NO.Text.Trim() == "")
{
FeedHeatNo = "";
}
else
{
FeedHeatNo = ultraFEED_HEAT_NO.Value.ToString();
}
}
if (chkLotNo.Checked)
{
if (uteLotNo.Text.Trim() == "")
{
LotNo = "";
}
else
{
LotNo = uteLotNo.Value.ToString();
}
}
if (ultraIsLoad.Checked)
{
IsLoad = "1";
startTime = StartTime.Value.ToString();
endTime = EndTime.Value.ToString();
}
ArrayList alist = new ArrayList();
alist.Add(JudgeStoveNo);
alist.Add(LotNo);
alist.Add(IsLoad);
alist.Add(FeedHeatNo);
alist.Add(startTime);
alist.Add(endTime);
//string[] arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds, this.ob);
WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmFeedLoad.doQueryData", new Object[] { alist, pCode}, this.ob);
GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
GridHelper.RefreshAndAutoSize(this.ultraGrid1);
wf.Close();
ChangeGridColor();
if (ultraGrid1.Rows.Count == 0)
{
dataTable2.Rows.Clear();
dataTable3.Rows.Clear();
dataTable4.Rows.Clear();
return;
}
}
#endregion
#region 事件
private void FrmFeedLoadResult_Load(object sender, EventArgs e)
{
NativeMethodNew na = new NativeMethodNew(this.ob);
departm = UserInfo.GetDepartment();
arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds, this.ob);
pCode = BaseMethod.GetPlineCode(this.ValidDataPurviewIds, this.ob);//获取 用户 对应的产线
PlineCode = pCode[0];
//PlineCode = na.GetPCode(departm); //获取 用户 对应的产线
planWeight.Value = UserInfo.GetUserOrderText();
actualWeight.Value = UserInfo.GetUserGroupText();
user = UserInfo.GetUserName();
bc = UserInfo.GetUserOrderText();
bz = UserInfo.GetUserGroupText();
Shift = UserInfo.GetUserOrder();
Group = UserInfo.GetUserGroup();
EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]);
//doQuery();
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
string IsLoad = "0";
if (ultraIsLoad.Checked)
{
IsLoad = "1";
}
UltraGridRow ugr = ultraGrid1.ActiveRow;
string judgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
string lotNo = ugr.Cells["ZY_BATCH_ID"].Value.ToString();
string plineCode = ugr.Cells["PLINE_CODE"].Value.ToString();
string heatPlanNo = ugr.Cells["HEAT_PLAN_NO"].Value.ToString();
string jugdeApplyCode = ugr.Cells["JUGDE_APPLY_CODE"].Value.ToString();
string feedHeatNo = ugr.Cells["FEED_HEAT_NO"].Value.ToString();
string PRO_PLAN_ID = ugr.Cells["PRO_PLAN_ID"].Value.ToString();
string GX_PLAN_NO = ugr.Cells["GX_PLAN_NO"].Value.ToString();
//左边上料信息
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmFeedLoad.doQueryMatData", new Object[] { heatPlanNo, plineCode,IsLoad,PRO_PLAN_ID,GX_PLAN_NO, arr }, this.ob);
GridHelper.CopyDataToDatatable(dt, this.dataTable2, true);
GridHelper.RefreshAndAutoSize(this.ultraGrid2);
//右边库存信息
DataTable dt1 = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmFeedLoad.doQueryMatData2", new Object[] { judgeStoveNo, PRO_PLAN_ID, GX_PLAN_NO, IsLoad }, this.ob);
GridHelper.CopyDataToDatatable(dt1, this.dataTable4, true);
GridHelper.RefreshAndAutoSize(this.ultraGrid5);
int a = 0;
double b = 0.0;
if (ultraGrid2.Rows.Count > 0)
{
foreach (UltraGridRow uRow in ultraGrid2.Rows)
{
uRow.Cells["CHK"].Value = true;
a += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) * int.Parse(uRow.Cells["CUT_NUM_GP"].Value.ToString3());
b += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) * double.Parse(uRow.Cells["PLAN_INDOUBLE_WT"].Value.ToString3()) / int.Parse(uRow.Cells["PLAN_INDOUBLE_NUM"].Value.ToString3());
//uRow.Cells["PLAN_INDOUBLE_WT"].Value = int.Parse(uRow.Cells["PLAN_INDOUBLE_NUM"].Value.ToString3()) * double.Parse(uRow.Cells["WEIGHT_M"].Value.ToString3());
}
}
planNum.Value = a;
actualNum.Value = a;
planWeight.Value = b;
actualWeight.Value = b;
//下面判定信息
DataTable dt2 = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmFeedLoad.doQueryApplyData", new Object[] { judgeStoveNo, jugdeApplyCode, plineCode }, this.ob);
GridHelper.CopyDataToDatatable(dt2, this.dataTable3, true);
GridHelper.RefreshAndAutoSize(this.ultraGrid3);
//ChangeGrid1Color();
}
private void ultraGrid2_CellChange(object sender, CellEventArgs e)
{
e.Cell.Row.Update();
int a = 0;
double b = 0.0;
if (ultraGrid2.Rows.Count > 0)
{
foreach (UltraGridRow uRow in ultraGrid2.Rows)
{
a += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) * int.Parse(uRow.Cells["CUT_NUM_GP"].Value.ToString3());
b += int.Parse(uRow.Cells["ACT_COUNT"].Value.ToString3()) * double.Parse(uRow.Cells["PLAN_INDOUBLE_WT"].Value.ToString3()) / int.Parse(uRow.Cells["PLAN_INDOUBLE_NUM"].Value.ToString3());
}
}
actualNum.Value = a;
actualWeight.Value = b;
}
private void chkLotNo_CheckedChanged(object sender, EventArgs e)
{
if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; }
if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; }
if (chkFEED_HEAT_NO.Checked) { ultraFEED_HEAT_NO.Enabled = true; } else { ultraFEED_HEAT_NO.Enabled = false; }
if (ultraIsLoad.Checked)
{
StartTime.Visible = true;
label1.Visible = true;
EndTime.Visible = true;
}
else
{
StartTime.Visible = false;
label1.Visible = false;
EndTime.Visible = false;
}
}
#endregion
private void uteLotNo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
doQuery();
}
}
}
}