wangxinhui
15 小时以前 67348f250a1b7970059698002949a5e0a5f3c52f
项目代码/WMS/WMSServices/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs
@@ -16,37 +16,10 @@
{
    public partial class StockQuantityChangeRecordService : ServiceBase<Dt_StockQuantityChangeRecord, IStockQuantityChangeRecordRepository>, IStockQuantityChangeRecordService
    {
        public void AddStockChangeRecord(Dt_StockInfo stockInfo, List<Dt_StockInfoDetail> stockInfoDetails, float beforeQuantity, float totalQuantity, StockChangeTypeEnum changeType, int? taskNum = null)
        public void AddStockChangeRecord(Dt_StockInfo stockInfo, float beforeQuantity, float totalQuantity, StockChangeTypeEnum changeType, int? taskNum = null)
        {
            try
            {
                List<Dt_StockQuantityChangeRecord> stockQuantityChangeRecords = new List<Dt_StockQuantityChangeRecord>();
                stockQuantityChangeRecords = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(stockInfoDetails);
                int index = 0;
                float currentQuantity = 0;
                stockQuantityChangeRecords.ForEach(x =>
                {
                    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;
                    index++;
                });
                BaseDal.AddData(stockQuantityChangeRecords);
            }
            catch (Exception ex)
            {
@@ -54,40 +27,11 @@
            }
        }
        public void AddStockChangeRecord(Dt_StockInfo stockInfo, List<Dt_StockInfoDetail> residueDetailList, List<Dt_StockInfoDetail> updateDetails, List<Dt_StockInfoDetail> deleteDetails, StockChangeTypeEnum changeType, int? taskNum = null)
        public void AddStockChangeRecord(Dt_StockInfo stockInfo, StockChangeTypeEnum changeType, int? taskNum = null)
        {
            try
            {
                List<Dt_StockQuantityChangeRecord> stockQuantityChangeRecords = new List<Dt_StockQuantityChangeRecord>();
                int index1 = 0;
                List<Dt_StockQuantityChangeRecord> records1 = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(updateDetails);
                float beforeQuantity = updateDetails.Sum(x => x.OutboundQuantity + x.StockQuantity) + deleteDetails.Sum(x => x.StockQuantity) + residueDetailList.Sum(x => x.StockQuantity);
                records1.ForEach(x =>
                {
                    x.PalleCode = stockInfo.PalletCode;
                    x.BeforeQuantity = beforeQuantity;
                    x.ChangeQuantity = -updateDetails[index1].OutboundQuantity;
                    x.AfterQuantity = beforeQuantity + x.ChangeQuantity;
                    beforeQuantity -= updateDetails[index1].OutboundQuantity;
                    index1++;
                });
                stockQuantityChangeRecords.AddRange(records1);
                int index2 = 0;
                List<Dt_StockQuantityChangeRecord> records2 = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(deleteDetails);
                records2.ForEach(x =>
                {
                    x.PalleCode = stockInfo.PalletCode;
                    x.BeforeQuantity = beforeQuantity;
                    x.ChangeQuantity = -deleteDetails[index2].StockQuantity;
                    x.AfterQuantity = beforeQuantity + x.ChangeQuantity;
                    beforeQuantity -= deleteDetails[index2].StockQuantity;
                    index2++;
                });
                stockQuantityChangeRecords.AddRange(records2);
                BaseDal.AddData(stockQuantityChangeRecords);
            }
            catch (Exception ex)
            {