Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        /// <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);
            }
        }