Exemple #1
0
        public void SubmitWoInfo(JObject requestValue, JObject Data, MESStationReturn StationReturn)
        {
            //wo
            string wo = Data["wo"].ToString();

            if (string.IsNullOrEmpty(wo))
            {
                //StationReturn.Status = StationReturnStatusValue.Fail;
                //StationReturn.MessageCode = "MES00000006";
                //StationReturn.MessagePara = new List<object>() { "Skuno" };
                //StationReturn.Data = "";
                //return;
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "WO" }));
            }

            OleExec     sfcdb = DBPools["SFCDB"].Borrow();
            T_R_WO_BASE t_wo  = new T_R_WO_BASE(sfcdb, DB_TYPE_ENUM.Oracle);

            if (!t_wo.CheckDataExist(wo, sfcdb))
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000008", new string[] { wo }));
            }

            R_WO_HEADER wo_header = new T_R_WO_HEADER(sfcdb, DB_TYPE_ENUM.Oracle).GetDetailByWo(sfcdb, wo);

            //sku info
            string skuno = Data["skuno"].ToString();//wo_header.MATNR

            if (string.IsNullOrEmpty(skuno))
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "SKUNO" }));
            }
            string skuver = Data["sku_ver"].ToString();//wo_header.REVLV

            C_SKU c_sku = new T_C_SKU(sfcdb, DB_TYPE_ENUM.Oracle).GetSku(skuno, sfcdb, DB_TYPE_ENUM.Oracle).GetDataObject();

            if (c_sku == null)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { skuno }));
            }


            //route exchange from name
            string route_name = Data["route_name"].ToString();

            if (string.IsNullOrEmpty(route_name))
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "ROUTE" }));
            }
            C_ROUTE c_route = new T_C_ROUTE(sfcdb, DB_TYPE_ENUM.Oracle).GetByRouteName(route_name, sfcdb);

            if (c_route == null)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { route_name }));
            }

            //station route check
            string station_name = Data["station"].ToString();

            if (string.IsNullOrEmpty(station_name))
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "STATION" }));
            }
            List <C_ROUTE_DETAIL> c_route_detail = new T_C_ROUTE_DETAIL(sfcdb, DB_TYPE_ENUM.Oracle).GetByRouteIdOrderBySEQASC(c_route.ID, sfcdb);

            if (c_route_detail != null && c_route_detail.Count > 0)
            {
                C_ROUTE_DETAIL check = c_route_detail.Find(t => t.STATION_NAME == station_name);
                if (check == null)
                {
                    throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { station_name }));
                }
            }
            else
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { route_name }));
            }

            //data record
            Row_R_WO_BASE row_wobase = (Row_R_WO_BASE)t_wo.NewRow();

            row_wobase.ID              = t_wo.GetNewID(this.BU, sfcdb);
            row_wobase.WORKORDERNO     = wo;
            row_wobase.PLANT           = Data["factory"].ToString();
            row_wobase.RELEASE_DATE    = DateTime.Now;
            row_wobase.DOWNLOAD_DATE   = Convert.ToDateTime(Data["date"].ToString());
            row_wobase.PRODUCTION_TYPE = "BTO";
            row_wobase.WO_TYPE         = Data["wo_type"].ToString();
            row_wobase.SKUNO           = skuno;
            row_wobase.SKU_VER         = skuver;
            row_wobase.SKU_NAME        = c_sku.SKU_NAME;
            //row_wobase.SKU_SERIES = null;
            //row_wobase.SKU_DESC = null;
            row_wobase.CUST_PN        = c_sku.CUST_PARTNO;
            row_wobase.ROUTE_ID       = c_route.ID;
            row_wobase.START_STATION  = station_name;
            row_wobase.KP_LIST_ID     = Data["kp_list_id"].ToString();
            row_wobase.CLOSED_FLAG    = "0";
            row_wobase.WORKORDER_QTY  = Convert.ToDouble(Data["qty"].ToString());
            row_wobase.STOCK_LOCATION = wo_header.LGORT;
            row_wobase.CUST_ORDER_NO  = wo_header.ABLAD;
            row_wobase.EDIT_EMP       = this.LoginUser.EMP_NO;
            row_wobase.EDIT_TIME      = DateTime.Now;

            string sql = row_wobase.GetInsertString(DB_TYPE_ENUM.Oracle);

            try
            {
                int res = sfcdb.ExecSqlNoReturn(sql, null);
                if (res == 0)
                {
                    throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { wo }));
                }
                if (sfcdb != null)
                {
                    DBPools["SFCDB"].Return(sfcdb);
                }
            }
            catch (Exception ex)
            {
                if (sfcdb != null)
                {
                    DBPools["SFCDB"].Return(sfcdb);
                }
                throw ex;
            }
        }
Exemple #2
0
        private void getById(string id, OleExec sfcdb, MESDataObject.DB_TYPE_ENUM dbtype)
        {
            T_C_ROUTE_DETAIL            TC_ROUTE_DETAIL            = new T_C_ROUTE_DETAIL(sfcdb, dbtype);
            T_C_ROUTE_DETAIL_DIRECTLINK TC_ROUTE_DETAIL_DIRECTLINK = new T_C_ROUTE_DETAIL_DIRECTLINK(sfcdb, dbtype);
            T_C_ROUTE_DETAIL_RETURN     TC_ROUTE_DETAIL_RETURN     = new T_C_ROUTE_DETAIL_RETURN(sfcdb, dbtype);
            C_ROUTE_DETAIL getRouteDetail = new C_ROUTE_DETAIL();
            List <C_ROUTE_DETAIL_RETURN>     getDetailReturn     = new List <C_ROUTE_DETAIL_RETURN>();
            List <C_ROUTE_DETAIL_DIRECTLINK> getDetailDirectLink = new List <C_ROUTE_DETAIL_DIRECTLINK>();

            getRouteDetail = TC_ROUTE_DETAIL.GetById(id, sfcdb);
            if (getDetailReturn != null)
            {
                this._ID           = getRouteDetail.ID;
                this._SEQ_NO       = getRouteDetail.SEQ_NO;
                this._ROUTE_ID     = getRouteDetail.ROUTE_ID;
                this._STATION_NAME = getRouteDetail.STATION_NAME;
                this._STATION_TYPE = getRouteDetail.STATION_TYPE;
                this._RETURN_FLAG  = getRouteDetail.RETURN_FLAG;
                if (getRouteDetail.RETURN_FLAG == "Y")
                {
                    getDetailReturn = TC_ROUTE_DETAIL_RETURN.GetByRoute_DetailId(getRouteDetail.ID, sfcdb);
                    if (getDetailReturn != null && getDetailReturn.Count > 0)
                    {
                        List <C_ROUTE_DETAIL> newReturnList = new List <C_ROUTE_DETAIL>();
                        for (int j = 0; j < getDetailReturn.Count; j++)
                        {
                            newReturnList.Add(TC_ROUTE_DETAIL.GetById(getDetailReturn[j].RETURN_ROUTE_DETAIL_ID, sfcdb));
                        }
                        this._RETURNLIST = newReturnList;
                    }
                }
                else
                {
                    this._RETURNLIST = null;
                }
                getDetailDirectLink = TC_ROUTE_DETAIL_DIRECTLINK.GetByDetailId(getRouteDetail.ID, sfcdb);
                if (getDetailDirectLink != null && getDetailDirectLink.Count > 0)
                {
                    List <C_ROUTE_DETAIL> newDirectLinkList = new List <C_ROUTE_DETAIL>();
                    for (int n = 0; n < getDetailDirectLink.Count; n++)
                    {
                        newDirectLinkList.Add(TC_ROUTE_DETAIL.GetById(getDetailDirectLink[n].DIRECTLINK_ROUTE_DETAIL_ID, sfcdb));
                    }
                    this._DIRECTLINKLIST = newDirectLinkList;
                }
                else
                {
                    this._DIRECTLINKLIST = null;
                }
            }
            else
            {
                this._ID             = "";
                this._SEQ_NO         = null;
                this._ROUTE_ID       = "";
                this._STATION_NAME   = "";
                this._STATION_TYPE   = "";
                this._RETURN_FLAG    = "";
                this._DIRECTLINKLIST = null;
                this._RETURNLIST     = null;
                this._NEXTSTATION    = null;
            }
        }