예제 #1
0
        public void DataLoad(string packNo, string bu, OleExec sfcdb, DB_TYPE_ENUM DBType)
        {
            List <string>  itemList       = new List <string>();
            T_C_SKU        t_c_sku        = new T_C_SKU(sfcdb, DBType);
            T_R_PACKING    t_r_packing    = new T_R_PACKING(sfcdb, DBType);
            T_R_SN_PACKING t_r_sn_packing = new T_R_SN_PACKING(sfcdb, DBType);
            T_R_SN         t_r_sn         = new T_R_SN(sfcdb, DBType);
            T_C_PACKING    t_c_packing    = new T_C_PACKING(sfcdb, DBType);
            R_PACKING      packing        = new R_PACKING();
            C_SKU          sku            = new C_SKU();
            Packing        packObject     = new Packing();
            C_PACKING      c_packing      = new C_PACKING();

            packing = t_r_packing.GetRPackingByPackNo(sfcdb, packNo).GetDataObject();
            sku     = t_c_sku.GetSku(packing.SKUNO, sfcdb, DBType).GetDataObject();
            if (packing.PACK_TYPE == LogicObject.PackType.PALLET.ToString().ToUpper())
            {
                c_packing = t_c_packing.GetPackingBySkuAndType(sku.SKUNO, LogicObject.PackType.CARTON.ToString().ToUpper(), sfcdb);
                if (c_packing.MAX_QTY == 1 && bu.ToUpper().Equals("VERTIV"))
                {
                    //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN
                    itemList = t_r_packing.GetPakcingSNList(packing.ID, sfcdb);
                }
                else
                {
                    List <R_PACKING> packingList = t_r_packing.GetListPackByParentPackId(packing.ID, sfcdb);
                    foreach (R_PACKING pack in packingList)
                    {
                        itemList.Add(pack.PACK_NO);
                    }
                }
            }
            else if (packing.PACK_TYPE == LogicObject.PackType.CARTON.ToString().ToUpper())
            {
                List <Row_R_SN_PACKING> snPackingList = t_r_sn_packing.GetPackItem(packing.ID, sfcdb);
                foreach (Row_R_SN_PACKING sn in snPackingList)
                {
                    itemList.Add(t_r_sn.GetById(sn.SN_ID, sfcdb).SN);
                }
            }
            this.PackID       = packing.ID;
            this.PackNo       = packing.PACK_NO;
            this.PackType     = packing.PACK_TYPE;
            this.ParentPackID = packing.PARENT_PACK_ID;
            this.Skuno        = packing.SKUNO;
            this.SkunoVer     = sku.VERSION;
            this.MaxQty       = packing.MAX_QTY;
            this.Qty          = packing.QTY;
            this.ClosedFlag   = packing.CLOSED_FLAG;
            this.CreatTime    = packing.CREATE_TIME;
            this.EditTime     = packing.EDIT_TIME;
            this.EditEmp      = packing.EDIT_EMP;
            this.Line         = packing.LINE;
            this.Station      = packing.STATION;
            this.IP           = packing.IP;
            this.PackList     = itemList;
        }
예제 #2
0
        public void DeleteSkuById(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec       sfcdb  = null;
            T_C_SKU       Table  = null;
            C_SKU         Sku    = null;
            string        result = string.Empty;
            string        SkuId  = string.Empty;
            StringBuilder strSkuId;

            try
            {
                sfcdb  = this.DBPools["SFCDB"].Borrow();
                Table  = new T_C_SKU(sfcdb, DBTYPE);
                SkuId  = Data["SkuID"][0].ToString();
                Sku    = new C_SKU();
                Sku.ID = SkuId;
                result = Table.UpdateSku(BU, Sku, "DELETE", GetDBDateTime(), out strSkuId, sfcdb);

                if (Int32.Parse(result) > 0)
                {
                    //刪除成功
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000035";
                    StationReturn.MessagePara.Add(result);
                    StationReturn.Data = strSkuId.ToString();
                }
                else
                {
                    //沒有刪除任何數據
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000036";
                    StationReturn.Data        = result;
                }

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
            catch (Exception e)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(e.Message);
                StationReturn.Data = e.Message;

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
        }
예제 #3
0
        public void DeleteSku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec       sfcdb     = null;
            T_C_SKU       Table     = null;
            string        SkuObject = string.Empty;
            C_SKU         Sku       = null;
            string        result    = string.Empty;
            StringBuilder SkuId;

            try
            {
                sfcdb     = this.DBPools["SFCDB"].Borrow();
                Table     = new T_C_SKU(sfcdb, DBTYPE);
                SkuObject = Data["SkuObject"].ToString();
                Sku       = (C_SKU)JsonConvert.Deserialize(SkuObject, typeof(C_SKU));
                result    = Table.UpdateSku(BU, Sku, "DELETE", GetDBDateTime(), out SkuId, sfcdb);

                if (Int32.Parse(result) > 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000035";
                    StationReturn.MessagePara.Add(result);
                    StationReturn.Data = SkuId.ToString();
                }
                else
                {
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000036";
                    StationReturn.Data        = result;
                }

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
            catch (Exception e)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(e.Message);
                StationReturn.Data = e.Message;

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
        }
예제 #4
0
        /// <summary>
        ///  add by fgg 2018.05.17
        /// HWD PE 杜軍要求配置工單區間所輸入的SN必須符合機種設置的SN規則
        /// </summary>
        /// <param name="input"></param>
        /// <param name="sku"></param>
        /// <returns></returns>
        public bool InputIsMatchSkuRule(string input, C_SKU sku)
        {
            bool isMatchSkuRule = true;

            string[] ruleArray;
            string[] snArray;
            char[]   charConfigRule = sku.SN_RULE.ToCharArray();
            ruleArray = new string[charConfigRule.Length];

            if (sku.SN_RULE == "")
            {
                return(true);
            }
            //長度不符
            if (input.Length != sku.SN_RULE.Length)
            {
                return(false);
            }

            for (int i = 0; i < charConfigRule.Length; i++)
            {
                ruleArray[i] = charConfigRule[i].ToString();
            }

            char[] charSn = input.ToCharArray();
            snArray = new string[charSn.Length];
            for (int j = 0; j < charSn.Length; j++)
            {
                snArray[j] = charSn[j].ToString();
            }

            for (int k = 0; k < ruleArray.Length; k++)
            {
                if (ruleArray[k] == "*")
                {
                    continue;
                }
                if (!ruleArray[k].Equals(snArray[k]))
                {
                    isMatchSkuRule = false;
                    break;
                }
            }
            return(isMatchSkuRule);
        }
예제 #5
0
        public void ModifyWORange(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            T_R_WO_REGION rWo   = null;
            OleExec       sfcdb = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                rWo   = new T_R_WO_REGION(sfcdb, DB_TYPE_ENUM.Oracle);
                Row_R_WO_REGION r         = (Row_R_WO_REGION)rWo.NewRow();
                T_R_WO_BASE     StWoBase  = new T_R_WO_BASE(sfcdb, DB_TYPE_ENUM.Oracle);
                T_C_SKU         t_c_sku   = new T_C_SKU(sfcdb, DB_TYPE_ENUM.Oracle);
                Row_R_WO_BASE   RowWoBase = null;
                RowWoBase = StWoBase.GetWo((Data["WORKORDERNO"].ToString()).Trim(), sfcdb);

                string minSN    = (Data["MIN_SN"].ToString()).Trim();
                string maxSN    = (Data["MAX_SN"].ToString()).Trim();
                string checkOut = "";
                if (!rWo.InputIsStringOrNum(minSN, out checkOut))
                {
                    StationReturn.MessageCode = "MES00000258";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.Data        = "";
                    return;
                }
                if (!rWo.InputIsStringOrNum(maxSN, out checkOut))
                {
                    StationReturn.MessageCode = "MES00000258";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.Data        = "";
                    return;
                }
                C_SKU objectSku = t_c_sku.GetSku(RowWoBase.SKUNO, sfcdb, DB_TYPE_ENUM.Oracle).GetDataObject();
                if (!rWo.InputIsMatchSkuRule(minSN, objectSku))
                {
                    StationReturn.MessageCode = "MES00000259";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.Data        = "";
                    return;
                }
                if (!rWo.InputIsMatchSkuRule(maxSN, objectSku))
                {
                    StationReturn.MessageCode = "MES00000259";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.Data        = "";
                    return;
                }

                r             = (Row_R_WO_REGION)rWo.GetObjByID(Data["ID"].ToString(), sfcdb, DB_TYPE_ENUM.Oracle);
                r.ID          = (Data["ID"].ToString()).Trim();
                r.WORKORDERNO = (Data["WORKORDERNO"].ToString()).Trim();
                r.SKUNO       = RowWoBase.SKUNO;
                r.QTY         = RowWoBase.WORKORDER_QTY;
                //r.SKUNO = (Data["SKUNO"].ToString()).Trim();
                //r.QTY = int.Parse(Data["QTY"].ToString());
                r.MIN_SN    = minSN;
                r.MAX_SN    = maxSN;
                r.EDIT_EMP  = LoginUser.EMP_NO;
                r.EDIT_TIME = GetDBDateTime();
                string strRet = sfcdb.ExecSQL(r.GetUpdateString(DB_TYPE_ENUM.Oracle));
                if (Convert.ToInt32(strRet) > 0)
                {
                    StationReturn.MessageCode = "MES00000003";
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.Data        = "";
                }
                else
                {
                    StationReturn.MessageCode = "MES00000036";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.Data        = "";
                }
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
예제 #6
0
        public void UpdateSku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec       sfcdb     = null;
            T_C_SKU       Table     = null;
            string        SkuObject = string.Empty;
            C_SKU         Sku       = null;
            string        result    = string.Empty;
            StringBuilder SkuId;

            try
            {
                sfcdb        = this.DBPools["SFCDB"].Borrow();
                Table        = new T_C_SKU(sfcdb, DBTYPE);
                SkuObject    = Data["SkuObject"].ToString();
                Sku          = (C_SKU)JsonConvert.Deserialize(SkuObject, typeof(C_SKU));
                Sku.EDIT_EMP = LoginUser.EMP_NO;
                result       = Table.UpdateSku(BU, Sku, "UPDATE", GetDBDateTime(), out SkuId, sfcdb);

                if (Int32.Parse(result) > 0)
                {
                    //更新成功
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000035";
                    StationReturn.MessagePara.Add(result);
                    StationReturn.Data = SkuId.ToString();
                }
                else
                {
                    //更新失敗
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000036";
                    StationReturn.Data        = result;
                }

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
            catch (Exception e)
            {
                //不是最新的數據,返回字符串無法被 Int32.Parse 方法轉換成 int,所以出現異常
                if (!string.IsNullOrEmpty(result))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000032";
                    StationReturn.Data        = e.Message + ":" + result;
                }
                else
                {
                    //數據庫執行異常
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000037";
                    StationReturn.MessagePara.Add(e.Message);
                    StationReturn.Data = e.Message;
                }

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
        }
예제 #7
0
        public void GetLockStation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            string        lockType    = Data["LockType"].ToString().Trim();
            string        lockData    = Data["LockData"].ToString().Trim();
            DataTable     routeTable  = new DataTable();
            List <string> stationList = new List <string>();
            OleExec       sfcdb       = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                T_C_ROUTE_DETAIL t_c_route_detail = new T_C_ROUTE_DETAIL(sfcdb, DBTYPE);
                if (lockType == "LockByWo")
                {
                    T_R_WO_BASE t_r_wo_base = new T_R_WO_BASE(sfcdb, DBTYPE);
                    R_WO_BASE   r_wo_base   = t_r_wo_base.GetWo(lockData, sfcdb).GetDataObject();
                    stationList = t_c_route_detail.GetByRouteIdOrderBySEQASC(r_wo_base.ROUTE_ID, sfcdb).Select(route => route.STATION_NAME).ToList();
                }
                else if (lockType == "LockByLot")
                {
                    T_R_LOT_STATUS   t_r_lot_status = new T_R_LOT_STATUS(sfcdb, DBTYPE);
                    Row_R_LOT_STATUS rowLotStatus   = t_r_lot_status.GetByLotNo(lockData, sfcdb);
                    if (rowLotStatus.ID == null)
                    {
                        throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000161", new string[] { }));
                    }
                    R_LOT_STATUS       r_lot_status     = rowLotStatus.GetDataObject();
                    T_C_SKU            t_c_sku          = new T_C_SKU(sfcdb, DBTYPE);
                    C_SKU              c_sku            = t_c_sku.GetSku(r_lot_status.SKUNO, sfcdb, DBTYPE).GetDataObject();
                    T_R_SKU_ROUTE      t_r_sku_route    = new T_R_SKU_ROUTE(sfcdb, DBTYPE);
                    List <R_SKU_ROUTE> r_sku_route_list = t_r_sku_route.GetMappingBySkuId(c_sku.ID, sfcdb);
                    if (r_sku_route_list.Count > 0)
                    {
                        //t_c_route_detail.GetByRouteIdOrderBySEQASC(r_sku_route_list[0].ROUTE_ID, sfcdb);
                        stationList = t_c_route_detail.GetByRouteIdOrderBySEQASC(r_sku_route_list[0].ROUTE_ID, sfcdb).Select(route => route.STATION_NAME).ToList();
                    }
                    else
                    {
                        throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000179", new string[] {  }));
                    }
                }
                else
                {
                    routeTable = t_c_route_detail.GetALLStation(sfcdb);
                    foreach (DataRow row in routeTable.Rows)
                    {
                        stationList.Add(row["station_name"].ToString());
                    }
                    stationList.Sort();
                }

                this.DBPools["SFCDB"].Return(sfcdb);
                StationReturn.Data        = stationList;
                StationReturn.Status      = StationReturnStatusValue.Pass;
                StationReturn.MessageCode = "MES00000001";
            }
            catch (Exception exception)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(exception.Message);
                StationReturn.Data = exception.Message;
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
        }