Murphy il y a 3 ans
Parent
commit
695a0a57f7

+ 34 - 8
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -403,7 +403,29 @@ namespace Business.ResourceExamineManagement
             //await SaveChangesCompletedEventData()
 
             //数据库快照-同步mysql库数据到mongoDB中
-            //await SyncData(input.tenantId, input.factoryId, bangid);
+            await SyncData(input.tenantId, input.factoryId, bangid);
+
+            List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
+            BomChildExamineDto bomChild = new BomChildExamineDto();
+            bomChild.id = 4331979;
+            bomChild.item_id = 809914;
+            bomChild.item_name = "壳子";
+            bomChild.unit = "只";
+            bomChild.item_code = "2.1.01.01.0007";
+            bomChild.lack_qty = 20;
+            bomChild.erp_cls = 2;
+            returnlist.Add(bomChild);
+            BomChildExamineDto bomChild2 = new BomChildExamineDto();
+            bomChild2.id = 4331981;
+            bomChild2.item_id = 809667;
+            bomChild2.item_name = "壳子";
+            bomChild2.unit = "只";
+            bomChild2.item_code = "2.1.01.01.0053";
+            bomChild2.lack_qty = 20;
+            bomChild2.erp_cls = 2;
+            returnlist.Add(bomChild2);
+            DateTime dateTime = DateTime.Now.AddDays(5);
+            CheckOnOrder(returnlist, 102, 10201, dateTime, bangid);
 
             //产能检查
             await ProductiveExamine(bom_number, packages);
@@ -1569,7 +1591,7 @@ namespace Business.ResourceExamineManagement
         /// <param name="factoryid">工厂id</param>
         /// <param name="deliveryDate">销售订单交付日期</param>
         /// <returns></returns>
-        private async Task<List<ICItemDateDto>> CheckOnOrder(List<BomChildExamineDto> returnlist, long tenantId, long factoryid, DateTime deliveryDate)
+        private async Task<List<ICItemDateDto>> CheckOnOrder(List<BomChildExamineDto> returnlist, long tenantId, long factoryid, DateTime deliveryDate, long bangid)
         {
             //ToDo:企业Id,数据状态过滤以及isdeleted
             var po_list = _srm_po_list.Find(p => returnlist.Select(x => x.item_id).Contains(p.icitem_id) && p.tenant_id== tenantId && p.factory_id == factoryid && p.rarrdate >= DateTime.Now && p.rarrdate < deliveryDate && !p.IsDeleted).Result;
@@ -1588,14 +1610,14 @@ namespace Business.ResourceExamineManagement
                         //外购生成采购申请单
                         if (item.erp_cls == 3)
                         {
-                            DateTime lastTime=CreateSRMPR(item, tenantId, factoryid, 2, leadTimeList, supplierList, planList,deliveryDate);
+                            DateTime lastTime=CreateSRMPR(item, tenantId, factoryid, bangid,2, leadTimeList, supplierList, planList,deliveryDate);
                             itemlist.Add(new ICItemDateDto { item_id = item.item_id, dateTime = lastTime });
                         }
                         else if (item.erp_cls == 2)
                         {
                             //委外生成委外采购申请单和委外工单
-                            DateTime lastTime=CreateSRMPR(item, tenantId, factoryid, 1, leadTimeList, supplierList, planList,deliveryDate);
-                            CreateMesOOder(item, tenantId, factoryid, leadTimeList, supplierList,deliveryDate);
+                            DateTime lastTime=CreateSRMPR(item, tenantId, factoryid, bangid,1, leadTimeList, supplierList, planList,deliveryDate);
+                            CreateMesOOder(item, tenantId, factoryid, bangid, leadTimeList, supplierList,deliveryDate);
                             itemlist.Add(new ICItemDateDto { item_id = item.item_id, dateTime = lastTime});
                         }
                     }
@@ -1623,6 +1645,7 @@ namespace Business.ResourceExamineManagement
                                 po_Occupy.cby = "";//变更人
                                 po_Occupy.creason = "";//变更原因
                                 po_Occupy.ctime = DateTime.Now;//变更时间
+                                po_Occupy.bang_id = bangid;
                                 await _srm_po_occupy.InsertOne(po_Occupy);
                                 break;
                             }
@@ -1645,7 +1668,8 @@ namespace Business.ResourceExamineManagement
                                 po_Occupy.cby = "";//变更人
                                 po_Occupy.creason = "";//变更原因
                                 po_Occupy.ctime = DateTime.Now;//变更时间
-                               await _srm_po_occupy.InsertOne(po_Occupy);
+                                po_Occupy.bang_id = bangid;
+                                await _srm_po_occupy.InsertOne(po_Occupy);
                             }
                         }
                     }
@@ -1659,7 +1683,7 @@ namespace Business.ResourceExamineManagement
         /// </summary>
         /// <param name="returnlist"></param>
         /// <param name="factoryid"></param>
-        private DateTime CreateMesOOder(BomChildExamineDto returnlist, long tenantId, long factoryid, List<ICItemLeadTimeDto> iCItemLeadTimes,List<ic_item_pur> supplierList,DateTime deliveryDate)
+        private DateTime CreateMesOOder(BomChildExamineDto returnlist, long tenantId, long factoryid, long bangId, List<ICItemLeadTimeDto> iCItemLeadTimes,List<ic_item_pur> supplierList,DateTime deliveryDate)
         {
             mes_oorder oOrder = new mes_oorder();
             oOrder.GenerateNewId();
@@ -1701,6 +1725,7 @@ namespace Business.ResourceExamineManagement
             oOrder.need_icitem_status = 1;//所需物料是否充足  1-充足 0-缺料
             oOrder.tenant_id = tenantId;
             oOrder.factory_id = factoryid;
+            oOrder.bang_id = bangId;
             _mes_oorder.InsertOne(oOrder);
             return DateTime.Now;
         }
@@ -1712,7 +1737,7 @@ namespace Business.ResourceExamineManagement
         /// <param name="returnlist"></param>
         /// <param name="factoryid"></param>
         /// <param name="orderType">1委外采购申请单,2采购申请单</param>
-        private DateTime CreateSRMPR(BomChildExamineDto returnlist, long tenantId, long factoryid, int orderType,List<ICItemLeadTimeDto> iCItemLeadTimes, List<ic_item_pur> supplierList, List<ic_plan> planList,DateTime deliveryDate)
+        private DateTime CreateSRMPR(BomChildExamineDto returnlist, long tenantId, long factoryid,long bangId, int orderType,List<ICItemLeadTimeDto> iCItemLeadTimes, List<ic_item_pur> supplierList, List<ic_plan> planList,DateTime deliveryDate)
         {
             var leadTime = iCItemLeadTimes.Find(x => x.item_id == returnlist.item_id);
             var supplier = supplierList.Find(x => x.icitem_id == returnlist.item_id);//默认取第一个供应商
@@ -1750,6 +1775,7 @@ namespace Business.ResourceExamineManagement
             srm_Pr.secInv_ratio = plan.secinv_ratio;//安全库存触发采购比例
             srm_Pr.tenant_id = tenantId;
             srm_Pr.factory_id = factoryid;
+            srm_Pr.bang_id = bangId;
             _srm_pr_main.InsertOne(srm_Pr);
             decimal? totalLeadTime = leadTime.transportation_leadtime + leadTime.stock_leadtime + leadTime.production_leadtime + leadTime.order_leadtime;
             return deliveryDate.AddDays((double)totalLeadTime*-1);//减去提前期

+ 3 - 3
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs

@@ -161,14 +161,14 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_occupy>(b =>
             {
                 b.ToTable("srm_po_occupy").HasComment("粒劃隆等梩蚚砆ロ");
-
+                b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
             });
 
             builder.Entity<srm_pr_main>(b =>
             {
                 b.ToTable("srm_pr_main").HasComment("粒劃扠ワ等");
-
+                b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
             });
 
@@ -203,7 +203,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_oorder>(b =>
             {
                 b.ToTable("mes_oorder").HasComment("巹俋隆等桶");
-
+                b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
             });
 

+ 7 - 0
MicroServices/Business/Bussiness.Model/Production/mes_oorder.cs

@@ -5,6 +5,7 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -233,5 +234,11 @@ namespace Bussiness.Model.Production
         [Description("所需物料是否充足  1-充足 0-缺料")]
         public int? need_icitem_status { get; set; }
 
+        /// <summary>
+        /// 计算ID
+        /// </summary>
+        [Description("计算id")]
+        [NotMapped]
+        public long? bang_id { get; set; }
     }
 }

+ 7 - 0
MicroServices/Business/Bussiness.Model/SRM/srm_pr_main.cs

@@ -3,6 +3,7 @@ using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
 
 namespace Bussiness.Model.SRM
 {
@@ -210,5 +211,11 @@ namespace Bussiness.Model.SRM
         [Description("拒绝原因")]
         public string? pr_rreason { get; set; }
 
+        /// <summary>
+        /// 计算ID
+        /// </summary>
+        [Description("计算id")]
+        [NotMapped]
+        public long? bang_id { get; set; }
     }
 }