Exemple #1
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");
                }
            }
        }
Exemple #2
0
 public static void SystemSNScanRuleChecker(SN_KP config, LogicObject.SN sn, Row_R_SN_KP scan, List <Row_R_SN_KP> scans, MesAPIBase API, OleExec sfcdb)
 {
     LogicObject.SN kpsn = new LogicObject.SN(scan.VALUE, sfcdb, DB_TYPE_ENUM.Oracle);
     if (kpsn.CompletedFlag != "1")
     {
         throw new Exception($@"{kpsn.SerialNo} not finish !");
     }
     if (kpsn.ShippedFlag == "1")
     {
         throw new Exception($@"{kpsn.SerialNo} has being Shipped!");
     }
     if (kpsn.baseSN.SKUNO != scan.PARTNO)
     {
         throw new Exception($@"{kpsn.SerialNo} is {kpsn.SkuNo} config is {scan.PARTNO}");
     }
     kpsn.baseSN.SHIPPED_FLAG = "1";
     kpsn.baseSN.SHIPDATE     = DateTime.Now;
     kpsn.baseSN.EDIT_TIME    = DateTime.Now;
     kpsn.baseSN.EDIT_EMP     = API.LoginUser.EMP_NO;
     sfcdb.ORM.Updateable <R_SN>(kpsn.baseSN).Where(t => t.ID == kpsn.baseSN.ID).ExecuteCommand();
 }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
0
 public static void CheckTEST(SN_KP config, LogicObject.SN sn, Row_R_SN_KP scan, List <Row_R_SN_KP> scans, MesAPIBase API, OleExec sfcdb)
 {
 }