Browse Source

更新版本

master
学 赵 11 months ago
parent
commit
779cfb5fe3
  1. 99
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

99
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -410,7 +410,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
RequestDto inputTemp = new RequestDto();
//inputTemp.Filters.Add(new FilterCondition("BillTime", input.startBillTime, EnumFilterAction.BiggerThanOrEqual, EnumFilterLogic.And));
//inputTemp.Filters.Add(new FilterCondition("BillTime", input.endBillTime, EnumFilterAction.SmallThanOrEqual, EnumFilterLogic.And));
//var entities = await _logRepository.GetListByFilterAsync(inputTemp.Filters,null,3,0).ConfigureAwait(false);
var beginDate= DateTime.Parse(input.startBillTime).ToString("yyyy/MM/dd") + " 00:00:00 ";
var endDate = DateTime.Parse(input.endBillTime).ToString("yyyy/MM/dd") + " 23:59:59 ";
@ -418,10 +417,102 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
dtFormat.ShortDatePattern = "yyyy/MM/dd HH:mm:ss";
//DateTime aa= DateTime.ParseExact(DateTime.Parse(input.startBillTime).ToString("yyyy/MM/dd"), "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
var entities = await _logRepository.Where(p=>p.BillTime>= DateTime.Parse(beginDate) && p.BillTime<= DateTime.Parse(endDate)).ToListAsync();
//IQueryable<VmiLog> query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda<VmiLog>());
var result = (from temp1 in _logRepository
join temp2 in
(
from a in
(
from log in _logRepository
where (int)log.LogType == 200
group log by new { log.VinCode, log.RealPartCode } into groupLog
select new
{
VinCode = groupLog.Key.VinCode,
RealPartCode = groupLog.Key.RealPartCode,
ChangedQty = groupLog.Sum(x => x.ChangedQty),
ChangedTime = groupLog.Min(x => x.ChangedTime)
}
)
join b in
(
from log in _logRepository
where (int)log.LogType == 100
group log by new { log.VinCode, log.RealPartCode } into groupLog
select new
{
VinCode = groupLog.Key.VinCode,
RealPartCode = groupLog.Key.RealPartCode,
ChangedQty = groupLog.Sum(x => x.ChangedQty),
ChangedTime = groupLog.Min(x => x.ChangedTime)
}
) on new { a.RealPartCode, a.VinCode } equals new { b.RealPartCode, b.VinCode }
where a.ChangedTime < b.ChangedTime && a.ChangedQty <= b.ChangedQty
select b
) on new { temp1.VinCode, temp1.RealPartCode } equals new { temp2.VinCode, temp2.RealPartCode }
where temp1.ChangedQty > 0
select temp1).ToList();
//var temp2 = (from a in _logRepository
// where (int)a.LogType == 200
// group a by new { a.VinCode, a.RealPartCode } into g
// let SumChangedQty = g.Sum(log => log.ChangedQty)
// let MinChangedTime = g.Min(log => log.ChangedTime)
// select new
// {
// VinCode = g.Key.VinCode,
// RealPartCode = g.Key.RealPartCode,
// SumChangedQty,
// MinChangedTime
// } into a
// join b in (from log in _logRepository
// where (int)log.LogType == 100
// group log by new { log.VinCode, log.RealPartCode } into g
// let SumChangedQty = g.Sum(log => log.ChangedQty)
// let MinChangedTime = g.Min(log => log.ChangedTime)
// select new
// {
// VinCode = g.Key.VinCode,
// RealPartCode = g.Key.RealPartCode,
// SumChangedQty,
// MinChangedTime
// }) on new { a.VinCode, a.RealPartCode } equals new { b.VinCode, b.RealPartCode }
// where a.MinChangedTime < b.MinChangedTime && a.SumChangedQty <= b.SumChangedQty
// select b);
// var entities = await _logRepository.Where(p => p.BillTime >= DateTime.Parse(beginDate) && p.BillTime <= DateTime.Parse(endDate)).ToListAsync();
// IQueryable<VmiLog> query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda<VmiLog>());
var fileName = $"补货数据_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
var content = this.GetContent(entities, "补货数据_");
var content = this.GetContent(result, "补货数据_");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
return fileName;
}

Loading…
Cancel
Save