示例#1
0
        public void GetERPBOMChild(List <DTO_MBOM> lists, string PartNum)
        {
            var datas = from a in BasicDatas.ErpPartMtl
                        join part in BasicDatas.ErpPart on a.PartNum equals part.PartNum
                        join partMtl in BasicDatas.ErpPart on a.MtlPartNum equals partMtl.PartNum
                        where a.PartNum == PartNum
                        select new { a, part, partMtl };

            foreach (var item in datas)
            {
                GetERPBOMChild(lists, item.partMtl.PartNum);
                DTO_MBOM obj = new DTO_MBOM();
                obj.Company            = "001";
                obj.ECOGroupID         = "manager";
                obj.MtlPartNum         = item.partMtl.PartNum;
                obj.MtlPartDescription = item.partMtl.PartDescription;
                obj.MtlSeq             = item.a.MtlSeq;
                obj.PartDescription    = item.part.PartDescription;
                obj.PartNum            = item.part.PartNum;
                obj.Plant            = "MfgSys";
                obj.PullAsAsm        = item.partMtl.TypeCode == "M" ? "TRUE" : "FALSE";
                obj.QtyPer           = item.a.QtyPer;
                obj.RelatedOperation = 10;
                obj.RevisionNum      = "A";
                obj.ViewAsAsm        = item.partMtl.TypeCode == "M" ? "TRUE" : "FALSE";
                obj.Source           = item.partMtl.TypeCode == "M" ? "自制件" : "外购件";
                lists.Add(obj);
            }
        }
示例#2
0
        public List <DTO_MBOM> GetPLMBOM(string PartNum)
        {
            List <DTO_MBOM> MBOM = new List <DTO_MBOM>();
            var             data = from a in BasicDatas.PLM_MBOM
                                   join b in BasicDatas.PLM_MPART on a.PID equals b.ID
                                   join c in BasicDatas.PLM_MPART on a.CID equals c.ID
                                   where b.NO == PartNum
                                   select new { bom = a, part = b, partmtl = c };
            var data2 = from cn in BasicDatas.PLM_CONS
                        join cno in BasicDatas.PLM_CONS_OBJOF on cn.ID equals cno.ITEMID2
                        join mp in BasicDatas.PLM_MPART on cno.ITEMID1 equals mp.ID
                        where mp.NO == PartNum
                        select new { cn, cno, mp };

            foreach (var item in data)
            {
                DTO_MBOM obj = new DTO_MBOM();
                obj.Company            = "001";
                obj.ECOGroupID         = "manager";
                obj.MtlPartNum         = item.partmtl.NO.Trim();
                obj.MtlPartDescription = item.partmtl.NAME;
                obj.MtlSeq             = item.bom.BOMPST.Value;
                obj.PartDescription    = item.part.NAME;
                obj.PartNum            = item.part.NO.Trim();
                obj.Plant            = "MfgSys";
                obj.PullAsAsm        = ChkWGJ(item.partmtl.SMEMO, "FALSE", "TRUE");
                obj.QtyPer           = item.bom.BNUM.Value;
                obj.RelatedOperation = 10;
                obj.RevisionNum      = "A";
                obj.ViewAsAsm        = ChkWGJ(item.partmtl.SMEMO, "FALSE", "TRUE");
                obj.Source           = item.partmtl.SOURCE;
                MBOM.Add(obj);
            }
            foreach (var item in data2)
            {
                DTO_MBOM obj = new DTO_MBOM();
                obj.Company            = "001";
                obj.ECOGroupID         = "manager";
                obj.MtlPartNum         = item.cn.NO;
                obj.MtlPartDescription = item.cn.NAME;
                obj.MtlSeq             = 999;
                obj.PartDescription    = item.mp.NAME;
                obj.PartNum            = item.mp.NO;
                obj.Plant            = "MfgSys";
                obj.PullAsAsm        = "FALSE";
                obj.QtyPer           = item.cn.MTLMZ.HasValue ? item.cn.MTLMZ.Value : 0;
                obj.RelatedOperation = 10;
                obj.RevisionNum      = "A";
                obj.ViewAsAsm        = "FALSE";
                obj.Source           = item.mp.SOURCE;
                MBOM.Add(obj);
            }
            return(MBOM);
        }
示例#3
0
        /// <summary>
        /// 获取ERP产品设计BOM
        /// </summary>
        /// <param name="PartNum"></param>
        /// <returns></returns>
        public void GetERPBOM(string PartNum, List <DTO_MBOM> ERPBOM, bool isChild = true, string RevNum = "")
        {
            string PartRevNum = "";

            if (string.IsNullOrEmpty(RevNum))
            {
                var PartRev = BasicDatas.ErpPartRev.Where(o => o.PartNum == PartNum).OrderByDescending(o => o.EffectiveDate).FirstOrDefault();
                if (PartRev != null)
                {
                    PartRevNum = PartRev.RevisionNum;
                }
            }
            else
            {
                PartRevNum = RevNum;
            }

            var lists = from a in BasicDatas.ErpPartMtl.Where(a => a.PartNum == PartNum && a.RevisionNum == PartRevNum)
                        join part in BasicDatas.ErpPart on a.PartNum equals part.PartNum
                        join partMtl in BasicDatas.ErpPart on a.MtlPartNum equals partMtl.PartNum
                        select new { a, part, partMtl };

            foreach (var item in lists)
            {
                DTO_MBOM obj = new DTO_MBOM();
                obj.Company            = "001";
                obj.ECOGroupID         = "manager";
                obj.MtlPartNum         = item.partMtl.PartNum;
                obj.MtlPartDescription = item.partMtl.PartDescription;
                obj.MtlSeq             = item.a.MtlSeq;
                obj.PartDescription    = item.part.PartDescription;
                obj.PartNum            = item.part.PartNum;
                obj.Plant            = "MfgSys";
                obj.PullAsAsm        = item.partMtl.TypeCode == "M" ? "TRUE" : "FALSE";
                obj.QtyPer           = item.a.QtyPer;
                obj.RelatedOperation = 10;
                obj.RevisionNum      = item.a.RevisionNum;
                obj.ViewAsAsm        = item.partMtl.TypeCode == "M" ? "TRUE" : "FALSE";
                obj.Source           = item.partMtl.TypeCode == "M" ? "自制件" : "外购件";
                ERPBOM.Add(obj);
                if (isChild && item.partMtl.TypeCode == "M")
                {
                    GetERPBOM(obj.MtlPartNum, ERPBOM, true, PartRevNum);
                }
            }
        }
示例#4
0
        /// <summary>
        /// 获取更新的BOM物料
        /// </summary>
        /// <param name="LastGetTime"></param>
        /// <returns></returns>
        public List <DTO_MBOM> GetModBOM(DateTime LastGetTime)
        {
            List <DTO_MBOM> result  = new List <DTO_MBOM>();
            var             PRODATA = GetNewPLMBOO(LastGetTime);

            string[] PartNums = new string[PRODATA.Count];
            for (int i = 0; i < PRODATA.Count; i++)
            {
                PartNums[i] = PRODATA[i].PartNum.Trim();
            }
            using (PLM.PLMDbContext PLMDB = new PLM.PLMDbContext(Connection))
            {
                var MPART_DATA = from a in PLMDB.MPART
                                 where (a.CTIME > LastGetTime || a.MTIME > LastGetTime || a.DELTIME > LastGetTime)
                                 select a;

                var data = from a in PLMDB.MBOM
                           join b in MPART_DATA on a.PID equals b.ID
                           join c in PLMDB.MPART on a.CID equals c.ID
                           where a.DEL == false && a.STATE == "A" && (PartNums.Contains(b.NO.Trim()) || PartNums.Contains(c.NO.Trim()))
                           orderby a.MTIME descending, b.MTIME descending
                    select new { bom = a, part = b };

                foreach (var item in data)
                {
                    DTO_MBOM obj = new DTO_MBOM();
                    obj.Company          = "001";
                    obj.ECOGroupID       = "manager";
                    obj.MtlSeq           = item.bom.BOMPST.Value;
                    obj.PartDescription  = item.part.NAME;
                    obj.PartNum          = item.part.NO;
                    obj.Plant            = "MfgSys";
                    obj.PullAsAsm        = ChkWGJ(item.part.SMEMO, "FALSE", "TRUE");
                    obj.QtyPer           = item.bom.BNUM.Value;
                    obj.RelatedOperation = 10;
                    obj.RevisionNum      = "A";
                    obj.ViewAsAsm        = ChkWGJ(item.part.SMEMO, "FALSE", "TRUE");
                    obj.Source           = item.part.SOURCE;
                    result.Add(obj);
                }
            }
            return(result.ToList());
        }
示例#5
0
        /// <summary>
        /// 获取工单BOM结构
        /// </summary>
        /// <param name="lists"></param>
        /// <param name="JobAsmblDatas"></param>
        /// <param name="JobMtlDatas"></param>
        /// <param name="jobnum"></param>
        /// <param name="parent"></param>
        /// <param name="isRoot"></param>
        public void GetJobBom(List <DTO_MBOM> lists, List <JobAsmbl> JobAsmblDatas, List <JobMtl> JobMtlDatas, string partnum, int parent = 0, int isRoot = 1)
        {
            var items = JobAsmblDatas.Where(o => o.Parent == parent && o.PartNum != partnum).ToList();

            //if (parent <= 0)
            //{
            //    if (isRoot == 0)
            //        items = items.Where(o => o.BomLevel > 0).ToList();
            //    else
            //        items = items.Where(o => o.BomLevel == 0).ToList();
            //}

            foreach (var item in items)
            {
                DTO_MBOM obj = new DTO_MBOM();
                obj.Company          = "001";
                obj.ECOGroupID       = "manager";
                obj.Plant            = "MfgSys";
                obj.PartNum          = partnum;
                obj.RevisionNum      = "A";
                obj.MtlSeq           = item.AssemblySeq;
                obj.MtlPartNum       = item.PartNum;
                obj.QtyPer           = item.QtyPer;
                obj.RelatedOperation = 10;
                obj.PullAsAsm        = "TRUE";
                obj.ViewAsAsm        = "TRUE";
                lists.Add(obj);
                if (item.Child > 0)
                {
                    GetJobBom(lists, JobAsmblDatas, JobMtlDatas, item.PartNum, item.AssemblySeq, 0);
                }

                #region 获取第一个工序下的物料
                int firstOper = 0;
                try
                {
                    firstOper = GetJobOper(item.JobNum).Where(o => o.AssemblySeq == item.AssemblySeq).OrderBy(o => o.OprSeq).FirstOrDefault().OprSeq;
                }
                catch { firstOper = 10; }
                if (firstOper > 0)
                {
                    var jobMtls = JobMtlDatas.Where(o => o.AssemblySeq == item.AssemblySeq && o.RelatedOperation == firstOper).ToList();
                    if (jobMtls.Count > 0)
                    {
                        foreach (var mtl in jobMtls)
                        {
                            DTO_MBOM mtlobj = new DTO_MBOM();
                            mtlobj.Company            = "001";
                            mtlobj.ECOGroupID         = "manager";
                            mtlobj.Plant              = "MfgSys";
                            mtlobj.PartNum            = item.PartNum;
                            mtlobj.RevisionNum        = "A";
                            mtlobj.MtlSeq             = mtl.MtlSeq;
                            mtlobj.MtlPartNum         = mtl.PartNum;
                            mtlobj.MtlPartDescription = mtl.Description;
                            mtlobj.QtyPer             = mtl.QtyPer;
                            mtlobj.RelatedOperation   = 10;
                            mtlobj.PullAsAsm          = "FALSE";
                            mtlobj.ViewAsAsm          = "FALSE";
                            lists.Add(mtlobj);
                        }
                    }
                }
                #endregion
            }
        }