Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name="entity"/>
        /// <returns/>
        public bool OnAfterLoad_ProductRoute(ProductRoute entity)
        {
            try
            {
                entity.LINE_ID        = UtilityHelper.Trim(entity.LINE_ID);
                entity.FROM_PROD_ID   = UtilityHelper.Trim(entity.FROM_PROD_ID);
                entity.FROM_PROD_NAME = UtilityHelper.Trim(entity.FROM_PROD_NAME);
                entity.STEP_ID        = UtilityHelper.Trim(entity.STEP_ID);
                entity.TO_PROD_ID     = UtilityHelper.Trim(entity.TO_PROD_ID);
                entity.TO_PROD_NAME   = UtilityHelper.Trim(entity.TO_PROD_NAME);

                ProductDetail fromProdDetail = FindHelper.FindProductDetail(entity.LINE_ID, entity.FROM_PROD_ID);

                if (fromProdDetail == null)
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.PRODUCT, entity.LINE_ID, string.Empty,
                                                        string.Empty, entity.FROM_PROD_ID, string.Empty, string.Empty, 0, string.Empty, "Cannot find ProductMaster", string.Empty, "ProductRoute");
                    return(false);
                }

                Tuple <string, string, bool, bool, int> fromProdKey = new Tuple <string, string, bool, bool, int>(entity.LINE_ID, entity.FROM_PROD_ID, false, false, 1);

                MicronBEAssyProduct fromProduct;
                if (InputMart.Instance.MicronBEProducts.TryGetValue(fromProdKey, out fromProduct) == false)
                {
                    fromProduct = NewHelper.NewMicronBeAssyProduct(fromProdDetail);
                    fromProduct.PartChangeStep = entity.STEP_ID;
                    InputMart.Instance.MicronBEProducts.Add(fromProdKey, fromProduct);
                }

                ProductDetail toProdDetail = FindHelper.FindProductDetail(entity.LINE_ID, entity.TO_PROD_ID);

                if (toProdDetail == null)
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.PRODUCT, entity.LINE_ID, string.Empty,
                                                        string.Empty, entity.TO_PROD_ID, string.Empty, string.Empty, 0, string.Empty, "Cannot find ProductMaster", string.Empty, "ProductRoute");
                    return(false);
                }

                ICollection <AssyMcpPart> assyInProducts = FindHelper.FindAssyInParts(entity.LINE_ID, entity.TO_PROD_ID);

                if (assyInProducts.IsNullOrEmpty())
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.PRODUCT, entity.LINE_ID, string.Empty,
                                                        string.Empty, entity.TO_PROD_ID, string.Empty, string.Empty, 0, string.Empty, "Cannot find McpBom", string.Empty, "ProductRoute");
                    return(false);
                }

                foreach (AssyMcpPart inPart in assyInProducts)
                {
                    inPart.AddPrev(fromProduct);
                    fromProduct.AddNext(inPart);
                }

                return(false);
            }
            catch (Exception e)
            {
                WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <param name="entity"/>
        /// <returns/>
        public bool OnAfterLoad_McpBom(McpBom entity)
        {
            try
            {
                entity.LINE_ID           = UtilityHelper.Trim(entity.LINE_ID);
                entity.STEP_ID           = UtilityHelper.Trim(entity.STEP_ID);
                entity.FROM_PROD_ID      = UtilityHelper.Trim(entity.FROM_PROD_ID);
                entity.FROM_PROD_NAME    = UtilityHelper.Trim(entity.FROM_PROD_NAME);
                entity.TO_PROD_ID        = UtilityHelper.Trim(entity.TO_PROD_ID);
                entity.TO_PROD_NAME      = UtilityHelper.Trim(entity.TO_PROD_NAME);
                entity.FINAL_PROD_ID     = UtilityHelper.Trim(entity.FINAL_PROD_ID);
                entity.FINAL_PROD_NAME   = UtilityHelper.Trim(entity.FINAL_PROD_NAME);
                entity.ASSY_IN_PROD_ID   = UtilityHelper.Trim(entity.ASSY_IN_PROD_ID);
                entity.ASSY_IN_PROD_NAME = UtilityHelper.Trim(entity.ASSY_IN_PROD_NAME);

#if DEBUG
                if (entity.ASSY_IN_PROD_ID == "357937")
                {
                    Console.WriteLine();
                }

                if (entity.FINAL_PROD_ID == "357937")
                {
                    Console.WriteLine();
                }
#endif

                AssyMcpProduct finalProduct = null;
                Tuple <string, string, bool, bool, int> key = new Tuple <string, string, bool, bool, int>(entity.LINE_ID, entity.FINAL_PROD_ID, false, false, 1);

                if (InputMart.Instance.MicronBEProducts.TryGetValue(key, out finalProduct) == false)
                {
                    ProductDetail productDetail = FindHelper.FindProductDetail(entity.LINE_ID, entity.FINAL_PROD_ID);

                    if (productDetail == null)
                    {
                        WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.PRODUCT, entity.LINE_ID, string.Empty,
                                                            string.Empty, entity.FINAL_PROD_ID, string.Empty, string.Empty, 0, string.Empty, "Cannot find ProductMaster", string.Empty, "McpBom");
                        return(false);
                    }

                    finalProduct = NewHelper.NewAssyMcpProduct(entity, productDetail);

                    InputMart.Instance.MicronBEProducts.Add(key, finalProduct);
                }

                ProductDetail inProductDetail = FindHelper.FindProductDetail(entity.LINE_ID, entity.ASSY_IN_PROD_ID);

                if (inProductDetail == null)
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.PRODUCT, entity.LINE_ID, string.Empty,
                                                        string.Empty, entity.ASSY_IN_PROD_ID, string.Empty, string.Empty, 0, string.Empty, "Cannot find ProductMaster", string.Empty, "McpBom");
                    return(false);
                }

                Tuple <string, string, bool, bool, int> inProdKey = new Tuple <string, string, bool, bool, int>(entity.LINE_ID, entity.ASSY_IN_PROD_ID, true, false, entity.COMP_SEQ);

                AssyMcpPart inMcpPart;
                if (InputMart.Instance.MicronBEProducts.TryGetValue(inProdKey, out inMcpPart) == false)
                {
                    inMcpPart = NewHelper.NewAssyMcpPart(entity.LINE_ID, entity.ASSY_IN_PROD_ID, finalProduct, false, entity.COMP_SEQ, entity.COMP_QTY, inProductDetail);
                    inMcpPart.PartChangeStep = entity.STEP_ID;
                    InputMart.Instance.MicronBEProducts.Add(inProdKey, inMcpPart);
                }

                if (finalProduct.AllParts.Contains(inMcpPart) == false)
                {
                    finalProduct.AllParts.Add(inMcpPart);
                }

                if (finalProduct.AssyParts.Contains(inMcpPart) == false)
                {
                    finalProduct.AssyParts.Add(inMcpPart);
                }

                finalProduct.MaxSequence = finalProduct.AssyParts.Count;

                return(true);
            }
            catch (Exception e)
            {
                WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// </summary>
        /// <param name="context"/>
        public void OnAction_McpBom(IPersistContext context)
        {
            try
            {
                HashSet <AssyMcpProduct> mcpProductList = new HashSet <AssyMcpProduct>();

                InputMart.Instance.McpBom.DefaultView.Sort = "COMP_SEQ";
                foreach (McpBom bom in InputMart.Instance.McpBom.DefaultView)
                {
#if DEBUG
                    if (bom.FINAL_PROD_ID == "357937")
                    {
                        Console.WriteLine();
                    }
#endif
                    Tuple <string, string, bool, bool, int> key = new Tuple <string, string, bool, bool, int>(bom.LINE_ID, bom.FINAL_PROD_ID, false, false, 1);

                    AssyMcpProduct mcpProduct = FindHelper.FindProduct(bom.LINE_ID, bom.FINAL_PROD_ID) as AssyMcpProduct;

                    if (mcpProduct == null)
                    {
                        continue;
                    }

                    mcpProductList.Add(mcpProduct);

                    AssyMcpPart inMcpPart = FindHelper.FindProduct(bom.LINE_ID, bom.ASSY_IN_PROD_ID, true, false, bom.COMP_SEQ) as AssyMcpPart;

                    if (inMcpPart == null)
                    {
                        continue;
                    }

                    AssyMcpPart fromMcpPart = null;

                    if (bom.FROM_PROD_ID == bom.ASSY_IN_PROD_ID && bom.COMP_SEQ == 1)
                    {
                        fromMcpPart = null;
                    }
                    else
                    {
                        fromMcpPart = FindHelper.FindProduct(bom.LINE_ID, bom.FROM_PROD_ID, true, true, bom.COMP_SEQ - 1) as AssyMcpPart;

                        if (fromMcpPart == null)
                        {
                            continue;
                        }

                        fromMcpPart.PartChangeStep = bom.STEP_ID;
                    }

#if DEBUG
                    try
                    {
                        if (mcpProduct.MaxSequence > bom.COMP_QTY)
                        {
                            Console.WriteLine();
                        }
                    }
                    catch
                    {
                        Console.WriteLine();
                    }
#endif

                    if (mcpProduct.MaxSequence > bom.COMP_SEQ)
                    {
                        AssyMcpPart toMcpPart = FindHelper.FindProduct(bom.LINE_ID, bom.TO_PROD_ID, true, true, bom.COMP_SEQ) as AssyMcpPart;

                        if (toMcpPart == null)
                        {
                            ProductDetail midProductDetail = FindHelper.FindProductDetail(bom.LINE_ID, bom.TO_PROD_ID);

                            if (midProductDetail == null)
                            {
                                continue;
                            }

                            Tuple <string, string, bool, bool, int> midKey = new Tuple <string, string, bool, bool, int>(bom.LINE_ID, bom.TO_PROD_ID, true, true, bom.COMP_SEQ);

                            if (InputMart.Instance.MicronBEProducts.ContainsKey(midKey) == false)
                            {
                                toMcpPart = NewHelper.NewAssyMcpPart(bom.LINE_ID, bom.TO_PROD_ID, mcpProduct, true, bom.COMP_SEQ, 1, midProductDetail);
                                InputMart.Instance.MicronBEProducts.Add(midKey, toMcpPart);

                                toMcpPart.AddPrev(inMcpPart);

                                inMcpPart.AddNext(toMcpPart);

                                if (fromMcpPart != null)
                                {
                                    fromMcpPart.AddNext(toMcpPart);
                                    toMcpPart.AddPrev(fromMcpPart);
                                }

                                mcpProduct.AllParts.Add(toMcpPart);
                            }
                        }
                    }
                    else
                    {
                        if (fromMcpPart != null)
                        {
                            mcpProduct.AddPrev(fromMcpPart);
                        }

                        mcpProduct.AddPrev(inMcpPart);
                    }
                }

                foreach (AssyMcpProduct mcpProduct in mcpProductList)
                {
                    foreach (AssyMcpPart mcpPart in mcpProduct.AllParts)
                    {
                        if (mcpPart.IsMidPart || mcpPart.CompSeq == 1)
                        {
                            mcpPart.IsBase = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
            }
        }
Пример #4
0
        /// <summary>
        /// </summary>
        /// <param name="entity"/>
        /// <returns/>
        public bool OnAfterLoad_Wip(Wip entity)
        {
            try
            {
                entity.LOT_ID             = UtilityHelper.Trim(entity.LOT_ID);
                entity.LINE_ID            = UtilityHelper.Trim(entity.LINE_ID);
                entity.STEP_ID            = UtilityHelper.Trim(entity.STEP_ID);
                entity.PROCESS_ID         = UtilityHelper.Trim(entity.PROCESS_ID);
                entity.PRODUCT_ID         = UtilityHelper.Trim(entity.PRODUCT_ID);
                entity.PRODUCT_NAME       = UtilityHelper.Trim(entity.PRODUCT_NAME);
                entity.HOLD_CODE          = UtilityHelper.Trim(entity.HOLD_CODE);
                entity.LOT_STATE          = UtilityHelper.Trim(entity.LOT_STATE);
                entity.EQP_ID             = UtilityHelper.Trim(entity.EQP_ID);
                entity.ASM_RESERVATION_ID = UtilityHelper.Trim(entity.ASM_RESERVATION_ID);

#if DEBUG
                if (entity.LOT_ID.StartsWith("BF8QK4N.5X"))
                {
                    Console.WriteLine();
                }

                if (entity.PRODUCT_ID == "BF8QK4N.5X")
                {
                    Console.WriteLine();
                }
#endif

                ProductDetail productDetail = FindHelper.FindProductDetail(entity.LINE_ID, entity.PRODUCT_ID);
                Mozart.SeePlan.Simulation.EntityState state = FindHelper.FindLotState(entity.LOT_STATE, entity.HOLD_CODE, entity.EQP_ID);

                if (productDetail == null)
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.WIP, entity.LINE_ID, entity.STEP_ID,
                                                        entity.LOT_ID, entity.PRODUCT_ID, string.Empty, string.Empty, entity.LOT_QTY, string.Empty, "Cannot find ProductMaster", string.Empty, "Wip");

                    WriteHelper.WriteUnpeg(entity, string.Empty, false, state, UnpegReason.MASTER_DATA, "Cannot find ProductMaster");
                    return(false);
                }

                MicronBEAssyProcess process = productDetail.Process;

                MicronBEAssyBEStep step = process.FindStep(entity.STEP_ID) as MicronBEAssyBEStep;

                if (step == null)
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.WIP, entity.LINE_ID, entity.STEP_ID,
                                                        entity.LOT_ID, entity.PRODUCT_ID, productDetail.DesignID, string.Empty, entity.LOT_QTY, string.Empty, "Cannot find ProcessStep", string.Format("PROCESS_ID : {0}", productDetail.Process.ProcessID), "Wip");

                    WriteHelper.WriteUnpeg(entity, productDetail.DesignID, false, state, UnpegReason.MASTER_DATA, "Cannot find ProcessStep");
                    return(false);
                }

                string  unpegReason = string.Empty;
                Product product     = FindHelper.FindWipProduct(entity, process, step, state, out unpegReason);

                if (product == null)
                {
                    WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.WIP, entity.LINE_ID, entity.STEP_ID,
                                                        entity.LOT_ID, entity.PRODUCT_ID, productDetail.DesignID, string.Empty, entity.LOT_QTY, string.Empty, "Cannot find ProcessStep", string.Format("PROCESS_ID : {0}", productDetail.Process.ProcessID), "Wip");

                    WriteHelper.WriteUnpeg(entity, productDetail.DesignID, false, state, UnpegReason.MASTER_DATA, unpegReason);
                    return(false);
                }

                MicronBEAssyWipInfo wipInfo = new MicronBEAssyWipInfo();
                wipInfo.LotID   = entity.LOT_ID;
                wipInfo.Product = product;
                wipInfo.Process = process;

                wipInfo.UnitQty      = (double)entity.LOT_QTY;
                wipInfo.InitialStep  = process.FindStep(entity.STEP_ID);
                wipInfo.CurrentState = state;
                wipInfo.LineID       = entity.LINE_ID;

                InputMart.Instance.MicronBEAssyWipInfo.Add(wipInfo.InitialStep.StepID, wipInfo);

                return(false);
            }
            catch (Exception e)
            {
                WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
                return(false);
            }
        }