Просмотр исходного кода

Merge branch 'dev' of http://123.60.180.165:4647/ZZYDOP/DOPCore into dev

Murphy 2 лет назад
Родитель
Сommit
829ce2de53

+ 24 - 9
MicroServices/Business/Business.Application/ReplenishmentManagement/ReplenishmentAppService.cs

@@ -209,6 +209,8 @@ namespace Business.Replenishment
         /// </summary>
         public List<QualityLineWorkDetail> qualityLineWorks = new List<QualityLineWorkDetail>();
 
+        private readonly ISqlRepository<ConfigurationItem> _configurationItem;
+
         /// <summary>
         /// 节假日
         /// </summary>
@@ -304,7 +306,7 @@ namespace Business.Replenishment
             IExtSqlRepository<DMS_IN_LOCDETAIL> DMS_IN_LOCDETAIL,
             IExtSqlRepository<DMS_IN_SHIPPINGDETAIL> DMS_IN_SHIPPINGDETAIL,
             IRepository<ReplenishmentTurnOverSet> ReplenishmentTurnOverSet,
-
+            ISqlRepository<ConfigurationItem> configurationItem,
             SerialNumberAppService serialNumberAppService,
             PretreatmentAppService pretreatmentAppService,
             PurchaseOrderAppService purchaseOrderAppService,
@@ -394,8 +396,8 @@ namespace Business.Replenishment
             _DMS_IN_LOCDETAIL = DMS_IN_LOCDETAIL;
             _DMS_IN_SHIPPINGDETAIL = DMS_IN_SHIPPINGDETAIL;
             _ReplenishmentTurnOverSet= ReplenishmentTurnOverSet;
-
-            _serialNumberAppService= serialNumberAppService;
+            _configurationItem = configurationItem;
+            _serialNumberAppService = serialNumberAppService;
             _pretreatmentAppService = pretreatmentAppService;
             _CalcBomViewAppService = CalcBomViewAppService;
             _purchaseOrderAppService = purchaseOrderAppService;
@@ -4895,18 +4897,31 @@ namespace Business.Replenishment
             if (icitemStokc.Count > 0)
             {
                 List<string> numbers = pretreatments.Select(s => s.item_number).ToList();
+                var locationRange = _configurationItem.Select(x => x.FldName == "MRPLocationRange" && x.Domain == factoryId.ToString()).FirstOrDefault();
+
                 List<string> locationList = new List<string> { "1000", "1001", "5008", "8000", "8001" };
+                if (locationRange != null && locationRange.Val != null)
+                {
+                    locationList = locationRange.Val.SplitToArray(",").ToList();
+                }
                 var locStock = _invMaster.Select(a => numbers.Contains(a.ItemNum) && a.IsActive && a.Domain == factoryId.ToString() && locationList.Contains(a.Location));
-                var sapInvList = _SAPInv.Select(a => a.WERKS == factoryId.ToString() && numbers.Contains(a.MATNR) && (a.SOBKZ.ToUpper() == "O"));
+                var sapInvList = _SAPInv.Select(a => a.WERKS == factoryId.ToString() && numbers.Contains(a.MATNR) && (a.SOBKZ.ToUpper() == "O" || locationList.Contains(a.LGORT)));
+
                 //设置当前计算bangid
                 icitemStokc.ForEach(item => {
                     item.bang_id = bangid;
-                    /*var pret = pretreatments.Find(s => s.item_id == item.icitem_id);
-                    if(pret != null) {
-                    }*/
                     item.sqty = 0;
-                    item.sqty = locStock.Where(s => s.ItemNum == item.icitem_number).Sum(p => p.AvailStatusQty.GetValueOrDefault() + p.Assay.GetValueOrDefault());
-                    item.sqty += sapInvList.Where(x => x.MATNR == item.icitem_number).Sum(p => p.LABST + p.INSME);
+
+                    foreach (var lct in locationList)
+                    {
+                        var lctQty = locStock.Where(s => s.ItemNum == item.icitem_number && s.Location == lct).Sum(p => p.AvailStatusQty.GetValueOrDefault() + p.Assay.GetValueOrDefault());
+                        if (lctQty == 0)
+                        {
+                            lctQty = sapInvList.Where(x => x.MATNR == item.icitem_number && x.LGORT == lct).Sum(p => p.LABST + p.INSME);
+                        }
+                        item.sqty += lctQty;
+                    }
+                    item.sqty += sapInvList.Where(x => x.MATNR == item.icitem_number && x.SOBKZ.ToUpper() == "O").Sum(p => p.LABST + p.INSME);
                 });
                 var moIcitemStokc = ObjectMapper.Map<List<ic_item_stock>, List<mo_ic_item_stock>>(icitemStokc);
                 moIcitemStokc.ForEach(item => { item.GenerateNewId(help.NextId()); });

+ 17 - 10
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -2027,7 +2027,7 @@ namespace Business.ResourceExamineManagement
             if (icitemStokc.Count > 0)
             {
                 List<string> numbers = pretreatments.Select(s => s.item_number).ToList();
-                var locationRange = _configurationItem.Select(x => x.FldName == "MRPLocationRange" && x.Domain == companyId.ToString()).FirstOrDefault();
+                var locationRange = _configurationItem.Select(x => x.FldName == "MRPLocationRange" && x.Domain == factoryId.ToString()).FirstOrDefault();
 
                 List<string> locationList = new List<string> { "1000", "1001", "5008", "8000", "8001" };
                 if (locationRange != null && locationRange.Val != null)
@@ -2035,17 +2035,23 @@ namespace Business.ResourceExamineManagement
                     locationList = locationRange.Val.SplitToArray(",").ToList();
                 }
                 var locStock = _invMaster.Select(a => numbers.Contains(a.ItemNum) && a.IsActive && a.Domain == factoryId.ToString() && locationList.Contains(a.Location));
-                var sapInvList = _SAPInv.Select(a => a.WERKS == factoryId.ToString() && numbers.Contains(a.MATNR) && (a.SOBKZ.ToUpper() == "O"));
+                var sapInvList = _SAPInv.Select(a => a.WERKS == factoryId.ToString() && numbers.Contains(a.MATNR) && (a.SOBKZ.ToUpper() == "O" || locationList.Contains(a.LGORT)));
 
                 //设置当前计算bangid
                 icitemStokc.ForEach(item => { 
                     item.bang_id = bangid;
-                    /*var pret = pretreatments.Find(s => s.item_id == item.icitem_id);
-                    if(pret != null) {
-                    }*/
                     item.sqty = 0;
-                    item.sqty = locStock.Where(s => s.ItemNum == item.icitem_number).Sum(p => p.AvailStatusQty.GetValueOrDefault() + p.Assay.GetValueOrDefault());
-                    item.sqty += sapInvList.Where(x => x.MATNR == item.icitem_number).Sum(p => p.LABST + p.INSME);
+
+                    foreach (var lct in locationList)
+                    {
+                       var lctQty = locStock.Where(s => s.ItemNum == item.icitem_number && s.Location == lct).Sum(p => p.AvailStatusQty.GetValueOrDefault() + p.Assay.GetValueOrDefault());
+                        if (lctQty == 0)
+                        {
+                            lctQty = sapInvList.Where(x => x.MATNR == item.icitem_number && x.LGORT == lct).Sum(p => p.LABST + p.INSME);
+                        }
+                        item.sqty += lctQty;
+                    }
+                    item.sqty += sapInvList.Where(x => x.MATNR == item.icitem_number && x.SOBKZ.ToUpper() == "O").Sum(p => p.LABST + p.INSME);
                 });
                 var moIcitemStokc = ObjectMapper.Map<List<ic_item_stock>, List<mo_ic_item_stock>>(icitemStokc);
                 moIcitemStokc.ForEach(item => { item.GenerateNewId(help.NextId()); });
@@ -2960,7 +2966,7 @@ namespace Business.ResourceExamineManagement
         /// <returns></returns>
         public async Task<string> ProduceDayPlanKittingCheck(string startime,string endtime,string domain, string userAccount)
         {
-            DateTime stime = DateTime.Now.AddDays(1).Date;
+            /*DateTime stime = DateTime.Now.AddMonths(1).Date;
             if (!string.IsNullOrEmpty(startime))
             {
                 DateTime.TryParse(startime, out stime);
@@ -2969,9 +2975,10 @@ namespace Business.ResourceExamineManagement
             if (!string.IsNullOrEmpty(endtime))
             {
                 DateTime.TryParse(endtime, out etime);
-            }
+            }*/
             List<string> tsWork = new List<string> { "test", "tcn", "rw" };
-            var ordlist = _workOrdMaster.Select(x => x.Domain == domain && x.OrdDate>= stime && x.OrdDate <= etime && (string.IsNullOrEmpty(x.Typed) == true || tsWork.Contains(x.Typed)) && (x.Status.ToLower() == "p" || x.Status.ToLower() == "r")).ToList();
+            //var ordlist = _workOrdMaster.Select(x => x.Domain == domain && x.OrdDate>= stime && x.OrdDate <= etime && (string.IsNullOrEmpty(x.Typed) == true || tsWork.Contains(x.Typed)) && (x.Status.ToLower() == "p" || x.Status.ToLower() == "r")).ToList();
+            var ordlist = _workOrdMaster.Select(x => x.Domain == domain && (string.IsNullOrEmpty(x.Typed) == true || tsWork.Contains(x.Typed)) && (x.Status.ToLower() == "p" || x.Status.ToLower() == "r")).ToList();
 
             //根据排产日计划来获取
             var periodSd = _periodSequenceDet.Select(s => s.Domain == domain && ordlist.Select(x => x.WorkOrd).Contains(s.WorkOrds)).ToList();