Пример #1
0
        /// <summary>
        /// 從SKU加載Customer
        /// 若Series已裝載則從Series加載
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void CustFromSKUDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            OleExec           sfcdb        = Station.SFCDB;
            C_SERIES          c_series     = null;
            C_CUSTOMER        c_customer   = null;
            MESStationSession serieSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (serieSession == null)
            {
                MESStationSession skuSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);
                if (skuSession == null)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" }));
                }
                SKU sku = (SKU)skuSession.Value;
                if (sku == null)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" }));
                }
                c_series = new T_C_SERIES(sfcdb, DB_TYPE_ENUM.Oracle).GetDetailById(sfcdb, sku.CSeriesId);//sku.CSeriesId
                //是否加入StationSession...
            }
            else
            {
                c_series = (C_SERIES)serieSession.Value;
            }
            if (c_series == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SERIES" }));
            }
            //構建查詢CUSTOMER參數
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("ID", c_series.CUSTOMER_ID);
            List <C_CUSTOMER> customers = new T_C_CUSTOMER(sfcdb, DB_TYPE_ENUM.Oracle).GetCustomerList(parameters, sfcdb);

            if (customers.Count == 0)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "CUSTOMER" }));
            }
            c_customer = customers[0];
            MESStationSession custSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (custSession == null)
            {
                custSession = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, SessionKey = Paras[2].SESSION_KEY
                };
                Station.StationSession.Add(custSession);
            }
            custSession.Value = c_customer;

            Station.AddMessage("MES00000029", new string[] { "CUSTOMER", c_customer.CUSTOMER_NAME }, StationMessageState.Pass);
        }
Пример #2
0
        public void AddSeries(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec    sfcdb        = null;
            T_C_SERIES table        = null;
            string     SeriesObject = string.Empty;
            C_SERIES   series       = null;
            string     result       = string.Empty;

            try
            {
                sfcdb            = this.DBPools["SFCDB"].Borrow();
                table            = new T_C_SERIES(sfcdb, DBTYPE);
                SeriesObject     = Data["SeriesObject"].ToString();
                series           = (C_SERIES)JsonConvert.Deserialize(SeriesObject, typeof(C_SERIES));
                series.EDIT_EMP  = "A0225204";// LoginUser.EMP_NO;
                series.EDIT_TIME = DateTime.Now;
                result           = table.UpdateSeries(BU, series, "ADD", sfcdb);

                if (Int32.Parse(result) > 0)
                {
                    //添加成功
                    ConstructReturns(
                        ref StationReturn,
                        StationReturnStatusValue.Pass,
                        MESReturnMessage.GetMESReturnMessage("UpdateOK", new string[] { result }),
                        result);
                }
                else
                {
                    //沒有添加任何數據
                    ConstructReturns(
                        ref StationReturn,
                        StationReturnStatusValue.Pass,
                        MESReturnMessage.GetMESReturnMessage("UpdateNoData"),
                        result);
                }
            }
            catch (Exception e)
            {
                ConstructReturns(
                    ref StationReturn,
                    StationReturnStatusValue.Fail,
                    MESReturnMessage.GetMESReturnMessage("Exception", new string[] { e.Message }),
                    e.Message);
            }
            finally
            {
                this.DBPools["SFCDB"].Return(sfcdb);
            }
        }
Пример #3
0
        public void DeleteSeriesById(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec    sfcdb    = null;
            T_C_SERIES table    = null;
            C_SERIES   series   = null;
            string     result   = string.Empty;
            string     SeriesId = string.Empty;

            try
            {
                sfcdb     = this.DBPools["SFCDB"].Borrow();
                table     = new T_C_SERIES(sfcdb, DBTYPE);
                SeriesId  = Data["SeriesID"].ToString();
                series    = new C_SERIES();
                series.ID = SeriesId;
                result    = table.UpdateSeries(BU, series, "DELETE", sfcdb);

                if (Int32.Parse(result) > 0)
                {
                    //刪除成功
                    ConstructReturns(
                        ref StationReturn,
                        StationReturnStatusValue.Pass,
                        MESReturnMessage.GetMESReturnMessage("UpdateOK", new string[] { result }),
                        result);
                }
                else
                {
                    //沒有刪除任何數據
                    ConstructReturns(
                        ref StationReturn,
                        StationReturnStatusValue.Pass,
                        MESReturnMessage.GetMESReturnMessage("UpdateNoData"),
                        result);
                }
            }
            catch (Exception e)
            {
                ConstructReturns(
                    ref StationReturn,
                    StationReturnStatusValue.Fail,
                    MESReturnMessage.GetMESReturnMessage("Exception", new string[] { e.Message }),
                    e.Message);
            }
            finally
            {
                this.DBPools["SFCDB"].Return(sfcdb);
            }
        }
Пример #4
0
        /// <summary>
        /// 從SKU加載Series
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void SeriesFromSKUDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            //加載SeriesSavePoint
            MESStationSession SeriesSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SeriesSession == null)
            {
                SeriesSession = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, SessionKey = Paras[0].SESSION_KEY
                };
                Station.StationSession.Add(SeriesSession);
            }

            //SKULoadPoint
            MESStationSession SkuSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (SkuSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" }));
            }


            SKU sku = (SKU)SkuSession.Value;

            if (sku == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" }));
            }
            OleExec    sfcdb      = Station.SFCDB;
            T_C_SERIES t_c_series = new T_C_SERIES(sfcdb, DB_TYPE_ENUM.Oracle);
            C_SERIES   c_series   = t_c_series.GetDetailById(sfcdb, sku.CSeriesId);//sku.CSeriesId

            if (c_series == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SERIES" }));
            }

            SeriesSession.Value = c_series;

            Station.AddMessage("MES00000029", new string[] { "SERIES", c_series.SERIES_NAME }, StationMessageState.Pass);
        }
Пример #5
0
        /// <summary>
        /// convert wo
        /// </summary>
        protected void ConvertWO()
        {
            if (_downloadWO != "")
            {
                dtConvertWO = R_WO_HEADER.GetConvertWoTableByWO(SFCDB, DB_TYPE_ENUM.Oracle, _downloadWO);
            }
            else
            {
                dtConvertWO = R_WO_HEADER.GetConvertWoTable(SFCDB, DB_TYPE_ENUM.Oracle, arrayConvertWO);
            }
            if (dtConvertWO.Rows.Count > 0)
            {
                foreach (DataRow row in dtConvertWO.Rows)
                {
                    rowSku          = null;
                    rowRoute        = null;
                    rowWOBase       = null;
                    rowWOType       = null;
                    routeDetailList = null;
                    keypartList     = null;
                    keypartIDList   = null;
                    linkStationList = null;
                    C_Series        = null;
                    sql             = "";
                    try
                    {
                        rowSku = (Row_C_SKU)C_SKU.GetSku(row["MATNR"].ToString(), SFCDB, DB_TYPE_ENUM.Oracle);
                        if (rowSku == null)
                        {
                            throw new Exception(" sku " + row["MATNR"].ToString() + " can't exist");
                        }
                        //if (!string.Equals(rowSku.VERSION.ToString(), row["REVLV"].ToString()))
                        //{
                        //    throw new Exception(" The sku version is not the same," + rowSku.VERSION.ToString() + "," + row["REVLV"].ToString());
                        //}
                        C_Series = T_Series.GetDetailById(SFCDB, rowSku.C_SERIES_ID);
                        if (C_Series == null)
                        {
                            throw new Exception(" the series of " + row["MATNR"].ToString() + " can't exist");
                        }
                        rowWOType = WOType.GetWOTypeByWO(SFCDB, row["AUART"].ToString());
                        if (rowWOType == null)
                        {
                            throw new Exception("get wo type fail");
                        }
                        rowRoute = (Row_C_ROUTE)C_ROUTE.GetRouteBySkuno(rowSku.ID, SFCDB, DB_TYPE_ENUM.Oracle);
                        if (rowRoute == null)
                        {
                            throw new Exception(" the route of " + row["MATNR"].ToString() + " can't exist");
                        }
                        routeDetailList = RouteDetail.GetByRouteIdOrderBySEQASC(rowRoute.ID, SFCDB);
                        if (routeDetailList == null || routeDetailList.Count == 0)
                        {
                            throw new Exception("get route detail fail by " + rowRoute.ID);
                        }
                        keypartIDList = t_c_kp_list.GetListIDBySkuno(rowSku.SKUNO, SFCDB);
                        if (keypartIDList.Count > 0 && keypartIDList.Count != 1)
                        {
                            throw new Exception("skuno:" + row["MATNR"].ToString() + " have more keypart id");
                        }

                        //HWD的邏輯
                        //linkStationList = routeDetailList.Where(link => link.STATION_NAME == "LINK").ToList();
                        //if (linkStationList != null && linkStationList.Count > 0)
                        //{
                        //    keypartList = Keypart.GetKeypartListBySkuVersion(SFCDB, row["MATNR"].ToString(), row["REVLV"].ToString());
                        //    keypartIDList = keypartList.Select(id => id.KEYPART_ID).Distinct().ToList();
                        //    if (keypartIDList == null || keypartIDList.Count != 1)
                        //    {
                        //        throw new Exception("get keypart id fail by skuno:" + row["MATNR"].ToString() + " and version:" + row["REVLV"].ToString());
                        //    }
                        //}

                        rowWOBase                 = (Row_R_WO_BASE)R_WO_BASE.NewRow();
                        rowWOBase.ID              = R_WO_BASE.GetNewID(BU, SFCDB);
                        rowWOBase.WORKORDERNO     = row["AUFNR"].ToString();
                        rowWOBase.PLANT           = row["WERKS"].ToString();
                        rowWOBase.RELEASE_DATE    = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                        rowWOBase.DOWNLOAD_DATE   = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                        rowWOBase.PRODUCTION_TYPE = "BTO";//HWD原有邏輯寫死
                        rowWOBase.WO_TYPE         = rowWOType.WORKORDER_TYPE;
                        rowWOBase.SKUNO           = row["MATNR"].ToString();
                        rowWOBase.SKU_VER         = row["REVLV"].ToString();
                        rowWOBase.SKU_SERIES      = C_Series.SERIES_NAME;
                        rowWOBase.SKU_NAME        = rowSku.SKU_NAME;
                        rowWOBase.SKU_DESC        = rowSku.DESCRIPTION;
                        rowWOBase.CUST_PN         = rowSku.CUST_PARTNO;
                        rowWOBase.CUST_PN_VER     = "";
                        rowWOBase.CUSTOMER_NAME   = rowSku.CUST_SKU_CODE;
                        rowWOBase.ROUTE_ID        = rowRoute.ID;
                        rowWOBase.START_STATION   = routeDetailList[0].STATION_NAME;
                        rowWOBase.KP_LIST_ID      = (keypartIDList != null && keypartIDList.Count > 0) ? keypartIDList[0] : "";
                        rowWOBase.CLOSED_FLAG     = "0";
                        rowWOBase.WORKORDER_QTY   = Convert.ToDouble(row["GAMNG"]);
                        rowWOBase.INPUT_QTY       = 0;
                        rowWOBase.FINISHED_QTY    = 0;
                        rowWOBase.SCRAPED_QTY     = 0;
                        rowWOBase.STOCK_LOCATION  = row["LGORT"].ToString();
                        rowWOBase.PO_NO           = "";
                        rowWOBase.CUST_ORDER_NO   = row["ABLAD"].ToString();
                        rowWOBase.ROHS            = row["ROHS_VALUE"].ToString();
                        rowWOBase.EDIT_EMP        = "interface";
                        rowWOBase.EDIT_TIME       = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                        SFCDB.ThrowSqlExeception  = true;
                        sql = rowWOBase.GetInsertString(DB_TYPE_ENUM.Oracle);
                        SFCDB.ExecSQL(rowWOBase.GetInsertString(DB_TYPE_ENUM.Oracle));
                        SFCDB.CommitTrain();
                    }
                    catch (Exception ex)
                    {
                        WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.HWD.DownLoadWO", "ConvertWO", ip + ";" + row["AUFNR"].ToString() + ";ConvertWO fail," + ex.Message.ToString(), sql, "interface");
                    }
                }
            }
        }
Пример #6
0
 /// <summary>
 /// convert wo
 /// </summary>
 protected void ConvertWO()
 {
     if (_downloadWO != "")
     {
         //如果指定了工單Download,且工單不存在于R_WO_BASE表中,則返回該工單R_WO_Header記錄
         dtConvertWO = R_WO_HEADER.GetConvertWoTableByWO(SFCDB, DB_TYPE_ENUM.Oracle, _downloadWO);
     }
     else
     {
         //否則抓取所有不存在于R_WO_BASE表中工單,并結合CONVERTWO=00251的設定返回工單R_WO_Header記錄
         //MBD 正常工單類型,且ModelType不包含094的才轉
         dtConvertWO = R_WO_HEADER.GetConvertWoTableForMBD(SFCDB, DB_TYPE_ENUM.Oracle, arrayConvertWO);
     }
     if (dtConvertWO.Rows.Count > 0)
     {
         //循環所有待轉工單
         foreach (DataRow row in dtConvertWO.Rows)
         {
             rowSku          = null;
             rowRoute        = null;
             rowWOBase       = null;
             rowWOType       = null;
             routeDetailList = null;
             keypartList     = null;
             keypartIDList   = null;
             linkStationList = null;
             C_Series        = null;
             sql             = "";
             try
             {
                 //判斷料號是否存在
                 rowSku = (Row_C_SKU)C_SKU.GetSku(row["MATNR"].ToString(), SFCDB, DB_TYPE_ENUM.Oracle);
                 if (rowSku == null)
                 {
                     throw new Exception(" sku " + row["MATNR"].ToString() + " not exist");
                 }
                 if (rowSku.C_SERIES_ID == null)
                 {
                     throw new Exception(" the series of " + row["MATNR"].ToString() + " can not be null ");
                 }
                 //從C_Series表中獲取系列信息
                 C_Series = T_Series.GetDetailById(SFCDB, rowSku.C_SERIES_ID);
                 if (C_Series == null)
                 {
                     throw new Exception(" the series of " + row["MATNR"].ToString() + " not exist");
                 }
                 //從R_WO_TYPE表中獲取工單類型:這張表需要事先設定
                 rowWOType = WOType.GetWOTypeByWO(SFCDB, row["AUART"].ToString());
                 if (rowWOType == null)
                 {
                     throw new Exception("get wo type fail");
                 }
                 //從R_Sku_Route&C_Route表中獲取默認路由
                 rowRoute = (Row_C_ROUTE)C_ROUTE.GetDefaultRouteBySkuno(rowSku.ID, SFCDB, DB_TYPE_ENUM.Oracle);
                 if (rowRoute == null)
                 {
                     throw new Exception(" the route of " + row["MATNR"].ToString() + " not exist");
                 }
                 //從C_Route_Detail表中獲取路由
                 routeDetailList = RouteDetail.GetByRouteIdOrderBySEQASC(rowRoute.ID, SFCDB);
                 if (routeDetailList == null || routeDetailList.Count == 0)
                 {
                     throw new Exception("get route detail fail by " + rowRoute.ID);
                 }
                 //???KeyParts如何轉
                 keypartIDList = t_c_kp_list.GetListIDBySkuno(rowSku.SKUNO, SFCDB);
                 if (keypartIDList.Count > 0 && keypartIDList.Count != 1)
                 {
                     throw new Exception("skuno:" + row["MATNR"].ToString() + " have more keypart id");
                 }
                 rowWOBase                 = (Row_R_WO_BASE)R_WO_BASE.NewRow();
                 rowWOBase.ID              = R_WO_BASE.GetNewID(BU, SFCDB);
                 rowWOBase.WORKORDERNO     = row["AUFNR"].ToString();
                 rowWOBase.PLANT           = row["WERKS"].ToString();
                 rowWOBase.RELEASE_DATE    = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                 rowWOBase.DOWNLOAD_DATE   = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                 rowWOBase.PRODUCTION_TYPE = "BTO";//原有邏輯寫死
                 rowWOBase.WO_TYPE         = rowWOType.WORKORDER_TYPE;
                 rowWOBase.SKUNO           = row["MATNR"].ToString();
                 rowWOBase.SKU_VER         = row["REVLV"].ToString();
                 rowWOBase.SKU_SERIES      = C_Series.SERIES_NAME;
                 rowWOBase.SKU_NAME        = rowSku.SKU_NAME;
                 rowWOBase.SKU_DESC        = rowSku.DESCRIPTION;
                 rowWOBase.CUST_PN         = rowSku.CUST_PARTNO;
                 rowWOBase.CUST_PN_VER     = "";
                 rowWOBase.CUSTOMER_NAME   = rowSku.CUST_SKU_CODE;
                 rowWOBase.ROUTE_ID        = rowRoute.ID;
                 rowWOBase.START_STATION   = routeDetailList[0].STATION_NAME;
                 //??????
                 rowWOBase.KP_LIST_ID     = (keypartIDList != null && keypartIDList.Count > 0) ? keypartIDList[0] : "";
                 rowWOBase.CLOSED_FLAG    = "0";
                 rowWOBase.WORKORDER_QTY  = Convert.ToDouble(row["GAMNG"]);
                 rowWOBase.INPUT_QTY      = 0;
                 rowWOBase.FINISHED_QTY   = 0;
                 rowWOBase.SCRAPED_QTY    = 0;
                 rowWOBase.STOCK_LOCATION = row["LGORT"].ToString();
                 rowWOBase.PO_NO          = "";
                 rowWOBase.CUST_ORDER_NO  = row["ABLAD"].ToString();
                 rowWOBase.ROHS           = row["ROHS_VALUE"].ToString();
                 rowWOBase.EDIT_EMP       = "interface";
                 rowWOBase.EDIT_TIME      = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                 SFCDB.ThrowSqlExeception = true;
                 sql = rowWOBase.GetInsertString(DB_TYPE_ENUM.Oracle);
                 SFCDB.ExecSQL(rowWOBase.GetInsertString(DB_TYPE_ENUM.Oracle));
                 SFCDB.CommitTrain();
             }
             catch (Exception ex)
             {
                 WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.MBD.DownLoadWO", "ConvertWO", ip + ";" + row["AUFNR"].ToString() + ";ConvertWO fail," + ex.Message.ToString(), sql, "interface");
             }
         }
     }
 }