Esempio n. 1
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));
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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);
            }
        }