| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Mcp.Treatment.Entity;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- namespace Core.StlMes.Client.Mcp.Treatment.Report
- {
- public partial class FrmHttRunTimeRpt : FrmBase
- {
- public FrmHttRunTimeRpt()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- private string balMonth = "";
- private string[] plineCodes = null;
- private string[] uceFactorys = null;
- private string ProcessCode = "";
- private List<YdmHttInitialEntityPlus> CurrentlistEntity;
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ProcessCode = this.CustomInfo.ToString2();
- if (ProcessCode == "") ProcessCode = "F";
- plineCodes = comm.InitDropPlinePower(ProcessCode, cboPline, this.ValidDataPurviewIds, ob);
- uceFactorys = comm.InitDroProStation(ProcessCode, uceFactory , this.ValidDataPurviewIds, ob);
- if (plineCodes == null || plineCodes.Length <= 0)
- {
- MessageBox.Show("无数据权限!");
- this.Close();
- }
- if (uceFactorys == null || uceFactorys.Length <= 0)
- {
- MessageBox.Show("无数据权限!");
- this.Close();
- }
-
- if (ProcessCode != "G")
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Groups["JG"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Groups["S0"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Groups["S1"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Groups["S2"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Groups["XH"].Hidden = true;
-
- chkType.Visible = false;
- uceType.Visible = false;
- }
-
- EntityHelper.ShowGridCaption<YdmHttInitialEntityPlus>(ultraGrid1.DisplayLayout.Bands[0]);
- comm.RefreshAndAutoSizeWithHeader(ultraGrid1);
- dtBathYear.Value = DateTime.Now;
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- Query();
- break;
- case "Export":
- Export();
- break;
- case "insertTal":
- insertTal();
- break;
- case "cancelInsertTal":
- cancelinsertTal();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- private void insertTal()
- {
- var data = ydmHttInitialEntityPlusBindingSource.DataSource as List<YdmHttInitialEntityPlus>;
- data = data.Where(p => p.EndNum > 0).ToList();
- if (!data.Any())
- {
- MessageBox.Show("无期末,无需结转");
- return;
- }
- DateTime dt = DateTime.ParseExact( data[0].BalYearMonth, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
-
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.common.FrmHttRunTimeRpt";
- ccp.MethodName = "insertTal";
- ccp.ServerParams = new object[]
- {
- dt.AddMonths(1).ToString("yyyyMM"),
- dt.AddMonths(2).ToString("yyyyMM"),
- data.Select(JSONFormat.Format).ToList(),
- data.Select(p=>p.PlineCode).Distinct().ToArray()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("结转成功!"))
- {
- Query();
- }
- }
- }
- private void cancelinsertTal()
- {
- var data = ydmHttInitialEntityPlusBindingSource.DataSource as List<YdmHttInitialEntityPlus>;
- data = data.Where(p => p.EndNum > 0).ToList();
- if (!data.Any())
- {
- MessageBox.Show("无数据,无法撤销结转");
- }
- DateTime dt = DateTime.ParseExact(data[0].BalYearMonth, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.common.FrmHttRunTimeRpt";
- ccp.MethodName = "cancelinsertTal";
- ccp.ServerParams = new object[]
- {
- dt.AddMonths(1).ToString("yyyyMM"),
- dt.AddMonths(2).ToString("yyyyMM"),
- data.Select(p=>p.PlineCode).Distinct().ToArray()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("撤销成功!"))
- {
- Query();
- }
- }
- }
- private void Export()
- {
- string title = "";
- if (ucePlineCode.Checked && cboPline.CheckedItems.Count > 0)
- {
- title += cboPline.Text;
- }
- else if (chkFactory.Checked && uceFactory.SelectedIndex >= 0)
- {
- title += uceFactory.Text;
- }
- else
- {
- title += (ProcessCode == "F" ? "热处理" : ProcessCode=="E"?"镦拔扩": "加工线");
- }
- if (chkQc.Checked)
- {
- title += "期初";
- }
- else
- {
- title += "收发存一览表";
- }
- GridHelper.ulGridToExcel(ultraGrid1, title);
-
- }
- private void Query()
- {
- WaitingForm2 wf = new WaitingForm2("正在查询,请稍候....");
- try
- {
- this.Cursor = Cursors.WaitCursor;
- CurrentlistEntity =
- EntityHelper.GetData<YdmHttInitialEntityPlus>(
- ProcessCode.Equals("F")
- ? "com.steering.mes.mcp.common.FrmHttRunTimeRpt.doQueryHtt"
- :ProcessCode.Equals("G")?
- "com.steering.mes.mcp.common.FrmHttRunTimeRpt.doQueryMch"
- : "com.steering.mes.mcp.common.FrmHttRunTimeRpt.doQueryVrp",
- new object[]
- {
- dtBathYear.Value.ToString("yyyyMM"),
- dtBathYear.Value.AddMonths(1).ToString("yyyyMM"),
- ucePlineCode.Checked && cboPline.CheckedItems.Count > 0
- ? cboPline.CheckedItems.Select(p => p.DataValue.ToString()).ToArray()
- : plineCodes, //uceFactory
- chkFactory.Checked && uceFactory.CheckedItems.Count >= 0
- ? uceFactory.CheckedItems.Select(p => p.DataValue.ToString()).ToArray()
- : uceFactorys,
- chkType.Checked && uceType.SelectedIndex >= 0
- ? uceType.SelectedItem.DataValue.ToString()
- : "",
- uceJudgeStove.Checked?txtJudgeStove.Text:""
- }, ob);
- ShowData();
- }
- catch (Exception)
- {
-
- }
- finally
- {
- wf.Close();
- this.Cursor = Cursors.Default;
- }
-
- }
- private void ShowData()
- {
- if (CurrentlistEntity == null) return;
- List<YdmHttInitialEntityPlus> NewList;
- if (chkQc.Checked)
- {
- NewList = CurrentlistEntity.Where(p => p.ActCount > 0).ToList();
- foreach (var ultraGridGroup in ultraGrid1.DisplayLayout.Bands[0].Groups)
- {
- if (ProcessCode != "G" && (ultraGridGroup.Key == "JG" || ultraGridGroup.Key == "S0" || ultraGridGroup.Key == "S1" || ultraGridGroup.Key == "S2" || ultraGridGroup.Key == "XH") ) continue;
- if (ultraGridGroup.Key != "QC") ultraGridGroup.Hidden = true;
- }
- }
- else
- {
- NewList = CurrentlistEntity;
- foreach (var ultraGridGroup in ultraGrid1.DisplayLayout.Bands[0].Groups)
- {
- if (ProcessCode != "G" && (ultraGridGroup.Key == "JG" || ultraGridGroup.Key == "S0" || ultraGridGroup.Key == "S1" || ultraGridGroup.Key == "S2" || ultraGridGroup.Key == "XH")) continue;
- if (ultraGridGroup.Key != "QC") ultraGridGroup.Hidden = false;
- }
- }
- if (checkShowJudge.Checked)
- {
- if (ProcessCode == "F")
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = true;
- }
-
- else
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = false;
- }
- ultraGrid1.DisplayLayout.Bands[0].Columns["WatingDecisionMemo"].Hidden = false;
- ultraGrid1.DisplayLayout.Bands[0].Columns["JudgeStoveNo"].Hidden = false;
- ultraGrid1.DisplayLayout.Bands[0].Columns["ProOrderNo"].Hidden = false;
- //ultraGrid1.DisplayLayout.Bands[0].Groups["zlGroup"].Hidden = false;
- }
- else if (ProcessCode == "E")
- {
- ultraGrid1.DisplayLayout.Bands[0].Groups["销售合计"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Groups["差值合计"].Hidden = true;
- }
- else
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Columns["WatingDecisionMemo"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Columns["JudgeStoveNo"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Columns["ProOrderNo"].Hidden = true;
- // ultraGrid1.DisplayLayout.Bands[0].Groups["zlGroup"].Hidden = true;
- NewList = NewList.GroupBy(p => new
- {
- p.BalYearMonth,
- p.Dimater,
- p.Height,
- p.Gradecode,
- p.Gradename,
- p.Produccode,
- p.Producname,
- p.Steelcode,
- p.Steelname,
- p.ModelCode,
- p.ModelDesc,
- p.PlineCode,
- p.PlineName
-
- }
- ).Select(p => new YdmHttInitialEntityPlus()
- {
- BalYearMonth = p.Key.BalYearMonth,
- Dimater = p.Key.Dimater,
- Height = p.Key.Height,
- Gradecode = p.Key.Gradecode,
- Gradename = p.Key.Gradename,
- Produccode = p.Key.Produccode,
- Producname = p.Key.Producname,
- Steelcode = p.Key.Steelcode,
- Steelname = p.Key.Steelname,
- ModelCode = p.Key.ModelCode,
- ModelDesc = p.Key.ModelDesc,
- PlineCode = p.Key.PlineCode,
- PlineName = p.Key.PlineName,
- SourceNum0 = p.Sum(q => q.SourceNum0??0),
- SourceNum1 = p.Sum(q => q.SourceNum1 ?? 0),
- SourceNum2 = p.Sum(q => q.SourceNum2 ?? 0),
- SourceNumTotal = p.Sum(q => q.SourceNumTotal ?? 0),
- SourceNumTotal2 = p.Sum(q => q.SourceNumTotal2 ?? 0),
- SourceWt0 = p.Sum(q => q.SourceWt0 ?? 0),
- SourceWt1 = p.Sum(q => q.SourceWt1 ?? 0),
- SourceWt2 = p.Sum(q => q.SourceWt2 ?? 0),
- SourceWtTotal = p.Sum(q => q.SourceWtTotal ?? 0),
- SourceWtTotal2 = p.Sum(q => q.SourceWtTotal2 ?? 0),
- FailNum = p.Sum(q => q.FailNum ?? 0),
- FailWt = p.Sum(q => q.FailWt ?? 0),
- GroupNum = p.Sum(q => q.GroupNum ?? 0),
- GroupWt = p.Sum(q => q.GroupWt ?? 0),
- CouplingNum = p.Sum(q => q.CouplingNum ?? 0),
- CouplingWt = p.Sum(q => q.CouplingWt ?? 0),
- JudgeNum = p.Sum(q => q.JudgeNum ?? 0),
- JudgeWt = p.Sum(q => q.JudgeWt ?? 0),
- EndNum = p.Sum(q => q.EndNum ?? 0),
- EndWt = p.Sum(q => q.EndWt ?? 0),
- ActCount = p.Sum(q => q.ActCount ?? 0),
- ActWeight = p.Sum(q => q.ActWeight ?? 0),
- XsActCount = p.Sum(q => q.XsActCount ?? 0),
- XsActWeight = p.Sum(q => q.XsActWeight ?? 0),
- CzNum = p.Sum(q => q.CzNum ?? 0),
- CzWeight = p.Sum(q => q.CzWeight ?? 0),
- }
- ).ToList();
-
- }
- ydmHttInitialEntityPlusBindingSource.DataSource = NewList;
- comm.RefreshAndAutoSizeWithHeader(ultraGrid1, new string[] { "WatingDecisionMemo" });
- }
- private void checkShowJudge_CheckedChanged(object sender, EventArgs e)
- {
- ShowData();
- }
- private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
- {
- /* YdmHttInitialEntityPlus entity = e.Row.ListObject as YdmHttInitialEntityPlus;
- if (entity.SourceNumTotal + entity.ActCount != entity.FailNum + entity.GroupNum + entity.EndNum + entity.JudgeNum)
- {
- e.Row.Appearance.BackColor = Color.Red;
- }*/
- }
- }
- }
|