public static void AutoMerge(string invLot, TransactionStamp txs, ReasonCategoryInfo reasonCategory) { //找到相同的INVLot的序號 var lots = LotInfoEx.GetLotListByInvertoryLot(invLot); //排除送過NG的序號 var autoMergeLots = lots.FindAll(p => p.UserDefineColumn01.IsNullOrTrimEmpty()); //利用小工單號確認是否還有QC未檢驗的資料(包含FAI、PQC、PPK) //只要有一張未檢,則代表檢驗未完成,回傳false,反之 var qcFlag = CheckQCInspectionDone(lots[0].WorkOrderLot); //檢查數量是否可以做AUTOMERGE var waitMergeLots = autoMergeLots.FindAll(p => p.Status == "WaitMerge"); if (waitMergeLots.Count == autoMergeLots.Count && qcFlag) { var customizeFunction = new CustomizeFunction(); //取得命名規則 //var naming = customizeFunction.GetNamingRule("SplitLot", txs.UserID, autoMergeLots[0], null); //拆批 var split = SplitLotInfo.CreateSplitLotByLotAndQuantity(autoMergeLots[0].Lot, autoMergeLots[0].WorkOrderLot, 0, 0, txs.CategoryReasonCode, txs.Description); //母批不做結批 var splitIndicator = WIPTxn.SplitIndicator.Create(null, null, null, TerminateBehavior.NoTerminate); WIPTxn.Default.SplitLot(autoMergeLots[0], split, splitIndicator, txs); //更新命名規則 //if (naming.Second.Count > 0) //{ // DBCenter.ExecuteSQL(naming.Second); //} //再取一次批號資訊 var newLot = LotInfo.GetLotByLot(split.Lot); //併批與子單元 List <MergeLotInfo> mergeLotList = new List <MergeLotInfo>(); waitMergeLots.ForEach(mergelot => { var compData = ComponentInfo.GetComponentByComponentID(mergelot.ComponentLot); var mergeLot = MergeLotInfo.GetMergeLotByLotAndQuantity(mergelot.Lot, new List <ComponentInfo>() { compData }, reasonCategory, txs.Description); mergeLotList.Add(mergeLot); }); WIPTransaction.MergeLot(newLot, mergeLotList, txs); //再取一次批號資訊 var newMergeLot = LotInfo.GetLotByLot(split.Lot); //將批號狀態變更為wait WIPTransaction.ModifyLotSystemAttribute(newMergeLot, "STATUS", LotDefaultStatus.Wait.ToCimesString(), txs); //將COMPLOT、PROCESS_EQUIP欄位清空,因為這個時間點這個欄位已經沒意義了 WIPTransaction.ModifyLotSystemAttribute(newMergeLot, "COMPLOT", string.Empty, txs); WIPTransaction.ModifyLotSystemAttribute(newMergeLot, "PROCESS_EQUIP", string.Empty, txs); //Dispatch到下一站 WIPTransaction.DispatchLot(newMergeLot, txs); } }
private LotInfo SplitLot(LotInfo distinctLot, bool isRelative, TransactionStamp txnStamp) { LotInfo lotData = LotInfo.GetLotByLot(distinctLot.Lot); List <SqlAgent> splitLotArchiSQLList = new List <SqlAgent>(); List <ComponentInfo> lsComponentDatas = new List <ComponentInfo>(); if (isRelative) { // 找出相同批號的所有Component _RelativePackingList.FindAll(lot => lot.LotInfo.Lot == lotData.Lot).ForEach(pack => { lsComponentDatas.Add(ComponentInfo.GetComponentByComponentID(pack.ComponentID)); }); } else { // 找出相同批號的所有Component _PackingList.FindAll(lot => lot.LotInfo.Lot == lotData.Lot).ForEach(pack => { lsComponentDatas.Add(ComponentInfo.GetComponentByComponentID(pack.ComponentID)); }); } var generator = NamingIDGenerator.GetRule("SplitLot"); if (generator == null) { //WRN-00411,找不到可產生的序號,請至命名規則維護設定,規則名稱:{0}!!! throw new Exception(TextMessage.Error.T00437("SplitLot")); } var serialData = generator.GenerateNextIDs(1, lotData, new string[] { }, User.Identity.Name); splitLotArchiSQLList = serialData.Second; var splitLotID = serialData.First[0]; var reasonCategoryInfo = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER"); SplitLotInfo splitLotData = SplitLotInfo.CreateSplitLotByLotAndQuantity(lotData.Lot, splitLotID, lsComponentDatas, reasonCategoryInfo, "Pack"); WIPTxn.SplitIndicator splitInd = WIPTxn.SplitIndicator.Create(); // 拆批交易 WIPTxn.Default.SplitLot(lotData, splitLotData, splitInd, txnStamp); //若子單元為自動產生,更新序號至DB if (splitLotArchiSQLList != null && splitLotArchiSQLList.Count > 0) { DBCenter.ExecuteSQL(splitLotArchiSQLList); } return(LotInfo.GetLotByLot(splitLotID)); }
/// <summary> /// 確認此批號是否為COMPONENTID /// </summary> /// <param name="lot"></param> /// <returns></returns> private bool CheckComponentID(string lot) { //確認此批號是否為COMPONENTID var component = ComponentInfo.GetComponentByComponentID(lot); if (component == null) { return(false); } //取得批號資料 var lotData = LotInfoEx.GetLotByLot(component.CurrentLot).ChangeTo <LotInfoEx>(); if (lotData == null) { return(false); } //驗證批號狀態,Wait的批號 if (lotData.Status != LotDefaultStatus.Wait.ToString()) { //狀態為{0},不可執行 throw new Exception(RuleMessage.Error.C10003(lotData.Status)); } //驗證currentRule if (lotData.CurrentRuleName != _ProgramInformationBlock.ProgramRight) { //該批號作業為XXXX,不為此功能,請遵循作業規範 throw new Exception(RuleMessage.Error.C10004(lotData.CurrentRuleName)); } //取得工件序號 var componentDataList = ComponentInfoEx.GetDataByCurrentLot(lotData.Lot); if (componentDataList.Count > 0) { ttbItemSN.Text = componentDataList[0].ComponentID; } //取得送待判原因 var lotDefectData = LotDefectInfoEx.GetDataByLotAndComponentID(lotData.Lot, ttbItemSN.Text); if (lotDefectData != null) { var reason = ReasonInfo.GetReasonByName(lotDefectData.ReasonCode); if (reason == null) { throw new CimesException(RuleMessage.Error.C00051(lotDefectData.ReasonCode)); } //格式:(批號) 原因碼_說明_備註 string defectText = "(" + lotDefectData.Lot + ")"; defectText += " " + lotDefectData.ReasonCode; if (!reason.Description.IsNullOrTrimEmpty()) { defectText += "_" + reason.Description; } if (!lotDefectData.Description.IsNullOrTrimEmpty()) { defectText += "_" + lotDefectData.Description; } ddlJudgeDefect.Items.Add(new ListItem(defectText, lotDefectData.ID)); ddlJudgeDefect_SelectedIndexChanged(null, EventArgs.Empty); } else { //查無送待判原因! throw new Exception(RuleMessage.Error.C10187()); } return(true); }
/// <summary> /// 確定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { #region 確認選擇結果,如果是選擇NG,確認是否有選擇原因碼 string result = ""; if (rdbOK.Checked) { result = "OK"; } else if (rdbNG.Checked) { result = "NG"; //確認是否有選擇原因碼 ddlPQCReasonCode.Must(lblPQCReasonCode); } #endregion TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { #region 更新檢驗主檔[MES_QC_INSP] //取得檢驗主檔資料 var QCInsepctionData = InfoCenter.GetBySID <QCInspectionInfo>(_SelectedQCData.QCInspectionSID).ChangeTo <QCInspectionInfoEx>(); //有選擇原因碼才更新[NG_Category]及[NG_Reason] if (string.IsNullOrEmpty(ddlPQCReasonCode.SelectedValue) == false) { var reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPQCReasonCode.SelectedValue); QCInsepctionData.NG_Category = reason.Category; QCInsepctionData.NG_Reason = reason.Reason; } QCInsepctionData.NG_Description = ttbDescr.Text; QCInsepctionData.Result = result; QCInsepctionData.Status = "Finished"; QCInsepctionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime); #endregion #region 更新自主檢數據內容[CST_EDC_COMP] bool inSpec = true; gvComponentEDC.Rows.LoopDo <GridViewRow>((p, i) => { // 取得TextBox Control var ttbEDC = p.FindControl("ttbEDC") as TextBox; if (ttbEDC.Text.IsNullOrEmpty()) { AjaxFocus(ttbEDC); throw new Exception(TextMessage.Error.T00043(GetUIResource("CenterHoleData"))); } // 是否符合規格判斷 var measureVal = ttbEDC.Text.ToDecimal(); if (measureVal > _SAICenterHole.Remark02.ToDecimal()) { inSpec = false; } if (measureVal < _SAICenterHole.Remark03.ToDecimal()) { inSpec = false; } var lotData = ComponentInfo.GetComponentByComponentID(_SelectedQCData.ComponentLot); // 將量測資料記錄到客製表 var edcCompInfo = InfoCenter.Create <CSTEDCComponentInfo>(); edcCompInfo.ComponentID = _SelectedQCData.ComponentLot; edcCompInfo.Data = measureVal; edcCompInfo.UpSpecification = _SAICenterHole.Remark02.ToDecimal(); edcCompInfo.LowSpecification = _SAICenterHole.Remark03.ToDecimal(); edcCompInfo.INSPEC = inSpec == true ? "OK" : "NG"; edcCompInfo.Lot = (lotData == null) ? "" : lotData.CurrentLot; edcCompInfo["LINKSID"] = txnStamp.LinkSID; edcCompInfo["PARAMETER"] = "SC" + (i + 1).ToString(); edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); }); #endregion #region 更新機台狀態及更新檢驗單對應的批號資料 //如果選擇結果為NG時,則更新機台狀態及更新檢驗單對應的批號資料 if (rdbNG.Checked) { //取得機台狀態資料 var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("DOWN"); var equipData = EquipmentInfo.GetEquipmentByName(_SelectedQCData.EquipmentName); //如果機台狀態為IDLE,則變更狀態為DOWN if (equipData.CurrentState == "IDLE") { //更新機台狀態 EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp); } else { //如果機台狀態不為IDLE,則註記機台[USERDEFINECOL01]為Y EMSTransaction.ModifyEquipmentSystemAttribute(equipData, "USERDEFINECOL01", "Y", txnStamp); } //上一次的檢驗單號資料 QCInspectionInfoEx previousInspectionData = null; //依據機台及料號查詢,然後用建立時間逆排序,找出所有FAI及MPQC的檢驗單號資料 var QCDataList = QCInspectionInfoEx.GetInspDataListByEquipmentAndDevice(QCInsepctionData.EquipmentName, QCInsepctionData.DeviceName); //如果筆數大於1,則目前檢驗單號的索引值 if (QCDataList.Count > 1) { //找出目前檢驗單號的索引值 var NGIndex = QCDataList.FindIndex(p => p.InspectionNo == QCInsepctionData.InspectionNo); //如果找到的索引值不是最後一筆的話,則找出上一次的檢驗單號資料 if (NGIndex != (QCDataList.Count - 1)) { //找出上一次的檢驗單號資料 previousInspectionData = QCDataList[NGIndex + 1]; } } //取得目前檢驗單號的批號子單元資料 var componentList = ComponentInfoEx.GetDataByInspectionNo(QCInsepctionData.InspectionNo); componentList.ForEach(component => { //取得批號資料 var lotData = LotInfo.GetLotByLot(component.CurrentLot); //更新欄位[PQCNGFLAG] WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp); //更新欄位[PQCNGNO] WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp); }); if (previousInspectionData != null) { //取得上一次檢驗單號的批號子單元資料 var previousComponentList = ComponentInfoEx.GetDataByInspectionNo(previousInspectionData.InspectionNo); //取得不需要註記的ComponentID var passInspectionDataList = QCInspectionObjectInfo.GetInspectionObjects(previousInspectionData); previousComponentList.ForEach(component => { //確認是否為不需要註記的ComponentID if (passInspectionDataList.FindIndex(p => p.ItemName1 == component.ComponentID) == -1) { //取得批號資料 var lotData = LotInfo.GetLotByLot(component.CurrentLot); //更新欄位[PQCNGFLAG] WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp); //更新欄位[PQCNGNO] WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp); } }); } } #endregion cts.Complete(); } ClearField(); AjaxFocus(ttbLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 鍛造出站有不良數量直接拆批及送待判工作站 /// </summary> /// <param name="txnLotData">機加批號</param> /// <param name="defectGridDataList">不良清單</param> /// <param name="txnStamp"></param> public void SplitDefectLotList(LotInfoEx txnLotData, List <DefectGridData> defectGridDataList, TransactionStamp txnStamp) { //待判工作站點名稱 string judgeOperationName = ""; //確認是否有不良清單,如果有不良清單的話,則要取得待判工作站資料 if (defectGridDataList.Count > 0) { //在系統資料維護裡,取得此批號對應製程(CPC/CPF)的待判工作站名稱 List <WpcExClassItemInfo> operationList = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIJudgeOperation"); WpcExClassItemInfo judgeOperationData = operationList.Find(p => p.Remark01 == txnLotData.Process); if (judgeOperationData == null) { //找不到待判站資訊,請至系統資料維護增加資訊,屬性:{0} throw new Exception(RuleMessage.Error.C10014(txnLotData.Process)); } //取得待判工作站名稱 judgeOperationName = judgeOperationData.Remark02; } //處理不良批號 defectGridDataList.ForEach(defectGridData => { //取得原因碼資訊 var reasonData = InfoCenter.GetBySID <ReasonCategoryInfo>(defectGridData.DefectID); //取得批號子單元資訊 var component = ComponentInfo.GetComponentByComponentID(defectGridData.ComponentID); //取得不良子批批號名稱 var splitLotNaming = GetNamingRule("SplitLot", txnStamp.UserID, txnLotData); //批號拆子批 var splitLot = SplitLotInfo.CreateSplitLotByLotAndQuantity(txnLotData.Lot, splitLotNaming.First[0], new List <ComponentInfo>() { component }, reasonData, reasonData.Description); WIPTxn.Default.SplitLot(txnLotData, splitLot, WIPTxn.SplitIndicator.Create(null, null, null, TerminateBehavior.NoTerminate), txnStamp); if (splitLotNaming.Second != null && splitLotNaming.Second.Count != 0) { DBCenter.ExecuteSQL(splitLotNaming.Second); } //註記不良 var compDefect = ComponentDefectObject.Create(component, component.ComponentQuantity, 0, reasonData, defectGridData.DefectDesc); WIPTransaction.DefectComponent(splitLot, new List <ComponentDefectObject>() { compDefect }, WIPTransaction.DefectIndicator.Create(), txnStamp); #region 送至待判工作站 //取得目前批號的流程線上版本 RouteVersionInfo RouteVersion = RouteVersionInfo.GetRouteActiveVersion(txnLotData.RouteName); //以目前工作站名稱去查詢在所有流程中的序號 var routeOperation = RouteOperationInfo.GetRouteAllOperations(RouteVersion).Find(p => p.OperationName == judgeOperationName); //以目前工作站名稱去查詢在所有流程中的序號 var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER"); ////將批號的UDC01註記不良批 //WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL01", "Y", txnStamp); ////將批號的UDC02註記工作站序號 //WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL02", operationSequence, txnStamp); ////將批號的UDC03註記工作站名稱 //WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL03", operationName, txnStamp); var modifyAttrList = new List <ModifyLotAttributeInfo>(); //將批號的UDC01註記不良批 modifyAttrList.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL01", "Y")); //將批號的UDC02註記工作站序號 modifyAttrList.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL02", splitLot.OperationSequence)); //將批號的UDC03註記工作站名稱 modifyAttrList.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL03", splitLot.OperationName)); WIPTransaction.ModifyLotMultipleAttribute(splitLot, modifyAttrList, txnStamp); WIPTransaction.ReassignOperation(splitLot, routeOperation, reasonCategory, reasonCategory.Description, txnStamp); #endregion }); }
protected void ttbTempWorkpiece_TextChanged(object sender, EventArgs e) { try { //必須輸入Device if (_DeviceName.IsNullOrEmpty()) { ttbTempWorkpiece.Text = ""; AjaxFocus(ttbDeviceName); throw new RuleCimesException(TextMessage.Error.T00826(lblDeviceName.Text)); } if (ttbTempWorkpiece.Text.Trim().IsNullOrEmpty()) { return; } string sTempWorkpiece = CustomizeFunction.ConvertDMCCode(ttbTempWorkpiece.Text.Trim()); //取得BatchID var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", sTempWorkpiece); if (cstWIPPackTempInfo == null) { throw new CimesException(RuleMessage.Error.C00054(ttbTempWorkpiece.Text.Trim())); } if (cstWIPPackTempInfo.SIDE == "R" && _DeviceName == cstWIPPackTempInfo.DeviceName) { throw new RuleCimesException(RuleMessage.Error.C10168()); } _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID; if (_BatchID == "") { AjaxFocus(ttbTempWorkpiece); throw new RuleCimesException(TextMessage.Error.T00045(lblTempWorkpiece.Text)); } var lstCSTWIPPackTempInfo = InfoCenter.GetList <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE BATCHID = #[STRING]", _BatchID); int idx = 1; lstCSTWIPPackTempInfo.FindAll(p => p.SIDE == "L").ForEach(p => { var packingInfo = new PackingInfo(); packingInfo.Item = idx.ToString(); packingInfo.Device = _DeviceName; packingInfo.ComponentID = p.ComponentID; ComponentInfo componentInfo = ComponentInfo.GetComponentByComponentID(p.ComponentID); packingInfo.ComponentInfo = componentInfo; packingInfo.DMC = componentInfo["DMC"].ToString(); LotInfo lotInfo = LotInfo.GetLotByLot(componentInfo.CurrentLot); packingInfo.LotInfo = lotInfo; idx++; _PackingList.Add(packingInfo); }); idx = 1; lstCSTWIPPackTempInfo.FindAll(p => p.SIDE == "R").ForEach(p => { var packingInfo = new PackingInfo(); packingInfo.Item = idx.ToString(); packingInfo.Device = _RelativeDeviceName; packingInfo.ComponentID = p.ComponentID; ComponentInfo componentInfo = ComponentInfo.GetComponentByComponentID(p.ComponentID); packingInfo.ComponentInfo = componentInfo; packingInfo.DMC = componentInfo["DMC"].ToString(); LotInfo lotInfo = LotInfo.GetLotByLot(componentInfo.CurrentLot); packingInfo.LotInfo = lotInfo; idx++; _RelativePackingList.Add(packingInfo); }); gvWorkpiece.DataSource = _PackingList; gvWorkpiece.DataBind(); gvRelativeWorkpiece.DataSource = _RelativePackingList; gvRelativeWorkpiece.DataBind(); ttbTempWorkpiece.Text = ""; if (_PackingList.Count != 0 || _RelativePackingList.Count != 0) { ttbTempWorkpiece.ReadOnly = true; } else { ttbTempWorkpiece.ReadOnly = false; } AjaxFocus(ttbWorkpiece); } catch (Exception ex) { HandleError(ex); } }