Selaa lähdekoodia

Merge branch 'master' of http://123.60.180.165:4647/ZZYDOP/DOPCore

zhengly 3 vuotta sitten
vanhempi
commit
7bab02430b

+ 19 - 2
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/Dto/BomChildExamineDto.cs

@@ -32,13 +32,18 @@ namespace Business.ResourceExamineManagement.Dto
         /// <summary>
         /// BOMid
         /// </summary>
-        public long bom_id { get; set; }
+        public long? bom_id { get; set; }
 
         /// <summary>
         /// 序号
         /// </summary>
         public string num { get; set; }
 
+        /// <summary>
+        /// 类型 0标准件,1替代件
+        /// </summary>
+        public int type { get; set; }
+
         /// <summary>
         /// 物料id
         /// </summary>
@@ -178,7 +183,19 @@ namespace Business.ResourceExamineManagement.Dto
         /// 群组ids
         /// </summary>
         public string icitem_ids { get; set; }
-
+        /// <summary>
+        /// 替代数量
+        /// </summary>
         public decimal replace_amount { get; set; }
+
+        /// <summary>
+        /// 替代策略
+        /// </summary>
+        public int substitute_strategy { get; set; }
+
+        /// <summary>
+        /// 替代方式
+        /// </summary>
+        public int substitute_mode { get; set; }
     }
 }

+ 72 - 58
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -559,7 +559,8 @@ namespace Business.ResourceExamineManagement
             dto.haveicsubs = 0;
             dto.substitute_code = "";
             dto.icitem_ids = "";
-            GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist);
+            int type = 0;
+            GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist, type);
         }
 
         /// <summary>
@@ -570,7 +571,7 @@ namespace Business.ResourceExamineManagement
         /// <param name="icitemlist"></param>
         /// <param name="dto"></param>
         /// <param name="returnlist"></param>
-        public void GetBomList(List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist, BomChildExamineDto dto, List<BomChildExamineDto> returnlist)
+        public void GetBomList(List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist, BomChildExamineDto dto, List<BomChildExamineDto> returnlist,int type)
         {
             int level = dto.level++;//初始化定义level层级
             var help = new SnowFlake();
@@ -581,11 +582,6 @@ namespace Business.ResourceExamineManagement
             {
 
             }
-            //var dto = new BomChildExamineDto();
-            //dto.level = level;
-            //dto.bom_id = bomId;
-            //dto.id = help.NextId();
-            //dto.parent_id = parent_id;
             dto.item_id = bom.icitem_id;
             dto.item_name = bom.item_name;
             dto.item_code = bom.item_number;
@@ -593,7 +589,7 @@ namespace Business.ResourceExamineManagement
             dto.unit = bom.unit;
             dto.erp_cls = item.erp_cls;
             dto.erp_cls_name = item.erp_cls_name;
-
+            dto.type = type;
 
             //var bdto = ObjectMapper.Map<ic_bom,BomChildExamineDto>(bom);
             returnlist.Add(dto);
@@ -622,7 +618,9 @@ namespace Business.ResourceExamineManagement
                         cdto.haveicsubs = c.haveicsubs;
                         cdto.substitute_code = c.substitute_code;
                         cdto.icitem_ids = c.icitem_ids;
-                        GetBomList(bomlist, bomchildlist, icitemlist, cdto, returnlist);
+                        cdto.type = type;
+                        //递归寻找子级
+                        GetBomList(bomlist, bomchildlist, icitemlist, cdto, returnlist, type);
                     }
                 }
                 else
@@ -649,6 +647,7 @@ namespace Business.ResourceExamineManagement
                         childDto.haveicsubs = c.haveicsubs;
                         childDto.substitute_code = c.substitute_code;
                         childDto.icitem_ids = c.icitem_ids;
+                        childDto.type = type;
                         returnlist.Add(childDto);
                     }
                 }
@@ -661,7 +660,7 @@ namespace Business.ResourceExamineManagement
         /// <summary>
         /// BOM替代关系预处理
         /// </summary>
-        public void BomSubstitute(List<BomChildExamineDto> returnlist, List<ic_item> icitemlist)
+        public void BomSubstitute(List<BomChildExamineDto> returnlist, List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist)
         {
             var sublist = _ic_substitute.GetManyByCondition(s => s.substitute_code.IsIn(returnlist.Select(c => c.substitute_code))).Result.ToList();
             var suballlist = _ic_substitute_all.GetManyByCondition(s => s.substitute_id.IsIn(sublist.Select(c => c.Id))).Result.ToList();
@@ -669,6 +668,7 @@ namespace Business.ResourceExamineManagement
 
             List<long> dicIds = new List<long>();
             var help = new SnowFlake();
+            int type = 1;
             //除顶级外,其他层级关系全带出来。生成平铺
             foreach (var item in returnlist)
             {
@@ -678,23 +678,7 @@ namespace Business.ResourceExamineManagement
                     //有替代关系
                     if (item.haveicsubs == 1)
                     {
-                        /*//群组替代
-                        if (item.is_replace == 1)
-                        {
-                            if (!string.IsNullOrEmpty(item.icitem_ids))
-                            {
-                                var ids = item.icitem_ids.Split(',');
-                                foreach (var i in ids)
-                                {
-                                    long id = 0;
-                                    if (long.TryParse(i, out id))
-                                    {
-                                        dicIds.Add(id);
-                                    }
-                                }
-                            }
-                        }*/
-
+                        //找到当前物料的替代群组关系集
                         var sl = sublist.Find(s => s.substitute_code == item.substitute_code);
                         if (sl != null)
                         {
@@ -704,35 +688,8 @@ namespace Business.ResourceExamineManagement
                                 var sadl = subdtllist.Where(s => s.substitute_allid == sal.Id).ToList();
                                 foreach (var dtl in sadl)
                                 {
-                                    SubstitutePretreatment(sal, dtl, item, returnlist, icitemlist);
-                                    //var sitem = icitemlist.Find(s => s.Id == dtl.icitem_id);
-                                    //if (sitem != null)
-                                    //{
-                                    //    var childDto = new BomChildExamineDto();
-                                    //    childDto.level = item.level;
-                                    //    childDto.bom_id = item.bom_id;
-                                    //    childDto.id = help.NextId();
-                                    //    childDto.parent_id = item.parent_id;
-                                    //    childDto.item_id = sitem.Id;
-                                    //    childDto.item_name = sitem.name;
-                                    //    childDto.item_code = sitem.number;
-                                    //    childDto.num = item.num;
-                                    //    childDto.model = sitem.model;
-                                    //    childDto.unit = sitem.unit;
-                                    //    childDto.erp_cls = sitem.erp_cls;
-                                    //    childDto.erp_cls_name = sitem.erp_cls_name;
-                                    //    childDto.backflush = item.backflush;
-                                    //    childDto.replace_amount = dtl.use_amount.Value;
-                                    //    childDto.replace_amount = dtl.replace_amount.Value;
-
-                                    //    childDto.isbom = 0;
-                                    //    childDto.is_replace = c.is_replace;
-                                    //    childDto.haveicsubs = c.haveicsubs;
-                                    //    childDto.substitute_code = c.substitute_code;
-                                    //    childDto.icitem_ids = c.icitem_ids;
-                                    //    returnlist.Add(childDto);
-                                    //}
-
+                                    //递归将替代关系组装出来。
+                                    SubstitutePretreatment(sl, sal, dtl, item, returnlist, icitemlist, bomlist, bomchildlist,type);
                                 }
                             }
                         }
@@ -741,11 +698,68 @@ namespace Business.ResourceExamineManagement
             }
         }
 
-        public void SubstitutePretreatment(ic_substitute_all sal, ic_substitute_all_dtl dtl, BomChildExamineDto toDto, List<BomChildExamineDto> returnlist, List<ic_item> icitemlist)
+        /// <summary>
+        /// 替代关系递归组装出来
+        /// </summary>
+        /// <param name="sal"></param>
+        /// <param name="dtl"></param>
+        /// <param name="toDto"></param>
+        /// <param name="returnlist"></param>
+        /// <param name="icitemlist"></param>
+        /// <param name="bomlist"></param>
+        /// <param name="bomchildlist"></param>
+        public void SubstitutePretreatment(ic_substitute sl, ic_substitute_all sal, ic_substitute_all_dtl dtl,BomChildExamineDto toDto,List<BomChildExamineDto> returnlist, List<ic_item> icitemlist, List<ic_bom> bomlist, List<ic_bom_child> bomchildlist,int type)
         {
-            //生成sal层级dto,是toDto的替代关系,类似R6-K50的BOM的层级1.1.1
             //循环生成dtl层级dto,明细
             //如果dtl对应的icitem是BOM,还需要向下继续展开。
+            var help = new SnowFlake();
+            
+            //List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
+            var dto = new BomChildExamineDto();
+            var bom = bomlist.WhereIf(true, s => s.icitem_id == dtl.icitem_id).FirstOrDefault();
+            var icitem = icitemlist.Find(s => s.Id == dtl.icitem_id);
+            if (icitem == null)
+            {
+                return;
+            }
+            dto.id = help.NextId();
+            dto.level = toDto.level;
+            dto.parent_id = toDto.parent_id;
+            dto.item_id = icitem.Id;
+            dto.item_name = icitem.name;
+            dto.item_code = icitem.number;
+            dto.num = toDto.num;
+            dto.model = icitem.model;
+            dto.unit = icitem.unit;
+            dto.erp_cls = icitem.erp_cls;
+            dto.erp_cls_name = icitem.erp_cls_name;
+            dto.backflush = toDto.backflush;
+            dto.qty = toDto.qty;
+            dto.replace_amount = dtl.replace_amount.Value;
+            dto.is_replace = 0;
+            dto.haveicsubs = 0;
+            dto.substitute_code = "";
+            dto.icitem_ids = "";
+            dto.substitute_strategy = sl.substitute_strategy.Value;
+            dto.substitute_mode = sl.substitute_mode.Value;
+            dto.type = type;
+            if (bom != null)
+            {
+                dto.bom_id = bom.Id;
+                
+                dto.qty = dtl.replace_amount.Value;
+                dto.isbom = 1;
+                dto.is_replace = 0;
+                dto.haveicsubs = 0;
+                dto.substitute_code = "";
+                dto.icitem_ids = "";
+                GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist, type);
+            }
+            else {
+                dto.bom_id = null;
+                dto.isbom = 0;
+                returnlist.Add(dto);
+            }
         }
 
         /// <summary>

+ 57 - 0
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContext.cs

@@ -29,6 +29,7 @@ namespace Business.EntityFrameworkCore
         /// </summary>
         public DbSet<crm_seorder> crm_seorder { get; set; }
 
+        #region 物料
         /// <summary>
         /// 物料详情
         /// </summary>
@@ -44,6 +45,62 @@ namespace Business.EntityFrameworkCore
         /// </summary>
         public DbSet<ic_bom_child> ic_bom_child { get; set; }
 
+        /// <summary>
+        /// 物料质检
+        /// </summary>
+        public DbSet<ic_check> ic_check { get; set; }
+
+        /// <summary>
+        /// 工厂物料明细表
+        /// </summary>
+        public DbSet<ic_factory_details> ic_factory_details { get; set; }
+
+        /// <summary>
+        /// 物料IE信息
+        /// </summary>
+        public DbSet<ic_item_ie> ic_item_ie { get; set; }
+
+        /// <summary>
+        /// 物料库存明细表
+        /// </summary>
+        public DbSet<ic_item_inventory> ic_item_inventory { get; set; }
+
+        /// <summary>
+        /// 物料采购报价单
+        /// </summary>
+        public DbSet<ic_item_pur> ic_item_pur { get; set; }
+
+        /// <summary>
+        /// 物料库存表
+        /// </summary>
+        public DbSet<ic_item_stock> ic_item_stock { get; set; }
+
+        /// <summary>
+        /// 物料计量表
+        /// </summary>
+        public DbSet<ic_metering_unit> ic_metering_unit { get; set; }
+
+        /// <summary>
+        /// 物料采购计划表
+        /// </summary>
+        public DbSet<ic_plan> ic_plan { get; set; }
+
+        /// <summary>
+        /// 替代群组
+        /// </summary>
+        public DbSet<ic_substitute> ic_substitute { get; set; }
+
+        /// <summary>
+        /// 物料替代多群组
+        /// </summary>
+        public DbSet<ic_substitute_all> ic_substitute_all { get; set; }
+
+        /// <summary>
+        /// 物料替代多群组明细
+        /// </summary>
+        public DbSet<ic_substitute_all_dtl> ic_substitute_all_dtl { get; set; }
+        #endregion
+
         #region 工艺路径
 
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_factory_details.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 工厂物料明细表
     /// </summary>
+    [CollectionName("dopbase", "ic_factory_details")]
     public class ic_factory_details : BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_item_ie.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -12,6 +13,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料ie信息表
     /// </summary>
+    [CollectionName("dopbase", "ic_item_ie")]
     public class ic_item_ie:BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_item_inventory.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料库存明细表
     /// </summary>
+    [CollectionName("dopbase", "ic_item_inventory")]
     public class ic_item_inventory:BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_item_pur.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料采购报价单
     /// </summary>
+    [CollectionName("dopbase", "ic_item_pur")]
     public class ic_item_pur : BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_metering_unit.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -12,6 +13,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料计量表
     /// </summary>
+    [CollectionName("dopbase", "ic_metering_unit")]
     public class ic_metering_unit : BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_plan.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料采购计划表
     /// </summary>
+    [CollectionName("dopbase", "ic_plan")]
     public class ic_plan : BaseEntity
     {
         /// <summary>

+ 14 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_substitute.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -13,6 +14,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 替代群组
     /// </summary>
+    [CollectionName("dopbase", "ic_substitute")]
     public class ic_substitute : BaseEntity
     {
         /// <summary>
@@ -27,5 +29,16 @@ namespace Bussiness.Model.MES.IC
         [Description("替代类型")]
         public int substitute_type { get; set; }
 
+        /// <summary>
+        /// 替代策略
+        /// </summary>
+        [Description("替代策略")]
+        public int? substitute_strategy { get; set; }
+
+        /// <summary>
+        /// 替代方式
+        /// </summary>
+        [Description("替代方式")]
+        public int? substitute_mode { get; set; }
     }
 }

+ 3 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ic_substitute_all.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -12,6 +13,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料替代多群组
     /// </summary>
+    [CollectionName("dopbase", "ic_substitute_all")]
     public class ic_substitute_all : BaseEntity
     {
         /// <summary>

+ 11 - 3
MicroServices/Business/Bussiness.Model/MES/IC/ic_substitute_all_dtl.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
@@ -13,6 +14,7 @@ namespace Bussiness.Model.MES.IC
     /// <summary>
     /// 物料替代多群组明细
     /// </summary>
+    [CollectionName("dopbase", "ic_substitute_all_dtl")]
     public class ic_substitute_all_dtl : BaseEntity
     {
         /// <summary>
@@ -39,12 +41,18 @@ namespace Bussiness.Model.MES.IC
         [Description("主/替")]
         public int ismain { get; set; }
 
-        /// <summary>
+        /*/// <summary>
         /// 使用数量
         /// </summary>
         [Precision(20, 8)]
         [Description("使用数量")]
-        public decimal? use_amount { get; set; }
+        public decimal? use_amount { get; set; }*/
+
+        /// <summary>
+        /// 序号
+        /// </summary>
+        [Description("序号")]
+        public int num { get; set; }
 
         /// <summary>
         /// 替代数量

+ 3 - 1
MicroServices/Business/Bussiness.Model/SRM/srm_po_list.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.SRM
     /// <summary>
     /// 采购订单明细详情
     /// </summary>
+    [CollectionName("dopbase", "srm_po_list")]
     public class srm_po_list : BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SRM/srm_po_main.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.SRM
     /// <summary>
     /// 采购订单
     /// </summary>
+    [CollectionName("dopbase", "srm_po_main")]
     public class srm_po_main : BaseEntity
     {
 

+ 3 - 1
MicroServices/Business/Bussiness.Model/SRM/srm_po_occupy.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.SRM
     /// <summary>
     /// 采购订单占用详情
     /// </summary>
+    [CollectionName("dopbase", "srm_po_occupy")]
     public class srm_po_occupy : BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SRM/srm_pr_main.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.SRM
     /// <summary>
     /// 采购申请单
     /// </summary>
+    [CollectionName("dopbase", "srm_pr_main")]
     public class srm_pr_main : BaseEntity
     {
         /// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SRM/srm_purchase.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -8,6 +9,7 @@ namespace Bussiness.Model.SRM
     /// <summary>
     /// 物料采购信息表
     /// </summary>
+    [CollectionName("dopbase", "srm_purchase")]
     public class srm_purchase : BaseEntity
     {
         /// <summary>