Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 確認出站後是否有下一站的預約紀錄,如果有,則將批號進站至下一個工作站
        /// </summary>
        /// <param name="txnLotData">機加批號</param>
        /// <param name="txnStamp"></param>
        public void CheckNextReserveCheckIn(LotInfoEx txnLotData, TransactionStamp txnStamp)
        {
            //取得預約工作站資料
            var WIPNextReserveList = CSTWIPReserveCheckInInfo.GetDataByLot(txnLotData.Lot);

            if (WIPNextReserveList.Count > 0)
            {
                //下一個預約工作站資料
                var reserveData = WIPNextReserveList[0];

                //將預約的進站時間回寫到hist的Remark01
                txnStamp.Remark01 = reserveData.InTime;

                //取得機台資料
                var equipData = EquipmentInfo.GetEquipmentByName(reserveData.Equipment);
                if (equipData == null)
                {
                    //[00885]機台{0}不存在!
                    throw new Exception(TextMessage.Error.T00885(reserveData.Equipment));
                }

                //取得機台狀態資料
                var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("RUN");

                if (equipData.CurrentState != "RUN")
                {
                    //更新機台狀態
                    EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                }

                //批號上機台
                EMSTxn.Default.AddLotToEquipment(txnLotData, equipData, txnStamp);

                //批號進站
                WIPTransaction.CheckIn(txnLotData, equipData.EquipmentName, "", "", LotDefaultStatus.Run.ToString(), txnStamp);

                //將批號Dispatch到下一規則
                WIPTransaction.DispatchLot(txnLotData, txnStamp);
            }
        }
Beispiel #4
0
        /// <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);

                //檢查維修原因是否有選擇
                ddlRepairReasonCode.Must(lblJudgeReason);

                #region 檢查維修結果是否有選擇
                if (rdbOK.Checked == false && rdbNG.Checked == false)
                {
                    throw new Exception(TextMessage.Error.T00841(lblRepairResult.Text));
                }
                #endregion

                using (var cts = CimesTransactionScope.Create())
                {
                    //選取的原因碼
                    var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlRepairReasonCode.SelectedValue);

                    #region 紀錄維修結束 To do...
                    List <WIPRepairFinishInfo> repairFinishDatas = new List <WIPRepairFinishInfo>();

                    var repairData = WIPRepairInfo.GetRepairByLotAndReason(_LotData.Lot, _DefectJudgementData.Reason);

                    var repairFinishData = WIPRepairFinishInfo.CreateInfo(repairData);

                    repairFinishData.ActionCategory   = reasonCategory.Category;
                    repairFinishData.ActionReasonCode = reasonCategory.Reason;
                    repairFinishData.ActionReasonSID  = reasonCategory.ReasonSID;
                    repairFinishData.Result           = rdbOK.Checked ? "OK" : "NG";
                    repairFinishDatas.Add(repairFinishData);

                    var issueOperation = OperationInfo.GetOperationByName(_LotData.OperationName);

                    WIPTransaction.RepairEnd(_LotData, repairFinishDatas, issueOperation, txnStamp);

                    #endregion

                    #region 2017/10/26 跟詩涵確認,無論維修結果如何,一律送回待判站由品保決定處理結果

                    /*
                     #region OK:依照批號的UDC02(工作站序號)+UDC03(工作站名稱)找出預設流程的下一站點,將批號跳站至該站
                     *
                     * if (rdbOK.Checked)
                     * {
                     *  //取得流程線上版本 取得目前Lot的所有流程(所有工作站)
                     *  RouteVersionInfo RouteVersion = RouteVersionInfo.GetRouteActiveVersion(_LotData.RouteName);
                     *
                     *  //以此工作站名稱去查詢在流程中的序號
                     *  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.CheckOut(_LotData, txnStamp);
                     *
                     *  WIPTransaction.ReassignOperation(_LotData, NextRouteOperation, reasonCategory, ttbRepairDescr.Text, txnStamp);
                     * }
                     #endregion
                     *
                     #region NG:送到下一站
                     * if (rdbNG.Checked)
                     * {
                     *  //執行出站
                     *  WIPTransaction.CheckOut(_LotData, txnStamp);
                     *
                     *  WIPTransaction.DispatchLot(_LotData, txnStamp);
                     * }
                     #endregion
                     *
                     */
                    #endregion

                    //執行出站
                    WIPTransaction.CheckOut(_LotData, txnStamp);

                    WIPTransaction.DispatchLot(_LotData, txnStamp);


                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Beispiel #5
0
        /// <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);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                /*  1.	如有不良數量,先確認有待判站。
                 * 2.	待判站找尋方式:到系統資料設定(MES_WPC_EXTENDITEM)裡找尋屬性SAIJudgeOperation,依照process找出待判站的名稱。如找不到要報錯。(找不到待判站資訊,請至系統資料維護增加資訊,屬性:xxxx。)
                 *  拿MES_WIP_LOT_PROCESS 跟系統資料設定裡的REMARK01比對後,找出工作站點(REMARK02)
                 * 3.	將批號出站。(CheckOut)
                 * 4.	將批號下機。(EQPRemoveLot)
                 * 5.	判定機台容量如果為0,將機台狀態變更為IDLE。(ChangeStaus)
                 *  機台容量判定方式:MES_EQP_EQP. CAPACITY = 0。
                 * 6.	將CST_WIP_RESERVE_CHECKIN_INFO搬移至CST_WIP_RESERVE_CHECKIN_INFO_LOG。
                 *  資料條件:Lot + Operation
                 * 7.	如有不良數量,拆一個不良批號,將批號送到待判站。(Defect、SplitLot、ReassignOperation)
                 * 8.	將原批號派送至下一規則。(Dispatch)
                 */

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    //取得批號資料
                    var txnLotData = _LotData;

                    //取得批號上機台資料
                    var equipmentLotData = EquipmentLotInfo.GetEquipmentLotByLot(txnLotData.Lot);

                    //如果批號上機台是有資料,表示必須執行機台相關的交易
                    if (equipmentLotData != null)
                    {
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("IDLE");

                        var equipment = EquipmentInfo.GetEquipmentByName(txnLotData.ResourceName);
                        if (equipment == null)
                        {
                            //[00885]機台{0}不存在!
                            throw new Exception(TextMessage.Error.T00885(txnLotData.ResourceName));
                        }

                        //機台移批號
                        EMSTransaction.RemoveLotFromEquipment(txnLotData, equipment, txnStamp);

                        //確認機台的最大容量是否為零,如果不是,則執行變更機台狀態
                        if (equipment.Capacity == 0)
                        {
                            //變更機台狀態 Run=>IDLE
                            EMSTransaction.ChangeState(equipment, newStateInfo, txnStamp);
                        }
                    }

                    //更新預約資料
                    UpdateReserveCheckInData(txnLotData, txnLotData.OperationName, txnStamp);

                    //批號出站
                    WIPTransaction.CheckOut(txnLotData, txnStamp);

                    //如果有不良數量,則拆號及送待判工作站
                    if (_DefectGridData != null && _DefectGridData.Count > 0)
                    {
                        SplitDefectLotList(txnLotData, _DefectGridData, txnStamp);
                    }

                    //將批號Dispatch到下一規則
                    WIPTransaction.DispatchLot(txnLotData, txnStamp);

                    //檢查是否還有預約工作站資料
                    CheckNextReserveCheckIn(txnLotData, txnStamp);

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                /*  1.	檢查畫面上所有輸入欄位是否都已輸入。
                 *  2.	如為當站進站(批號狀態為Wait),則將批號進站併上機台。(EquipmentAddLot、CheckIn、Dispatch)。
                 *  3.	如為預約進站,則將預約資訊塞入客製表,做批號備註。(AddComment)
                 *  4.	清空畫面,游標停在機加批號。
                 */
                string           equipmentName = "";
                EquipmentInfo    equipData     = null;
                TransactionStamp txnStamp      = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台是否有輸入
                if (ttbLot.Text.IsNullOrEmpty() || _LotData == null)
                {
                    AjaxFocus(ttbLot);
                    throw new Exception(TextMessage.Error.T00030(GetUIResource("LotCheckInLot"), ""));
                }

                //如果機台下拉式清單Enabled為TRUE,則必須檢查是否有選擇機台
                if (ddlEquip.Enabled)
                {
                    ddlEquip.Must(lblEquip);

                    //取得機台資訊
                    equipData = EquipmentInfo.GetEquipmentByID(ddlEquip.SelectedValue);

                    //註記機台名稱
                    equipmentName = equipData.EquipmentName;
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //批號狀態為Wait時,表示目前要執行進站
                    if (_LotData.Status == LotDefaultStatus.Wait.ToString())
                    {
                        CheckBom(_LotData.OperationName, equipData, _LotData);

                        if (equipData != null)
                        {
                            //批號上機台
                            EMSTxn.Default.AddLotToEquipment(_LotData, equipData, txnStamp);

                            //取得機台狀態資料
                            var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("RUN");

                            if (equipData.CurrentState != "RUN")
                            {
                                //更新機台狀態
                                EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                            }
                        }

                        //批號進站
                        WIPTransaction.CheckIn(_LotData, equipmentName, "", "", LotDefaultStatus.Run.ToString(), txnStamp);

                        //將批號Dispatch到下一規則
                        WIPTransaction.DispatchLot(_LotData, txnStamp);
                    }
                    else
                    {
                        CheckBom(_WIPReserveCheckInData.OperationName, equipData, _LotData);

                        //執行預約進站功能
                        _WIPReserveCheckInData.Equipment = equipmentName;
                        _WIPReserveCheckInData.InTime    = DBCenter.GetSystemTime();
                        _WIPReserveCheckInData.InsertToDB();

                        //做批號備註。(AddComment)
                        var reason  = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "ReserveLotCheckIn");
                        var massage = "";

                        WIPTransaction.AddLotComment(_LotData, reason, massage, txnStamp);
                    }
                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }