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