Exemplo n.º 1
0
        /// <summary>
        /// 檢查首件是否檢驗完成,檢驗完成回傳 True,未完成回傳 False
        /// </summary>
        /// <param name="equipmentName"></param>
        /// <param name="lot"></param>
        /// <returns></returns>
        public static bool CheckFAI(string equipmentName, string lot)
        {
            /*
             * 在CST_EQP_FAI裡沒有資料代表沒有送驗,則視為FAI未完成
             * 在CST_EQP_FAI有資料,但是waitCount不等於0,代表FAI未完成
             * 在CST_EQP_FAI有資料,且waitCount = 0,代表FAI完成
             */

            //取得批號資料
            var lotData = LotInfo.GetLotByLot(lot);

            var faiData = CSTEquipmentFAIInfo.GetDataByEquipmentAndDevice(equipmentName, lotData.DeviceName);

            if (faiData == null)
            {
                //找不到首件檢驗的資料,請確認是否已執行調機作業!!!
                throw new CimesException(RuleMessage.Error.C00026());
            }

            if (faiData != null && faiData.WAITFAICOUNT <= 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 取得預約工作站的序號
        /// </summary>
        /// <param name="lot"></param>
        /// <param name="ruleName"></param>
        /// <returns></returns>
        public static string GetAppointmentOperationSequence(string lot, string ruleName)
        {
            var    lotData = LotInfo.GetLotByLot(lot).ChangeTo <LotInfoEx>();
            string nextOperationSequence = "";

            //依據傳入的批號去取得預約表資訊
            var WIPReserveCheckInDataList = CSTWIPReserveCheckInInfo.GetDataByLot(lotData.Lot);

            //用批號去客製表找出所有預約紀錄,先比較currentRule是否存在於客製表,若有,則拋錯
            if (WIPReserveCheckInDataList.Count > 0)
            {
                //從預約表中找出相同的RuleName
                List <CSTWIPReserveCheckInInfo> matchReserveList = WIPReserveCheckInDataList.FindAll(x => x.RuleName == ruleName);

                if (matchReserveList.Count > 0)
                {
                    //批號:{0}已進行站點:{1}預約進站作業,請遵循作業規範
                    throw new Exception(RuleMessage.Error.C10001(lotData.Lot, lotData.OperationName));
                }

                //取得最後一次預約的工作站點名稱
                var lastAppointmentOperation = WIPReserveCheckInDataList[0].OperationName;

                //取得目前批號的流程線上版本
                RouteVersionInfo RouteVersion = RouteVersionInfo.GetRouteActiveVersion(lotData.RouteName);

                //以目前工作站名稱去查詢在所有流程中的序號
                var routeOperation = RouteOperationInfo.GetRouteAllOperations(RouteVersion).Find(p => p.OperationName == lastAppointmentOperation);

                //取得下一個工作站序號
                nextOperationSequence = string.Format("{0:000}", (Convert.ToDecimal(routeOperation.OperationSequence) + 1));
            }

            return(nextOperationSequence);
        }
Exemplo n.º 3
0
        protected void ttbBoxNo_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // 清除資料與使用者介面
                ClearField();

                var convertInfo = WIPConvertInfoEx.GetWIPConvertInfoByTargetLot(ttbBoxNo.Text.Trim());
                if (convertInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00030(lblBoxNo.Text, ttbBoxNo.Text.Trim()), ttbBoxNo);
                }

                // 取得批號
                _ProcessLot = LotInfo.GetLotByLot(ttbBoxNo.Text.Trim());
                // 若批號不存在拋錯
                if (_ProcessLot == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 取得批號的所有資單元
                _ComponentList = ComponentInfo.GetLotAllComponents(_ProcessLot);
                // 資料繫結
                gvComponent.SetDataSource(_ComponentList, true);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (_ProcessLot == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00826(lblUnPackingInventoryLot.Text));
                }

                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    // 將入庫批取消完工
                    WIPTransaction.UndoFinish(_ProcessLot, txnStamp);
                    var unPackingLot = LotInfo.GetLotByLot(ttbBoxNo.Text.Trim());
                    // 取得拆包Component
                    var lstUnPackingComp = unPackingLot.GetLotAllComponents();
                    // 將轉為子單元的批號還原,例如可使用於拆包
                    var txn = WIPTxn.Default.ConvertToLot(unPackingLot, lstUnPackingComp, txnStamp);
                    txn.LotList.ForEach(lot => {
                        //寫入WMSMaster & Detail
                        var wmsMaster = CSTWMSMastInfo.GetMaterialLotDataByMaterialLot(lot["INVLOT"].ToString());
                        if (wmsMaster == null)
                        {
                            wmsMaster            = InfoCenter.Create <CSTWMSMastInfo>();
                            wmsMaster.Lot        = lot["INVLOT"].ToString();
                            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["INVLOT"].ToString();
                            wmsDetail.ComponentID = comp.ComponentID;
                            wmsDetail.Quantity    = comp.ComponentQuantity;
                            wmsDetail.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });
                        WIPTransaction.TerminateLot(lot, txnStamp);
                    });

                    cts.Complete();
                }
                // 返回定義的預設網頁
                ReturnToPortal();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更新FAI,檢驗完成回壓FAICount,第一次首件回壓FAIDevice
        /// </summary>
        /// <param name="equipmentName"></param>
        /// <param name="lot"></param>
        public static void UpdateFAI(string equipmentName, string lot, bool initFlag, TransactionStamp txs)
        {
            //取得批號資料
            var lotData = LotInfo.GetLotByLot(lot);

            var faiData = CSTEquipmentFAIInfo.GetDataByEquipmentAndDevice(equipmentName, lotData.DeviceName);

            if (faiData == null)
            {
                return;
            }

            if (faiData.INSPTYPE == FAIType.CN.ToCimesString())
            {
                #region 連N測試,只要一支NG,就要reset檢驗次數,重新送件

                //判定NG的時候回壓初始化FAICount,判定OK則WAITFAICOUNT減1
                if (initFlag) //NG
                {
                    //取得料號版本的資料
                    var deviceVerExData = DeviceVersionInfo.GetDeviceVersion(lotData.DeviceName, lotData.DeviceVersion).ChangeTo <DeviceVersionInfoEx>();

                    //檢查料號的FAICount有無設定
                    if (deviceVerExData.FAICount.ToString().IsNullOrTrimEmpty())
                    {
                        //T00541
                        //料號:xxx的系統屬性:xxx 未設定,請洽IT人員!) error code:T00031
                        throw new Exception(TextMessage.Error.T00541(deviceVerExData.DeviceName, "FAICount"));
                    }

                    faiData.WAITFAICOUNT = deviceVerExData.FAICount;
                }
                else //OK
                {
                    faiData.WAITFAICOUNT = faiData.WAITFAICOUNT - 1;
                }
                #endregion
            }
            else
            {
                //首N測試,判定OK將WAITFAICOUNT減1就好,判定NG不須動作
                if (!initFlag)
                {
                    faiData.WAITFAICOUNT = faiData.WAITFAICOUNT - 1;
                }
            }

            faiData.UpdateToDB(txs.UserID, txs.RecordTime);
            LogCenter.LogToDB(faiData, LogCenter.LogIndicator.Create(ActionType.Set, txs.UserID, txs.RecordTime));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 依照輸入LotID取得相關欄位資料及相關Button設定
        /// </summary>
        /// <param name="LotID">批號名稱</param>
        private void LoadControlByLot(string LotID)
        {
            // 清除欄位資訊
            ClearField();
            if (cbxWO.Checked)
            {
                _LotData = LotInfoEx.GetLotByWorkOrderLot(LotID);
            }

            if (cbxLot.Checked)
            {
                _LotData = LotInfoEx.GetLotByLot(LotID);
            }

            if (cbxSN.Checked)
            {
                var lot = CustomizeFunction.ConvertDMCCode(LotID);

                var compInfo = ComponentInfoEx.GetComponentByComponentID(lot);
                if (compInfo == null)
                {
                    var compList = ComponentInfoEx.GetComponentByDMCCode(lot);
                    if (compList.Count != 0)
                    {
                        compInfo = compList[0];
                    }
                }

                if (compInfo != null)
                {
                    _LotData = LotInfo.GetLotByLot(compInfo.CurrentLot).ChangeTo <LotInfoEx>();
                }
            }

            // 若該批號無資料可顯示,離開程式並顯示訊息
            if (_LotData == null)
            {
                btnPrint.Enabled = false;
                AjaxFocus(ttbWOLot);
                throw new Exception(TextMessage.Error.T00060(LotID));
            }

            btnPrint.Enabled = true;
        }
Exemplo n.º 10
0
        /// <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);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 依照檢驗計畫取得該物件的datatable
        /// </summary>
        /// <param name="QCTypeData"></param>
        /// <param name="objectName"></param>
        /// <returns></returns>
        public static DataTable GetInspectionData(QCTypeInfo QCTypeData, string objectName)
        {
            string    sql        = "";
            DataTable dtQCTarget = null;

            #region 依照檢驗計畫取得該物件的datatable
            switch (QCTypeData.QCTarget)
            {
            case "MES_WIP_LOT":
            {
                LotInfo lot = LotInfo.GetLotByLot(objectName);
                if (lot == null)
                {
                    throw new Exception(TextMessage.Error.T00378(objectName));
                }

                dtQCTarget = lot.CopyDataToTable(lot.ID);
            }
            break;

            case "MES_WIP_COMP":
            {
                //取得component資訊以及所在的工作站
                sql = @"SELECT L.OPERATION,C.* FROM MES_WIP_COMP C
                                 INNER JOIN MES_WIP_LOT L ON C.CURRENTLOT = L.LOT
                                 WHERE COMPONENTID = #[STRING]";

                ComponentInfo comp = InfoCenter.GetBySQL <ComponentInfo>(sql, objectName);
                if (comp == null)
                {
                    throw new Exception(TextMessage.Error.T00154(objectName));
                }

                dtQCTarget = comp.CopyDataToTable(comp.ID);
            }
            break;

            case "MES_CMS_CAR":
            {
                CarrierInfo carrier = CarrierInfo.GetCarrierByCarrierNo(objectName);
                if (carrier == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00725(objectName));
                }

                dtQCTarget = carrier.CopyDataToTable(carrier.ID);
            }
            break;

            case "MES_TOOL_MAST":
            {
                ToolInfo tool = ToolInfo.GetToolByName(objectName);
                if (tool == null)
                {
                    throw new Exception(TextMessage.Error.T00592(objectName));
                }
                dtQCTarget = tool.CopyDataToTable(tool.ID);
            }
            break;

            case "MES_MMS_MLOT":
            {
                MaterialLotInfo mlot = MaterialLotInfo.GetMaterialLotByMaterialLot(objectName);
                if (mlot == null)
                {
                    throw new Exception(TextMessage.Error.T00512(objectName));
                }

                dtQCTarget = mlot.CopyDataToTable(mlot.ID);
            }
            break;

            case "MES_EQP_EQP":
            {
                EquipmentInfo equipment = EquipmentInfo.GetEquipmentByName(objectName);
                if (equipment == null)
                {
                    throw new Exception(TextMessage.Error.T00885(objectName));
                }

                dtQCTarget = equipment.CopyDataToTable(equipment.ID);
            }
            break;

            default:
            {
                sql        = string.Format("SELECT * FROM {0} WHERE {1} = #[STRING]", QCTypeData.QCTarget, QCTypeData.IdentityColumn);
                dtQCTarget = DBCenter.GetDataTable(sql, objectName);
                if (dtQCTarget == null || dtQCTarget.Rows.Count == 0)
                {
                    throw new Exception(TextMessage.Error.T00030("InspectionTarget", objectName));
                }
            }
            break;
            }
            #endregion

            return(dtQCTarget);
        }
Exemplo n.º 12
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                // 包裝數量必須符合滿箱數量,否則須拋錯
                if (!ckbNoControl.Checked && _PackType == "Standard" && (_PackingList.Count + _RelativePackingList.Count) != ttbMaxPackSize.Text.ToDecimal())
                {
                    throw new RuleCimesException(RuleMessage.Error.C10043((_PackingList.Count + _RelativePackingList.Count).ToString(), ttbMaxPackSize.Text));
                }
                // 若包裝方式為左右手,則左右手的輸入數量需相同
                if (!ckbNoControl.Checked && _PackType == "Mix" && _PackingList.Count != _RelativePackingList.Count)
                {
                    throw new RuleCimesException(RuleMessage.Error.C10044(_DeviceName, _PackingList.Count.ToString(), _RelativeDeviceName, _RelativePackingList.Count.ToString()));
                }
                // 若包裝方式為左右手,則左右手的輸入數量需相同且需符合滿箱數量乘以二
                if (!ckbNoControl.Checked && _PackType == "Mix" && (_PackingList.Count + _RelativePackingList.Count) != (ttbMaxPackSize.Text.ToDecimal() * 2))
                {
                    throw new RuleCimesException(RuleMessage.Error.C10043((_PackingList.Count + _RelativePackingList.Count).ToString(), (ttbMaxPackSize.Text.ToDecimal() * 2).ToString()));
                }

                if (ddlInspector.SelectedValue.IsNullOrEmpty())
                {
                    //[00826] 請輸入{0}!
                    throw new RuleCimesException(TextMessage.Error.T00826(lblInspector.Text), ddlInspector);
                }


                var lstSourceLot = new List <LotInfo>();
                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    // 若有不同的批號需拆批
                    _PackingList.Distinct <PackingInfo>(new PackCompare()).ToList().ForEach(p =>
                    {
                        lstSourceLot.Add(SplitLot(p.LotInfo, false, txnStamp));
                    });
                    // 若有不同的批號需拆批
                    _RelativePackingList.Distinct <PackingInfo>(new PackCompare()).ToList().ForEach(p =>
                    {
                        lstSourceLot.Add(SplitLot(p.LotInfo, true, txnStamp));
                    });

                    #region SplitBoxLot
                    List <SqlAgent> splitLotArchiSQLList = new List <SqlAgent>();
                    var             generator            = NamingIDGenerator.GetRule("BoxNo");
                    if (generator == null)
                    {
                        //WRN-00411,找不到可產生的序號,請至命名規則維護設定,規則名稱:{0}!!!
                        throw new Exception(TextMessage.Error.T00437("BoxNo"));
                    }
                    var serialData = generator.GenerateNextIDs(1, lstSourceLot[0], new string[] { }, User.Identity.Name);
                    splitLotArchiSQLList = serialData.Second;
                    var boxNoLotID = serialData.First[0];

                    var reasonCategoryInfo = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER");
                    var splitLotData       = SplitLotInfo.CreateSplitLotByLotAndQuantity(lstSourceLot[0].Lot, boxNoLotID, 0, 0, reasonCategoryInfo, "SplitBoxLot");

                    WIPTxn.SplitIndicator splitInd = WIPTxn.SplitIndicator.Create();
                    WIPTxn.Default.SplitLot(lstSourceLot[0], splitLotData, splitInd, txnStamp);

                    //若子單元為自動產生,更新序號至DB
                    if (splitLotArchiSQLList != null && splitLotArchiSQLList.Count > 0)
                    {
                        DBCenter.ExecuteSQL(splitLotArchiSQLList);
                    }
                    #endregion

                    var targetLot = LotInfo.GetLotByLot(boxNoLotID);
                    // 將批號轉換為另一個批號的子單元,轉換後批號結批,例如可使用於包裝
                    WIPTxn.Default.ConvertToComponent(targetLot, lstSourceLot, "Box", WIPTxn.ConvertToComponentIndicator.Default, txnStamp);
                    // 紀錄檢驗人員
                    //WIPTransaction.ModifyLotSystemAttribute(targetLot, "USERDEFINECOL12", ddlInspector.SelectedValue, txnStamp);
                    // 進行Dispatch
                    WIPTransaction.DispatchLot(targetLot, txnStamp);
                    // 刪除暫存檔案
                    if (_BatchID != "")
                    {
                        CSTWIPPackTempInfo.DeletePackTempByBatchID(_BatchID);
                    }

                    var packInfo = InfoCenter.Create <CSTWIPPackInfo>();
                    packInfo.BOXNO    = boxNoLotID;
                    packInfo.Quantity = _PackingList.Count + _RelativePackingList.Count;
                    packInfo.INSPUSER = ddlInspector.SelectedValue;
                    packInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                    _PackingList.ForEach(comp => {
                        var packDataInfo          = InfoCenter.Create <CSTWIPPackDataInfo>();
                        packDataInfo.WIP_PACK_SID = packInfo.ID;
                        packDataInfo.ComponentID  = comp.ComponentID;
                        packDataInfo.DMC          = comp.DMC;
                        packDataInfo.DeviceName   = comp.Device;
                        packDataInfo.Quantity     = 1;
                        packDataInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });

                    _RelativePackingList.ForEach(comp => {
                        var packDataInfo          = InfoCenter.Create <CSTWIPPackDataInfo>();
                        packDataInfo.WIP_PACK_SID = packInfo.ID;
                        packDataInfo.ComponentID  = comp.ComponentID;
                        packDataInfo.DMC          = comp.DMC;
                        packDataInfo.DeviceName   = comp.Device;
                        packDataInfo.Quantity     = 1;
                        packDataInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });

                    //工時
                    _UserWorkTimeList.ForEach(p => {
                        p.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });
                    _UserWorkTimeList.Clear();

                    #region Print
                    _dsReport = new DataSet();
                    // 取得Report資料
                    _dsReport = GetRunCardDataSource(targetLot);
                    _dsReport.AcceptChanges();

                    if (_dsReport.Tables.Count > 0)
                    {
                        string sPrintProgram    = "/CustomizeRule/WIPRule/W035View.aspx";
                        string sHost            = Request.Url.Host;
                        string sApplicationPath = Request.ApplicationPath;
                        string ReportPath       = "http://" + sHost + sApplicationPath + sPrintProgram;
                        Session["W035View"] = _dsReport;
                        //開啟查詢工單頁面
                        string openPrintWindow = "window.open('" + ReportPath + "','pop','resizable: yes; status: no; scrollbars:no; menubar:no;toolbar:no;location:no;dialogLeft:10px;dialogTop:10px;dialogHeight:10px;dialogWidth:10px',false);";
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), openPrintWindow, true);
                    }
                    #endregion
                    cts.Complete();
                }
                // ClearUI不會清除Device資料
                ttbDeviceName.Text = "";
                ClearField();
                //ReturnToPortal();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemplo n.º 13
0
        protected void ttbWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // 若卡控需輸入料號
                if (ttbDeviceName.Text.Trim().IsNullOrEmpty() && !ckbNoControl.Checked)
                {
                    throw new RuleCimesException(TextMessage.Error.T00043(lblDeviceName.Text));
                }
                // 取得輸入工件
                string inputObject = ttbWorkpiece.Text.Trim();
                if (inputObject.IsNullOrEmpty())
                {
                    return;
                }

                ComponentInfo componentInfo = null;
                LotInfo       lotInfo       = null;

                var lstDMCComponent = ComponentInfoEx.GetComponentByDMCCode(inputObject).OrderBy(p => p.ComponentID).ToList();
                if (lstDMCComponent.Count == 0)
                {
                    var compID = CustomizeFunction.ConvertDMCCode(inputObject);
                    lstDMCComponent = ComponentInfoEx.GetComponentListByComponentID(compID).OrderBy(p => p.ComponentID).ToList();
                }

                lstDMCComponent.ForEach(comp =>
                {
                    // 若DMC是唯一值可以檢查是否已經重複
                    if (_ProdType == "S" || _ProdType == "B")
                    {
                        // 取得批號資料
                        lotInfo = LotInfo.GetLotByLot(comp.CurrentLot);

                        // 自動線沒有DMCCode
                        if (lotInfo.UserDefineColumn08 == "Y" && comp["DMC"].ToString().IsNullOrEmpty())
                        {
                            var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                            using (var cts = CimesTransactionScope.Create())
                            {
                                WIPTransaction.ModifyLotComponentSystemAttribute(lotInfo, comp, "DMC", inputObject, txnStamp);
                                cts.Complete();
                            }
                        }

                        #region 檢查子單元資料是否重複
                        if (lotInfo.DeviceName == _DeviceName)
                        {
                            _PackingList.ForEach(p =>
                            {
                                if (p.ComponentID == comp.ComponentID)
                                {
                                    throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID));
                                }
                            });
                        }
                        else if (lotInfo.DeviceName == _RelativeDeviceName)
                        {
                            _RelativePackingList.ForEach(p =>
                            {
                                if (p.ComponentID == comp.ComponentID)
                                {
                                    throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID));
                                }
                            });
                        }
                        #endregion
                        componentInfo = comp;
                    }
                    else
                    {
                        if (_PackingList.Find(p => p.ComponentID == comp.ComponentID) == null && _RelativePackingList.Find(p => p.ComponentID == comp.ComponentID) == null && componentInfo == null)
                        {
                            componentInfo = comp;
                            // 取得批號資料
                            lotInfo = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                        }
                    }
                });

                // 找不到子單元需拋錯
                if (componentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Workpiece")));
                }
                // 找不到批號需拋錯
                if (lotInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 檢查CurrentRule是否正確
                if (lotInfo.CurrentRuleName != ProgramInformationBlock1.ProgramRight)
                {
                    throw new RuleCimesException(TextMessage.Error.T00384(lotInfo.CurrentRuleName, ProgramInformationBlock1.ProgramRight));
                }
                // 若需卡控
                if (!ckbNoControl.Checked)
                {
                    // 檢查批號型號與輸入的型號是否相同
                    if (_PackType == "Standard" && lotInfo.DeviceName != _DeviceName)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10041(_DeviceName));
                    }
                    // 如果為包裝方式為Mix(左右手),則對應料號與對應料號須符合
                    if (_PackType == "Mix" && lotInfo.DeviceName != _DeviceName && lotInfo.DeviceName != _RelativeDeviceName)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10042(_DeviceName, _RelativeDeviceName));
                    }
                }

                var packTempInfo = CSTWIPPackTempInfo.GetPackTempByComponentID(componentInfo.ComponentID);
                if (packTempInfo != null)
                {
                    ttbWorkpiece.Text = "";
                    throw new RuleCimesException(RuleMessage.Error.C10093());
                }

                // 新增PackingInfo物件
                var newPackItem = new PackingInfo();
                newPackItem.ComponentID   = componentInfo.ComponentID;
                newPackItem.ComponentInfo = componentInfo;
                newPackItem.LotInfo       = lotInfo;
                newPackItem.DMC           = componentInfo["DMC"].ToString();

                // 將PackingInfo物件加入包裝清單全域變數
                if (_PackType == "Standard" || (_PackType == "Mix" && lotInfo.DeviceName == _DeviceName) || ckbNoControl.Checked)
                {
                    // 工件數量({0})達到滿箱數量({1}) !
                    if (!ckbNoControl.Checked && _PackingList.Count >= ttbMaxPackSize.Text.ToDecimal())
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10092(_PackingList.Count.ToString(), ttbMaxPackSize.Text));
                    }

                    newPackItem.Device = lotInfo.DeviceName;
                    newPackItem.Item   = (_PackingList.Count + 1).ToString();
                    _PackingList.Add(newPackItem);
                }
                // 將PackingInfo物件加入對應料號包裝清單全域變數
                else
                {
                    // 工件數量({0})達到滿箱數量({1}) !
                    if (!ckbNoControl.Checked && _RelativePackingList.Count >= ttbMaxPackSize.Text.ToDecimal())
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10092(_RelativePackingList.Count.ToString(), ttbMaxPackSize.Text));
                    }

                    newPackItem.Device = lotInfo.DeviceName;
                    newPackItem.Item   = (_RelativePackingList.Count + 1).ToString();
                    _RelativePackingList.Add(newPackItem);
                }
                // 將目前已經輸入的物件顯示至畫面上
                _PackingList           = _PackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList();
                gvWorkpiece.DataSource = _PackingList;
                gvWorkpiece.DataBind();
                // 將目前已經輸入的物件顯示至畫面上
                _RelativePackingList           = _RelativePackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList();
                gvRelativeWorkpiece.DataSource = _RelativePackingList;
                gvRelativeWorkpiece.DataBind();
                // 清除工件欄位
                ttbWorkpiece.Text = "";
                // 將指標焦點放工件欄位輸入框
                AjaxFocus(ttbWorkpiece);

                if (_PackingList.Count != 0 || _RelativePackingList.Count != 0)
                {
                    ttbTempWorkpiece.ReadOnly = true;
                }
                else
                {
                    ttbTempWorkpiece.ReadOnly = false;
                }
                // 取得BatchID
                if (_BatchID == "")
                {
                    var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", inputObject);
                    _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID;
                }

                #region ProcessWorkTime
                string sysTime     = DBCenter.GetSystemTime();
                var    usrWorkTime = InfoCenter.Create <CSTUserWorkTimeInfo>();
                usrWorkTime.WorkOrder    = lotInfo.WorkOrder;
                usrWorkTime.WorkUserID   = User.Identity.Name;
                usrWorkTime.StartTime    = _StartTime;
                usrWorkTime.EndTime      = DateTime.Parse(sysTime).AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss");
                usrWorkTime.EXECUTEFLAG  = "N";
                usrWorkTime.SHIFTDATE    = _ShiftDate;
                usrWorkTime.SHIFT        = _Shift;
                usrWorkTime.Lot          = lotInfo.Lot;
                usrWorkTime["OPERATION"] = lotInfo.OperationName;
                _StartTime = sysTime;
                _UserWorkTimeList.Add(usrWorkTime);
                #endregion
            }
            catch (Exception ex)
            {
                HandleError(ex, ttbWorkpiece.ClientID);
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        /// <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);
                }
                else if (rdbCLOSE.Checked)
                {
                    result = "CLOSE";

                    //確認是否有選擇原因碼
                    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>();

                    //原因碼
                    ReasonCategoryInfo reason = null;

                    //有選擇原因碼才更新[NG_Category]及[NG_Reason]
                    if (string.IsNullOrEmpty(ddlPQCReasonCode.SelectedValue) == false)
                    {
                        reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPQCReasonCode.SelectedValue);
                        QCInsepctionData.NG_Category = reason.Category;
                        QCInsepctionData.NG_Reason   = reason.Reason;
                    }

                    //如果判定結果為結單的話,則必須把結單時間及人員資料寫回資料庫
                    if (result == "CLOSE")
                    {
                        QCInsepctionData.FINISHTIME = txnStamp.RecordTime;
                        QCInsepctionData.FINISHUSER = txnStamp.UserID;
                    }

                    QCInsepctionData.NG_Description = ttbDescr.Text;
                    QCInsepctionData.Result         = result;
                    QCInsepctionData.Status         = "Finished";

                    QCInsepctionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

                    #endregion

                    #region 更新機台檢驗主檔[CST_WIP_CMM]

                    if (_CSTWIPCMMList != null)
                    {
                        //更新檢驗主檔的QCInspectionSID欄位
                        _CSTWIPCMMList.ForEach(data =>
                        {
                            data.QCInspectionSID = QCInsepctionData.ID;
                            data.UpdateToDB();
                        });
                    }

                    #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及PQC的檢驗單號資料
                        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

                    //如果判定結果選擇為NG,則必須拆批送待判
                    if (rdbNG.Checked)
                    {
                        //判定NG直接拆批及送待判工作站
                        CustomizeFunction.SplitDefectLot(_SelectedQCData.ComponentLot, ttbDescr.Text, reason, txnStamp);
                    }

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemplo n.º 16
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                // 子單元不存在拋錯
                if (ComponentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Component")));
                }
                // 批號不存在拋錯
                if (ProcessLotData == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    bool inSpec = true;
                    if (_CenterHoleFlag != "N")
                    {
                        gvComponentEDC.Rows.LoopDo <GridViewRow>((p, i) => {
                            // 取得TextBox Control
                            var ttbEDC = p.FindControl("ttbEDC") as TextBox;
                            if (ttbEDC.Text.IsNullOrEmpty())
                            {
                                throw new RuleCimesException(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 edcCompInfo              = InfoCenter.Create <CSTEDCComponentInfo>();
                            edcCompInfo.ComponentID      = ComponentInfo.ComponentID;
                            edcCompInfo.Data             = measureVal;
                            edcCompInfo.UpSpecification  = SAICenterHole.Remark02.ToDecimal();
                            edcCompInfo.LowSpecification = SAICenterHole.Remark03.ToDecimal();
                            edcCompInfo.INSPEC           = inSpec == true ? "OK" : "NG";
                            edcCompInfo.Lot              = ProcessLotData.Lot;
                            edcCompInfo["LINKSID"]       = txnStamp.LinkSID;
                            edcCompInfo["PARAMETER"]     = "SC" + (i + 1).ToString();
                            edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });
                    }

                    if (!ttbTemperature.Text.IsNullOrEmpty())
                    {
                        // 溫度必須是數值
                        ttbTemperature.MustDecimal(lblTemperature);
                        // 將量測資料記錄到客製表
                        var edcCompInfo = InfoCenter.Create <CSTEDCComponentInfo>();
                        edcCompInfo.ComponentID  = ComponentInfo.ComponentID;
                        edcCompInfo.Data         = ttbTemperature.Text.ToDecimal();
                        edcCompInfo.Lot          = ProcessLotData.Lot;
                        edcCompInfo["LINKSID"]   = txnStamp.LinkSID;
                        edcCompInfo["PARAMETER"] = "Temperature";
                        edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }

                    var lstCompAttr = new List <ModifyAttributeInfo>();
                    // 紀錄子單元量測時間
                    lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_TIME", txnStamp.RecordTime));
                    lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("DMC", ttbWorkpiece.Text.Trim()));
                    if (inSpec)
                    {
                        // 修改子單元系統屬性
                        lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_FLAG", "OK"));
                        WIPTransaction.ModifyLotComponentMultipleAttribute(ProcessLotData, ComponentInfo, lstCompAttr, txnStamp);
                    }
                    else
                    {
                        // 修改子單元系統屬性
                        lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_FLAG", "NG"));
                        WIPTransaction.ModifyLotComponentMultipleAttribute(ProcessLotData, ComponentInfo, lstCompAttr, txnStamp);

                        #region 若不在規格範圍內則拆批至待判站點
                        var                  lstSourceLot         = new List <LotInfo>();
                        List <SqlAgent>      splitLotArchiSQLList = new List <SqlAgent>();
                        List <ComponentInfo> lsComponentDatas     = new List <ComponentInfo>();
                        lsComponentDatas.Add(ComponentInfo);

                        var generator = NamingIDGenerator.GetRule("SplitLot");
                        if (generator == null)
                        {
                            //WRN-00411,找不到可產生的序號,請至命名規則維護設定,規則名稱:{0}!!!
                            throw new Exception(TextMessage.Error.T00437("SplitLot"));
                        }
                        var serialData = generator.GenerateNextIDs(1, ProcessLotData, new string[] { }, User.Identity.Name);
                        splitLotArchiSQLList = serialData.Second;
                        var splitLotID = serialData.First[0];

                        var          reasonCategoryInfo = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER");
                        SplitLotInfo splitLotData       = SplitLotInfo.CreateSplitLotByLotAndQuantity(ProcessLotData.Lot, splitLotID, lsComponentDatas, reasonCategoryInfo, "EDC");

                        WIPTxn.SplitIndicator splitInd = WIPTxn.SplitIndicator.Create();
                        WIPTxn.Default.SplitLot(ProcessLotData, splitLotData, splitInd, txnStamp);

                        //若子單元為自動產生,更新序號至DB
                        if (splitLotArchiSQLList != null && splitLotArchiSQLList.Count > 0)
                        {
                            DBCenter.ExecuteSQL(splitLotArchiSQLList);
                        }
                        #endregion

                        var splitLotInfo = LotInfo.GetLotByLot(splitLotID);

                        // 新增Defect
                        List <ComponentDefectObject> lstCompDefectObj = new List <ComponentDefectObject>();
                        var reason = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "MeasureNG_MES");
                        lstCompDefectObj.Add(ComponentDefectObject.Create(ComponentInfo, 1, 0, reason, "CENTER_HOLE_FLAG:NG"));
                        WIPTransaction.DefectComponent(splitLotInfo, lstCompDefectObj, WIPTransaction.DefectIndicator.Create(), txnStamp);

                        #region ReassignOperation
                        // 取得待判站點設定
                        var saiJudgeOperation = WpcExClassItemInfo.GetExClassItemInfo("SAIJudgeOperation", splitLotInfo["PROCESS"].ToString());
                        if (saiJudgeOperation.Count == 0)
                        {
                            throw new RuleCimesException(TextMessage.Error.T00555("SAIJudgeOperation", splitLotInfo["PROCESS"].ToString()));
                        }
                        var reassignOperationInfo = RouteOperationInfo.GetLotAllRouteOperations(splitLotInfo).Find(oper => oper.OperationName == saiJudgeOperation[0].Remark02);
                        if (reassignOperationInfo == null)
                        {
                            throw new RuleCimesException(RuleMessage.Error.C10050());
                        }

                        var lstLotAttr = new List <ModifyLotAttributeInfo>();
                        // 修改批號系統屬性
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL01", "Y"));
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL02", splitLotInfo.OperationSequence));
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL03", splitLotInfo.OperationName));
                        WIPTransaction.ModifyLotMultipleAttribute(splitLotInfo, lstLotAttr, txnStamp);
                        WIPTransaction.ReassignOperation(splitLotInfo, reassignOperationInfo, reasonCategoryInfo, "EDCSplitReassignOperation", txnStamp);
                        WIPTransaction.ResetLotRule(splitLotInfo, txnStamp);
                        #endregion
                    }
                    cts.Complete();
                }

                ClearUI();
                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 判定NG直接拆批及送待判工作站
        /// </summary>
        /// <param name="componentID">工件序號</param>
        /// <param name="defectDescription">不良說明</param>
        /// <param name="reasonData">待判原因碼</param>
        /// <param name="txnStamp"></param>
        public static void SplitDefectLot(string componentID, string defectDescription, ReasonCategoryInfo reasonData, TransactionStamp txnStamp)
        {
            //待判工作站點名稱
            string judgeOperationName = "";

            //取得批號子單元資訊
            var component = ComponentInfo.GetComponentByComponentID(componentID);

            //取得批號資料
            var txnLotData = LotInfo.GetLotByLot(component.CurrentLot).ChangeTo <LotInfoEx>();

            //在系統資料維護裡,取得此批號對應製程(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;

            //取得不良子批批號名稱
            var splitLotNaming = CustomizeFunction.GetNamingRule("SplitLot", txnStamp.UserID, 1, 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, defectDescription);

            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");

            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
        }