Beispiel #1
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));
            }
        }
Beispiel #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);
            }
        }