1
dengjunjie
2025-06-19 681d093f9ea16ab2d480d77e6b04b197e506ff60
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs
@@ -17,32 +17,39 @@
    {
        public void AddStockChangeRecord(Dt_StockInfo stockInfo, List<Dt_StockInfoDetail> stockInfoDetails, decimal beforeQuantity, decimal totalQuantity, StockChangeType changeType,int taskNum)
        {
            List<Dt_StockQuantityChangeRecord> stockQuantityChangeRecords = new List<Dt_StockQuantityChangeRecord>();
            stockQuantityChangeRecords = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(stockInfoDetails);
            int index = 0;
            decimal currentQuantity = 0;
            stockQuantityChangeRecords.ForEach(x =>
            {
                x.PalleCode = stockInfo.PalletCode;
                x.BeforeQuantity = beforeQuantity;
                if (totalQuantity > beforeQuantity)
         try
         {
                List<Dt_StockQuantityChangeRecord> stockQuantityChangeRecords = new List<Dt_StockQuantityChangeRecord>();
                stockQuantityChangeRecords = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(stockInfoDetails);
                int index = 0;
                decimal currentQuantity = 0;
                stockQuantityChangeRecords.ForEach(x =>
                {
                    x.ChangeQuantity = stockInfoDetails[index].StockQuantity;
                    currentQuantity += stockInfoDetails[index].StockQuantity;
                    x.AfterQuantity = stockInfoDetails[index].StockQuantity + beforeQuantity;
                }
                else
                {
                    x.ChangeQuantity = -stockInfoDetails[index].StockQuantity;
                    currentQuantity -= stockInfoDetails[index].StockQuantity;
                    x.AfterQuantity = beforeQuantity - stockInfoDetails[index].StockQuantity;
                }
                    x.PalleCode = stockInfo.PalletCode;
                    x.BeforeQuantity = beforeQuantity;
                    if (totalQuantity > beforeQuantity)
                    {
                        x.ChangeQuantity = stockInfoDetails[index].StockQuantity;
                        currentQuantity += stockInfoDetails[index].StockQuantity;
                        x.AfterQuantity = stockInfoDetails[index].StockQuantity + beforeQuantity;
                    }
                    else
                    {
                        x.ChangeQuantity = -stockInfoDetails[index].StockQuantity;
                        currentQuantity -= stockInfoDetails[index].StockQuantity;
                        x.AfterQuantity = beforeQuantity - stockInfoDetails[index].StockQuantity;
                    }
                x.ChangeType = changeType.ObjToInt();
                beforeQuantity += x.ChangeQuantity;
                x.TaskNum = taskNum;
            });
            BaseDal.AddData(stockQuantityChangeRecords);
                    x.ChangeType = changeType.ObjToInt();
                    beforeQuantity += x.ChangeQuantity;
                    x.TaskNum = taskNum;
                });
                BaseDal.AddData(stockQuantityChangeRecords);
            }
         catch (Exception ex)
         {
            throw new Exception(ex.Message);
         }
        }
    }
}