mahao
1 year ago
25 changed files with 5953 additions and 1352 deletions
@ -1,569 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.IO; |
|
||||
using System.Linq; |
|
||||
using System.Reflection; |
|
||||
using System.Threading.Tasks; |
|
||||
using EFCore.BulkExtensions; |
|
||||
using Magicodes.ExporterAndImporter.Core; |
|
||||
using Magicodes.ExporterAndImporter.Csv; |
|
||||
using Magicodes.ExporterAndImporter.Excel; |
|
||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.EntityFrameworkCore; |
|
||||
using Microsoft.Extensions.Caching.Distributed; |
|
||||
using Shouldly; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Volo.Abp.Caching; |
|
||||
using Volo.Abp.Domain.Repositories; |
|
||||
using Volo.Abp.Guids; |
|
||||
using Volo.Abp.ObjectMapping; |
|
||||
using Volo.Abp.Uow; |
|
||||
using Win.Abp.Snowflakes; |
|
||||
using Win.Sfs.BaseData.ImportExcelCommon; |
|
||||
using Win.Sfs.SettleAccount.CommonManagers; |
|
||||
using Win.Sfs.SettleAccount.Constant; |
|
||||
using Win.Sfs.SettleAccount.Entities.CodeSettings; |
|
||||
using Win.Sfs.SettleAccount.Entities.ImportMap; |
|
||||
using Win.Sfs.SettleAccount.ExcelImporter; |
|
||||
using Win.Sfs.SettleAccount.ExportReports; |
|
||||
|
|
||||
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
||||
using Win.Sfs.Shared.CacheBase; |
|
||||
using Win.Sfs.Shared.Enums.SettleAccount; |
|
||||
using Win.Sfs.Shared.Filter; |
|
||||
using Win.Utils; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.FISes |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 区域相关应用服务
|
|
||||
/// </summary>
|
|
||||
//[Authorize(SettleAccountPermissions.FISs.Default)]
|
|
||||
//[AllowAnonymous]
|
|
||||
[ApiExplorerSettings(IgnoreApi = true)] |
|
||||
[Route("api/settleaccount/fis")] |
|
||||
public class FISAppService : SettleAccountApplicationBase<FIS>, IFISAppService |
|
||||
{ |
|
||||
private readonly IExcelImportAppService _excelImportService; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<FIS, Guid> _repository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> _preBatchRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<FISExtend, Guid> _extendRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<FISVersion, Guid> _versionRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _relrepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _importRepository; |
|
||||
/// <summary>
|
|
||||
///
|
|
||||
/// </summary>
|
|
||||
/// <param name="guidGenerator"></param>
|
|
||||
/// <param name="objectMapper"></param>
|
|
||||
/// <param name="repository"></param>
|
|
||||
/// <param name="versionRepository"></param>
|
|
||||
/// <param name="extendRepository"></param>
|
|
||||
/// <param name="preBatchRepository"></param>
|
|
||||
/// <param name="cache"></param>
|
|
||||
/// <param name="excelImportService"></param>
|
|
||||
/// <param name="snowflakeIdGenerator"></param>
|
|
||||
/// <param name="commonManager"></param>
|
|
||||
/// <param name="relrepository"></param>
|
|
||||
public FISAppService(IGuidGenerator guidGenerator, |
|
||||
IObjectMapper objectMapper, |
|
||||
ISettleAccountBranchEfCoreRepository<FIS, Guid> repository, |
|
||||
ISettleAccountBranchEfCoreRepository<FISVersion, Guid> versionRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<FISExtend, Guid> extendRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> preBatchRepository, |
|
||||
IDistributedCache<FIS> cache, |
|
||||
IExcelImportAppService excelImportService, |
|
||||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
||||
ICommonManager commonManager, |
|
||||
ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> relrepository, |
|
||||
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> importRepository |
|
||||
) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) |
|
||||
{ |
|
||||
_versionRepository = versionRepository; |
|
||||
_repository = repository; |
|
||||
_excelImportService = excelImportService; |
|
||||
_extendRepository = extendRepository; |
|
||||
_preBatchRepository = preBatchRepository; |
|
||||
_relrepository = relrepository; |
|
||||
_importRepository = importRepository; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导入功能
|
|
||||
/// </summary>
|
|
||||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("ExcelImport")] |
|
||||
[DisableRequestSizeLimit] |
|
||||
|
|
||||
public async Task<string> FISUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory, string model, DateTime? beginDate, DateTime? endDate) |
|
||||
{ |
|
||||
|
|
||||
// List<string> _errorList = new List<string>();
|
|
||||
if (string.IsNullOrEmpty(model) || beginDate == null || endDate == null) |
|
||||
{ |
|
||||
throw new BusinessException("8989", "产线、开始时间和结束时间、不能为空!"); |
|
||||
} |
|
||||
List<FIS> _setls = new List<FIS>(); |
|
||||
List<FISExtend> _extendls = new List<FISExtend>(); |
|
||||
var _id = GuidGenerator.Create(); |
|
||||
var _prelist = await _preBatchRepository.GetAllAsync(GuidGenerator.Create()); |
|
||||
var _chList= await _relrepository.GetAllAsync(GuidGenerator.Create(), true); |
|
||||
var _chls= _chList.Select(p => p.ShipMaterailCode).Distinct(); |
|
||||
var checkList = new List<ErrorExportDto>(); |
|
||||
foreach (var file in files) |
|
||||
{ |
|
||||
|
|
||||
using (TextReader textReader = new StreamReader(file.OpenReadStream())) |
|
||||
{ |
|
||||
|
|
||||
int i = 0; |
|
||||
while (true) |
|
||||
{ |
|
||||
string str = await textReader.ReadLineAsync(); |
|
||||
if (string.IsNullOrEmpty(str)) |
|
||||
{ |
|
||||
break; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
try |
|
||||
{ |
|
||||
var _lst = str.Split(new char[] { ';' }).ToList(); |
|
||||
var orderBillNum = _lst[0]; |
|
||||
var materialCode = _lst[1]; |
|
||||
var qty = decimal.Parse(_lst[2]); |
|
||||
var cp5 = DateTime.Parse(_lst[3]); |
|
||||
var fisYear = cp5.Year.ToString(); |
|
||||
var extend1 = model; |
|
||||
var sequenceNumber = _lst[6]; |
|
||||
var chassisNumber = _lst[7]; |
|
||||
var kenncode = string.Empty; |
|
||||
var chassisNumber2 = string.Empty; |
|
||||
EnumSettleStatus state = EnumSettleStatus.未结算; |
|
||||
if (orderBillNum.Length == 10) |
|
||||
{ |
|
||||
kenncode = orderBillNum.Substring(2 , 7); |
|
||||
} |
|
||||
if (chassisNumber.Length != 18) |
|
||||
{ |
|
||||
chassisNumber2 = chassisNumber.Substring(9, 8); |
|
||||
} |
|
||||
var kenn = _prelist.Where(p => p.KENNCode == kenncode).FirstOrDefault(); |
|
||||
if (kenn != null) |
|
||||
{ |
|
||||
if ((int)EnumSettleStatus.预批量 == kenn.State) |
|
||||
{ |
|
||||
state = EnumSettleStatus.预批量; |
|
||||
} |
|
||||
} |
|
||||
if (beginDate.Value < cp5 && cp5 < endDate.Value) |
|
||||
{ |
|
||||
var _fisId = GuidGenerator.Create(); |
|
||||
var fis = new FIS( |
|
||||
_fisId, |
|
||||
branchId, |
|
||||
year, |
|
||||
period, |
|
||||
extend1, |
|
||||
chassisNumber, |
|
||||
qty, |
|
||||
cp5, |
|
||||
sequenceNumber, |
|
||||
orderBillNum, |
|
||||
materialCode, |
|
||||
fisYear, |
|
||||
_id, |
|
||||
kenncode, |
|
||||
chassisNumber2, |
|
||||
state, |
|
||||
DateTime.Now, |
|
||||
0, |
|
||||
version, |
|
||||
DateTime.Now, |
|
||||
GuidGenerator.Create(), |
|
||||
beginDate == null ? DateTime.Now : beginDate.Value, |
|
||||
endDate == null ? DateTime.Now : endDate.Value, |
|
||||
string.Empty |
|
||||
); |
|
||||
fis.SetModel(model); |
|
||||
_setls.Add(fis); |
|
||||
} |
|
||||
} |
|
||||
catch |
|
||||
{ |
|
||||
} |
|
||||
} |
|
||||
i++; |
|
||||
} |
|
||||
textReader.Close(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
var _copyls= _setls.GroupBy(x =>new { x.ChassisNumber2, x.Version, x.Model, x.ItemCode }).Select(y => y.First()).ToList(); |
|
||||
|
|
||||
var _l = _copyls.Select(p => p.ItemCode).Distinct(); |
|
||||
|
|
||||
var _notls= _l.Where(p=>!_chls.Contains(p)).ToList(); |
|
||||
foreach (var itm in _notls) |
|
||||
{ |
|
||||
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm, string.Empty, string.Format("关系表中不存在发运物料号{0}!", itm), string.Empty)); |
|
||||
} |
|
||||
if (checkList.Count > 0) |
|
||||
{ |
|
||||
return await ExportErrorReportAsync(checkList); |
|
||||
} |
|
||||
if (_copyls != null && _copyls.Count > 0) |
|
||||
{ |
|
||||
foreach (var itm in _copyls) |
|
||||
{ |
|
||||
var fisextend = new FISExtend( |
|
||||
itm.Id, |
|
||||
branchId, |
|
||||
year, |
|
||||
period, |
|
||||
itm.Extend1, |
|
||||
itm.ChassisNumber, |
|
||||
itm.Qty, |
|
||||
itm.CP5Time, |
|
||||
itm.SequenceNumber, |
|
||||
itm.OrderBillNum, |
|
||||
itm.ItemCode, |
|
||||
itm.FISYear, |
|
||||
itm.ParentId, |
|
||||
itm.KENNCode, |
|
||||
itm.ChassisNumber2, |
|
||||
itm.State, |
|
||||
DateTime.Now, |
|
||||
0, |
|
||||
version, |
|
||||
DateTime.Now, |
|
||||
GuidGenerator.Create(), |
|
||||
beginDate == null ? DateTime.Now : beginDate.Value, |
|
||||
endDate == null ? DateTime.Now : endDate.Value, |
|
||||
string.Empty |
|
||||
|
|
||||
); |
|
||||
fisextend.SetModel(model); |
|
||||
|
|
||||
_extendls.Add(fisextend); |
|
||||
} |
|
||||
} |
|
||||
var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Model == model); |
|
||||
await _versionQuery.BatchDeleteAsync(); |
|
||||
var _query = _repository.Where(p => p.Version == version && p.Model == model); |
|
||||
await _query.BatchDeleteAsync(); |
|
||||
var _extendQuery = _extendRepository.Where(p => p.Version == version && p.Model == model); |
|
||||
await _extendQuery.BatchDeleteAsync(); |
|
||||
await _repository.GetDbContext().BulkInsertAsync(_copyls); |
|
||||
await _extendRepository.GetDbContext().BulkInsertAsync(_extendls); |
|
||||
FISVersion _version = new FISVersion(_id, branchId, year, period, version, customerCode, factory, model, beginDate.Value, endDate.Value); |
|
||||
var _ls = new List<FISVersion>(); |
|
||||
_ls.Add(_version); |
|
||||
await _versionRepository.GetDbContext().BulkInsertAsync(_ls); |
|
||||
return ApplicationConsts.SuccessStr; |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// 按ID获取唯一实体
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 返回实体全部属性
|
|
||||
/// </remarks>
|
|
||||
/// <param name="id">ID</param>
|
|
||||
/// <returns>实体DTO</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("{id}")] |
|
||||
|
|
||||
virtual public async Task<FISDto> GetAsync(Guid id) |
|
||||
{ |
|
||||
var result = await GetFromCacheAsync(id); |
|
||||
var dto = ObjectMapper.Map<FIS, FISDto>(result); |
|
||||
return dto; |
|
||||
} |
|
||||
|
|
||||
private async Task<FIS> GetFromCacheAsync(Guid id) |
|
||||
{ |
|
||||
var result = await _repository.GetAsync(id); |
|
||||
|
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
private async Task<long> GetCountAsync(FISRequestDto input) |
|
||||
{ |
|
||||
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|
||||
} |
|
||||
|
|
||||
private async Task<long> GetCountAsync(FISVersionRequestDto input) |
|
||||
{ |
|
||||
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 根据筛选条件获取实体列表
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("list")] |
|
||||
// [Authorize(SettleAccountPermissions.FISs.Default)]
|
|
||||
virtual public async Task<PagedResultDto<FISDto>> GetListAsync(Guid parendid,FISRequestDto input) |
|
||||
{ |
|
||||
//if (input.ParentId != Guid.Empty)
|
|
||||
//{
|
|
||||
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version.ToString() });
|
|
||||
//}
|
|
||||
//else
|
|
||||
//{
|
|
||||
// return new PagedResultDto<FISDto>(0, new List<FISDto>());
|
|
||||
//}
|
|
||||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount, true); |
|
||||
var totalCount = await GetCountAsync(input); |
|
||||
var dtos = ObjectMapper.Map<List<FIS>, List<FISDto>>(entities); |
|
||||
return new PagedResultDto<FISDto>(totalCount, dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 根据筛选条件获取实体列表
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("list_th")] |
|
||||
// [Authorize(SettleAccountPermissions.FISs.Default)]
|
|
||||
virtual public async Task<PagedResultDto<FISDto>> GetListTHAsync(Guid parendid, FISRequestDto input) |
|
||||
{ |
|
||||
//if (input.ParentId != Guid.Empty)
|
|
||||
//{
|
|
||||
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
|
|
||||
//}
|
|
||||
//else
|
|
||||
//{
|
|
||||
// return new PagedResultDto<FISDto>(0, new List<FISDto>());
|
|
||||
//}
|
|
||||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); |
|
||||
var totalCount = await GetCountAsync(input); |
|
||||
var dtos = ObjectMapper.Map<List<FIS>, List<FISDto>>(entities); |
|
||||
return new PagedResultDto<FISDto>(totalCount, dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 获取实体总数
|
|
||||
/// </summary>
|
|
||||
/// <returns>实体总数</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("count")] |
|
||||
|
|
||||
virtual public async Task<long> GetTotalCountAsync(Guid branchId) |
|
||||
{ |
|
||||
return await _repository.GetCountAsync(branchId); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 获取全部实体列表
|
|
||||
/// </summary>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("all")] |
|
||||
|
|
||||
virtual public async Task<ListResultDto<FISDto>> GetAllAsync(Guid branchId) |
|
||||
{ |
|
||||
var entities = await _repository.GetAllAsync(branchId, true); |
|
||||
var dtos = ObjectMapper.Map<List<FIS>, List<FISDto>>(entities); |
|
||||
return new ListResultDto<FISDto>(dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 删除实体
|
|
||||
/// </summary>
|
|
||||
/// <param name="id">ID</param>
|
|
||||
/// <returns>无</returns>
|
|
||||
[HttpDelete] |
|
||||
[Route("{id}")] |
|
||||
|
|
||||
virtual public async Task DeleteAsync(Guid id) |
|
||||
{ |
|
||||
var entity = await GetFromCacheAsync(id); |
|
||||
await Cache.DeleteAsync<FIS>(id.ToString()); |
|
||||
await _repository.DeleteAsync(id); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 按IDs删除实体列表
|
|
||||
/// </summary>
|
|
||||
/// <param name="ids">IDs</param>
|
|
||||
/// <returns>是否执行成功</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("delete")] |
|
||||
|
|
||||
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) |
|
||||
{ |
|
||||
foreach (var id in ids) |
|
||||
{ |
|
||||
var entity = await GetFromCacheAsync(id); |
|
||||
await Cache.DeleteAsync<FIS>(id.ToString()); |
|
||||
} |
|
||||
return await _repository.DeleteListAsync(ids); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 版本列表
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("listversion")] |
|
||||
|
|
||||
public async Task<PagedResultDto<FISVersionDto>> GetVersionListAsync(FISVersionRequestDto input) |
|
||||
{ |
|
||||
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|
||||
input.SkipCount, true); |
|
||||
|
|
||||
var totalCount = await GetCountAsync(input); |
|
||||
var dtos = ObjectMapper.Map<List<FISVersion>, List<FISVersionDto>>(entities); |
|
||||
foreach (var itm in dtos) |
|
||||
{ |
|
||||
itm.Version = itm.Version + string.Format("({0})", itm.Model); |
|
||||
} |
|
||||
return new PagedResultDto<FISVersionDto>(totalCount, dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 根据筛选条件获取实体列表
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("duplicate")] |
|
||||
|
|
||||
[UnitOfWork(isTransactional: false)] |
|
||||
|
|
||||
public async Task<bool> UPdateFisAsync() |
|
||||
{ |
|
||||
await _repository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
||||
"EXEC sp_fis_remove_duplicate" |
|
||||
); |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导出文件
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("Export")] |
|
||||
virtual public async Task<string> ExportAsync(FISRequestDto input) |
|
||||
{ |
|
||||
|
|
||||
IExporter _csv = new CsvExporter(); |
|
||||
|
|
||||
IExporter _excel = new ExcelExporter(); |
|
||||
if (input.ParentId != Guid.Empty) |
|
||||
{ |
|
||||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); |
|
||||
} |
|
||||
|
|
||||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|
||||
0, true); |
|
||||
|
|
||||
var dtoDetails = ObjectMapper.Map<List<FIS>, List<FISExportDto>>(entities); |
|
||||
|
|
||||
string _fileName = string.Empty; |
|
||||
//声明导出容器
|
|
||||
|
|
||||
byte[] result = null; |
|
||||
switch (input.FileType) |
|
||||
{ |
|
||||
case 0: |
|
||||
_fileName = string.Format("大众FIS_{0}.csv", input.UserId.ToString()); |
|
||||
result = await _csv.ExportAsByteArray(dtoDetails); |
|
||||
break; |
|
||||
case 1: |
|
||||
_fileName = string.Format("大众FIS_{0}.xlsx", input.UserId.ToString()); |
|
||||
result = await _excel.ExportAsByteArray(dtoDetails); |
|
||||
break; |
|
||||
} |
|
||||
result.ShouldNotBeNull(); |
|
||||
|
|
||||
//保存导出文件到服务器存成二进制
|
|
||||
await _excelImportService.SaveBlobAsync( |
|
||||
new SaveExcelImportInputDto |
|
||||
{ |
|
||||
Name = _fileName, |
|
||||
Content = result |
|
||||
} |
|
||||
); |
|
||||
return _fileName; |
|
||||
} |
|
||||
//[HttpPost]
|
|
||||
//[Route("ExportJob")]
|
|
||||
//[Authorize(SettleAccountPermissions.FISs.Default)]
|
|
||||
//public Task ExportFile(string taskid,string fileName)
|
|
||||
//{
|
|
||||
|
|
||||
// return Task.CompletedTask;
|
|
||||
//}
|
|
||||
//[HttpPost]
|
|
||||
//[Route("NotifyJob")]
|
|
||||
//[Authorize(SettleAccountPermissions.FISs.Default)]
|
|
||||
//public async Task<string> SendNotify(string taskid,string fileName, string realFileName)
|
|
||||
//{
|
|
||||
// return "str";
|
|
||||
//}
|
|
||||
//[HttpPost]
|
|
||||
//[Route("ImportJob")]
|
|
||||
//[Authorize(SettleAccountPermissions.Materials.Default)]
|
|
||||
//public async Task<string> ImportFile(string taskid,string fileName,string realFileName)
|
|
||||
//{
|
|
||||
// IExcelImporter _importer = new Magicodes.ExporterAndImporter.Excel.ExcelImporter();
|
|
||||
// //await _importer.Import<MaterialDto>(path);
|
|
||||
// return string.Empty;
|
|
||||
|
|
||||
//}
|
|
||||
|
|
||||
} |
|
||||
} |
|
@ -1,580 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.Extensions.Caching.Distributed; |
|
||||
using AutoMapper; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using Volo.Abp.Guids; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Volo.Abp.Caching; |
|
||||
|
|
||||
using Volo.Abp.ObjectMapping; |
|
||||
using Win.Sfs.SettleAccount.ExcelImporter; |
|
||||
using Win.Sfs.Shared.CacheBase; |
|
||||
using Win.Utils; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Win.Sfs.BaseData.ImportExcelCommon; |
|
||||
using Volo.Abp.Domain.Repositories; |
|
||||
using EFCore.BulkExtensions; |
|
||||
using System.IO; |
|
||||
using Microsoft.EntityFrameworkCore; |
|
||||
using Win.Sfs.SettleAccount.Entities.SettleAccountVersion; |
|
||||
using Win.Sfs.SettleAccount.FISes; |
|
||||
using Win.Sfs.Shared.Enums.SettleAccount; |
|
||||
using Win.Sfs.Shared.Filter; |
|
||||
using Shouldly; |
|
||||
using Magicodes.ExporterAndImporter.Csv; |
|
||||
using Magicodes.ExporterAndImporter.Core; |
|
||||
using Magicodes.ExporterAndImporter.Excel; |
|
||||
using System.Data.Common; |
|
||||
using Volo.Abp.Uow; |
|
||||
using Volo.Abp; |
|
||||
using Win.Abp.Snowflakes; |
|
||||
using Win.Sfs.SettleAccount.CommonManagers; |
|
||||
using Win.Sfs.SettleAccount.ExportReports; |
|
||||
using Win.Sfs.SettleAccount.Constant; |
|
||||
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
||||
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|
||||
using Magicodes.ExporterAndImporter.Core.Models; |
|
||||
|
|
||||
using TaskJob.Services; |
|
||||
using TaskJob.EventArgs; |
|
||||
using Win.Sfs.SettleAccount.Entities.Wms; |
|
||||
using Win.Sfs.SettleAccount.Repository; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 大众准时化结算明细导入-R3已结
|
|
||||
/// </summary>
|
|
||||
[ApiExplorerSettings(IgnoreApi = true)] |
|
||||
[Authorize(SettleAccountPermissions.SettleAccounts.Default)] |
|
||||
//[AllowAnonymous]
|
|
||||
[Route("api/settleaccount/SettleAccount")] |
|
||||
public class SettleAccountAppService : SettleAccountApplicationBase<SettleAccount>, ISettleAccountAppService |
|
||||
{ |
|
||||
private readonly IGuidGenerator _guidGenerator; |
|
||||
|
|
||||
private readonly IExcelImportAppService _excelImportService; |
|
||||
|
|
||||
private readonly ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> _preBatchRepository; |
|
||||
|
|
||||
|
|
||||
|
|
||||
private readonly ISettleAccountBranchEfCoreRepository<SettleAccount, Guid> _repository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<SettleAccountVersion, Guid> _versionRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<FIS, Guid> _fisRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _relrepository; |
|
||||
private readonly TaskJobService _service; |
|
||||
/// <summary>
|
|
||||
/// 构建方法
|
|
||||
/// </summary>
|
|
||||
/// <param name="guidGenerator">构建UID</param>
|
|
||||
|
|
||||
/// <param name="repository">仓储接口</param>
|
|
||||
/// <param name="cache">缓存</param>
|
|
||||
public SettleAccountAppService(IGuidGenerator guidGenerator, |
|
||||
ISettleAccountBranchEfCoreRepository<SettleAccountVersion, Guid> versionRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<SettleAccount, Guid> repository, |
|
||||
IDistributedCache<SettleAccount> cache, |
|
||||
IExcelImportAppService excelImportService, |
|
||||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
||||
ICommonManager commonManager, |
|
||||
TaskJobService service, |
|
||||
ISettleAccountBranchEfCoreRepository<FIS, Guid> fisRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> preBatchRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> relrepository |
|
||||
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|
||||
{ |
|
||||
_service = service; |
|
||||
_fisRepository = fisRepository; |
|
||||
_versionRepository = versionRepository; |
|
||||
_guidGenerator = guidGenerator; |
|
||||
_excelImportService = excelImportService; |
|
||||
_repository = repository; |
|
||||
_preBatchRepository = preBatchRepository; |
|
||||
_relrepository = relrepository; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导入功能
|
|
||||
/// </summary>
|
|
||||
/// <param name="files"></param>
|
|
||||
/// <param name="branchId"></param>
|
|
||||
/// <param name="year"></param>
|
|
||||
/// <param name="period"></param>
|
|
||||
/// <param name="version"></param>
|
|
||||
/// <param name="customerCode"></param>
|
|
||||
/// <param name="factory"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("ExcelImport-PG")] |
|
||||
[DisableRequestSizeLimit] |
|
||||
[Authorize(SettleAccountPermissions.SettleAccounts.Create)] |
|
||||
[UnitOfWork(false)] |
|
||||
|
|
||||
public async Task<string> SettleAccountUploadExcelImportTH([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory) |
|
||||
{ |
|
||||
List<CustomCondition> customConditionList = new List<CustomCondition>(); |
|
||||
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version??string.Empty }); |
|
||||
customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty }); |
|
||||
customConditionList.Add(new CustomCondition() { Name = "Year", Value = year ?? string.Empty }); |
|
||||
customConditionList.Add(new CustomCondition() { Name = "Period", Value = period ?? string.Empty }); |
|
||||
customConditionList.Add(new CustomCondition() { Name = "Factory", Value = factory ?? string.Empty }); |
|
||||
var _versionQuery = _versionRepository.Where(p => p.Version == version); |
|
||||
if (_versionQuery.Count() > 0) |
|
||||
{ |
|
||||
_versionQuery.BatchDelete(); |
|
||||
} |
|
||||
|
|
||||
var _query = _repository.Where(p => p.Version == version); |
|
||||
if (_query.Count() > 0) |
|
||||
{ |
|
||||
await _query.BatchDeleteAsync(); |
|
||||
} |
|
||||
var _taskid = await _service.ImportEnqueueAsync<ImportTaskArgs>(files, "结算数据", CurrentUser, typeof(SettleAccountImportService), customConditionList, (rs) => |
|
||||
{ |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
}); |
|
||||
|
|
||||
|
|
||||
return _taskid; |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// 导入功能
|
|
||||
/// </summary>
|
|
||||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("ExcelImport")] |
|
||||
[DisableRequestSizeLimit] |
|
||||
[Authorize(SettleAccountPermissions.SettleAccounts.Create)] |
|
||||
public async Task<string> SettleAccountUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory) |
|
||||
{ |
|
||||
List<SettleAccount> _setls = new List<SettleAccount>(); |
|
||||
List<string> _errorList = new List<string>(); |
|
||||
var _id = GuidGenerator.Create(); |
|
||||
var checkList = new List<ErrorExportDto>(); |
|
||||
var _chList = await _relrepository.GetAllAsync(GuidGenerator.Create(), true); |
|
||||
var _chls = _chList.Select(p => p.SettleMaterialCode).Distinct(); |
|
||||
List<string> _precodeList = new List<string>();//
|
|
||||
using (TextReader textReader = new StreamReader(files[0].OpenReadStream())) |
|
||||
{ |
|
||||
var _preList = _preBatchRepository.Where(p => p.State == 3).ToList(); |
|
||||
var _versionQuery = _versionRepository.Where(p => p.Version == version); |
|
||||
await _versionQuery.BatchDeleteAsync(); |
|
||||
var _query = _repository.Where(p => p.Version == version); |
|
||||
await _query.BatchDeleteAsync(); |
|
||||
int i = 0; |
|
||||
//var _userId = CurrentUser.Id.Value;
|
|
||||
while (true) |
|
||||
{ |
|
||||
string str = await textReader.ReadLineAsync(); |
|
||||
if (string.IsNullOrEmpty(str)) |
|
||||
{ |
|
||||
break; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
//if (i > headerNumber)
|
|
||||
//{
|
|
||||
try |
|
||||
{ |
|
||||
var _lst = str.Split(new char[] { '|' }).ToList(); |
|
||||
string _settleyear = _lst[1].Trim(); |
|
||||
string _kENNCode = _lst[2].Trim(); |
|
||||
string _chassisNumber = _lst[3].Trim(); |
|
||||
string _model = _lst[4].Trim(); |
|
||||
DateTime _cP5A = DateTime.Parse(_lst[5].Trim()); |
|
||||
DateTime _cP7 = DateTime.Parse(_lst[6].Trim()); |
|
||||
string _materialCode = _lst[7].Trim(); |
|
||||
decimal _qty = decimal.Parse(_lst[8].Trim()); |
|
||||
string _settlementID = _lst[9].Trim(); |
|
||||
string _settlementSupplier = _lst[10].Trim(); |
|
||||
if (_preList.Any(p => p.KENNCode == _kENNCode)) |
|
||||
{ |
|
||||
_precodeList.Add(_kENNCode); |
|
||||
} |
|
||||
_setls.Add(new SettleAccount( |
|
||||
GuidGenerator.Create(), |
|
||||
branchId, |
|
||||
_settleyear, |
|
||||
_kENNCode, |
|
||||
_chassisNumber, |
|
||||
_model, |
|
||||
_cP5A, |
|
||||
_cP7, |
|
||||
_materialCode, |
|
||||
_qty, |
|
||||
_settlementID, |
|
||||
_settlementSupplier, |
|
||||
period, |
|
||||
year, |
|
||||
_id, |
|
||||
version, |
|
||||
DateTime.Now, |
|
||||
GuidGenerator.Create() |
|
||||
// _userId
|
|
||||
)); |
|
||||
} |
|
||||
catch |
|
||||
{ |
|
||||
} |
|
||||
//}
|
|
||||
} |
|
||||
i++; |
|
||||
} |
|
||||
textReader.Close(); |
|
||||
} |
|
||||
|
|
||||
var _ls = _setls; |
|
||||
|
|
||||
var query = from arc in _ls |
|
||||
group arc by new { arc.ChassisNumber, arc.MaterialCode } |
|
||||
into g |
|
||||
where g.Count() > 1 |
|
||||
select g; |
|
||||
|
|
||||
var _l = _setls.Select(p => p.MaterialCode).Distinct(); |
|
||||
|
|
||||
var _notls = _l.Where(p => !_chls.Contains(p)).ToList(); |
|
||||
|
|
||||
foreach (var itm in _notls) |
|
||||
{ |
|
||||
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm, string.Empty, string.Format("关系表中不存在结算物料号{0}!", itm), string.Empty)); |
|
||||
} |
|
||||
foreach (var itm in query) |
|
||||
{ |
|
||||
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}底盘号 {1}有重复", itm.Key.MaterialCode, itm.Key.ChassisNumber), string.Empty)); |
|
||||
} |
|
||||
if (checkList.Count > 0) |
|
||||
{ |
|
||||
return await ExportErrorReportAsync(checkList); |
|
||||
} |
|
||||
var _existls = _preBatchRepository.Where(p => _precodeList.Contains(p.KENNCode)).ToList(); |
|
||||
if (_existls.Count > 0) |
|
||||
{ |
|
||||
foreach (var itm in _existls) |
|
||||
{ |
|
||||
itm.Update(string.Format("结算修改预批量{0}", DateTime.Now.ToString("yyyyMMdd")), 0,string.Empty,string.Empty,string.Empty); |
|
||||
} |
|
||||
} |
|
||||
await _preBatchRepository.GetDbContext().BulkUpdateAsync(_existls); |
|
||||
await _repository.GetDbContext().BulkInsertAsync(_setls); |
|
||||
|
|
||||
await _versionRepository.InsertAsync(new SettleAccountVersion(_id, branchId, year, period, version, customerCode, factory)); |
|
||||
|
|
||||
return ApplicationConsts.SuccessStr; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 按ID获取唯一实体
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 返回实体全部属性
|
|
||||
/// </remarks>
|
|
||||
/// <param name="id">ID</param>
|
|
||||
/// <returns>实体DTO</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("{id}")] |
|
||||
[Authorize(SettleAccountPermissions.SettleAccounts.Default)] |
|
||||
virtual public async Task<SettleAccountDto> GetAsync(Guid id) |
|
||||
{ |
|
||||
var result = await GetFromCacheAsync(id); |
|
||||
var dto = ObjectMapper.Map<SettleAccount, SettleAccountDto>(result); |
|
||||
return dto; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
private async Task<SettleAccount> GetFromCacheAsync(Guid id) |
|
||||
{ |
|
||||
var result = await _repository.GetAsync(id); |
|
||||
return result; |
|
||||
} |
|
||||
private async Task<long> GetCountAsync(SettleAccountRequestDto input) |
|
||||
{ |
|
||||
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|
||||
} |
|
||||
|
|
||||
private async Task<long> GetCountAsync(SettleAccountVersionRequestDto input) |
|
||||
{ |
|
||||
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导出预批量
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpGet] |
|
||||
[Route("ExportPreBatch")] |
|
||||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
||||
virtual public async Task<string> ExportPreBatchAsync(string version) |
|
||||
{ |
|
||||
|
|
||||
IExporter _csv = new CsvExporter(); |
|
||||
IExporter _excel = new ExcelExporter(); |
|
||||
var _query = from itm1 in _preBatchRepository join itm2 in _repository on new { itm1.KENNCode, itm1.Year } equals new { itm2.KENNCode, itm2.Year } where itm2.Version == version select itm2; |
|
||||
var _ls=await _query.ToListAsync(); |
|
||||
foreach (var itm in _ls) |
|
||||
{ |
|
||||
itm.state = 3; |
|
||||
} |
|
||||
var dtoDetails = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountExportDto>>(_ls); |
|
||||
string _fileName = string.Empty; |
|
||||
//声明导出容器
|
|
||||
|
|
||||
byte[] result = null; |
|
||||
//switch (input.FileType)
|
|
||||
//{
|
|
||||
// case 0:
|
|
||||
// _fileName = string.Format("结算数据(预批量)_{0}.csv", Guid.NewGuid().ToString());
|
|
||||
// result = await _csv.ExportAsByteArray(dtoDetails);
|
|
||||
// break;
|
|
||||
// case 1:
|
|
||||
// _fileName = string.Format("结算数据_{0}.xlsx", Guid.NewGuid().ToString());
|
|
||||
// result = await _excel.ExportAsByteArray(dtoDetails);
|
|
||||
// break;
|
|
||||
//}
|
|
||||
|
|
||||
_fileName = string.Format("结算数据(预批量)_{0}.xlsx", Guid.NewGuid().ToString()); |
|
||||
result = await _excel.ExportAsByteArray(dtoDetails); |
|
||||
result.ShouldNotBeNull(); |
|
||||
|
|
||||
//保存导出文件到服务器存成二进制
|
|
||||
await _excelImportService.SaveBlobAsync( |
|
||||
new SaveExcelImportInputDto |
|
||||
{ |
|
||||
Name = _fileName, |
|
||||
Content = result |
|
||||
} |
|
||||
); |
|
||||
return _fileName; |
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导出文件
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("Export")] |
|
||||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
||||
virtual public async Task<string> ExportAsync(SettleAccountRequestDto input) |
|
||||
{ |
|
||||
|
|
||||
IExporter _csv = new CsvExporter(); |
|
||||
IExporter _excel = new ExcelExporter(); |
|
||||
if (input.ParentId != Guid.Empty) |
|
||||
{ |
|
||||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); |
|
||||
} |
|
||||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|
||||
0, true); |
|
||||
|
|
||||
var dtoDetails = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountExportDto>>(entities); |
|
||||
|
|
||||
string _fileName = string.Empty; |
|
||||
//声明导出容器
|
|
||||
|
|
||||
byte[] result = null; |
|
||||
switch (input.FileType) |
|
||||
{ |
|
||||
case 0: |
|
||||
_fileName = string.Format("结算数据_{0}.csv", input.UserId.ToString()); |
|
||||
result = await _csv.ExportAsByteArray(dtoDetails); |
|
||||
break; |
|
||||
case 1: |
|
||||
_fileName = string.Format("结算数据_{0}.xlsx", input.UserId.ToString()); |
|
||||
result = await _excel.ExportAsByteArray(dtoDetails); |
|
||||
break; |
|
||||
} |
|
||||
result.ShouldNotBeNull(); |
|
||||
|
|
||||
//保存导出文件到服务器存成二进制
|
|
||||
await _excelImportService.SaveBlobAsync( |
|
||||
new SaveExcelImportInputDto |
|
||||
{ |
|
||||
Name = _fileName, |
|
||||
Content = result |
|
||||
} |
|
||||
); |
|
||||
return _fileName; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 根据筛选条件获取实体列表
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("list")] |
|
||||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
||||
virtual public async Task<PagedResultDto<SettleAccountDto>> GetListAsync(Guid id, SettleAccountRequestDto input) |
|
||||
{ |
|
||||
if (input.ParentId != Guid.Empty) |
|
||||
{ |
|
||||
|
|
||||
// var _entity = await _versionRepository.GetAsync(input.ParentId);
|
|
||||
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = _entity.Version });
|
|
||||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
return new PagedResultDto<SettleAccountDto>(0, new List<SettleAccountDto>()); |
|
||||
} |
|
||||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, |
|
||||
input.SkipCount, true); |
|
||||
|
|
||||
var totalCount = await GetCountAsync(input); |
|
||||
var dtos = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountDto>>(entities); |
|
||||
|
|
||||
return new PagedResultDto<SettleAccountDto>(totalCount, dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 获取实体总数
|
|
||||
/// </summary>
|
|
||||
/// <returns>实体总数</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("count")] |
|
||||
[Authorize(SettleAccountPermissions.SettleAccounts.Default)] |
|
||||
virtual public async Task<long> GetTotalCountAsync(Guid branchId) |
|
||||
{ |
|
||||
return await _repository.GetCountAsync(branchId); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 获取全部实体列表
|
|
||||
/// </summary>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("all")] |
|
||||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
||||
virtual public async Task<ListResultDto<SettleAccountDto>> GetAllAsync(Guid branchId) |
|
||||
{ |
|
||||
var entities = await _repository.GetAllAsync(branchId, true); |
|
||||
var dtos = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountDto>>(entities); |
|
||||
return new ListResultDto<SettleAccountDto>(dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 删除实体
|
|
||||
/// </summary>
|
|
||||
/// <param name="id">ID</param>
|
|
||||
/// <returns>无</returns>
|
|
||||
[HttpDelete] |
|
||||
[Route("{id}")] |
|
||||
/// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
|
|
||||
virtual public async Task DeleteAsync(Guid id) |
|
||||
{ |
|
||||
var entity = await GetFromCacheAsync(id); |
|
||||
await Cache.DeleteAsync<SettleAccount>(id.ToString()); |
|
||||
await _repository.DeleteAsync(id); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 按IDs删除实体列表
|
|
||||
/// </summary>
|
|
||||
/// <param name="ids">IDs</param>
|
|
||||
/// <returns>是否执行成功</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("delete")] |
|
||||
// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
|
|
||||
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) |
|
||||
{ |
|
||||
foreach (var id in ids) |
|
||||
{ |
|
||||
var entity = await GetFromCacheAsync(id); |
|
||||
//await Cache.DeleteAsync<SettleAccount>(id.ToString());
|
|
||||
} |
|
||||
|
|
||||
return await _repository.DeleteListAsync(ids); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
///调用存储
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("listversion")] |
|
||||
|
|
||||
|
|
||||
public async Task<PagedResultDto<SettleAccountVersionDto>> GetVersionListAsync(SettleAccountVersionRequestDto input) |
|
||||
{ |
|
||||
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|
||||
input.SkipCount, true); |
|
||||
var totalCount = await GetCountAsync(input); |
|
||||
var dtos = ObjectMapper.Map<List<SettleAccountVersion>, List<SettleAccountVersionDto>>(entities); |
|
||||
return new PagedResultDto<SettleAccountVersionDto>(totalCount, dtos); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 根据筛选条件获取实体列表
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("updateFis")] |
|
||||
|
|
||||
[UnitOfWork(isTransactional: false)] |
|
||||
public async Task<bool> UPdateFisAsync() |
|
||||
{ |
|
||||
_repository.GetDbContext().Database.SetCommandTimeout(300000); |
|
||||
await _repository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
||||
"EXEC sp_settle_fis_update" |
|
||||
); |
|
||||
return true; |
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
||||
} |
|
@ -1,108 +1,56 @@ |
|||||
using System; |
using System; |
||||
using Win.Sfs.Shared.DomainBase; |
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.Domain.Entities.Auditing; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.MaterialRelationships; |
||||
|
|
||||
namespace Win.Sfs.SettleAccount.MaterialRelationships |
|
||||
{ |
|
||||
/// <summary>
|
/// <summary>
|
||||
/// 客户零件关系
|
/// 客户零件关系
|
||||
/// </summary>
|
/// </summary>
|
||||
public class MaterialRelationship : FullAuditedAggregateRootBase<Guid> |
public class MaterialRelationship : AuditedAggregateRoot<Guid> |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 厂内物料号
|
/// 厂内物料号
|
||||
/// </summary>
|
/// </summary>
|
||||
public string ErpMaterialCode { get; set; } |
public string ErpMaterialCode { get; set; } |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// 厂内物料描述
|
/// 厂内物料描述
|
||||
/// </summary>
|
/// </summary>
|
||||
public string MaterialDesc { get; set; } |
public string MaterialDesc { get; set; } |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// 客户物料号
|
/// 客户物料号
|
||||
/// </summary>
|
/// </summary>
|
||||
public string SettleMaterialCode { get; set; } |
public string SettleMaterialCode { get; set; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// 物料属性
|
/// 业务分类
|
||||
/// </summary>
|
/// </summary>
|
||||
public string MaterialProperty { get; set; } |
[Display(Name = "业务分类")] |
||||
|
public EnumBusinessType BusinessType { get; set; } |
||||
|
|
||||
|
|
||||
|
|
||||
///// <summary>
|
|
||||
///// 结算物料号
|
|
||||
///// </summary>
|
|
||||
//public string SettleMaterialCode { get; set; }
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 发货看板物料号
|
|
||||
/// </summary>
|
|
||||
public string ShipMaterailCode { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 估价类
|
|
||||
/// </summary>
|
|
||||
public string AppraisalCategory { get; set; } |
|
||||
|
|
||||
|
|
||||
public void SetId(Guid id, Guid branchId) |
public void SetId(Guid id, Guid branchId) |
||||
{ |
{ |
||||
|
|
||||
Id = id; |
Id = id; |
||||
BranchId = branchId; |
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
} |
||||
|
|
||||
protected MaterialRelationship() |
protected MaterialRelationship() |
||||
{ |
{ |
||||
} |
} |
||||
public void Update( string materialDesc, string materialProperty, string settlMaterialCode, string shipMaterailCode) |
public void Update(string materialDesc, string settlMaterialCode) |
||||
{ |
{ |
||||
|
|
||||
MaterialDesc = materialDesc; |
MaterialDesc = materialDesc; |
||||
MaterialProperty = materialProperty; |
|
||||
SettleMaterialCode = settlMaterialCode; |
SettleMaterialCode = settlMaterialCode; |
||||
ShipMaterailCode = shipMaterailCode; |
|
||||
//AppraisalCategory = appraisalCategory;
|
|
||||
} |
} |
||||
|
|
||||
public MaterialRelationship( |
public MaterialRelationship(Guid id) : base(id) |
||||
Guid id, |
|
||||
Guid branchId, |
|
||||
|
|
||||
string erpMaterialCode, string materialDesc, string materialProperty, string settlMaterialCode, string shipMaterailCode, string appraisalCategory) :base(id) |
|
||||
{ |
{ |
||||
BranchId = branchId; |
|
||||
ErpMaterialCode = erpMaterialCode; |
|
||||
MaterialDesc = materialDesc; |
|
||||
MaterialProperty = materialProperty; |
|
||||
SettleMaterialCode = settlMaterialCode; |
|
||||
ShipMaterailCode = shipMaterailCode; |
|
||||
AppraisalCategory = appraisalCategory; |
|
||||
} |
} |
||||
|
|
||||
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode, string appraisalCategory) : base(id) |
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode, EnumBusinessType businessType) : base(id) |
||||
{ |
{ |
||||
ErpMaterialCode = erpMaterialCode; |
ErpMaterialCode = erpMaterialCode; |
||||
MaterialDesc = materialDesc; |
MaterialDesc = materialDesc; |
||||
SettleMaterialCode = settlMaterialCode; |
SettleMaterialCode = settlMaterialCode; |
||||
AppraisalCategory = appraisalCategory; |
BusinessType = businessType; |
||||
} |
|
||||
} |
} |
||||
} |
} |
File diff suppressed because it is too large
@ -0,0 +1,191 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Migrations |
||||
|
{ |
||||
|
public partial class _202308181 : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropIndex( |
||||
|
name: "IX_Set_relationship_ErpMaterialCode", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DeleteData( |
||||
|
table: "Set_VmiBalance", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("42240e52-f4f4-4e40-b321-2bc395fde07c")); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "AppraisalCategory", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "BranchId", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DeleterId", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DeletionTime", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "Enabled", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsDeleted", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "MaterialProperty", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "Remark", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ShipMaterailCode", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<int>( |
||||
|
name: "BusinessType", |
||||
|
table: "Set_relationship", |
||||
|
type: "int", |
||||
|
nullable: false, |
||||
|
defaultValue: 0); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<DateTime>( |
||||
|
name: "BillTime", |
||||
|
table: "Set_PUB_SE_DETAIL", |
||||
|
type: "datetime2", |
||||
|
nullable: true, |
||||
|
oldClrType: typeof(DateTime), |
||||
|
oldType: "datetime2"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"), |
||||
|
column: "Service", |
||||
|
value: "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanHBPOSeSyncAppService"); |
||||
|
|
||||
|
migrationBuilder.InsertData( |
||||
|
table: "Set_VmiBalance", |
||||
|
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" }, |
||||
|
values: new object[] { new Guid("ab6a3a74-bb4e-442c-84b5-d148f2cd99f6"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "6947bb1f686043fcb95d9db67c0ca6c8", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Set_relationship_ErpMaterialCode_BusinessType", |
||||
|
table: "Set_relationship", |
||||
|
columns: new[] { "ErpMaterialCode", "BusinessType" }, |
||||
|
unique: true); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropIndex( |
||||
|
name: "IX_Set_relationship_ErpMaterialCode_BusinessType", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.DeleteData( |
||||
|
table: "Set_VmiBalance", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("ab6a3a74-bb4e-442c-84b5-d148f2cd99f6")); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "BusinessType", |
||||
|
table: "Set_relationship"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "AppraisalCategory", |
||||
|
table: "Set_relationship", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "BranchId", |
||||
|
table: "Set_relationship", |
||||
|
type: "uniqueidentifier", |
||||
|
nullable: false, |
||||
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "DeleterId", |
||||
|
table: "Set_relationship", |
||||
|
type: "uniqueidentifier", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<DateTime>( |
||||
|
name: "DeletionTime", |
||||
|
table: "Set_relationship", |
||||
|
type: "datetime2", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "Enabled", |
||||
|
table: "Set_relationship", |
||||
|
type: "bit", |
||||
|
nullable: false, |
||||
|
defaultValue: false); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsDeleted", |
||||
|
table: "Set_relationship", |
||||
|
type: "bit", |
||||
|
nullable: false, |
||||
|
defaultValue: false); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "MaterialProperty", |
||||
|
table: "Set_relationship", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "Remark", |
||||
|
table: "Set_relationship", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "ShipMaterailCode", |
||||
|
table: "Set_relationship", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<DateTime>( |
||||
|
name: "BillTime", |
||||
|
table: "Set_PUB_SE_DETAIL", |
||||
|
type: "datetime2", |
||||
|
nullable: false, |
||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), |
||||
|
oldClrType: typeof(DateTime), |
||||
|
oldType: "datetime2", |
||||
|
oldNullable: true); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"), |
||||
|
column: "Service", |
||||
|
value: "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService"); |
||||
|
|
||||
|
migrationBuilder.InsertData( |
||||
|
table: "Set_VmiBalance", |
||||
|
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" }, |
||||
|
values: new object[] { new Guid("42240e52-f4f4-4e40-b321-2bc395fde07c"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "3a0fa479f64a4e84949961ac4a8aed89", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Set_relationship_ErpMaterialCode", |
||||
|
table: "Set_relationship", |
||||
|
column: "ErpMaterialCode", |
||||
|
unique: true, |
||||
|
filter: "IsDeleted=0"); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue