mahao
1 year ago
12 changed files with 6163 additions and 987 deletions
@ -1,303 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.IO; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using EFCore.BulkExtensions; |
|
||||
using Magicodes.ExporterAndImporter.Core; |
|
||||
using Magicodes.ExporterAndImporter.Excel; |
|
||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.Extensions.Caching.Distributed; |
|
||||
using Shouldly; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Volo.Abp.BackgroundJobs; |
|
||||
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.Boms; |
|
||||
using Win.Sfs.SettleAccount.CommonManagers; |
|
||||
using Win.Sfs.SettleAccount.Constant; |
|
||||
using Win.Sfs.SettleAccount.Entities.Boms; |
|
||||
using Win.Sfs.SettleAccount.Entities.Errors; |
|
||||
using Win.Sfs.SettleAccount.Entities.ImportMap; |
|
||||
using Win.Sfs.SettleAccount.Entities.Prices; |
|
||||
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|
||||
using Win.Sfs.SettleAccount.Errors; |
|
||||
using Win.Sfs.SettleAccount.ExcelImporter; |
|
||||
using Win.Sfs.SettleAccount.ExportReports; |
|
||||
using Win.Sfs.SettleAccount.Reports; |
|
||||
using Win.Sfs.Shared.CacheBase; |
|
||||
using Win.Utils; |
|
||||
namespace Win.Sfs.SettleAccount.Entities.ErrorBills |
|
||||
{ |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 物料主数据应用服务
|
|
||||
/// </summary>
|
|
||||
// [Authorize(SettleAccountPermissions.ErrorBills.Default)]
|
|
||||
//[AllowAnonymous]
|
|
||||
[Route("api/settleaccount/ErrorBill")] |
|
||||
[ApiExplorerSettings(IgnoreApi = true)] |
|
||||
public class ErrorBillAppService : SettleAccountApplicationBase<ErrorBill> |
|
||||
{ |
|
||||
|
|
||||
|
|
||||
private readonly IExcelImportAppService _excelImportService; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<ErrorBill, Guid> _repository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<Bom, Guid> _bomRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<BomVersion, Guid> _bomversionRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<PriceList, Guid> _priceRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> _priceversionRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository; |
|
||||
//private readonly ISettleAccountBranchEfCoreRepository<ErrorBillRelationship, Guid> _relationshipRepository;
|
|
||||
/// <summary>
|
|
||||
/// 构建方法
|
|
||||
/// </summary>
|
|
||||
/// <param name="guidGenerator">构建UID</param>
|
|
||||
/// <param name="objectMapper">自动map</param>
|
|
||||
/// <param name="repository">仓储接口</param>
|
|
||||
/// <param name="cache">缓存</param>
|
|
||||
public ErrorBillAppService( |
|
||||
|
|
||||
ISettleAccountBranchEfCoreRepository<ErrorBill, Guid> repository, |
|
||||
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<Bom, Guid> bomRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<BomVersion, Guid> bomversionRepository, |
|
||||
TaskJobService service, |
|
||||
//ISettleAccountBranchEfCoreRepository<ErrorBillRelationship, Guid> relationshipRepository,
|
|
||||
ISettleAccountBranchEfCoreRepository<PriceList, Guid> priceRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> priceversionRepository, |
|
||||
|
|
||||
IDistributedCache<ErrorBill> cache, |
|
||||
IExcelImportAppService excelImportService, |
|
||||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
||||
ICommonManager commonManager |
|
||||
|
|
||||
) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) |
|
||||
{ |
|
||||
_priceRepository = priceRepository; |
|
||||
_priceversionRepository = priceversionRepository; |
|
||||
_bomRepository = bomRepository; |
|
||||
_excelImportService = excelImportService; |
|
||||
_repository = repository; |
|
||||
//_relationshipRepository = relationshipRepository;
|
|
||||
_mapRepository = mapRepository; |
|
||||
_bomversionRepository = bomversionRepository; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导入功能
|
|
||||
/// </summary>
|
|
||||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|
||||
/// <returns></returns>
|
|
||||
//[HttpPost]
|
|
||||
//[Route("ExcelImport")]
|
|
||||
//[DisableRequestSizeLimit]
|
|
||||
|
|
||||
//public async Task<string> ErrorBillUploadExcelImportMap([FromForm] IFormFileCollection files,string version)
|
|
||||
//{
|
|
||||
// ExportImporter _exportImporter = new ExportImporter();
|
|
||||
// var result = await _exportImporter.ExtendExcelImport<ErrorBill>(files, _excelImportService);
|
|
||||
// return ApplicationConsts.SuccessStr;
|
|
||||
//}
|
|
||||
|
|
||||
|
|
||||
|
|
||||
//public List<T> RemoveError<T>(List<T> p_list) where T : ReportDetailBase, new ()
|
|
||||
//{
|
|
||||
|
|
||||
|
|
||||
// return p_list;
|
|
||||
|
|
||||
|
|
||||
//}
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导入功能
|
|
||||
/// </summary>
|
|
||||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpPost] |
|
||||
[Route("ExcelImport")] |
|
||||
[DisableRequestSizeLimit] |
|
||||
|
|
||||
public async Task<string> ErrorBillUploadExcelImport([FromForm] IFormFileCollection files) |
|
||||
{ |
|
||||
ExportImporter _exportImporter = new ExportImporter(); |
|
||||
var result = await _exportImporter.UploadExcelImport<ErrorBillImportDto>(files, _excelImportService); |
|
||||
var _ls = ObjectMapper.Map<List<ErrorBillImportDto>, List<ErrorBill>>(result); |
|
||||
var checkList = new List<ErrorExportDto>(); |
|
||||
foreach (var itm in _ls) |
|
||||
{ |
|
||||
var _first = await _repository.FirstOrDefaultAsync(p => p.BillNum == itm.BillNum && p.CustomerMaterialCode==itm.CustomerMaterialCode && p.WmsBillNum==itm.WmsBillNum); |
|
||||
if (_first == null) |
|
||||
{ |
|
||||
var entity = new ErrorBill( |
|
||||
GuidGenerator.Create(), |
|
||||
GuidGenerator.Create(), |
|
||||
itm.BillNum, |
|
||||
itm.MaterialCode, |
|
||||
itm.WmsBillNum, |
|
||||
itm.MaterialDesc, |
|
||||
itm.CustomerMaterialCode |
|
||||
); |
|
||||
await _repository.InsertAsync(entity); |
|
||||
} |
|
||||
} |
|
||||
return ApplicationConsts.SuccessStr; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 按ID获取唯一实体
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 返回实体全部属性
|
|
||||
/// </remarks>
|
|
||||
/// <param name="id">ID</param>
|
|
||||
/// <returns>实体DTO</returns>
|
|
||||
[HttpGet] |
|
||||
[Route("{id}")] |
|
||||
|
|
||||
virtual public async Task<ErrorBillDto> GetAsync(Guid id) |
|
||||
{ |
|
||||
var result = await GetFromCacheAsync(id); |
|
||||
var dto = ObjectMapper.Map<ErrorBill, ErrorBillDto>(result); |
|
||||
return dto; |
|
||||
} |
|
||||
|
|
||||
private async Task<ErrorBill> GetFromCacheAsync(Guid id) |
|
||||
{ |
|
||||
var result = await _repository.GetAsync(id); |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
private async Task<long> GetCountAsync(ErrorBillRequestDto input) |
|
||||
{ |
|
||||
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 根据筛选条件获取实体列表
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|
||||
/// </remarks>
|
|
||||
/// <param name="input">请求条件</param>
|
|
||||
/// <returns>实体DTO列表</returns>
|
|
||||
[HttpPost] |
|
||||
[Route("list")] |
|
||||
|
|
||||
virtual public async Task<PagedResultDto<ErrorBillDto>> GetListAsync(ErrorBillRequestDto input) |
|
||||
{ |
|
||||
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<ErrorBill>, List<ErrorBillDto>>(entities); |
|
||||
|
|
||||
return new PagedResultDto<ErrorBillDto>(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<ErrorBillDto>> GetAllAsync(Guid branchId) |
|
||||
{ |
|
||||
var entities = await _repository.GetAllAsync(branchId, true); |
|
||||
var dtos = ObjectMapper.Map<List<ErrorBill>, List<ErrorBillDto>>(entities); |
|
||||
return new ListResultDto<ErrorBillDto>(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<ErrorBill>(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) |
|
||||
{ |
|
||||
var _query = _repository.Where(p => ids.Contains(p.Id)); |
|
||||
int i = await _query.BatchDeleteAsync(); |
|
||||
|
|
||||
if (i == 0) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
return true; |
|
||||
} |
|
||||
[HttpPost] |
|
||||
[Route("Export")] |
|
||||
|
|
||||
virtual public async Task<string> ExportAsync(ErrorBillRequestDto input) |
|
||||
{ |
|
||||
string _fileName = string.Format("错误单据输出_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd")); |
|
||||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|
||||
0, true); |
|
||||
var dtoDetails = ObjectMapper.Map<List<ErrorBill>, List<ErrorBillExportDto>>(entities); |
|
||||
//声明导出容器
|
|
||||
ExportImporter _exportImporter = new ExportImporter(); |
|
||||
var result = await _exportImporter.ExcelExporter(dtoDetails); |
|
||||
result.ShouldNotBeNull(); |
|
||||
//保存导出文件到服务器存成二进制
|
|
||||
await _excelImportService.SaveBlobAsync( |
|
||||
new SaveExcelImportInputDto |
|
||||
{ |
|
||||
Name = _fileName, |
|
||||
Content = result |
|
||||
} |
|
||||
); |
|
||||
return _fileName; |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,338 +0,0 @@ |
|||||
using EFCore.BulkExtensions; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.Domain.Repositories; |
|
||||
using Volo.Abp.Domain.Services; |
|
||||
using Win.Sfs.Shared.DomainBase; |
|
||||
using Win.Sfs.Shared.Filter; |
|
||||
using Win.Sfs.Shared.RepositoryBase; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.Prices |
|
||||
{ |
|
||||
public class PriceListManager : DomainService |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 销售价格仓储
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository; |
|
||||
|
|
||||
private readonly ISettleAccountBranchEfCoreRepository<PriceList, Guid> _repository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> _versionRepository; |
|
||||
protected PriceListManager() { } |
|
||||
public PriceListManager( |
|
||||
INormalEfCoreRepository<PriceList, Guid> priceListRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<PriceList, Guid> repository, |
|
||||
ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> versionRepository |
|
||||
) |
|
||||
{ |
|
||||
_priceListRepository = priceListRepository; |
|
||||
_versionRepository = versionRepository; |
|
||||
_repository = repository; |
|
||||
} |
|
||||
public virtual async Task<PriceList> GetAsync(Guid id) |
|
||||
{ |
|
||||
return await _repository.GetAsync(id); |
|
||||
} |
|
||||
|
|
||||
public virtual List<PriceList> GetPriceList(string version) |
|
||||
{ |
|
||||
var entities = _repository.Where(p => p.Version == version); |
|
||||
return entities.ToList(); |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<List<PriceList>> GetListAsync( |
|
||||
|
|
||||
List<FilterCondition> filters, |
|
||||
string sorting = null, |
|
||||
int maxResultCount = int.MaxValue, |
|
||||
int skipCount = 0, |
|
||||
bool includeDetails = false, |
|
||||
CancellationToken cancellationToken = default) |
|
||||
{ |
|
||||
var entities = await _repository.GetListByFilterAsync(GuidGenerator.Create(), filters, sorting, maxResultCount, |
|
||||
skipCount); |
|
||||
return entities; |
|
||||
} |
|
||||
public virtual async Task<List<PriceListVersion>> GetVersionListAsync( |
|
||||
|
|
||||
List<FilterCondition> filters, |
|
||||
string sorting = null, |
|
||||
int maxResultCount = int.MaxValue, |
|
||||
int skipCount = 0, |
|
||||
bool includeDetails = false, |
|
||||
CancellationToken cancellationToken = default) |
|
||||
{ |
|
||||
var entities = await _versionRepository.GetListByFilterAsync(GuidGenerator.Create(), filters, sorting, maxResultCount, |
|
||||
skipCount); |
|
||||
return entities; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
public async Task<long> GetCountAsync(List<FilterCondition> p_filter |
|
||||
, Guid branchId) |
|
||||
{ |
|
||||
return await _repository.GetCountByFilterAsync(branchId, p_filter); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导入
|
|
||||
/// </summary>
|
|
||||
public virtual async Task<List<string>> ImportAsync(List<PriceList> entities, string version) |
|
||||
{ |
|
||||
List<string> _errorList = new List<string>(); |
|
||||
//写校验在这里
|
|
||||
|
|
||||
var lus = entities.Select(p => p.LU).ToList(); |
|
||||
var pricelist = await _priceListRepository.GetListAsync(p => lus.Contains(p.LU)); |
|
||||
|
|
||||
var update = from item1 in entities |
|
||||
join item2 in pricelist |
|
||||
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } |
|
||||
where item1.Price != item2.Price && item1.BeginTime == item2.BeginTime && item1.EndTime == item1.EndTime |
|
||||
select new PriceList(item2.Id, item2.LU, item1.Price, item2.BeginTime, item2.EndTime, item2.ClientCode, item2.Date, item2.ContractNo); |
|
||||
|
|
||||
//新日期
|
|
||||
var updateNewDate = from item1 in entities |
|
||||
join item2 in pricelist |
|
||||
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } |
|
||||
where item1.BeginTime != item2.BeginTime || item1.EndTime != item2.EndTime |
|
||||
select item1; |
|
||||
update = update.Concat(updateNewDate); |
|
||||
if (update.Any()) |
|
||||
{ |
|
||||
await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); |
|
||||
} |
|
||||
|
|
||||
//新零件号
|
|
||||
var addNewLu = from item1 in entities |
|
||||
join item2 in pricelist |
|
||||
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } |
|
||||
into temp |
|
||||
from item3 in temp.DefaultIfEmpty() |
|
||||
where item3 == null |
|
||||
select item1; |
|
||||
|
|
||||
if (addNewLu.Any()) |
|
||||
{ |
|
||||
await _repository.GetDbContext().BulkInsertAsync(addNewLu.ToList()); |
|
||||
} |
|
||||
|
|
||||
return _errorList; |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<PriceList> CreateAsync(PriceList input) |
|
||||
{ |
|
||||
var entity = new PriceList( |
|
||||
GuidGenerator.Create(), input.BeginTime, input.EndTime, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version,input.CustomerCode |
|
||||
); |
|
||||
|
|
||||
return await _repository.InsertAsync(entity); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task<PriceList> UpdateAsync(Guid id, PriceList input) |
|
||||
{ |
|
||||
var entity = await _repository.GetAsync(id); |
|
||||
entity.Set( |
|
||||
input.BeginTime, input.EndTime, input.Price, input.MaterialCode, input.Type,input.CustomerCode |
|
||||
); |
|
||||
return await _repository.UpdateAsync(entity); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task DeleteAsync(Guid id) |
|
||||
{ |
|
||||
await _repository.DeleteAsync(id); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task<bool> DeleteListAsync(List<Guid> ids) |
|
||||
{ |
|
||||
return await _repository.DeleteListAsync(ids); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task<long> GetTotalCountAsync(Guid branchId) |
|
||||
{ |
|
||||
return await _repository.GetCountAsync(branchId); |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<List<PriceList>> GetAllAsync(Guid branchId) |
|
||||
{ |
|
||||
var entities = await _repository.GetAllAsync(branchId); |
|
||||
|
|
||||
return entities; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public class PriceListManagerBJ : DomainService |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 备件价格仓储
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _priceListBJRepository; |
|
||||
|
|
||||
private readonly ISettleAccountBranchEfCoreRepository<PriceListBJ, Guid> _repository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersionBJ, Guid> _versionRepository; |
|
||||
protected PriceListManagerBJ() { } |
|
||||
public PriceListManagerBJ( |
|
||||
INormalEfCoreRepository<PriceListBJ, Guid> priceListBJRepository, |
|
||||
ISettleAccountBranchEfCoreRepository<PriceListBJ, Guid> repository, |
|
||||
ISettleAccountBranchEfCoreRepository<PriceListVersionBJ, Guid> versionRepository |
|
||||
) |
|
||||
{ |
|
||||
_priceListBJRepository = priceListBJRepository; |
|
||||
_versionRepository = versionRepository; |
|
||||
_repository = repository; |
|
||||
} |
|
||||
public virtual async Task<PriceListBJ> GetAsync(Guid id) |
|
||||
{ |
|
||||
return await _repository.GetAsync(id); |
|
||||
} |
|
||||
|
|
||||
public virtual List<PriceListBJ> GetPriceList(string version) |
|
||||
{ |
|
||||
var entities = _repository.Where(p => p.Version == version); |
|
||||
return entities.ToList(); |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<List<PriceListBJ>> GetListAsync( |
|
||||
|
|
||||
List<FilterCondition> filters, |
|
||||
string sorting = null, |
|
||||
int maxResultCount = int.MaxValue, |
|
||||
int skipCount = 0, |
|
||||
bool includeDetails = false, |
|
||||
CancellationToken cancellationToken = default) |
|
||||
{ |
|
||||
var entities = await _repository.GetListByFilterAsync(GuidGenerator.Create(), filters, sorting, maxResultCount, |
|
||||
skipCount); |
|
||||
return entities; |
|
||||
} |
|
||||
public virtual async Task<List<PriceListVersionBJ>> GetVersionListAsync( |
|
||||
|
|
||||
List<FilterCondition> filters, |
|
||||
string sorting = null, |
|
||||
int maxResultCount = int.MaxValue, |
|
||||
int skipCount = 0, |
|
||||
bool includeDetails = false, |
|
||||
CancellationToken cancellationToken = default) |
|
||||
{ |
|
||||
var entities = await _versionRepository.GetListByFilterAsync(GuidGenerator.Create(), filters, sorting, maxResultCount, |
|
||||
skipCount); |
|
||||
return entities; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
public async Task<long> GetCountAsync(List<FilterCondition> p_filter |
|
||||
, Guid branchId) |
|
||||
{ |
|
||||
return await _repository.GetCountByFilterAsync(branchId, p_filter); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 导入
|
|
||||
/// </summary>
|
|
||||
public virtual async Task<List<string>> ImportAsync(List<PriceListBJ> entities, string version) |
|
||||
{ |
|
||||
List<string> _errorList = new List<string>(); |
|
||||
//写校验在这里
|
|
||||
|
|
||||
var lus = entities.Select(p => p.LU).ToList(); |
|
||||
var pricelist = await _priceListBJRepository.GetListAsync(p => lus.Contains(p.LU)); |
|
||||
|
|
||||
var update = from item1 in entities |
|
||||
join item2 in pricelist |
|
||||
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } |
|
||||
where item1.Price != item2.Price && item1.BeginDate == item2.BeginDate && item1.EndDate == item1.EndDate |
|
||||
select new PriceListBJ(item2.Id, item2.LU, item1.Price, item2.BeginDate, item2.EndDate, item2.ClientCode, item2.Date, item2.ContractNo); |
|
||||
if (update.Any()) |
|
||||
{ |
|
||||
await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); |
|
||||
} |
|
||||
|
|
||||
//新零件号
|
|
||||
var addNewLu = from item1 in entities |
|
||||
join item2 in pricelist |
|
||||
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } |
|
||||
into temp |
|
||||
from item3 in temp.DefaultIfEmpty() |
|
||||
where item3 == null |
|
||||
select item1; |
|
||||
//新日期
|
|
||||
var addNewDate = from item1 in entities |
|
||||
join item2 in pricelist |
|
||||
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } |
|
||||
where item1.BeginDate != item2.BeginDate || item1.EndDate != item2.EndDate |
|
||||
select item1; |
|
||||
|
|
||||
var add = addNewLu.Concat(addNewDate); |
|
||||
if (add.Any()) |
|
||||
{ |
|
||||
await _repository.GetDbContext().BulkInsertAsync(add.ToList()); |
|
||||
} |
|
||||
|
|
||||
return _errorList; |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<PriceListBJ> CreateAsync(PriceListBJ input) |
|
||||
{ |
|
||||
var entity = new PriceListBJ( |
|
||||
GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type, input.ParentId, input.Version, input.CustomerCode |
|
||||
); |
|
||||
|
|
||||
return await _repository.InsertAsync(entity); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task<PriceListBJ> UpdateAsync(Guid id, PriceListBJ input) |
|
||||
{ |
|
||||
var entity = await _repository.GetAsync(id); |
|
||||
entity.Set( |
|
||||
input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type, input.CustomerCode |
|
||||
); |
|
||||
return await _repository.UpdateAsync(entity); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task DeleteAsync(Guid id) |
|
||||
{ |
|
||||
await _repository.DeleteAsync(id); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task<bool> DeleteListAsync(List<Guid> ids) |
|
||||
{ |
|
||||
return await _repository.DeleteListAsync(ids); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
public virtual async Task<long> GetTotalCountAsync(Guid branchId) |
|
||||
{ |
|
||||
return await _repository.GetCountAsync(branchId); |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<List<PriceListBJ>> GetAllAsync(Guid branchId) |
|
||||
{ |
|
||||
var entities = await _repository.GetAllAsync(branchId); |
|
||||
|
|
||||
return entities; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
|
File diff suppressed because it is too large
@ -0,0 +1,294 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Migrations |
||||
|
{ |
||||
|
public partial class _202308311 : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "BranchId", |
||||
|
table: "Set_PriceListBJ"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DeleterId", |
||||
|
table: "Set_PriceListBJ"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DeletionTime", |
||||
|
table: "Set_PriceListBJ"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "Enabled", |
||||
|
table: "Set_PriceListBJ"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsDeleted", |
||||
|
table: "Set_PriceListBJ"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "Remark", |
||||
|
table: "Set_PriceListBJ"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "BranchId", |
||||
|
table: "Set_PriceList"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DeleterId", |
||||
|
table: "Set_PriceList"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DeletionTime", |
||||
|
table: "Set_PriceList"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "Enabled", |
||||
|
table: "Set_PriceList"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsDeleted", |
||||
|
table: "Set_PriceList"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "Remark", |
||||
|
table: "Set_PriceList"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "d12f27a181f54465b338dd2401a08b6e"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "d9f3e1d0603c46479198f5baad678663"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "20cdc48f0766480d9c7a70b390ce0f9f"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "7da7c559aba84699ae1c6c6fa0a5dc59"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "20c50e67224d4595986559438cd975ad"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "366afac45e0e485d8f43e53346442ad2"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "662702ee66444ca08ef7190b6ad1e8f3"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "8e44067496fa43c085d2cf3bc2ed8779"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "7fd5fef49685400fb7254abbfd3754a1"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "42aed6aa66044a06ab92e8bf2d882cb2"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "c2cbd6a620fe4fd08d3f021939d31509"); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "BranchId", |
||||
|
table: "Set_PriceListBJ", |
||||
|
type: "uniqueidentifier", |
||||
|
nullable: false, |
||||
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "DeleterId", |
||||
|
table: "Set_PriceListBJ", |
||||
|
type: "uniqueidentifier", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<DateTime>( |
||||
|
name: "DeletionTime", |
||||
|
table: "Set_PriceListBJ", |
||||
|
type: "datetime2", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "Enabled", |
||||
|
table: "Set_PriceListBJ", |
||||
|
type: "bit", |
||||
|
nullable: false, |
||||
|
defaultValue: false); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsDeleted", |
||||
|
table: "Set_PriceListBJ", |
||||
|
type: "bit", |
||||
|
nullable: false, |
||||
|
defaultValue: false); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "Remark", |
||||
|
table: "Set_PriceListBJ", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "BranchId", |
||||
|
table: "Set_PriceList", |
||||
|
type: "uniqueidentifier", |
||||
|
nullable: false, |
||||
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "DeleterId", |
||||
|
table: "Set_PriceList", |
||||
|
type: "uniqueidentifier", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<DateTime>( |
||||
|
name: "DeletionTime", |
||||
|
table: "Set_PriceList", |
||||
|
type: "datetime2", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "Enabled", |
||||
|
table: "Set_PriceList", |
||||
|
type: "bit", |
||||
|
nullable: false, |
||||
|
defaultValue: false); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsDeleted", |
||||
|
table: "Set_PriceList", |
||||
|
type: "bit", |
||||
|
nullable: false, |
||||
|
defaultValue: false); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "Remark", |
||||
|
table: "Set_PriceList", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "89ee40808b37440e89bc3e3c9c0312a7"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "b9efd317f87e4288841ddcd9fef8f6a2"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "862d578df0fe406995bc827f9feaae60"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "dc1523b4145f4c60a1e9543aa36da361"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "76d675a5b6d644ef8ec3358006afcb36"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "658f74bf334f4a34a3fb10eaf00a840a"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "1f52b09ccce24e3fb30c5549b19b23e4"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "5ebb150f3f9e4ccd89d5fab0a6dde4e4"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "71311c84551343b099c049672a4c421f"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "681ede5c262642f1a02d7a67dbd83d1b"); |
||||
|
|
||||
|
migrationBuilder.UpdateData( |
||||
|
table: "Set_JobItem", |
||||
|
keyColumn: "Id", |
||||
|
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"), |
||||
|
column: "ConcurrencyStamp", |
||||
|
value: "eb2e56c9379e4cb0b0f0f5f0bc8d4292"); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue