Browse Source

更新寄售库导出发运时间

master
学 赵 1 year ago
parent
commit
7c4308953b
  1. 108
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

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

@ -10,12 +10,15 @@ using System.Linq.Dynamic.Core;
using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using AutoMapper;
using ClosedXML.Excel;
using DocumentFormat.OpenXml;
using EFCore.BulkExtensions;
using LinqToDB.EntityFrameworkCore;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Extension;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -26,7 +29,9 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Omu.ValueInjecter;
using RestSharp.Extensions;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Shouldly;
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
@ -37,8 +42,11 @@ using Volo.Abp.Guids;
using Volo.Abp.Users;
using Volo.Abp.Validation;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
@ -59,7 +67,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly IHubContext<PageHub> _hubContext;
private readonly ICurrentUser _currentUser;
private readonly ILogger<VmiAppService> _logger;
protected readonly IExcelImportAppService _excelImportService;
public VmiAppService(IConfiguration cfg,
IServiceProvider serviceProvider,
IGuidGenerator guidGenerator,
@ -68,7 +76,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
IBlobContainer<MyFileContainer> fileContainer,
IHubContext<PageHub> hubContext,
ICurrentUser currentUser,
ILogger<VmiAppService> logger)
ILogger<VmiAppService> logger,
IExcelImportAppService excelImportService)
{
this._cfg = cfg;
this._guidGenerator = guidGenerator;
@ -80,6 +89,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
this._currentUser = currentUser;
this._logger = logger;
LinqToDBForEFTools.Initialize();
_excelImportService = excelImportService;
}
/// <summary>
@ -403,7 +413,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//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.startBillTime).ToString("yyyy/MM/dd") + " 23:59:59 ";
var endDate = DateTime.Parse(input.endBillTime).ToString("yyyy/MM/dd") + " 23:59:59 ";
DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
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);
@ -416,6 +426,96 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return fileName;
}
/// <summary>
/// 补货数据导出
/// </summary>
[HttpPost]
public async Task<string> ReplenishedExport1Async(ARequestDto input)
{
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 ";
DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
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>());
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
byte[] result = null;
result = await _excel.ExportAsByteArray(entities).ConfigureAwait(false);
result.ShouldNotBeNull();
string _fileName = $"导出文件_{Guid.NewGuid().ToString()}.xlsx";
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
).ConfigureAwait(false);
return _fileName;
}
///// <summary>
///// 输出报错信息
///// </summary>
///// <param name="errorList"></param>
///// <param name="fileName"></param>
///// <returns></returns>
//protected async Task<string> ExportErrorReportAsync(List<ERR_EXP_DTO> errorList, string fileName = "")
//{
// //没有信息返回成功
// if (errorList == null || errorList.Count == 0)
// {
// return ApplicationConsts.SuccessStr;
// }
// if (string.IsNullOrEmpty(fileName))
// {
// //导出文件名称
// fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.CheckErroFileName, _snowflakeIdGenerator.Create().ToString(), ApplicationConsts.FileExtension);
// }
// errorList = errorList.Distinct().OrderBy(p => p.Type).ThenBy(p => p.Model).ThenBy(p => p.ItemCode).ToList();
// //声明导出容器
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.ExcelExporter(errorList).ConfigureAwait(false);
// result.ShouldNotBeNull();
// //保存导出文件到服务器存成二进制
// await _excelImportService.SaveBlobAsync(
// new SaveExcelImportInputDto
// {
// Name = fileName,
// Content = result
// }
// ).ConfigureAwait(false);
// return fileName;
//}
/// <summary>
/// 4.寄售库存调整
@ -779,7 +879,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
}
var results = new List<ValidationResult>();
Validator.TryValidateObject(model, new ValidationContext(model, null, null), results);
Validator.TryValidateObject(model, new System.ComponentModel.DataAnnotations.ValidationContext (model, null, null), results);
list.Add(new Tuple<T, List<ValidationResult>>(model, results));
}
return list;

Loading…
Cancel
Save