Explorar o código

库位检查范围逻辑修改。

tangdi %!s(int64=2) %!d(string=hai) anos
pai
achega
7d1e16aa12

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

@@ -201,6 +201,8 @@ namespace Business.Replenishment
         /// </summary>
         public List<QualityLineWorkDetail> qualityLineWorks = new List<QualityLineWorkDetail>();
 
+        private readonly ISqlRepository<ConfigurationItem> _configurationItem;
+
         /// <summary>
         /// 节假日
         /// </summary>
@@ -295,7 +297,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,
@@ -383,8 +385,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;
@@ -4884,18 +4886,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()); });

+ 13 - 7
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()); });