| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.LgResMgt.Mcms.entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.LgResMgt.Mcms
- {
- public partial class FrmBuyCheck : FrmBase
- {
- public FrmBuyCheck()
- {
- InitializeComponent();
- buyGpCheckResultEntityBindingSource.DataSource = new List<BuyGpCheckResultEntity>(){new BuyGpCheckResultEntity()};
- buyGpCheckResultDEntityBindingSource.DataSource = new List<BuyGpCheckResultDEntity>() { new BuyGpCheckResultDEntity() };
- EntityHelper.ShowGridCaption<CmmBlankPredictionEntity>(planGrid.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<BuyGpCheckResultEntity>(ugResult.DisplayLayout.Bands[0]);
- }
- private List<BuyGpCheckResultFEntity> listFail = new List<BuyGpCheckResultFEntity>();
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ugData.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
- ugData.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- var dt = ServerHelper.GetData("com.steering.Mcms.BuyCheckServer.doQueryName",
- new object[] { }, ob);
- if ((dt != null) && (dt.Rows.Count > 0))
- {
- uceUserName.DataSource = dt;
- uceUserName.ValueMember = "USER_NAME";
- uceUserName.DisplayMember = "USER_NAME";
- }
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "DoQuery":
- Query();
- break;
- case "DoAdd":
- DoAdd();
- break;
- case "DoDelete":
- DoDelete();
- break;
- case "DoBeside":
- DoBeside();
- break;
- case "CelBeside":
- DoCelBeside();
- break;
- case "DoClose":
- Close();
- break;
- }
- }
- private void DoDelete()
- {
- if (planGrid.ActiveRow == null) return;
- if (ugResult.ActiveRow == null)
- {
- MessageBox.Show("清选择需求要删除的记录");
- return;
- }
- BuyGpCheckResultEntity entity = ugResult.ActiveRow.ListObject as BuyGpCheckResultEntity;
- var blank = planGrid.ActiveRow.ListObject as CmmBlankPredictionEntity;
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyCheckServer";
- ccp.MethodName = "DoDelete";
- ccp.ServerParams = new object[]
- {
- JSONFormat.Format(entity),
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功!"))
- {
- if (!string.IsNullOrEmpty(blank.ReportPath))
- {
- try
- {
- FileHelper.Delete(entity.ReportPath);
- ServerHelper.SetData("com.steering.Mcms.BlankPredictionServer.UpdatePath",
- new object[] { "", entity.PredictionId }, ob);
- }
- catch (Exception)
- {
- MessageUtil.ShowTips("报告删除失败!");
- }
- }
- Query();
- }
-
- }
- }
- private void DoCelBeside()
- {
- if (planGrid.ActiveRow == null) return;
- CmmBlankPredictionEntity entity = planGrid.ActiveRow.ListObject as CmmBlankPredictionEntity;
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyCheckServer";
- ccp.MethodName = "DoCelBeside";
- ccp.ServerParams = new object[]
- {
- JSONFormat.Format(entity),
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功!"))
- Query();
- }
- }
- private void DoBeside()
- {
- if(planGrid.ActiveRow==null) return;
- CmmBlankPredictionEntity entity = planGrid.ActiveRow.ListObject as CmmBlankPredictionEntity;
- Upload(entity, false);
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyCheckServer";
- ccp.MethodName = "DoBeside";
- ccp.ServerParams = new object[]
- {
- JSONFormat.Format(entity),
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功!"))
- Query();
- }
- }
- private void DoAdd()
- {
- if (planGrid.ActiveRow == null) return;
- matGrid.UpdateData();
- ugData.UpdateData();
- List<BuyGpCheckResultEntity> list =
- buyGpCheckResultEntityBindingSource.DataSource as List<BuyGpCheckResultEntity>;
- List<BuyGpCheckResultDEntity> listd =
- buyGpCheckResultDEntityBindingSource.DataSource as List<BuyGpCheckResultDEntity>;
- if(listd==null) listd = new List<BuyGpCheckResultDEntity>();
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyCheckServer";
- ccp.MethodName = "DoAdd";
- ccp.ServerParams = new object[]
- {
- JSONFormat.Format(list[0]), listd.Select(JSONFormat.Format).ToList(),listFail.Select(JSONFormat.Format).ToList()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功"))
- Query();
- }
- }
- private void Query()
- {
- var dic = new Dictionary<string, object>();
- if (chkJudgeStove.Checked) dic.Add("judgeStoveNoD", txtJudgeStove.Text);
- if (chkPound.Checked) dic.Add("isPound","1");
- if (chkShippersName.Checked) dic.Add("shippersName", uteShippersName.Text);
- dic.Add("checkFlag", ultraOptionSet2.Value.ToString2());
- cmmBlankPredictionEntityBindingSource.DataSource = EntityHelper.GetData<CmmBlankPredictionEntity>(
- "com.steering.Mcms.BlankPredictionServer.doQuery",
- new object[] { dic },
- ob).OrderBy(p=>p.JudgeStoveNo).ToList();
- Comm.RefreshAndAutoSize(planGrid, new string[] { "ReportPath" });
- }
- private void planGrid_AfterRowActivate(object sender, EventArgs e)
- {
- buyGpCheckResultDEntityBindingSource.Clear();
- CmmBlankPredictionEntity row = planGrid.ActiveRow.ListObject as CmmBlankPredictionEntity;
- if(row==null) return;
- var proList = QueryResult(row.PredictionId);
- decimal total = row.PlanNum ?? 0;
- decimal addNum = proList != null && proList.Any()
- ? proList.Where(p => p.ProNum != null).Select(p => (decimal) p.ProNum).Sum()
- : 0;
- decimal proNum = total - addNum;
- if (proNum <= 0) proNum = 0;
- decimal check = 0;
- if (proNum > 0)
- {
- check = decimal.Parse(Math.Ceiling(proNum / 5).ToString3());
- }
- buyGpCheckResultEntityBindingSource.DataSource = new List<BuyGpCheckResultEntity>()
- {
- new BuyGpCheckResultEntity()
- {
- ActDimater = "Φ" + row.ActDimater + "*" + row.ActLen + "mm",
- JudgeStoveNo = row.JudgeStoveNo,
- ProNum =proNum,
- CheckNum = check,
- PassNum = proNum,
- UnpassNum = 0,
- Steelcode = row.Gradecode,
- Steelname = row.Gradename,
- ProShift = this.UserInfo.GetUserOrder(),
- ProGroup = this.UserInfo.GetUserGroup(),
- ProUser = ugData.Rows[0].Cells["ProUser"].Value.ToString2(),
- ProTime = DateTime.Now.ToString("yyyy-MM-dd"),
- PredictionId = row.PredictionId,
- Standard = row.Standard
- }
- };
- listFail = new List<BuyGpCheckResultFEntity>();
- }
- private List<BuyGpCheckResultEntity> QueryResult(string id)
- {
- var dic = new Dictionary<string, object>();
- dic.Add("predictionId", id);
- List<BuyGpCheckResultEntity> proList = EntityHelper.GetData<BuyGpCheckResultEntity>(
- "com.steering.Mcms.BuyCheckServer.doQuery",
- new object[] {dic},
- ob);
- bindingSource1.DataSource = proList;
- Comm.RefreshAndAutoSize(ugResult, new string[] {"ReportPath"});
- return proList;
- }
- private void matGrid_ClickCell(object sender, ClickCellEventArgs e)
- {
- if (matGrid.ActiveRow.IsAddRow)
- {
- int a = matGrid.ActiveCell.Row.Index;
- int b = matGrid.ActiveCell.Column.Index;
- matGrid.Rows.Band.AddNew();
- matGrid.Rows[a].Cells[b].Activated = true;
- matGrid.PerformAction(UltraGridAction.EnterEditMode);
- matGrid.PerformAction(UltraGridAction.EnterEditMode);
- }
- }
- private void uteUnpass_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- using (var FrmUnpassEdit = new FrmUnpassEdit(ob, listFail))
- {
- if (FrmUnpassEdit.ShowDialog() == DialogResult.OK)
- {
- listFail = FrmUnpassEdit.UnPassList;
- ugData.Rows[0].Cells["UnpassNum"].Value = listFail.Any() ?listFail.Select(p => p.FailNum).Sum():0;
- ugData_CellChange(null, null);
- }
-
-
- }
- }
- private void ugData_CellChange(object sender, CellEventArgs e)
- {
- decimal total = 0;
- decimal unPass = 0;
- if (decimal.TryParse(ugData.Rows[0].Cells["ProNum"].Text, out total) && decimal.TryParse(ugData.Rows[0].Cells["UnpassNum"].Text, out unPass))
- {
- decimal pass = total - unPass;
- ugData.Rows[0].Cells["PassNum"].Value = pass < 0 ? 0 : pass;
- }
- }
- private void utUpLoad1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
-
- }
- private void Upload(CmmBlankPredictionEntity entity, bool showMsg = true)
- {
- string strurl;
- // strurl = "http://172.16.2.145/WebReport/ReportServer?reportlet=RepGpPipeRecordTH.cpt&format=pdf&PREDICTION_ID=" + entity.PredictionId;
- strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpPipeRecordTH.cpt&format=pdf&PREDICTION_ID=" + entity.PredictionId;
- var webClient = new WebClient();
- var listPdf = new List<FileBean>();
- var date = DateTime.Now.ToString("yyyyMMdd");
- var filePathNew = ""; //报告目录
- var reportNo = ""; //报告编号
- filePathNew = "BuyCheck/" + entity.JudgeStoveNo + "/";
- reportNo = entity.PredictionId;
- var pdf = webClient.DownloadData(strurl);
- var fileBean = new FileBean();
- fileBean.setFile(pdf);
- fileBean.setFileName(reportNo + ".pdf");
- fileBean.setPathName(filePathNew);
- listPdf.Add(fileBean);
- webClient.Dispose();
- var a = FileHelper.Upload(listPdf);
- if (a)
- {
- ServerHelper.SetData("com.steering.Mcms.BlankPredictionServer.UpdatePath",
- new object[] { filePathNew + reportNo + ".pdf", entity.PredictionId }, ob);
- if (showMsg)
- {
- MessageUtil.ShowTips("上传报告成功!");
- Query();
- }
- }
- }
- private void ugResult_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- var BuyGpCheckResultEntity = e.Row.ListObject as BuyGpCheckResultEntity;
- e.Row.Cells["ReportPath"].Appearance.BackColor = string.IsNullOrEmpty(BuyGpCheckResultEntity.ReportPath)
- ? Color.Red
- : Color.LightGreen;
- }
- private void uteUpload2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- var entity = planGrid.ActiveRow.ListObject as CmmBlankPredictionEntity;
- var strurl = "";
- if (e.Button.Key == "VIEW")
- {
- //strurl =
- // "http://172.16.2.145/WebReport/ReportServer?reportlet=RepGpPipeRecordTH.cpt&op=view&PREDICTION_ID=" +
- // entity.PredictionId;
- strurl =
- "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpPipeRecordTH.cpt&op=view&PREDICTION_ID=" +
- entity.PredictionId;
- var fre = new FrmRepExcel(ob, strurl);
- fre.AutoSize = true;
- fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
- Screen.PrimaryScreen.WorkingArea.Height);
- fre.WindowState = FormWindowState.Maximized;
- fre.Show();
- }
- else if (e.Button.Key == "UPLOAD")
- {
- Upload(entity);
- }
- else
- {
- MessageUtil.ShowError("系统生成PDF失败,请稍后再试!");
- }
- }
- private void matGrid_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["SurfaceQuality"].Value = "合格";
- e.Row.Cells["Identification"].Value = "合格";
- }
- }
- }
|