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); } }
protected void btnOK_Click(object sender, EventArgs e) { try { var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "ManualMerge"); if (reasonCategory == null) { //[00030]{0}:{1}不存在! throw new CimesException(TextMessage.Error.T00030(GetUIResource("ReasonCode"), "CustomizeReason- ManualMerge")); } var baseLot = _LotDatas.Find(p => p.Status == "WaitMerge"); // 定義交易戳記 var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { //拆批 var split = SplitLotInfo.CreateSplitLotByLotAndQuantity(baseLot.Lot, baseLot.WorkOrderLot, 0, 0, reasonCategory, ""); var splitIndicator = WIPTxn.SplitIndicator.Create(); WIPTxn.Default.SplitLot(baseLot, split, splitIndicator, txnStamp); //再取一次批號資訊 var newLot = LotInfo.GetLotByLot(split.Lot); //併批與子單元 List <MergeLotInfo> mergeLotList = new List <MergeLotInfo>(); _LotDatas.ForEach(mergelot => { var lstCompData = mergelot.GetLotAllComponents(); var mergeLot = MergeLotInfo.GetMergeLotByLotAndQuantity(mergelot.Lot, lstCompData, reasonCategory, ""); mergeLotList.Add(mergeLot); }); WIPTransaction.MergeLot(newLot, mergeLotList, txnStamp); //再取一次批號資訊 var newMergeLot = LotInfo.GetLotByLot(split.Lot); //將批號狀態變更為wait WIPTransaction.ModifyLotSystemAttribute(newMergeLot, "STATUS", LotDefaultStatus.Wait.ToCimesString(), txnStamp); //將COMPLOT、PROCESS_EQUIP欄位清空,因為這個時間點這個欄位已經沒意義了 WIPTransaction.ModifyLotSystemAttribute(newMergeLot, "COMPLOT", string.Empty, txnStamp); WIPTransaction.ModifyLotSystemAttribute(newMergeLot, "PROCESS_EQUIP", string.Empty, txnStamp); //Dispatch到下一站 WIPTransaction.DispatchLot(newMergeLot, txnStamp); cts.Complete(); } ClearField(); ttbWorkOrderLot.Text = ""; AjaxFocus(ttbWorkOrderLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 確認 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { if (_SelectLotDatas.Count > 0) { _SelectLotDatas.ForEach(lot => { //將勾選的入庫資料塞到ERP TEMP表 To do... //將入庫單號回寫到INVNO WIPTransaction.ModifyLotSystemAttribute(lot, "INVNO", ttbScrapNo.Text, txnStamp); //將勾選的批號結批 WIPTransaction.TerminateLot(lot, txnStamp); }); #region 更新命名規則 if (_ExecuteNamingSQLList != null && _ExecuteNamingSQLList.Count > 0) { DBCenter.ExecuteSQL(_ExecuteNamingSQLList); } #endregion cts.Complete(); } else { //[00816]請至少選取一個{0}! throw new Exception(TextMessage.Error.T00816(GetUIResource("WorkpieceLot"))); } } ClearField(); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 確定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); //確認是否有選擇送待判原因 ddlJudgeDefect.Must(lblJudgeDefect); #region 檢查判定結果是否有選擇 if (rdbGoods.Checked == false && rdbRepair.Checked == false && rdbDefectInv.Checked == false && rdbScrapInv.Checked == false) { throw new Exception(TextMessage.Error.T00841(lblJudgeResult.Text)); } #endregion //檢查判定原因是否有選擇 ddlJudgeReason.Must(lblJudgeReason); using (var cts = CimesTransactionScope.Create()) { #region 依照選擇的判定結果,對批號進行不同的處置 //選取的判定結果 string result = ""; //選取的原因碼 var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlJudgeReason.SelectedValue); #region 良品:依照批號的UDC02(工作站序號)+UDC03(工作站名稱)找出預設流程的下一站點,將批號跳站至該站 if (rdbGoods.Checked) { result = "Good"; //取得流程線上版本 取得目前Lot的所有流程(所有工作站) RouteVersionInfo RouteVersion = RouteVersionInfo.GetRouteActiveVersion(_LotData.RouteName); //取得設定包裝工作站名稱 var packingOperation = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIPackingOperation"); if (packingOperation.Count == 0) { //T00555:查無資料,請至系統資料維護新增類別{0}、項目{1}! throw new CimesException(TextMessage.Error.T00555("SAIPackingOperation", "")); } var reassignOperation = packingOperation[0]; //如果送待判站之前記錄的是包裝站,則直接跳至包裝站,反之,跳至下一站 if (reassignOperation.Remark01 == _LotData.UserDefineColumn03) { //取得包裝站名稱 string qcOperationName = reassignOperation.Remark01; //取得包裝工作站資訊 var operation = OperationInfo.GetOperationByName(qcOperationName); if (operation == null) { //T00171, 工作站:{0}不存在!! throw new CimesException(TextMessage.Error.T00171(qcOperationName)); } //根據指定的流程名稱、流程版本、工作站名稱, 找出第一個符合的流程工作站,新的站點包裝 var newOperation = RouteOperationInfo.GetRouteOperationByOperationName(_LotData.RouteName, _LotData.RouteVersion, qcOperationName); //將批號的UDC02清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL02", "", txnStamp); //將批號的UDC03清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL03", "", txnStamp); //變更至指定工作站 WIPTransaction.ReassignOperation(_LotData, newOperation, reasonCategory, ttbJudgeDescr.Text, txnStamp); } else { //以此工作站名稱去查詢在流程中的序號 var routeOperation = RouteOperationInfo.GetRouteAllOperations(RouteVersion).Find(p => p.OperationName == _LotData.UserDefineColumn03); var lastOperationSeq = string.Format("{0:000}", (Convert.ToDecimal(routeOperation.OperationSequence) + 1)); //下一個工作站 用LOT和流程中下一站的序號去查出下一個工作站資訊 var NextRouteOperation = RouteOperationInfo.GetRouteOperationByLotSequence(_LotData, lastOperationSeq); if (NextRouteOperation == null) { //批號:{0}已無下個工作站點,請確認[流程設定] throw new Exception(RuleMessage.Error.C10008(_LotData.Lot)); } //將批號的UDC02清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL02", "", txnStamp); //將批號的UDC03清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL03", "", txnStamp); WIPTransaction.ReassignOperation(_LotData, NextRouteOperation, reasonCategory, ttbJudgeDescr.Text, txnStamp); } } #endregion #region 維修:紀錄維修及將批號派送至下一規則 if (rdbRepair.Checked) { result = "Repair"; List <WIPRepairInfo> repairDatas = new List <WIPRepairInfo>(); var componentData = ComponentInfoEx.GetDataByCurrentLot(_LotData.Lot)[0]; var repairData = WIPRepairInfo.CreateInfo(_LotData, componentData, componentData.ComponentQuantity, reasonCategory, _LotData.OperationName, _LotData.ResourceName, string.Empty, string.Empty); repairDatas.Add(repairData); var issueOperation = OperationInfo.GetOperationByName(_LotData.OperationName); WIPTransaction.RepairAdd(_LotData, repairDatas, issueOperation, txnStamp); WIPTransaction.DispatchLot(_LotData, txnStamp); } #endregion #region 良品入庫:將批號狀態變更為DefectInv if (rdbDefectInv.Checked) { result = "DefectInv"; WIPTransaction.ModifyLotSystemAttribute(_LotData, "STATUS", "DefectInv", txnStamp); } #endregion #region 報廢品入庫:將批號狀態變更為ScrapInv if (rdbScrapInv.Checked) { result = "ScrapInv"; WIPTransaction.ModifyLotSystemAttribute(_LotData, "STATUS", "ScrapInv", txnStamp); } #endregion #endregion #region 將判定結果紀錄在CST_WIP_DEFECT_JUDGEMENT,Result:良品(Goods)、維修(Repair)、不良品入庫(DefectInv)、報廢入庫(ScrapInv) var insertData = InfoCenter.Create <CSTWIPDefectJudgementInfo>(); insertData.WIPDefectSID = _LotDefectData.DefectSID; insertData["REASONCATEGORY"] = reasonCategory.Category; insertData["LOT"] = _LotData.Lot; insertData.Reason = reasonCategory.Reason; insertData.Result = result; insertData.Description = ttbJudgeDescr.Text; insertData.LinkSID = WIPHistoryInfo.GetLotFirstHistory(_LotData.Lot).LinkSID; insertData.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); #endregion cts.Complete(); } ttbLot.Text = ""; ClearField(); AjaxFocus(ttbLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 確認 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { if (_SelectLotDatas.Count > 0) { string sLotInString = ""; // 組出where in字串 _SelectLotDatas.ForEach(p => { sLotInString += "'" + p.Lot + "',"; }); sLotInString = sLotInString.EndsWith(",") ? sLotInString.Substring(0, sLotInString.Length - 1) : sLotInString; var dtInvData = DBCenter.GetDataTable(@"SELECT WO,INVLOT,SUM(QUANTITY) QUANTITY,DEVICE,FACTORY FROM MES_WIP_LOT WHERE LOT IN(" + sLotInString + ") GROUP BY WO,INVLOT,DEVICE,FACTORY ORDER BY WO"); string headerSID = ""; string date = txnStamp.RecordTime.Substring(0, 10).Replace("/", ""); string time = txnStamp.RecordTime.Substring(11).Replace(":", ""); string preWo = string.Empty; int seq = 1; // SAI倉位對應表 var lstSAIWarehouse = WpcExClassItemInfo.GetInfoByClass("SAIWarehouse"); dtInvData.Rows.LoopDo <DataRow>((p, i) => { string currentWO = p["WO"].ToString(); string device = p["DEVICE"].ToString(); string factory = p["FACTORY"].ToString(); string invLot = p["INVLOT"].ToString(); string qty = p["QUANTITY"].ToString(); if (preWo != currentWO) { seq = 1; headerSID = DBCenter.GetSystemID(); DBCenter.ExecuteParse(@"INSERT INTO PPFHK (SID, WDATE, WTIME, BUDAT, AUFNR, FLAG) VALUES (#[STRING], #[STRING], #[STRING], #[STRING], #[STRING],'N')", headerSID, date, time, date, currentWO); } //寫入PPFHP //WERKS:Factory //LGORT:入庫倉位 //CHARG:INVLOT //MATNR:Device var lstDetail = _SelectLotDatas.FindAll(select => select.InventoryLot == invLot); var warehouseInfo = lstSAIWarehouse.Find(wpcItem => wpcItem.Remark01 == lstDetail[0].Process && wpcItem.Remark03 == "DEFECT"); if (warehouseInfo == null) { //T00555:查無資料,請至系統資料維護新增類別{0}、項目{1}! throw new CimesException(TextMessage.Error.T00555("SAIWarehouse", lstDetail[0].Process + "Remark03:DEFECT")); } DBCenter.ExecuteParse(@"INSERT INTO PPFHP (SID, SEQNR, WDATE, WTIME, MATNR, WERKS, LGORT, CHARG, MENGE, MEINS, FLAG) VALUES (#[STRING], #[DECIMAL], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], 'N')", headerSID, seq, date, time, device, factory, warehouseInfo.Remark02, invLot, qty, lstDetail[0].Unit); int detailseq = 1; lstDetail.ForEach(lot => { var defectInfo = CSTWIPDefectJudgementInfo.GetDataByLot(lot.Lot); var reasonGroupInfo = WIPReasonGroupInfoEx.GetReasonGroupByCategory(defectInfo["REASONCATEGORY"].ToString()); var reasonGroup = reasonGroupInfo == null ? "" : reasonGroupInfo.REASONGROUP; //寫入PPBCH DBCenter.ExecuteParse(@"INSERT INTO PPBCH (SID, MATNR, WERKS, CHARG, SEQNO, WDATE, WTIME, CLASS, ATINN, ATWRT, FLAG) Values (#[STRING], #[STRING], #[STRING], #[STRING], #[DECIMAL], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], 'N')", headerSID, device, factory, invLot, detailseq, date, time, reasonGroup, defectInfo["REASONCATEGORY"].ToString(), defectInfo.Reason); detailseq += 1; }); seq += 1; preWo = currentWO; }); _SelectLotDatas.ForEach(lot => { //寫入WMSMaster & Detail var wmsMaster = CSTWMSMastInfo.GetMaterialLotDataByMaterialLot(lot.InventoryLot); if (wmsMaster == null) { wmsMaster = InfoCenter.Create <CSTWMSMastInfo>(); wmsMaster.Lot = lot.InventoryLot; wmsMaster.DeviceName = lot.DeviceName; wmsMaster.RuleName = txnStamp.RuleName; wmsMaster.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); } //理論上只會有一個Comp lot.GetLotAllComponents().ForEach(comp => { var wmsDetail = InfoCenter.Create <CSTWMSDetailInfo>(); wmsDetail.Lot = lot.InventoryLot; wmsDetail.ComponentID = comp.ComponentID; wmsDetail.Quantity = comp.ComponentQuantity; wmsDetail.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); }); //將入庫單號回寫到批號身上 WIPTransaction.ModifyLotSystemAttribute(lot, "INVNO", ttbDefectNo.Text, txnStamp); //將勾選的批號結批 WIPTransaction.TerminateLot(lot, txnStamp); }); #region 更新命名規則 if (_ExecuteNamingSQLList != null && _ExecuteNamingSQLList.Count > 0) { DBCenter.ExecuteSQL(_ExecuteNamingSQLList); } #endregion cts.Complete(); } else { //[00816]請至少選取一個{0}! throw new Exception(TextMessage.Error.T00816(GetUIResource("WorkpieceLot"))); } } ClearField(); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 確定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { //確認是否輸入工件序號 ttbCompLot.Must(lblCompLot); //確認是否有選擇流程 ddlRoute.Must(lblRoute); //確認是否有選擇流程工作站 ddlRouteOperation.Must(lblRouteOperation); TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { //以第一個工件序號為拆批的母批 var txnLotData = _MergeLotDataList[0]; //取得原因碼資料 var reasonData = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER"); #region 執行拆批 //批號子單元清單 var lsComponetData = ComponentInfoEx.GetDataByCurrentLot(txnLotData.Lot); //取得併批批號名稱 var splitLotNaming = GetNamingRule("SplitLot", txnStamp.UserID, txnLotData); //批號拆批 var splitLot = SplitLotInfo.CreateSplitLotByLotAndQuantity(txnLotData.Lot, splitLotNaming.First[0], lsComponetData, reasonData, reasonData.Description); WIPTxn.Default.SplitLot(txnLotData, splitLot, WIPTxn.SplitIndicator.Create(null, null, null, TerminateBehavior.TerminateWithHistory), txnStamp); //將批號的UDC08註記N WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL08", "N", txnStamp); if (splitLotNaming.Second != null && splitLotNaming.Second.Count != 0) { DBCenter.ExecuteSQL(splitLotNaming.Second); } #endregion #region 執行併批 //移除第一個工件序號(因為拆批已處理過了) _MergeLotDataList.RemoveAt(0); List <MergeLotInfo> lsMergeLots = new List <MergeLotInfo>(); foreach (var mergeLot in _MergeLotDataList) { //批號子單元清單 var componetDataList = ComponentInfoEx.GetDataByCurrentLot(mergeLot.Lot); //加入併批清單 lsMergeLots.Add(MergeLotInfo.GetMergeLotByLotAndQuantity(mergeLot.Lot, componetDataList, reasonData, reasonData.Description)); } //將數量合併到在狀態為Run的批號上 if (lsMergeLots.Count > 0) { WIPTransaction.MergeLot(splitLot, lsMergeLots, txnStamp); } #endregion #region 變更流程 //取得料號版本資料 var deviceVersionData = DeviceVersionInfo.GetDeviceVersion(splitLot.DeviceName, splitLot.DeviceVersion); //取得所選擇的流程資料 var routeData = InfoCenter.GetBySID <RouteInfo>(ddlRoute.SelectedValue); //取得所選擇流程目前線上版本資料 var routeVersionData = RouteVersionInfo.GetActiveRouteVersion(routeData); //取得所選擇的流程工作站資料 var routeOpeartionData = InfoCenter.GetBySID <RouteOperationInfo>(ddlRouteOperation.SelectedValue); WIPTransaction.ReassignRoute(splitLot, deviceVersionData, routeVersionData, routeOpeartionData, reasonData, reasonData.Description, txnStamp); #endregion cts.Complete(); } ClearField(); AjaxFocus(ttbCompLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }