示例#1
0
        /// <summary>
        /// 檢查SN條碼或SN對象的KEYPART
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void SNStationKeypartDatachecker(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);
            OleExec           SFCDB     = Station.SFCDB;
            SN snObject = null;

            if (SNSession.Value is string)
            {
                snObject = new SN(SNSession.Value.ToString(), Station.SFCDB, Station.DBType);
            }
            else
            {
                snObject = (SN)SNSession.Value;
            }

            if (snObject == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { SNSession.Value.ToString() }));
            }

            T_R_SN_KP      TRKP = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle);
            List <R_SN_KP> snkp = TRKP.GetKPRecordBySnIDStation(snObject.ID, Station.StationName, SFCDB);

            List <R_SN_KP> kpwait = snkp.FindAll(T => T.VALUE == "" || T.VALUE == null);

            if (kpwait.Count > 0)
            {
                Station.AddKPScan(snObject.SerialNo, snObject.WorkorderNo, Station.StationName);
                throw new Exception($@"{snObject.SerialNo} 缺少Keypart");
            }
        }
示例#2
0
        public static void RepairPCBASNChecker(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 2)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null || SNSession.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "PCBASNSession" }));
            }
            MESStationSession PCBASNSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (PCBASNSession == null || PCBASNSession.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "PCBASNSession" }));
            }
            try
            {
                LogicObject.SN snObject = (LogicObject.SN)SNSession.Value;
                if (snObject.SerialNo != PCBASNSession.Value.ToString() && snObject.BoxSN != PCBASNSession.Value.ToString())
                {
                    T_R_SN_KP t_sn_kp = new T_R_SN_KP(Station.SFCDB, Station.DBType);
                    if (!t_sn_kp.KpIsLinkBySN(snObject.ID, PCBASNSession.Value.ToString(), Station.SFCDB))
                    {
                        throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180616081316", new string[] { PCBASNSession.Value.ToString(), snObject.SerialNo }));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public static void LastScanRuleChecker(SN_KP config, LogicObject.SN sn, Row_R_SN_KP scan, List <Row_R_SN_KP> scans, MesAPIBase API, OleExec sfcdb)
        {
            T_R_SN_KP      t_r_sn_kp     = new T_R_SN_KP(sfcdb, DB_TYPE_ENUM.Oracle);
            List <R_SN_KP> kpList        = t_r_sn_kp.GetKPRecordBySnID(sn.ID, sfcdb);
            R_SN_KP        lastScan      = kpList.Find(k => k.SCANSEQ == (scan.SCANSEQ - 1));
            string         scanValue     = scan.VALUE.Substring(4, scan.VALUE.Length - 4);
            string         lastScanVlaue = lastScan.VALUE.Substring(0, scan.VALUE.Length - 4);

            if (lastScan != null)
            {
                if (scanValue != lastScanVlaue)
                {
                    throw new Exception("this value " + scan.VALUE + "is inconsistent with the last one");
                }
            }
        }
示例#4
0
        public static void SNStationKPDatachecker(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);
            //MESStationSession WO = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);
            OleExec SFCDB = Station.SFCDB;

            SN             sn   = (SN)SNSession.Value;
            T_R_SN_KP      TRKP = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle);
            List <R_SN_KP> snkp = TRKP.GetKPRecordBySnIDStation(sn.ID, Station.StationName, SFCDB);

            List <R_SN_KP> kpwait = snkp.FindAll(T => T.VALUE == "" || T.VALUE == null);

            if (kpwait.Count > 0)
            {
                Station.AddKPScan(sn.SerialNo, sn.WorkorderNo, Station.StationName);
                //throw new Exception($@"{sn.SerialNo} 缺少Keypart");
            }
        }
示例#5
0
        public void GetSNStationKPList(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow();
            try
            {
                string strSN      = Data["SN"].ToString();
                string strSTATION = Data["STATION"].ToString();
                string strWO      = null;
                try
                {
                    strWO = Data["WO"].ToString();
                }
                catch
                { }

                LogicObject.SN SN = new LogicObject.SN();
                SN.Load(strSN, SFCDB, DB_TYPE_ENUM.Oracle);

                MESDataObject.Module.T_R_WO_BASE TWO = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle);
                Row_R_WO_BASE RWO  = TWO.GetWo(SN.WorkorderNo, SFCDB);
                T_R_SN_KP     TRKP = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle);

                List <R_SN_KP> snkp = TRKP.GetKPRecordBySnIDStation(SN.ID, strSTATION, SFCDB);

                SN_KP ret = new SN_KP(snkp, SN.WorkorderNo, SN.SkuNo, SFCDB);


                StationReturn.Data   = ret;
                StationReturn.Status = StationReturnStatusValue.Pass;
            }
            catch (Exception ee)
            {
                //this.DBPools["SFCDB"].Return(SFCDB);
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ee.Message);
            }
            this.DBPools["SFCDB"].Return(SFCDB);
        }
示例#6
0
        public void ScanKPItem(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow();
            SFCDB.BeginTrain();
            try
            {
                /*
                 * new APIInputInfo() {InputName = "SN", InputType = "STRING", DefaultValue = ""},
                 * new APIInputInfo() {InputName = "STATION", InputType = "STRING", DefaultValue = ""},
                 * new APIInputInfo() {InputName = "KPITEM", InputType = "STRING", DefaultValue = ""}
                 */
                string         strSN     = Data["SN"].ToString();
                string         station   = Data["STATION"].ToString();
                JToken         _ItemData = Data["KPITEM"];
                T_R_SN_KP      TRKP      = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle);
                List <R_SN_KP> ItemData  = new List <R_SN_KP>();
                for (int i = 0; i < _ItemData.Count(); i++)
                {
                    if (TRKP.CheckLinkByValue(_ItemData[i]["VALUE"].ToString(), SFCDB))
                    {
                        throw new Exception(_ItemData[i]["VALUE"].ToString() + " has been link on other sn!");
                    }
                    R_SN_KP I = new R_SN_KP();
                    I.ID        = _ItemData[i]["ID"].ToString();
                    I.VALUE     = _ItemData[i]["VALUE"].ToString();
                    I.MPN       = _ItemData[i]["MPN"].ToString();
                    I.PARTNO    = _ItemData[i]["PARTNO"].ToString();
                    I.SCANTYPE  = _ItemData[i]["SCANTYPE"].ToString();
                    I.ITEMSEQ   = double.Parse(_ItemData[i]["ITEMSEQ"].ToString());
                    I.SCANSEQ   = double.Parse(_ItemData[i]["SCANSEQ"].ToString());
                    I.DETAILSEQ = double.Parse(_ItemData[i]["DETAILSEQ"].ToString());

                    ItemData.Add(I);
                }
                if (ItemData.Count == 0)
                {
                    StationReturn.Status = StationReturnStatusValue.Pass;
                }

                LogicObject.SN SN = new LogicObject.SN();
                SN.Load(strSN, SFCDB, DB_TYPE_ENUM.Oracle);
                MESDataObject.Module.T_R_WO_BASE TWO = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle);
                Row_R_WO_BASE RWO = TWO.GetWo(SN.WorkorderNo, SFCDB);

                List <R_SN_KP> snkp     = TRKP.GetKPRecordBySnIDStation(SN.ID, station, SFCDB);
                SN_KP          KPCONFIG = new SN_KP(snkp, SN.WorkorderNo, SN.SkuNo, SFCDB);

                R_SN_KP kpItem = KPCONFIG.KPS.Find(T => T.ID == ItemData[0].ID);
                if (kpItem == null)
                {
                    throw new Exception("Data Error!");
                }

                List <R_SN_KP> ConfigItem = KPCONFIG.KPS.FindAll(T => T.PARTNO == kpItem.PARTNO &&
                                                                 T.ITEMSEQ == kpItem.ITEMSEQ &&
                                                                 T.SCANSEQ == kpItem.SCANSEQ
                                                                 );

                if (ConfigItem.Count != ItemData.Count)
                {
                    throw new Exception("Data Error! ConfigItem.Count != ItemData.Count");
                }


                for (int i = 0; i < ItemData.Count; i++)
                {
                    Row_R_SN_KP item = (Row_R_SN_KP)TRKP.GetObjByID(ItemData[i].ID, SFCDB);
                    if (item.ITEMSEQ == ItemData[i].ITEMSEQ &&
                        item.SCANSEQ == ItemData[i].SCANSEQ &&
                        item.DETAILSEQ == ItemData[i].DETAILSEQ)
                    {
                        item.VALUE     = ItemData[i].VALUE;
                        item.MPN       = ItemData[i].MPN;
                        item.PARTNO    = ItemData[i].PARTNO;
                        item.EDIT_TIME = DateTime.Now;
                        item.EDIT_EMP  = LoginUser.EMP_NO;
                        SFCDB.ExecSQL(item.GetUpdateString(DB_TYPE_ENUM.Oracle));
                    }
                    else
                    {
                        throw new Exception("Data Error! 1");
                    }
                }



                StationReturn.Status = StationReturnStatusValue.Pass;
                SFCDB.CommitTrain();
            }
            catch (Exception ee)
            {
                SFCDB.RollbackTrain();
                //this.DBPools["SFCDB"].Return(SFCDB);
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ee.Message);
            }
            this.DBPools["SFCDB"].Return(SFCDB);
        }
示例#7
0
        public void ScanKPItem(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow();
            SFCDB.BeginTrain();
            try
            {
                /*
                 * new APIInputInfo() {InputName = "SN", InputType = "STRING", DefaultValue = ""},
                 * new APIInputInfo() {InputName = "STATION", InputType = "STRING", DefaultValue = ""},
                 * new APIInputInfo() {InputName = "KPITEM", InputType = "STRING", DefaultValue = ""}
                 */
                string    strSN     = Data["SN"].ToString();
                string    station   = Data["STATION"].ToString();
                JToken    _ItemData = Data["KPITEM"];
                T_R_SN_KP TRKP      = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle);
                T_R_SN    t_r_sn    = new T_R_SN(SFCDB, DB_TYPE_ENUM.Oracle);

                List <R_SN_KP> ItemData = new List <R_SN_KP>();
                for (int i = 0; i < _ItemData.Count(); i++)
                {
                    //已被綁定的就不能重複綁定
                    if (TRKP.CheckLinkByValue(_ItemData[i]["VALUE"].ToString(), SFCDB))
                    {
                        throw new Exception(_ItemData[i]["VALUE"].ToString() + " has been link on other sn!");
                    }
                    R_SN r_sn = new R_SN();
                    r_sn = t_r_sn.LoadSN(_ItemData[i]["VALUE"].ToString(), SFCDB);
                    //如果KEYPART是本廠做的條碼則必須是完工狀態
                    if (r_sn != null && r_sn.COMPLETED_FLAG != "1")
                    {
                        throw new Exception(_ItemData[i]["VALUE"].ToString() + " is on " + r_sn.NEXT_STATION + ",can't completed!");
                    }
                    R_SN_KP I = new R_SN_KP();
                    I.ID        = _ItemData[i]["ID"].ToString();
                    I.VALUE     = _ItemData[i]["VALUE"].ToString();
                    I.MPN       = _ItemData[i]["MPN"].ToString();
                    I.PARTNO    = _ItemData[i]["PARTNO"].ToString();
                    I.SCANTYPE  = _ItemData[i]["SCANTYPE"].ToString();
                    I.ITEMSEQ   = double.Parse(_ItemData[i]["ITEMSEQ"].ToString());
                    I.SCANSEQ   = double.Parse(_ItemData[i]["SCANSEQ"].ToString());
                    I.DETAILSEQ = double.Parse(_ItemData[i]["DETAILSEQ"].ToString());

                    ItemData.Add(I);
                }
                if (ItemData.Count == 0)
                {
                    StationReturn.Status = StationReturnStatusValue.Pass;
                }

                LogicObject.SN SN = new LogicObject.SN();
                SN.Load(strSN, SFCDB, DB_TYPE_ENUM.Oracle);
                MESDataObject.Module.T_R_WO_BASE TWO = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle);
                Row_R_WO_BASE RWO = TWO.GetWo(SN.WorkorderNo, SFCDB);

                List <R_SN_KP> snkp     = TRKP.GetKPRecordBySnIDStation(SN.ID, station, SFCDB);
                SN_KP          KPCONFIG = new SN_KP(snkp, SN.WorkorderNo, SN.SkuNo, SFCDB);

                R_SN_KP kpItem = KPCONFIG.KPS.Find(T => T.ID == ItemData[0].ID);
                if (kpItem == null)
                {
                    throw new Exception("Data Error!");
                }

                List <R_SN_KP> ConfigItem = KPCONFIG.KPS.FindAll(T => T.PARTNO == kpItem.PARTNO &&
                                                                 T.ITEMSEQ == kpItem.ITEMSEQ &&
                                                                 T.SCANSEQ == kpItem.SCANSEQ
                                                                 );

                if (ConfigItem.Count != ItemData.Count)
                {
                    throw new Exception("Data Error! ConfigItem.Count != ItemData.Count");
                }

                List <Row_R_SN_KP> items = new List <Row_R_SN_KP>();
                for (int i = 0; i < ItemData.Count; i++)
                {
                    Row_R_SN_KP item = (Row_R_SN_KP)TRKP.GetObjByID(ItemData[i].ID, SFCDB);
                    if (item.ITEMSEQ == ItemData[i].ITEMSEQ &&
                        item.SCANSEQ == ItemData[i].SCANSEQ &&
                        item.DETAILSEQ == ItemData[i].DETAILSEQ)
                    {
                        item.VALUE     = ItemData[i].VALUE;
                        item.MPN       = ItemData[i].MPN;
                        item.PARTNO    = ItemData[i].PARTNO;
                        item.EDIT_TIME = DateTime.Now;
                        item.EDIT_EMP  = LoginUser.EMP_NO;
                        SFCDB.ExecSQL(item.GetUpdateString(DB_TYPE_ENUM.Oracle));
                        item.AcceptChange();
                        items.Add(item);
                    }
                    else
                    {
                        throw new Exception("Data Error! 1");
                    }
                }

                for (int i = 0; i < items.Count; i++)
                {
                    var ScanTypes = SFCDB.ORM.Queryable <C_KP_Check>().Where(t => t.TYPENAME == items[i].SCANTYPE).ToList();
                    if (ScanTypes.Count > 0)
                    {
                        Assembly assembly  = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + ScanTypes[0].DLL);
                        Type     APIType   = assembly.GetType(ScanTypes[0].CLASS);
                        object   API_CLASS = assembly.CreateInstance(ScanTypes[0].CLASS);
                        var      Methods   = APIType.GetMethods();
                        var      Funs      = Methods.Where <MethodInfo>(t => t.Name == ScanTypes[0].FUNCTION);
                        if (Funs.Count() > 0)
                        {
                            Funs.ElementAt(0).Invoke(API_CLASS, new object[] { KPCONFIG, SN, items[i], items, this, SFCDB });
                        }
                    }
                }



                StationReturn.Status = StationReturnStatusValue.Pass;
                SFCDB.CommitTrain();
            }
            catch (Exception ee)
            {
                SFCDB.RollbackTrain();
                //this.DBPools["SFCDB"].Return(SFCDB);
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                if (ee.InnerException != null)
                {
                    StationReturn.MessagePara.Add(ee.InnerException.Message);
                }
                else
                {
                    StationReturn.MessagePara.Add(ee.Message);
                }
            }
            this.DBPools["SFCDB"].Return(SFCDB);
        }
示例#8
0
        /// <summary>
        /// 從輸入加載SN對象集合
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void GetSnObjectListDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 4)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057"));
            }
            MESStationSession sessionWO = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (sessionWO == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE }));
            }
            MESStationSession sessionInputType = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionInputType == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE }));
            }
            if (sessionInputType.Value.ToString() == "")
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE }));
            }
            MESStationSession sessionInputString = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionInputString == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE }));
            }
            if (sessionInputString.Value.ToString() == "")
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE }));
            }
            MESStationSession snObjectList = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_KEY && t.SessionKey == Paras[3].SESSION_KEY);

            if (snObjectList == null)
            {
                snObjectList = new MESStationSession()
                {
                    MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[3].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(snObjectList);
            }
            try
            {
                WorkOrder objWorkorder = new WorkOrder();
                objWorkorder = (WorkOrder)sessionWO.Value;
                string      inputType   = sessionInputType.Value.ToString();
                string      inputString = sessionInputString.Value.ToString();
                List <R_SN> snList      = new List <R_SN>();
                T_R_SN_KP   t_r_sn_kp   = new T_R_SN_KP(Station.SFCDB, Station.DBType);
                if (inputType.Equals("SN"))
                {
                    T_R_SN t_r_sn = new T_R_SN(Station.SFCDB, Station.DBType);
                    snList.Add(t_r_sn.LoadSN(inputString, Station.SFCDB));
                }
                else if (inputType.Equals("PANEL"))
                {
                    T_R_PANEL_SN t_r_panel_sn = new T_R_PANEL_SN(Station.SFCDB, Station.DBType);
                    snList = t_r_panel_sn.GetValidSnByPanel(inputString, Station.SFCDB);
                }
                else
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180529094259"));
                }
                snObjectList.Value = snList;
                Station.AddMessage("MES00000001", new string[] { sessionInputString.Value.ToString() }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#9
0
        public void UpdateSNKP(WorkOrder woObject, List <R_SN> snList, BaseClass.MESStationBase Station)
        {
            T_C_KP_LIST             t_c_kp_list             = new T_C_KP_LIST(Station.SFCDB, Station.DBType);
            T_C_KP_List_Item        t_c_kp_list_item        = new T_C_KP_List_Item(Station.SFCDB, Station.DBType);
            T_C_KP_List_Item_Detail t_c_kp_list_item_detail = new T_C_KP_List_Item_Detail(Station.SFCDB, Station.DBType);
            T_R_SN_KP   t_r_sn_kp   = new T_R_SN_KP(Station.SFCDB, Station.DBType);
            T_C_SKU_MPN t_c_sku_mpn = new T_C_SKU_MPN(Station.SFCDB, Station.DBType);
            T_C_KP_Rule c_kp_rule   = new T_C_KP_Rule(Station.SFCDB, Station.DBType);
            Row_R_SN_KP rowSNKP;

            List <C_KP_List_Item>        kpItemList     = new List <C_KP_List_Item>();
            List <C_SKU_MPN>             skuMpnList     = new List <C_SKU_MPN>();
            List <C_KP_List_Item_Detail> itemDetailList = new List <C_KP_List_Item_Detail>();
            C_KP_Rule kpRule  = new C_KP_Rule();
            int       scanseq = 0;
            int       result;
            string    skuMpn = "";

            try
            {
                kpItemList = t_c_kp_list_item.GetItemObjectByListId(woObject.KP_LIST_ID, Station.SFCDB);
                if (kpItemList == null || kpItemList.Count == 0)
                {
                    throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO }));
                }

                foreach (R_SN r_sn in snList)
                {
                    result = t_r_sn_kp.DeleteBySNID(r_sn.ID, Station.SFCDB);
                    if (result <= 0)
                    {
                        throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000083", new string[] { "R_SN_KP:" + r_sn.SN, "DELETE" }));
                    }

                    foreach (C_KP_List_Item kpItem in kpItemList)
                    {
                        itemDetailList = t_c_kp_list_item_detail.GetItemDetailObjectByItemId(kpItem.ID, Station.SFCDB);
                        if (itemDetailList == null || itemDetailList.Count == 0)
                        {
                            throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO }));
                        }

                        skuMpnList = t_c_sku_mpn.GetMpnBySkuAndPartno(Station.SFCDB, woObject.SkuNO, kpItem.KP_PARTNO);
                        if (skuMpnList.Count != 0)
                        {
                            skuMpn = skuMpnList[0].MPN;
                        }


                        foreach (C_KP_List_Item_Detail itemDetail in itemDetailList)
                        {
                            scanseq = scanseq + 1;
                            kpRule  = c_kp_rule.GetKPRule(Station.SFCDB, kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE);
                            if (kpRule == null)
                            {
                                throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE }));
                            }
                            if (kpRule.REGEX == "")
                            {
                                throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE }));
                            }
                            rowSNKP            = (Row_R_SN_KP)t_r_sn_kp.NewRow();
                            rowSNKP.ID         = t_r_sn_kp.GetNewID(Station.BU, Station.SFCDB);
                            rowSNKP.R_SN_ID    = r_sn.ID;
                            rowSNKP.SN         = r_sn.SN;
                            rowSNKP.VALUE      = "";
                            rowSNKP.PARTNO     = kpItem.KP_PARTNO;
                            rowSNKP.KP_NAME    = kpItem.KP_NAME;
                            rowSNKP.MPN        = skuMpn;
                            rowSNKP.SCANTYPE   = itemDetail.SCANTYPE;
                            rowSNKP.ITEMSEQ    = kpItem.SEQ;
                            rowSNKP.SCANSEQ    = scanseq;
                            rowSNKP.DETAILSEQ  = itemDetail.SEQ;
                            rowSNKP.STATION    = kpItem.STATION;
                            rowSNKP.REGEX      = kpRule.REGEX;
                            rowSNKP.VALID_FLAG = 1;
                            rowSNKP.EXKEY1     = "";
                            rowSNKP.EXVALUE1   = "";
                            rowSNKP.EXKEY2     = "";
                            rowSNKP.EXVALUE2   = "";
                            rowSNKP.EDIT_EMP   = Station.LoginUser.EMP_NO;
                            rowSNKP.EDIT_TIME  = Station.GetDBDateTime();
                            result             = Convert.ToInt32(Station.SFCDB.ExecSQL(rowSNKP.GetInsertString(Station.DBType)));
                            if (result <= 0)
                            {
                                throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000083", new string[] { "R_SN_KP:" + r_sn.SN, "ADD" }));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#10
0
        private void Get2000E3CartonValue(R_SN r_sn, OleExec DB)
        {
            t_r_sn_kp           = new T_R_SN_KP(DB, MESDataObject.DB_TYPE_ENUM.Oracle);
            t_c_sku_ver_mapping = new T_C_SKU_VER_MAPPING(DB, DB_TYPE_ENUM.Oracle);

            R_SN kpSN;
            R_SN_STATION_DETAIL snStationDetail = null;
            C_SKU_VER_MAPPING   verMapping      = null;
            R_WO_BASE           r_wo_base       = null;
            List <R_SN_KP>      KPList          = new List <R_SN_KP>();
            List <R_SN_KP>      printKPList     = new List <R_SN_KP>();
            R_SN_KP             printKP         = null;
            R_SN_KP             GPNKP;
            R_SN_KP             GSNKP;
            C_SKU_DETAIL        skuDetail;

            if (r_sn != null)
            {
                r_wo_base = DB.ORM.Queryable <R_WO_BASE>().Where(wo => wo.WORKORDERNO == r_sn.WORKORDERNO).ToList().FirstOrDefault();
                KPList    = t_r_sn_kp.GetKPRecordBySnID(r_sn.ID, DB);

                skuDetail = DB.ORM.Queryable <C_SKU_DETAIL>().Where(d => d.SKUNO == r_wo_base.SKUNO && d.STATION_NAME == I_STATION.Value.ToString() &&
                                                                    d.CATEGORY == "PRINT" && d.CATEGORY_NAME == "KEYPART").ToList().FirstOrDefault();
                if (skuDetail != null)
                {
                    //打印keypart SN 對應的keypart 信息
                    printKP = KPList.Find(k => k.PARTNO == skuDetail.VALUE);
                }

                if (printKP != null)
                {
                    kpSN        = t_r_sn.LoadSN(printKP.VALUE, DB);
                    printKPList = t_r_sn_kp.GetKPRecordBySnID(kpSN.ID, DB);

                    GPNKP = printKPList.Find(k => k.SCANTYPE == "GPN");
                    GSNKP = printKPList.Find(k => k.SCANTYPE == "GSN");
                    if (GPNKP != null)
                    {
                        O_GPN.Value = GPNKP.VALUE;
                    }
                    if (GSNKP != null)
                    {
                        O_GSN.Value = GSNKP.VALUE;
                    }
                }

                snStationDetail = DB.ORM.Queryable <R_SN_STATION_DETAIL>().Where(s => s.R_SN_ID == r_sn.ID && s.STATION_NAME == I_STATION.Value.ToString()).ToList().FirstOrDefault();
                DateTime dateTime = (DateTime)snStationDetail.EDIT_TIME;
                O_PRINTDATE.Value = dateTime.ToString("MM/dd/yyyy");

                verMapping = t_c_sku_ver_mapping.GetMappingBySkuAndVersion(r_wo_base.SKUNO, r_wo_base.SKU_VER, DB);
                if (verMapping != null)
                {
                    O_VER.Value = verMapping.CUSTOMER_VERSION;
                }
                else
                {
                    O_VER.Value = r_wo_base.SKU_VER;
                }
            }
        }