Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
bf5ddeb0ba
  1. 140
      src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  2. 68
      src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListVersionDtoBase.cs
  3. 286
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  4. 86
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml
  5. 19
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  6. 74
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  7. 166
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs
  8. 25
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListVersion.cs
  9. 39
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

140
src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs

@ -151,6 +151,146 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public class PriceListBJDto : EntityDto<Guid>
{
/// <summary>
/// 版本
/// </summary>
[Display(Name = "版本")]
public string Version { set; get; }
/// <summary>
///开始时间
/// </summary>
[Display(Name = "开始时间")]
public DateTime BeginDate { get; set; }
/// <summary>
///结算时间
/// </summary>
[Display(Name = "结算时间")]
public DateTime EndDate { get; set; }
/// <summary>
///价格
/// </summary>
[Display(Name = "价格")]
public decimal Price { get; set; }
/// <summary>
///物料编号
/// </summary>
[Display(Name = "物料编号")]
public string MaterialCode { get; set; }
/// <summary>
///价格类型
/// </summary>
[Display(Name = "价格类型")]
public int Type { get; set; }
public Guid ParentId { set; get; }
[Display(Name = "客户")]
public string CustomerCode { get; set; }
}
public class PriceListBJExportDto
{
/// <summary>
/// 版本
/// </summary>
[Display(Name = "版本")]
[ExporterHeader(DisplayName = "版本")]
public string Version { set; get; }
[ImporterHeader(Name = "有效从")]
public DateTime BeginDate { get; set; }
/// <summary>
///结算时间
/// </summary>
[ImporterHeader(Name = "有效到")]
public DateTime EndDate { get; set; }
/// <summary>
///价格
/// </summary>
[ImporterHeader(Name = "*金额")]
public decimal Price { get; set; }
/// <summary>
///物料编号
/// </summary>
[ImporterHeader(Name = "*物料编码")]
public string MaterialCode { get; set; }
/// <summary>
///价格类型
/// </summary>
[ImporterHeader(Name = "*分销渠道")]
public int Type { get; set; }
[ImporterHeader(Name = "*客户")]
public string CustomerCode { get; set; }
}
public class PriceListBJImportDto
{
///// <summary>
///// 版本
///// </summary>
//[Display(Name = "版本")]
//public string Version { set; get; }
/// <summary>
///开始时间
/// </summary>
[ImporterHeader(Name = "有效从")]
public DateTime BeginDate { get; set; }
/// <summary>
///结算时间
/// </summary>
[ImporterHeader(Name = "有效到")]
public DateTime EndDate { get; set; }
/// <summary>
///价格
/// </summary>
[ImporterHeader(Name = "*金额")]
public decimal Price { get; set; }
/// <summary>
///物料编号
/// </summary>
[ImporterHeader(Name = "*物料编码")]
public string MaterialCode { get; set; }
/// <summary>
///价格类型
/// </summary>
[ImporterHeader(Name = "*分销渠道")]
public int Type { get; set; }
[ImporterHeader(Name = "*客户")]
public string CustomerCode { get; set; }
}
public class PriceListBJRequestDto : PagedAndSortedResultRequestDto
{
[Display(Name = "开始时间")]
public DateTime BeginDate { get; set; }
[Display(Name = "结算时间")]
public DateTime EndDate { get; set; }
[Display(Name = "价格")]
public decimal Price { get; set; }
[Display(Name = "物料编号")]
public string MaterialCode { get; set; }
[Display(Name = "价格类型")]
public int Type { get; set; }
public Guid ParentId { set; get; }
public int FileType { set; get; }
public string Version { set; get; }
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
}
}

68
src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListVersionDtoBase.cs

@ -62,5 +62,73 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public class PriceListVersionBJDto : EntityDto<Guid>
{
public string Year { get; set; }
public string Period { get; set; }
public string Version { get; set; }
public string Factory { get; set; }
}
public class PriceListVersionBJExportDto
{
public string Year { get; set; }
public string Period { get; set; }
public string Version { get; set; }
public string Factory { get; set; }
}
public class PriceListVersionBJImportDto
{
public string Year { get; set; }
public string Period { get; set; }
public string Version { get; set; }
public string Factory { get; set; }
}
public class PriceListVersionBJRequestDto : PagedAndSortedResultRequestDto
{
public string Year { get; set; }
public string Period { get; set; }
public string Version { get; set; }
public string Factory { get; set; }
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
}
}

286
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -0,0 +1,286 @@
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 Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.Prices
{
/// <summary>
/// 标准价格单-相关应用服务
/// </summary>
[Authorize(SettleAccountPermissions.PriceLists.Default)]
[Route("api/SettleAccount/PriceList")]
public class PriceListAppServiceBJ : ApplicationService
/*, IPriceListAppService*/
{
private readonly PriceListManagerBJ _mng;
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
public PriceListAppServiceBJ(
IExcelImportAppService excelImportService,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManagerBJ mng
)
{
_mapRepository = mapRepository;
_excelImportService = excelImportService;
_mng = mng;
}
/// <summary>
/// 按ID获取唯一实体
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
/// [Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PriceListBJDto> GetAsync(Guid id)
{
var result = await _mng.GetAsync(id); ;
var dto = ObjectMapper.Map<PriceListBJ, PriceListBJDto>(result);
return dto;
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("list")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PagedResultDto<PriceListBJDto>> GetListAsync(PriceListRequestDto input)
{
if (!string.IsNullOrEmpty(input.Version))
{
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version });
}
var entities = await _mng.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount,
input.SkipCount);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJDto>>(entities);
return new PagedResultDto<PriceListBJDto>(totalCount, dtos);
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("versionlist")]
// [Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PagedResultDto<PriceListVersionBJDto>> GetVersionListAsync(PriceListRequestDto input)
{
var entities = await _mng.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<PriceListVersionBJ>, List<PriceListVersionBJDto>>(entities);
return new PagedResultDto<PriceListVersionBJDto>(totalCount, dtos);
}
private async Task<long> GetCountAsync(PriceListRequestDto input)
{
return await _mng.GetCountAsync(input.Filters, GuidGenerator.Create());
}
/// <summary>
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{
return await _mng.GetCountAsync(new List<FilterCondition>(), branchId);
}
/// <summary>
/// 获取全部实体列表
/// </summary>
/// <returns>实体DTO列表</returns>
[HttpGet]
[Route("all")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<ListResultDto<PriceListBJDto>> GetAllAsync(Guid branchId)
{
var entities = await _mng.GetAllAsync(branchId);
var dtos = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJDto>>(entities);
return new ListResultDto<PriceListBJDto>(dtos);
}
/// <summary>
/// 批量导入实体列表
/// </summary>
/// <remarks>
/// 以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
/// </remarks>
/// <param name="entities">实体列表</param>
/// <returns>是否导入成功</returns>
[HttpPost]
[Route("ExcelImport-Map")]
[Authorize(SettleAccountPermissions.PriceLists.Create)]
virtual public async Task<string> ImportAsync([FromForm] IFormFileCollection files,string version)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService);
var list=result.Where(p => p.Type == 20).ToList();
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
var _ls = entityList.Where(p=>p.EndDate.ToString().Contains("9999")).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault());
foreach (var itm in _ls)
{
itm.Update(GuidGenerator.Create(),version);
}
await _mng.ImportAsync(_ls.ToList(), version);
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 修改实体
/// </summary>
/// <param name="id">ID</param>
/// <param name="input">修改实体DTO</param>
/// <returns>实体DTO</returns>
[HttpPut]
[Route("{id}")]
[Authorize(SettleAccountPermissions.PriceLists.Update)]
virtual public async Task<PriceListBJDto> UpdateAsync(Guid id, PriceListBJDto input)
{
var entity = new PriceListBJ(
);
var _ent = await _mng.UpdateAsync(id, entity);
var dto = ObjectMapper.Map<PriceListBJ, PriceListBJDto>(_ent);
return dto;
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
[Route("{id}")]
//[Authorize(SettleAccountPermissions.PriceLists.Delete)]
virtual public async Task DeleteAsync(Guid id)
{
await _mng.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary>
/// <param name="ids">ID列表</param>
/// <returns>是否执行成功</returns>
[HttpPost]
[Route("delete")]
//[Authorize(SettleAccountPermissions.PriceLists.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
return await _mng.DeleteListAsync(ids);
}
/// <summary>
/// 导出文件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("Export")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<string> ExportAsync(PriceListRequestDto input)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var entities = await _mng.GetListAsync(input.Filters, input.Sorting, int.MaxValue,
0, true);
var dtoDetails = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null;
switch (input.FileType)
{
case 0:
_fileName = string.Format("标准价格单_{0}.xlsx", 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;
}
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
}
}

86
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml

@ -1397,6 +1397,92 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="T:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ">
<summary>
标准价格单-相关应用服务
</summary>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.GetAsync(System.Guid)">
<summary>
按ID获取唯一实体
</summary>
<remarks>
返回实体全部属性
</remarks>
<param name="id">ID</param>
<returns>实体DTO</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.GetListAsync(Win.Sfs.SettleAccount.Entities.Prices.PriceListRequestDto)">
<summary>
根据筛选条件获取实体列表
</summary>
<remarks>
请求条件包括:筛选条件列表,排序条件,数据数量,页码
</remarks>
<param name="input">请求条件</param>
<returns>实体DTO列表</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.GetVersionListAsync(Win.Sfs.SettleAccount.Entities.Prices.PriceListRequestDto)">
<summary>
根据筛选条件获取实体列表
</summary>
<remarks>
请求条件包括:筛选条件列表,排序条件,数据数量,页码
</remarks>
<param name="input">请求条件</param>
<returns>实体DTO列表</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.GetTotalCountAsync(System.Guid)">
<summary>
获取实体总数
</summary>
<returns>实体总数</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.GetAllAsync(System.Guid)">
<summary>
获取全部实体列表
</summary>
<returns>实体DTO列表</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.ImportAsync(Microsoft.AspNetCore.Http.IFormFileCollection,System.String)">
<summary>
批量导入实体列表
</summary>
<remarks>
以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
</remarks>
<param name="entities">实体列表</param>
<returns>是否导入成功</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.UpdateAsync(System.Guid,Win.Sfs.SettleAccount.Entities.Prices.PriceListBJDto)">
<summary>
修改实体
</summary>
<param name="id">ID</param>
<param name="input">修改实体DTO</param>
<returns>实体DTO</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.DeleteAsync(System.Guid)">
<summary>
删除实体
</summary>
<param name="id">ID</param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.DeleteListAsync(System.Collections.Generic.List{System.Guid})">
<summary>
按IDs删除实体列表
</summary>
<param name="ids">ID列表</param>
<returns>是否执行成功</returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Entities.Prices.PriceListAppServiceBJ.ExportAsync(Win.Sfs.SettleAccount.Entities.Prices.PriceListRequestDto)">
<summary>
导出文件
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:Win.Sfs.SettleAccount.Entities.SecMatch.SecMatchAppService">
<summary>
总成与结算件关系

19
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -197,6 +197,10 @@ namespace Win.Sfs.SettleAccount
CreateMapSettlementPakAndSparePartsVersion();
CreateMapSecMatchBaseDto();
CreateMapPriceListBJVersion();
CreateMapPriceListBJ();
#endregion
@ -596,6 +600,14 @@ namespace Win.Sfs.SettleAccount
CreateMap<PriceListVersion, PriceListVersionImportDto>().ReverseMap();
CreateMap<PriceListVersion, PriceListVersionExportDto>().ReverseMap();
}
private void CreateMapPriceListBJVersion()
{
CreateMap<PriceListVersionBJ, PriceListVersionBJDto>().ReverseMap();
CreateMap<PriceListVersionBJ, PriceListVersionBJRequestDto>().ReverseMap();
CreateMap<PriceListVersionBJ, PriceListVersionBJImportDto>().ReverseMap();
CreateMap<PriceListVersionBJ, PriceListVersionBJExportDto>().ReverseMap();
}
@ -608,7 +620,14 @@ namespace Win.Sfs.SettleAccount
CreateMap<PriceList, PriceListExportDto>().ReverseMap();
}
private void CreateMapPriceListBJ()
{
CreateMap<PriceListBJ, PriceListBJDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJRequestDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJImportDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJExportDto>().ReverseMap();
}
private void CreateMapInvoiceSettledDiff()

74
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs

@ -90,4 +90,78 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public Guid ParentId { set; get; }
}
public class PriceListBJ : FullAuditedAggregateRootBase<Guid>
{
public PriceListBJ()
{ }
public PriceListBJ(Guid Id, DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type, Guid parentId, string version, string customerCode) : base(Id)
{
BeginDate = beginDate;
EndDate = endDate;
Price = price;
MaterialCode = materialCode;
Type = type;
ParentId = parentId;
Version = version;
CustomerCode = customerCode;
}
public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type, string customerCode)
{
BeginDate = beginDate;
EndDate = endDate;
Price = price;
MaterialCode = materialCode;
Type = type;
CustomerCode = customerCode;
}
public void Update(Guid id, string version)
{
Id = id;
Version = version;
}
[Display(Name = "客户")]
public string CustomerCode { get; set; }
/// <summary>
///版本
/// </summary>
[Display(Name = "版本")]
public string Version { set; get; }
/// <summary>
/// 开始时间
/// </summary>
[Display(Name = "开始时间")]
public DateTime BeginDate { set; get; }
/// <summary>
/// 结束时间
/// </summary>
[Display(Name = "结算时间")]
public DateTime EndDate { set; get; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
public Decimal Price { set; get; }
/// <summary>
/// 物料编号
/// </summary>
[Display(Name = "物料编号")]
public string MaterialCode { set; get; }
/// <summary>
/// 类型
/// </summary>
[Display(Name = "价格类型")]
public int Type { set; get; }
/// <summary>
/// 父Id
/// </summary>
[Display(Name = "父Id")]
public Guid ParentId { set; get; }
}
}

166
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

@ -171,5 +171,171 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
return entities;
}
}
public class PriceListManagerBJ : DomainService
{
private readonly ISettleAccountBranchEfCoreRepository<PriceListBJ, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersionBJ, Guid> _versionRepository;
protected PriceListManagerBJ() { }
public PriceListManagerBJ(
ISettleAccountBranchEfCoreRepository<PriceListBJ, Guid> repository,
ISettleAccountBranchEfCoreRepository<PriceListVersionBJ, Guid> versionRepository
)
{
_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);
}
public virtual async Task<List<string>> ImportAsync(List<PriceListBJ> entities, string version)
{
List<string> _errorList = new List<string>();
//写校验在这里
var pricelist = GetPriceList(version);
//var LeftJoin = from emp in ListOfEmployees
// join dept in ListOfDepartment
// on emp.DeptID equals dept.ID into JoinedEmpDept
// from dept in JoinedEmpDept.DefaultIfEmpty()
var update = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.MaterialCode } equals new { itm2.Type, itm2.MaterialCode }
where itm1.Price != itm2.Price
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode);
if (update.Count() > 0)
{
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
}
else
{
var add = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.MaterialCode }
equals new { itm2.Type, itm2.MaterialCode }
into temp
from itm3 in temp.DefaultIfEmpty()
where itm3 == null
select itm1;
await _repository.GetDbContext().BulkInsertAsync<PriceListBJ>(add.ToList());
}
var _first = _versionRepository.FirstOrDefault(p => p.Version == version);
if (_first == null)
{
List<PriceListVersionBJ> _versionList = new List<PriceListVersionBJ>() { new PriceListVersionBJ(GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version) };
await _versionRepository.GetDbContext().BulkInsertAsync(_versionList);
}
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;
}
}
}

25
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListVersion.cs

@ -31,6 +31,31 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
Version = version;
}
}
public class PriceListVersionBJ : FullAuditedAggregateRootBase<Guid>
{
public PriceListVersionBJ()
{ }
public string Year { get; private set; }
/// <summary>
/// 期间
/// </summary>
public string Period { get; private set; }
/// <summary>
/// 版本号
/// </summary>
public string Version { get; set; }
public string Factory { private set; get; }
public PriceListVersionBJ(Guid id, string year, string period, string version) : base(id)
{
Year = year;
Period = period;
Version = version;
}
}
}

39
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -354,6 +354,8 @@ namespace Win.Sfs.SettleAccount
//一汽轿车出库
builder.ConfigureWmsHQCarOutPutVersion(options);
builder.ConfigureWmsHQCarPutDetial(options);
builder.ConfigurePriceListVersionBJ(options);
builder.ConfigurePriceListBJ(options);
#endregion
@ -1608,6 +1610,43 @@ namespace Win.Sfs.SettleAccount
});
}
private static void ConfigurePriceListBJ(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<PriceList>(b =>
{
b.ToTable($"{options.TablePrefix}_PriceListBJ", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.MaterialCode).HasMaxLength(50);
b.Property(x => x.CustomerCode).HasMaxLength(50);
});
}
private static void ConfigurePriceListVersionBJ(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<PriceListVersion>(b =>
{
b.ToTable($"{options.TablePrefix}_PriceListVersionBJ", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.Year).HasMaxLength(50);
b.Property(x => x.Period).HasMaxLength(50);
b.Property(x => x.Version).HasMaxLength(50);
b.Property(x => x.Factory).HasMaxLength(50);
});
}
//private static void ConfigureMaterialRelationshipVersion(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
//{

Loading…
Cancel
Save