Exemplo n.º 1
0
 public override void init()
 {
     try
     {
         //從Ini檔中獲取BU/Plant/DB/Cust/Count/ConvertWo/DownloadWO
         BU    = ConfigGet("BU");
         Plant = ConfigGet("PLANT");
         DB    = ConfigGet("DB");//與App.config中配置的匹配
         CUST  = ConfigGet("CUST");
         COUNT = ConfigGet("COUNT");
         //可以依工單前綴來確定哪種類型的工單需要自動轉,哪種需手動轉
         arrayConvertWO = ConfigGet("CONVERTWO").Split(',');
         _downloadWO    = ConfigGet("DOWNLOADWO");
         List <System.Net.IPAddress> temp = HWDNNSFCBase.HostInfo.IP.Where(ipv4 => ipv4.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToList();
         ip = temp[0].ToString();
         //創建DownloadWO_UI,并附值給輸入對象Output.UI
         Output.UI = new DownLoadWO_UI(this);
         //依據Ini檔配置的DB從ConnectionManager中獲取數據庫連接
         SFCDB = new OleExec(DB, false);
         //程序運行狀態表
         synLock = new T_R_SYNC_LOCK(SFCDB, DB_TYPE_ENUM.Oracle);
         //工單欄位對照表
         C_TAB_COLUMN_MAP = new T_C_TAB_COLUMN_MAP(SFCDB, DB_TYPE_ENUM.Oracle);
         //從SAP Download下來后分別存儲在以下三張表
         R_WO_HEADER = new T_R_WO_HEADER(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_ITEM   = new T_R_WO_ITEM(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_TEXT   = new T_R_WO_TEXT(SFCDB, DB_TYPE_ENUM.Oracle);
         //獲取料號/Route
         C_SKU       = new T_C_SKU(SFCDB, DB_TYPE_ENUM.Oracle);
         RouteDetail = new T_C_ROUTE_DETAIL(SFCDB, DB_TYPE_ENUM.Oracle);
         C_ROUTE     = new T_C_ROUTE(SFCDB, DB_TYPE_ENUM.Oracle);
         T_Series    = new T_C_SERIES(SFCDB, DB_TYPE_ENUM.Oracle);
         //工單類型及前綴信息
         WOType      = new T_R_WO_TYPE(SFCDB, DB_TYPE_ENUM.Oracle);
         Keypart     = new T_C_KEYPART(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_BASE   = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle);
         t_c_kp_list = new T_C_KP_LIST(SFCDB, DB_TYPE_ENUM.Oracle);
         //創建RFC類:建立SAP連接,建立RFC輸入輸出參數
         ZRFC_SFC_NSG_0001B = new ZRFC_SFC_NSG_0001B(BU);
     }
     catch (Exception e)
     {
         throw new Exception("Init DownLoadWO Fail" + e.Message);
     }
     //取得RFC的輸出參數Table對象,并附值給Output.Tables
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("ITAB"));
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_HEADER"));
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_ITEM"));
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_TEXT"));
 }
Exemplo n.º 2
0
        public static List <KPListBase> GetKPListBySkuNo(string Skuno, MESDBHelper.OleExec SFCDB)
        {
            List <KPListBase> ret = new List <KPListBase>();
            T_C_KP_LIST       T   = new T_C_KP_LIST(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
            List <string>     IDS = T.GetListIDBySkuno(Skuno, SFCDB);

            for (int i = 0; i < IDS.Count; i++)
            {
                KPListBase I = new KPListBase(IDS[i], SFCDB);
                ret.Add(I);
            }

            return(ret);
        }
Exemplo n.º 3
0
        public static List <C_KP_LIST> getAllData(OleExec sfcdb)
        {
            List <C_KP_LIST> ret = new List <C_KP_LIST>();
            T_C_KP_LIST      T   = new T_C_KP_LIST(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);

            string        strSql = "select * from C_KP_LIST order by skuno";
            DataSet       res    = sfcdb.RunSelect(strSql);
            Row_C_KP_LIST R      = (Row_C_KP_LIST)T.NewRow();

            for (int i = 0; i < res.Tables[0].Rows.Count; i++)
            {
                R.loadData(res.Tables[0].Rows[i]);
                ret.Add(R.GetDataObject());
            }

            return(ret);
        }
Exemplo n.º 4
0
        public static KPListBase GetKPListByListName(string ListName, MESDBHelper.OleExec SFCDB)
        {
            List <KPListBase> ret = new List <KPListBase>();
            T_C_KP_LIST       T   = new T_C_KP_LIST(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
            //List<string> IDS = T.GetListIDBySkuno(Skuno, SFCDB);
            string  strSql = $@"select ID from c_kp_list where listname='{ListName}'";
            DataSet res    = SFCDB.RunSelect(strSql);

            if (res.Tables[0].Rows.Count > 0)
            {
                return(new KPListBase(res.Tables[0].Rows[0]["ID"].ToString(), SFCDB));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public void CheckKPListName(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow();
            string ListName           = Data["ListName"].ToString();

            try
            {
                MESDataObject.Module.T_C_KP_LIST T = new T_C_KP_LIST(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
                StationReturn.Data   = T.CheckKPListName(ListName, SFCDB);
                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);
        }
Exemplo n.º 6
0
        public KPListBase(string ID, OleExec sfcdb)
        {
            T_C_KP_LIST   T = new T_C_KP_LIST(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
            Row_C_KP_LIST R = (Row_C_KP_LIST)T.GetObjByID(ID, sfcdb);

            if (R != null)
            {
                value = R.GetDataObject();
            }
            else
            {
                throw new Exception($@"查詢不到ID為:{ID} 的KP_LIST");
            }
            List <string> itemID = T.GetItemID(ID, sfcdb);

            for (int i = 0; i < itemID.Count; i++)
            {
                KPListItem I = new KPListItem(itemID[i], this, sfcdb);
                Item.Add(I);
            }
        }
Exemplo n.º 7
0
        public static void UpdateWOKeypartID(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 1)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            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 }));
            }
            try
            {
                int       result;
                WorkOrder objWorkorder = new WorkOrder();
                objWorkorder = (WorkOrder)sessionWO.Value;
                T_C_KP_LIST   t_c_kp_list = new T_C_KP_LIST(Station.SFCDB, Station.DBType);
                T_R_WO_BASE   t_r_wo_base = new T_R_WO_BASE(Station.SFCDB, Station.DBType);
                Row_R_WO_BASE rowWOBase;
                List <string> kpList = t_c_kp_list.GetListIDBySkuno(objWorkorder.SkuNO, Station.SFCDB);
                if (kpList.Count == 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { objWorkorder.SkuNO }));
                }
                rowWOBase            = (Row_R_WO_BASE)t_r_wo_base.GetObjByID(objWorkorder.ID, Station.SFCDB);
                rowWOBase.KP_LIST_ID = kpList[0].ToString();
                result = Station.SFCDB.ExecSqlNoReturn(rowWOBase.GetUpdateString(Station.DBType), null);
                if (result <= 0)
                {
                    //報錯信息待改
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { objWorkorder.WorkorderNo }));
                }
                Station.AddMessage("MES00000063", new string[] { objWorkorder.WorkorderNo }, StationMessageState.Pass);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
 public override void init()
 {
     try
     {
         BU             = ConfigGet("BU");
         Plant          = ConfigGet("PLANT");
         DB             = ConfigGet("DB");
         CUST           = ConfigGet("CUST");
         COUNT          = ConfigGet("COUNT");
         arrayConvertWO = ConfigGet("CONVERTWO").Split(',');
         _downloadWO    = ConfigGet("DOWNLOADWO");
         List <System.Net.IPAddress> temp = HWDNNSFCBase.HostInfo.IP.Where(ipv4 => ipv4.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToList();
         ip                 = temp[0].ToString();
         Output.UI          = new DownLoadWO_UI(this);
         SFCDB              = new OleExec(DB, false);
         synLock            = new T_R_SYNC_LOCK(SFCDB, DB_TYPE_ENUM.Oracle);
         C_TAB_COLUMN_MAP   = new T_C_TAB_COLUMN_MAP(SFCDB, DB_TYPE_ENUM.Oracle);
         C_SKU              = new T_C_SKU(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_HEADER        = new T_R_WO_HEADER(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_ITEM          = new T_R_WO_ITEM(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_TEXT          = new T_R_WO_TEXT(SFCDB, DB_TYPE_ENUM.Oracle);
         RouteDetail        = new T_C_ROUTE_DETAIL(SFCDB, DB_TYPE_ENUM.Oracle);
         WOType             = new T_R_WO_TYPE(SFCDB, DB_TYPE_ENUM.Oracle);
         Keypart            = new T_C_KEYPART(SFCDB, DB_TYPE_ENUM.Oracle);
         C_ROUTE            = new T_C_ROUTE(SFCDB, DB_TYPE_ENUM.Oracle);
         R_WO_BASE          = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle);
         T_Series           = new T_C_SERIES(SFCDB, DB_TYPE_ENUM.Oracle);
         t_c_kp_list        = new T_C_KP_LIST(SFCDB, DB_TYPE_ENUM.Oracle);
         ZRFC_SFC_NSG_0001B = new ZRFC_SFC_NSG_0001B(BU);
     }
     catch (Exception e)
     {
         throw new Exception("Init DownLoadWO Fail" + e.Message);
     }
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("ITAB"));
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_HEADER"));
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_ITEM"));
     Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_TEXT"));
 }
Exemplo n.º 9
0
        public void UpLoadKPList(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow();
            SFCDB.BeginTrain();
            try
            {
                string Skuno    = Data["SkuNo"].ToString();
                string ListName = Data["ListName"].ToString();
                Newtonsoft.Json.Linq.JToken ListData = Data["ListData"];
                T_C_KP_LIST   T         = new T_C_KP_LIST(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
                string        NewListID = T.GetNewID(this.BU, SFCDB);
                Row_C_KP_LIST R         = (Row_C_KP_LIST)T.NewRow();
                DateTime      Now       = DateTime.Now;

                T_C_KP_List_Item   TItem = new T_C_KP_List_Item(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
                Row_C_KP_List_Item RItem = (Row_C_KP_List_Item)TItem.NewRow();

                T_C_KP_List_Item_Detail   TDetail = new T_C_KP_List_Item_Detail(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
                Row_C_KP_List_Item_Detail RDetail = (Row_C_KP_List_Item_Detail)TDetail.NewRow();

                KPListBase oldList = KPListBase.GetKPListByListName(ListName, SFCDB);
                if (oldList != null)
                {
                    oldList.ReMoveFromDB(SFCDB);
                }

                R.ID        = NewListID;
                R.SKUNO     = Skuno.Trim();
                R.LISTNAME  = ListName;
                R.EDIT_EMP  = this.LoginUser.EMP_NO;
                R.EDIT_TIME = Now;

                SFCDB.ExecSQL(R.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle));
                //Item	PartNO	KPName	Station	QTY	ScanType
                DataTable dt = new DataTable();
                dt.Columns.Add("Item");
                dt.Columns.Add("PartNO");
                dt.Columns.Add("KPName");
                dt.Columns.Add("Station");
                dt.Columns.Add("QTY");
                dt.Columns.Add("ScanType");
                List <DataRow> ListItem = new List <DataRow>();
                for (int i = 0; i < ListData.Count(); i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["Item"]     = ListData[i]["Item"].ToString();
                    dr["PartNO"]   = ListData[i]["PartNO"].ToString();
                    dr["KPName"]   = ListData[i]["KPName"].ToString();
                    dr["Station"]  = ListData[i]["Station"].ToString();
                    dr["QTY"]      = ListData[i]["QTY"].ToString();
                    dr["ScanType"] = ListData[i]["ScanType"].ToString();
                    dt.Rows.Add(dr);
                    ListItem.Add(dr);
                }
                Dictionary <string, string> Item = new Dictionary <string, string>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (!Item.ContainsKey(dt.Rows[i]["Item"].ToString()))
                    {
                        Item.Add(dt.Rows[i]["Item"].ToString(), dt.Rows[i]["PartNO"].ToString());
                    }
                }
                string[] itemNo = new string[Item.Keys.Count];
                Item.Keys.CopyTo(itemNo, 0);
                for (int i = 0; i < itemNo.Length; i++)
                {
                    List <DataRow> Items = ListItem.FindAll(TT => TT["Item"].ToString() == itemNo[i]);
                    for (int j = 0; j < Items.Count; j++)
                    {
                        if (j == 0)
                        {
                            RItem.ID        = TItem.GetNewID(BU, SFCDB);
                            RItem.LIST_ID   = NewListID;
                            RItem.KP_NAME   = Items[j]["KPName"].ToString();
                            RItem.KP_PARTNO = Items[j]["PartNO"].ToString();
                            RItem.STATION   = Items[j]["Station"].ToString();
                            RItem.QTY       = double.Parse(Items[j]["QTY"].ToString());
                            RItem.SEQ       = i;
                            RItem.EDIT_EMP  = this.LoginUser.EMP_NO;
                            RItem.EDIT_TIME = Now;
                            SFCDB.ExecSQL(RItem.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle));
                        }

                        RDetail.ID        = TDetail.GetNewID(BU, SFCDB);
                        RDetail.ITEM_ID   = RItem.ID;
                        RDetail.SCANTYPE  = Items[j]["ScanType"].ToString();
                        RDetail.SEQ       = j + 1;
                        RDetail.EDIT_EMP  = RItem.EDIT_EMP;
                        RDetail.EDIT_TIME = Now;
                        SFCDB.ExecSQL(RDetail.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle));
                    }
                }

                StationReturn.Status = StationReturnStatusValue.Pass;
            }
            catch (Exception ee)
            {
                SFCDB.RollbackTrain();
                this.DBPools["SFCDB"].Return(SFCDB);
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ee.Message);
                return;
            }
            SFCDB.CommitTrain();
            this.DBPools["SFCDB"].Return(SFCDB);
        }
Exemplo n.º 10
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;
            }
        }
Exemplo n.º 11
0
        public void startWO(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec Sfcdb  = this.DBPools["SFCDB"].Borrow();
            string  WO     = Data["WO"].ToString();
            T_R_SN  t_r_sn = new T_R_SN(Sfcdb, this.DBTYPE);
            string  id     = t_r_sn.findOneSNByWO(WO, Sfcdb);

            if (!string.IsNullOrEmpty(id))
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "工单已展开,不能重复展开";
                return;
            }
            T_R_WO_HEADER_TJ   t_R_WO_HEADER_TJ = new T_R_WO_HEADER_TJ(Sfcdb, this.DBTYPE);
            Row_R_WO_HEADER_TJ row_R_WO_HEADER  = t_R_WO_HEADER_TJ.GetWo(WO, Sfcdb);
            T_C_SKU            table_sku        = new T_C_SKU(Sfcdb, this.DBTYPE);
            string             user             = this.LoginUser.EMP_NO;

            MESDataObject.Module.SkuObject SkuObject = table_sku.GetSkuBySkuno(row_R_WO_HEADER.MATNR, Sfcdb);
            float qty = float.Parse(row_R_WO_HEADER.GAMNG);

            qty = 5;
            //获取路由id
            T_R_SKU_ROUTE t_R_SKU_ROUTE = new T_R_SKU_ROUTE(Sfcdb, this.DBTYPE);
            string        routeid       = t_R_SKU_ROUTE.getRouteIdBySkuName(row_R_WO_HEADER.MATNR, Sfcdb);
            //获取keypartlistid
            T_C_KP_LIST   t_C_KP_LIST    = new T_C_KP_LIST(Sfcdb, this.DBTYPE);
            List <string> keypartlistids = t_C_KP_LIST.GetListIDBySkuno(row_R_WO_HEADER.MATNR, Sfcdb);

            if (keypartlistids.Count == 0)
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "未配置keypartlistid";
                return;
            }
            //生成工单基础表
            T_R_WO_BASE t_R_WO_BASE = new T_R_WO_BASE(Sfcdb, this.DBTYPE);

            t_R_WO_BASE.deleteWOByWo(WO, Sfcdb);
            t_R_WO_BASE.addWOByWOHeader(BU, user, routeid, row_R_WO_HEADER, Sfcdb);

            WorkOrder objWorkorder = new WorkOrder();

            objWorkorder.Init(WO, Sfcdb);
            objWorkorder.WorkorderNo = WO;
            objWorkorder.KP_LIST_ID  = keypartlistids[0].ToString();
            objWorkorder.SkuNO       = row_R_WO_HEADER.MATNR;

            //生成SN
            for (int i = 0; i < qty; i++)
            {
                String nextSN = SNmaker.GetNextSN(SkuObject.SnRule, Sfcdb, WO);
                Console.Out.WriteLine(nextSN);
                t_r_sn.addStartSNRecords(BU, user, WO, routeid, row_R_WO_HEADER, nextSN, Sfcdb);
            }
            //生成keypartlistid

            List <R_SN> r_sns = t_r_sn.GETSN(WO, Sfcdb);

            for (int i = 0; i < r_sns.Count; i++)
            {
                T_C_KP_LIST c_kp_list = new T_C_KP_LIST(Sfcdb, this.DBTYPE);
                if (objWorkorder.KP_LIST_ID != "" && c_kp_list.KpIDIsExist(objWorkorder.KP_LIST_ID, Sfcdb))
                {
                    SN             snObject = new SN();
                    MESStationBase Station  = new MESStationBase();
                    Station.BU        = this.LoginUser.BU;
                    Station.LoginUser = this.LoginUser;
                    Station.SFCDB     = Sfcdb;
                    snObject.InsertR_SN_KP(objWorkorder, r_sns[i], Sfcdb, Station, this.DBTYPE);
                }
            }


            StationReturn.Data    = qty;
            StationReturn.Status  = StationReturnStatusValue.Pass;
            StationReturn.Message = MESReturnMessage.GetMESReturnMessage("MSGCODE20180801141046");
        }