private string GeneratePokaYokeXML(List <EntityBatchPWO> pwos, OpenPWO pwo) { string rlt = ""; for (int i = 0; i < pwos.Count; i++) { rlt += string.Format( "<RowSet><Ordinal>{0}</Ordinal>" + "<T102LeafID>{1}</T102LeafID>" + "<T216LeafID>{2}</T216LeafID></RowSet>\n", i + 1, pwos[i].T102LeafID, t216LeafID); } rlt += string.Format( "<RowSet><Ordinal>{0}</Ordinal>" + "<T102LeafID>{1}</T102LeafID>" + "<T216LeafID>{2}</T216LeafID></RowSet>\n", pwos.Count + 1, pwo.T102LeafID, t216LeafID); rlt = string.Format("<Param>\n{0}</Param>", rlt); return(rlt); }
/// <summary> /// 获取生产工单信息 /// </summary> /// <param name="pwoNo">生产工单号</param> /// <returns>OpenPWO</returns> private OpenPWO GetPWOInfoFromPWONo( string pwoNo, out int errCode, out string errText) { string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { OpenPWO rlt = null; List <OpenPWO> openPWOs = new List <OpenPWO>(); IRAPMESClient.Instance.ufn_GetList_OpenPWOsOfALine( IRAPUser.Instance.CommunityID, 134, t134LeafID, IRAPUser.Instance.SysLogID, ref openPWOs, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode == 0) { errCode = -1; errText = string.Format( "没有找到工单号[{0}]的生产工单信息", edtPWONo.Text); foreach (OpenPWO pwo in openPWOs) { if (pwo.PWONo == pwoNo) { errCode = 0; rlt = pwo.Clone(); break; } } } return(rlt); } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }
private void edtPWONo_Validating(object sender, CancelEventArgs e) { if (edtPWONo.Text == "") { data = new EntityBatchPWO(); edtProductNo.Text = ""; edtProductName.Text = ""; edtBatchNo.Text = ""; edtTextureCode.Text = ""; edtQuantity1.Value = 0; edtQuantity2.Value = 0; edtDisplayRemark.Text = ""; e.Cancel = false; return; } string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); foreach (EntityBatchPWO pwo in datas) { if (pwo.PWONo == edtPWONo.Text) { XtraMessageBox.Show( string.Format( "生产工单[{0}]已经存在,不能重复增加!", pwo.PWONo), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtPWONo.Text = ""; e.Cancel = true; return; } } WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; #region 根据输入的工单号查找工单 OpenPWO openPWO = null; openPWO = GetPWOInfoFromPWONo(edtPWONo.Text, out errCode, out errText); if (errCode != 0) { XtraMessageBox.Show( errText, "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtPWONo.Text = ""; e.Cancel = true; return; } #endregion #region 获取当前工单的材质,并校验是否和其它工单的材质一致 string textureCode = GetTextureCodeFromMaterialCode( openPWO.ProductNo, out errCode, out errText); if (errCode != 0) { XtraMessageBox.Show( string.Format( "获取生产工单[{0}]的材质时发生错误:[{1}]", openPWO.PWONo, errText), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtPWONo.Text = ""; e.Cancel = true; return; } foreach (EntityBatchPWO entityPWO in datas) { if (entityPWO.Texture.Substring(0, 3) != textureCode.Substring(0, 3)) { XtraMessageBox.Show( string.Format( "当前工单生产产品的材质是[{0}],无法和其他工单在同一炉中进行生产!", textureCode), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtPWONo.Text = ""; e.Cancel = true; return; } } #endregion #region 调用存储过程校验当前工单的工艺参数是否和其它工单一致 string pokaYokeXML = GeneratePokaYokeXML(datas, openPWO); IRAPMESClient.Instance.usp_PokaYoke_ParamConsistency( IRAPUser.Instance.CommunityID, t131LeafID, pokaYokeXML, IRAPUser.Instance.SysLogID, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { XtraMessageBox.Show( errText, "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtPWONo.Text = ""; e.Cancel = true; return; } #endregion if (data == null) { data = new EntityBatchPWO(); } data.PWONo = openPWO.PWONo; data.T102Code = openPWO.ProductNo; data.T102Name = openPWO.ProductName; data.T102LeafID = openPWO.T102LeafID; data.LotNumber = openPWO.LotNumber; data.Texture = textureCode; edtProductNo.Text = data.T102Code; edtProductName.Text = data.T102Name; edtBatchNo.Text = data.LotNumber; edtTextureCode.Text = data.Texture; } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }
private void RefreshOpenPWOs( int communityID, int resourceTreeID, int leafID, long sysLogID, ref string pwoNo) { string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; List <OpenPWO> pwos = new List <OpenPWO>(); pwoNo = ""; IRAPMESClient.Instance.ufn_GetList_OpenPWOsOfALine( communityID, resourceTreeID, leafID, sysLogID, ref pwos, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode == 0) { List <OpenPWO> openPWOs = new List <OpenPWO>(); int i = 0; foreach (OpenPWO pwo in pwos) { if (i > 1) { break; } if (i == 0 && pwo.PWOStatus == 5) { if (kpi.Tag is LineKPI_BTS) { LineKPI_BTS kpiData = (LineKPI_BTS)kpi.Tag; OpenPWO openPWO = pwo.Clone(); openPWO.ActualQuantity = kpiData.ActualQuantity.DoubleValue; openPWO.ActualStartTime = kpiData.ActualStartTime; openPWO.BTSStatus = kpiData.BTSStatus; pwoNo = kpiData.PWONo; openPWOs.Add(openPWO); i++; } } else { pwo.BTSStatus = -1; openPWOs.Add(pwo.Clone()); i += 2; } } grdOpenPWOs.DataSource = openPWOs; grdvOpenPWOs.BestFitColumns(); } else { grdOpenPWOs.DataSource = null; } } catch (Exception error) { WriteLog.Instance.Write(error.Message, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }