| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
-
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.LgClassModel;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.LgCommon
- {
- /// <summary>
- /// 实绩管理响应炉号选中事件
- /// </summary>
- public delegate void GetStoveResultDelegate(PlnSteelforfurnaceEntity PlnSteelforfurnaceEntity,bool Refresh);
-
- public partial class ucStoveQuery : UserControl
- {
- public event GetStoveResultDelegate GetStoveResultDelegate;
- private OpeBase Ob;
- private List<string> _plines;
- private string Stove;
- private volatile bool refresh;
- private Task rereshTast;
- private DateTime LastQuery = DateTime.Now;
- private bool Run = true;
-
- private LG_PROCESS _process;
- private object lockHelper = new object();
- public Func<bool> GiveUp =null;
- private bool AskGiveUp = false;
- private UltraGridRow ugActiveRow;
- public ucStoveQuery()
- {
- InitializeComponent();
- }
- private bool _orderByPline = true;
- public bool OrderByPline
- {
- get { return _orderByPline; }
- set
- {
- _orderByPline = value;
- ugPlan.DisplayLayout.Bands[0].Columns["CastNo"].Hidden = _orderByPline;
- }
- }
- public string uceStatusText
- {
- get
- {
- return uceStatus.Text;
- }
- set { uceStatus.Text = value; }
- }
- public void Init(OpeBase Ob,List<string> Plines,LG_PROCESS process)
- {
- this.Ob = Ob;
- _plines = Plines;
- _process = process;
- InitDropDowList();
- dtpStart.Value = DateTime.Now.AddDays(-1);
- dtpEnd.Value = DateTime.Now.AddDays(1);
- QueryStovePlan();
- ClsControlPack.RefreshAndAutoSize(ugPlan);
- GoNext();
- rereshTast = new Task(RereshTask);
- rereshTast.Start();
- }
- public void RereshTask()
- {
- while (Run)
- {
- try
- {
- Thread.Sleep(2000);
- if (cbx_AutoRefresh==null) break;
-
- if (!cbx_AutoRefresh.Checked) continue;
- TimeSpan timeSpan = DateTime.Now - LastQuery;
- if(timeSpan.Seconds<10) continue;
- if (AskGiveUp) continue;
- QueryStovePlan();
-
- }
- catch (Exception)
- {
-
- }
- }
- }
-
-
- // 刷新炉次信息
- /// <summary>
- /// 刷新炉次信息
- /// </summary>
- public void QueryStovePlan()
- {
- /*lock (lockHelper)
- {*/
- try{
- LastQuery = DateTime.Now;
- var status = uceStatus.CheckedItems.Select(p => p.DataValue.ToString()).ToList();
- if (!chbStatus.Checked || !status.Any()) status = new List<string>(){"10","20","30","40"};
-
- var datas =
- EntityHelper.GetData<PlnSteelforfurnaceEntity>(
- "Core.LgMes.Server.LgDeviceManager.PerformanceManage.SelectPlnSteelforfurnaceEntity",
- new[]
- {
- chbStove.Checked?Edt_StoveNo.Text:"",
- _plines,
- !chbGrade.Checked || cbEdt_Steel.SelectedItem==null?"": cbEdt_Steel.SelectedItem.DataValue,
- status,
- _process,
- chbStart.Checked? dtpStart.Value.ToString("yyyyMMdd"):"",
- chbEnd.Checked? dtpEnd.Value.ToString("yyyyMMdd"):"",
- OrderByPline
- }, Ob);
- ClsControlPack.SaftRefreshUI(ugPlan, () =>
- {
- plnSteelforfurnaceEntityBindingSource.DataSource = datas;
-
- });
-
- }
- catch (Exception ex)
- {
- // ignored
- }
- /* }*/
- }
- #region 初始化
- public void InitDropDowList()
- {
- var vlistGradeCode = ClsBusinessPack.GetValuelistSteel(Ob);
- cbEdt_Steel.ValueList = vlistGradeCode;
- var list = ClsBusinessPack.GetStatus();
- ClsControlPack.SetGridValuelist(ref ugPlan, "Status", ref list);
- }
- #endregion
- #region 事件
- private void btnQuery_Click(object sender, EventArgs e)
- {
- QueryStovePlan();
- }
- public void GoNext()
- {
- Stove = "";
- ugPlan.ActiveRow = ugPlan.Rows.AsEnumerable().Where(p =>
- {
- var row = p.ListObject as PlnSteelforfurnaceEntity;
- if (row != null)
- {
- int HeatState = 0;
- int CurrentState = ClsBusinessPack.GetHeatState(_process);
- int.TryParse(row.HeatState, out HeatState);
- if ((HeatState <= CurrentState) || row.Status == "10")
- return true;
- }
- return false;
- }).FirstOrDefault();
- if (ugPlan.ActiveRow!=null) ugPlan.Rows[ugPlan.ActiveRow.Index].Activate();
-
- ugPlan_AfterRowActivate(null, null);
- }
- private void cbx_AutoRefresh_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- btnQuery.Enabled = !cbx_AutoRefresh.Checked;
- cbEdt_Steel.Enabled = Edt_StoveNo.Enabled = !cbx_AutoRefresh.Checked;
- uceStatus.Enabled = Edt_StoveNo.Enabled = !cbx_AutoRefresh.Checked;
- dtpStart.Enabled = Edt_StoveNo.Enabled = !cbx_AutoRefresh.Checked;
- dtpEnd.Enabled = Edt_StoveNo.Enabled = !cbx_AutoRefresh.Checked;
- }
- catch
- {
- // ignored
- }
- }
- private void Edt_HeatNo_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- try
- {
- if (cbx_AutoRefresh.Checked) return;
- if (e.Button.Key.ToUpper().Equals("CLEAR".ToUpper()))
- {
- if (!string.IsNullOrEmpty(Edt_StoveNo.Text.Trim()))
- {
- Edt_StoveNo.Tag = Edt_StoveNo.Text.Trim();
- Edt_StoveNo.Clear();
- }
- else if (Edt_StoveNo.Tag != null) Edt_StoveNo.Text = Convert.ToString(Edt_StoveNo.Tag);
- }
- else if (e.Button.Key.ToUpper().Equals("EDIT".ToUpper()))
- {
- var frm = new frmHeatNoEditor {InputText = Edt_StoveNo.Text.Trim()};
- frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
- if (frm.ShowDialog() == DialogResult.OK)
- Edt_StoveNo.Text = frm.InputText;
- }
- }
- catch
- {
- // ignored
- }
- }
- #endregion
- private void ucStoveQuery_Load(object sender, EventArgs e)
- {
- ClsControlPack.SetReadOnly(ugPlan);
- EntityHelper.ShowGridCaption<PlnSteelforfurnaceEntity>(ugPlan.DisplayLayout.Bands[0]);
- ValueList vlist = ClsBusinessPack.GetHeatStatus();
- ClsControlPack.SetGridValuelist(ref ugPlan, "HEATSTATE", ref vlist);
- ugPlan.DisplayLayout.Bands[0].Columns["CastNo"].MergedCellStyle = MergedCellStyle.Always;
- }
-
- private void ugPlan_AfterRowActivate(object sender, EventArgs e)
- {
- // if (Activing) return;
- /* if (bGiveUp)
- {
- ugPlan.ActiveRow = ugActiveRow;
- bGiveUp = false;
- // Activing = false;
- return;
- }*/
- if (refresh) return;
-
- if (GetStoveResultDelegate != null && ugPlan.ActiveRow != null)
- {
-
- var plnSteelforfurnaceEntity = ugPlan.ActiveRow.ListObject as PlnSteelforfurnaceEntity;
- if (plnSteelforfurnaceEntity != null )
- {
- if ( plnSteelforfurnaceEntity.StoveNo!=Stove && Stove != "" && GiveUp != null )
- {
- //询问是否放弃编辑的时候 不刷新界面
- AskGiveUp = true;
- if (!GiveUp())
- {
- //放弃更改炉计划 则聚焦原炉计划
- ugPlan.ActiveRow = ugPlan.Rows.AsEnumerable().Where(p =>
- {
- var row = p.ListObject as PlnSteelforfurnaceEntity;
- if (row != null && row.StoveNo == Stove)
- {
- return true;
- }
- return false;
- }).FirstOrDefault();
- AskGiveUp = false;
- return;
- }
- }
- GetStoveResultDelegate(plnSteelforfurnaceEntity, plnSteelforfurnaceEntity.StoveNo == Stove);
- Stove = plnSteelforfurnaceEntity.StoveNo;
- AskGiveUp = false;
- }
- }
- //Activing = false;
- }
-
- private void ugPlan_InitializeRow(object sender, InitializeRowEventArgs e)
- {
-
- PlnSteelforfurnaceEntity plnSteelforfurnaceEntity = e.Row.ListObject as PlnSteelforfurnaceEntity;
- if (plnSteelforfurnaceEntity==null) return;
- switch (_process)
- {
- case LG_PROCESS.EAF:
- if (plnSteelforfurnaceEntity.BofStarttime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.BofStarttime) )
- {
-
- e.Row.Appearance.ResetBackColor();
- }
- else if (plnSteelforfurnaceEntity.BofEndtime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.BofEndtime))
- {
- e.Row.Appearance.BackColor = Color.LightGreen;
- }
- else
- {
- e.Row.Appearance.BackColor = Color.Yellow;
- }
- break;
- case LG_PROCESS.LF:
- if (plnSteelforfurnaceEntity.LfsStarttime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.LfsStarttime))
- {
- e.Row.Appearance.ResetBackColor();
- }
- else if (plnSteelforfurnaceEntity.LfsEndtime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.LfsEndtime))
- {
- e.Row.Appearance.BackColor = Color.LightGreen;
- }
- else
- {
- e.Row.Appearance.BackColor = Color.Yellow;
- }
- break;
- case LG_PROCESS.VD:
- if (plnSteelforfurnaceEntity.VdStarttime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.VdStarttime))
- {
- e.Row.Appearance.ResetBackColor();
- }
- else if (plnSteelforfurnaceEntity.VdEndtime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.VdEndtime))
- {
- e.Row.Appearance.BackColor = Color.LightGreen;
- }
- else
- {
- e.Row.Appearance.BackColor = Color.Yellow;
- }
- break;
- case LG_PROCESS.RH:
- if (plnSteelforfurnaceEntity.RhStarttime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.RhStarttime))
- {
- e.Row.Appearance.ResetBackColor();
- }
- else if (plnSteelforfurnaceEntity.RhEndtime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.RhEndtime))
- {
- e.Row.Appearance.BackColor = Color.LightGreen;
- }
- else
- {
- e.Row.Appearance.BackColor = Color.Yellow;
- }
- break;
- case LG_PROCESS.CCM:
- if (plnSteelforfurnaceEntity.CcmStarttime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.CcmStarttime))
- {
- e.Row.Appearance.ResetBackColor();
- }
- else if (plnSteelforfurnaceEntity.CcmEndtime == null || string.IsNullOrEmpty(plnSteelforfurnaceEntity.CcmEndtime))
- {
- e.Row.Appearance.BackColor = Color.LightGreen;
- }
- else
- {
- e.Row.Appearance.BackColor = Color.Yellow;
- }
- break;
-
- }
-
-
- }
-
- }
- }
|