Browse Source

结算主表添加业务类型字段

master
mahao 1 year ago
parent
commit
b7c096dec6
  1. 5
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs
  2. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Attributes/ExcelImporterHeadDescAttribute.cs
  3. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  4. 62
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  5. 84
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
  6. 246
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  7. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  8. 485
      code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs
  9. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  10. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SA.cs
  11. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/MaterialRelationships/MaterialRelationship.cs
  12. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  13. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs
  14. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBusinessType.cs
  15. 4038
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719022720_20230719-2.Designer.cs
  16. 24
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719022720_20230719-2.cs
  17. 3
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

5
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs

@ -1,5 +1,6 @@
using System;
using System;
using System.IO;
using Magicodes.ExporterAndImporter.Excel.Utility.TemplateExport;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -39,10 +40,10 @@ namespace Win.Sfs.SettleAccount
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo.Async(c => c.Console())
.CreateLogger();
try
{
Log.Information("Starting web host.");

21
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Attributes/ExcelImporterHeadDescAttribute.cs

@ -0,0 +1,21 @@
using System;
namespace Win.Sfs.SettleAccount.Attributes
{
/// <summary>
/// Excel导入头部描述
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ExcelImporterHeadDescAttribute : Attribute
{
/// <summary>
/// 行数
/// </summary>
public int Row { get; set; }
/// <summary>
/// 列数
/// </summary>
public int Cell { get; set; }
}
}

21
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core;
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
@ -32,7 +32,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
/// 导入
/// </summary>
public class ZGJ_PUB_SA_DETAIL_IMPORT_DTO
public class PUB_SA_DETAIL_IMPORT_DTO
{
///// <summary>
///// 期间
@ -103,9 +103,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
}
/// <summary>
/// 导出
/// 结算明细导出请求
/// </summary>
public class PUB_SA_EXPORT_DTO
public class PUB_SA_DETAIL_EXPORT_REQUEST_DTO
{
/// <summary>
/// 结算单号
/// </summary>
[Display(Name = "结算单号")]
[Required(ErrorMessage = "{0}不能为空")]
public string BillNum { set; get; }
}
/// <summary>
/// 结算明细导出
/// </summary>
public class PUB_SA_DETAIL_EXPORT_DTO
{
}

62
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs

@ -1,8 +1,10 @@
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
using Win.Sfs.SettleAccount.Attributes;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.Shared.Filter;
@ -87,14 +89,43 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[Display(Name = "客户编码")]
[ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { get; set; }
/// <summary>
/// 合同签订时间
/// </summary>
[Display(Name = "合同签订时间")]
[ExporterHeader(DisplayName = "合同签订时间")]
public DateTime Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
[Display(Name = "合同号")]
[ExporterHeader(DisplayName = "合同号")]
public string ContractNo { get; set; }
}
/// <summary>
/// 销售价格导入
/// </summary>
[ImportProject(Name = SettleAccountModuleName.PriceList)]
[Importer(HeaderRowIndex = 22)]
public class PriceListImportDto
{
/// <summary>
/// 合同签订时间
/// </summary>
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 1, Cell = 1)]
public string Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 2, Cell = 1)]
public string ContractNo { get; set; }
///// <summary>
///// ItemNo
///// </summary>
@ -265,8 +296,6 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
}
public class PriceListRequestDto : PagedAndSortedResultRequestDto
{
[Display(Name = "开始时间")]
public DateTime BeginDate { get; set; }
[Display(Name = "结算时间")]
@ -331,8 +360,22 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { get; set; }
/// <summary>
/// 合同签订时间
/// </summary>
[Display(Name = "合同签订时间")]
[ExporterHeader(DisplayName = "合同签订时间")]
public DateTime Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
[Display(Name = "合同号")]
[ExporterHeader(DisplayName = "合同号")]
public string ContractNo { get; set; }
}
[Importer(HeaderRowIndex = 22)]
public class PriceListBJImportDto
{
/// <summary>
@ -353,6 +396,19 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[ImporterHeader(Name = "客户编码")]
public string ClientCode { get; set; }
/// <summary>
/// 合同签订时间
/// </summary>
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 1, Cell = 1)]
public string Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 2, Cell = 1)]
public string ContractNo { get; set; }
}
public class PriceListBJRequestDto : RequestInputBase

84
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Caching;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ;
/// <summary>
/// PUB结算明细
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL>
{
/// <summary>
/// PUB结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository;
/// <summary>
/// PUB结算仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA, Guid> _pubSaRepository;
/// <summary>
/// 构造
/// </summary>
public PUB_SA_DETAIL_SERVICE(INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
INormalEfCoreRepository<PUB_SA, Guid> pubSaRepository,
IDistributedCache<PUB_SA_DETAIL> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_pubSaDetailRepository = pubSaDetailRepository;
_pubSaRepository = pubSaRepository;
}
#region 导出
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> ExportAsync(PUB_SA_DETAIL_EXPORT_REQUEST_DTO input)
{
var pubSaEntity = await _pubSaRepository.FirstOrDefaultAsync(t=>t.BillNum == input.BillNum);
if (pubSaEntity == null)
{
throw new UserFriendlyException($"导出失败,结算单号不存在!", "400");
}
var businessType = pubSaEntity.BusinessType;
string fileName = $"{businessType.GetDisplayName()}结算数据_{Guid.NewGuid()}.xlsx";
List<FilterCondition> filters = new List<FilterCondition>();
filters.Add(new FilterCondition("BillNum", input.BillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
var entities = await _pubSaDetailRepository.GetListByFilterAsync(filters);
var dtos = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_SA_DETAIL_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
}

246
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -1,16 +1,15 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.Util;
using NUglify.Helpers;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Extensions;
using NUglify.Helpers;
using SettleAccount.Domain.BQ;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
@ -24,6 +23,7 @@ using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -104,32 +104,151 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
#region 直供件
#region 导入
/// <summary>
/// 导入(直供件)
/// </summary>
[HttpPost]
public async Task<string> ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType)
{
return await ImportAsync(files, businessType);
}
///// <summary>
///// 导入(直供件)
///// </summary>
//[HttpPost]
//public async Task<string> ZhiGongJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.ZhiGongJian);
//}
///// <summary>
///// 导入(备件)
///// </summary>
//[HttpPost]
//public async Task<string> BeiJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.BeiJian);
//}
///// <summary>
///// 导入(备件)
///// </summary>
//[HttpPost]
//public async Task<string> BeiJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.BeiJian);
//}
///// <summary>
///// 导入(备件)
///// </summary>
//[HttpPost]
//public async Task<string> BeiJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.BeiJian);
//}
#endregion
#endregion
#region 导入、导出
#endregion
#region CURD
/// <summary>
/// 导入
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<PUB_SA_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_DTO>>(entities);
return new PagedResultDto<PUB_SA_DTO>(totalCount, dtos);
}
/// <summary>
/// 删除
/// </summary>
[HttpPost]
public async Task<string> ZGJImportAsync([FromForm] IFormFileCollection files)
public async Task DeleteAsync(Guid id)
{
//结算主表
PUB_SA pubSaDelEntity;
//结算明细
List<PUB_SA_DETAIL> pubSaDetailDelEntitys;
//可结算主表
List<PUB_CAN_SA> pubCanSaDelEntitys;
//可结算明细
List<PUB_CAN_SA_DETAIL> pubCanSaDetailDelEntitys;
//不可结算
List<PUB_NOT_SA_DETAIL> pubNotSaDetailDelEntitys;
pubSaDelEntity = await _repository.FindAsync(id);
if (pubSaDelEntity == null) return;
//结算单据
string pubSaBillNum = pubSaDelEntity.BillNum;
pubCanSaDelEntitys = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum);
//验证可结算主表状态
if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.))
{
throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400");
}
pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum);
pubCanSaDetailDelEntitys = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum);
pubNotSaDetailDelEntitys = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum);
//删除
await _repository.DeleteAsync(pubSaDelEntity);
if (pubSaDetailDelEntitys != null)
{
await _pubSaDetailRepository.DeleteManyAsync(pubSaDetailDelEntitys);
}
if (pubCanSaDelEntitys != null)
{
await _pubCanSaRepository.DeleteManyAsync(pubCanSaDelEntitys);
}
if (pubCanSaDetailDelEntitys != null)
{
await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetailDelEntitys);
}
if (pubNotSaDetailDelEntitys != null)
{
await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetailDelEntitys);
}
}
#endregion
#region 私有方法
/// <summary>
/// 导入
/// </summary>
private async Task<string> ImportAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType)
{
//数据校验
var checkList = new List<ErrorExportDto>();
//类型(直供件)
var businessType = EnumBusinessType.ZhiGongJian;
//结算单号
var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
//结算主表
var pubSa = new PUB_SA()
{
BillNum = pubSaBillNum,
State = "1"
State = "1",
BusinessType = businessType
};
//结算明细
var pubSaDetails = new List<PUB_SA_DETAIL>();
//可算单号
//可算单号
var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C");
//可算主表
//可算主表
var pubCanSa = new PUB_CAN_SA()
{
BillNum = pubCanSaBillNum,
@ -147,8 +266,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
#region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var importPubSaDetails = ObjectMapper.Map<List<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(result);
var result = await _exportImporter.UploadExcelImport<PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var importPubSaDetails = ObjectMapper.Map<List<PUB_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(result);
//结算分组号
var pubSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct();
@ -178,9 +297,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
importPubSaDetails.ForEach(importPubSaDetail =>
{
List<string> luList = importPubSaDetail.LU.Split(" ").ToList();
importPubSaDetail.LU = luList[0].Replace(" ", "");
if (luList.Count > 1)
{
importPubSaDetail.LU = luList[0].Replace(" ", "");
luList.RemoveAt(0);
var luAssemble = luList.Select(t => t.Replace(" ", ""));
importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
@ -209,7 +328,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t);
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType.ToString());
materialRelationships.Add(materialRelationship);
});
#endregion
@ -263,95 +382,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"HBPO的EDI数据_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
#region CURD
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<PUB_SA_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_DTO>>(entities);
return new PagedResultDto<PUB_SA_DTO>(totalCount, dtos);
}
/// <summary>
/// 删除
/// </summary>
[HttpPost]
public async Task DeleteAsync(Guid id)
{
//结算主表
PUB_SA pubSaDelEntity;
//结算明细
List<PUB_SA_DETAIL> pubSaDetailDelEntitys;
//可结算主表
List<PUB_CAN_SA> pubCanSaDelEntitys;
//可结算明细
List<PUB_CAN_SA_DETAIL> pubCanSaDetailDelEntitys;
//不可结算
List<PUB_NOT_SA_DETAIL> pubNotSaDetailDelEntitys;
pubSaDelEntity = await _repository.FindAsync(id);
if (pubSaDelEntity == null) return;
//结算单据
string pubSaBillNum = pubSaDelEntity.BillNum;
pubCanSaDelEntitys = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum);
//验证可结算主表状态
if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.))
{
throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400");
}
pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum);
pubCanSaDetailDelEntitys = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum);
pubNotSaDetailDelEntitys = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum);
//删除
await _repository.DeleteAsync(pubSaDelEntity);
if (pubSaDetailDelEntitys != null)
{
await _pubSaDetailRepository.DeleteManyAsync(pubSaDetailDelEntitys);
}
if (pubCanSaDelEntitys != null)
{
await _pubCanSaRepository.DeleteManyAsync(pubCanSaDelEntitys);
}
if (pubCanSaDetailDelEntitys != null)
{
await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetailDelEntitys);
}
if (pubNotSaDetailDelEntitys != null)
{
await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetailDelEntitys);
}
}
#endregion
}
}

18
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -1,9 +1,11 @@
using Magicodes.ExporterAndImporter.Core;
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 NPOI.SS.UserModel;
using NPOI.SS.Util;
using Shouldly;
using System;
using System.Collections.Generic;
@ -55,6 +57,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
// return new Microsoft.AspNetCore.Mvc.OkResult();
//}
private string GetOtherSheetStringValue(IWorkbook wk, String sheetName, String location)
{
ISheet sheet = wk.GetSheet(sheetName);
var cr = new CellReference(location);
var row = sheet.GetRow(cr.Row);
var cell = row.GetCell(cr.Col);
string result = cell.StringCellValue;
return result;
}
/// <summary>
/// 导入
/// </summary>
@ -63,7 +76,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListImportDto>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>();
_checkls.Add("1040");
@ -75,7 +88,6 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var _ls = entityList.OrderByDescending(p => p.BeginTime).GroupBy(p => new { p.LU, p.ClientCode }).Select(p => p.FirstOrDefault());
foreach (var itm in _ls)
{
itm.Update(GuidGenerator.Create(), version);

485
code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

@ -30,6 +30,12 @@ using Win.Sfs.SettleAccount.Entities.Errors;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.Entities.ImportMap;
using Magicodes.ExporterAndImporter.Excel.Utility;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Core.Filters;
using OfficeOpenXml.Attributes;
using Win.Sfs.SettleAccount.Attributes;
using Magicodes.ExporterAndImporter.Core.Extension;
namespace Win.Sfs.SettleAccount.ExcelImporter
{
@ -38,7 +44,7 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
private readonly IExporter _csvExporter= new Magicodes.ExporterAndImporter.Csv.CsvExporter();//导出CSV
private readonly IExporter _csvExporter = new Magicodes.ExporterAndImporter.Csv.CsvExporter();//导出CSV
private readonly IExcelImporter _importer = new Magicodes.ExporterAndImporter.Excel.ExcelImporter();//导入Excel
private readonly IExporter _exporter = new ExcelExporter();//导出Excel
@ -50,7 +56,7 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
ExcelImportResult returnResult = new ExcelImportResult();
List<string> _errorList = new List<string>();
var importAttrib= type.GetCustomAttribute<ImportProjectAttribute>();
var importAttrib = type.GetCustomAttribute<ImportProjectAttribute>();
if (importAttrib != null)
{
@ -98,18 +104,18 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
{
if (import.Exception.Message.ToString() == "导入文件不存在!")
{
throw new BusinessException("8989","文件容器配置的路径错误,请检查!");
throw new BusinessException("8989", "文件容器配置的路径错误,请检查!");
}
else
{
throw new BusinessException("8989",import.Exception.Message.ToString());
throw new BusinessException("8989", import.Exception.Message.ToString());
}
}
else
{
if (import.TemplateErrors.Count > 0)
{
throw new BusinessException("8989","模板错误!当前模板中字段不匹配!!请正确上传模板数据!导入不对的列名:"+import.TemplateErrors.FirstOrDefault().RequireColumnName);
throw new BusinessException("8989", "模板错误!当前模板中字段不匹配!!请正确上传模板数据!导入不对的列名:" + import.TemplateErrors.FirstOrDefault().RequireColumnName);
}
import.ShouldNotBeNull();
if (import.Exception != null)
@ -125,10 +131,10 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
string error = string.Empty;
foreach (var dic in itm.FieldErrors)
{
error += (dic.Key+ dic.Value+"|");
error += (dic.Key + dic.Value + "|");
}
_errorList.Add(string.Format("第{0}行{1}", itm.RowIndex.ToString(),error));
_errorList.Add(string.Format("第{0}行{1}", itm.RowIndex.ToString(), error));
}
//自动保存“{ 目标文件名称}_.xlsx”的标注文件到目标位置
//导入的数据有错误,比如重复列,必填项为空等(不包含警告),主要看DTO的设置
@ -150,142 +156,277 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
}
if (_errorList.Count > 0)
{
throw new BusinessException("8989",string.Join("\r\n", _errorList));
throw new BusinessException("8989", string.Join("\r\n", _errorList));
}
return ImportList;//返回客户端
}
// public virtual async Task<List<T>> UploadExcelImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService, ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> repository=null)
//where T : class, new()
// {
// Type type = typeof(T);
// var ImportList = new List<T>();
// ExcelImportResult returnResult = new ExcelImportResult();
// List<string> _errorList = new List<string>();
// //if (repository != null)
// //{
// // var importAttrib = type.GetCustomAttribute<ImportProjectAttribute>();
// // if (importAttrib != null)
// // {
// // var _columnList = repository.Where(p => p.ProjectName == importAttrib.Name);
// // if (_columnList.Count() > 0)
// // {
// // foreach (var itm in type.GetProperties())
// // {
// // var attrib = itm.GetCustomAttribute<ImporterHeaderAttribute>();
// // if (attrib != null)
// // {
// // var newColumn = _columnList.FirstOrDefault(p => p.OldColumnName == attrib.Name);
// // if (newColumn != null && !string.IsNullOrEmpty(newColumn.NewColumnName))
// // {
// // attrib.Name = !string.IsNullOrEmpty(newColumn.NewColumnName)? newColumn.NewColumnName:attrib.Name;
// // }
// // }
// // }
// // }
// // }
// //}
// foreach (var file in files)
// {
// if (file == null)
// {
// throw new BusinessException("上传附件不能为空!");
// }
// string FileOriginName = file.FileName;
// string getFileName = Path.GetFileName(FileOriginName);//获取附件名称
// using (var memoryStream = new MemoryStream())
// {
// //保存成物理文件
// await file.CopyToAsync(memoryStream);
// await _excelImportService.SaveBlobAsync(
// new SaveExcelImportInputDto
// {
// Name = Path.GetFileName(FileOriginName),
// Content = memoryStream.ToArray()
// }
// );
// }
// //读取文件保存的根目录
// string fileSaveRootDir = ConfigDirHelper.GetAppSetting("App", "FileRootPath");
// //读取WMS文件保存的模块的根目录
// string fileSaveDir = ConfigDirHelper.GetAppSetting("App", "WMSFiles");
// //文件保存的相对文件夹(保存到wwwroot目录下)
// string absoluteFileDir = fileSaveRootDir + @"\" + fileSaveDir;
// //文件保存的路径(应用的工作目录+文件夹相对路径);
// string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container" + absoluteFileDir;
// var filePath = fileSavePath + getFileName;//获取到导入的excel
// var import = await _importer.Import<T>(filePath);
// if (import.Exception != null)
// {
// if (import.Exception.Message.ToString() == "导入文件不存在!")
// {
// throw new BusinessException("8989", "文件容器配置的路径错误,请检查!");
// }
// else
// {
// throw new BusinessException("8989", import.Exception.Message.ToString());
// }
// }
// else
// {
// if (import.TemplateErrors.Count > 0)
// {
// throw new BusinessException("8989", "模板错误!当前模板中字段不匹配!!请正确上传模板数据!");
// }
// import.ShouldNotBeNull();
// if (import.Exception != null)
// {
// //导入的数据有异常
// throw new BusinessException(import.Exception.ToString());
// }
// returnResult.totalSize = import.Data.Count;
// if (import.RowErrors.Count > 0)
// {
// foreach (var itm in import.RowErrors)
// {
// string error = string.Empty;
// foreach (var dic in itm.FieldErrors)
// {
// error += (dic.Key + dic.Value + "|");
// }
// _errorList.Add(string.Format("第{0}行{1}", itm.RowIndex.ToString(), error));
// }
// //自动保存“{ 目标文件名称}_.xlsx”的标注文件到目标位置
// //导入的数据有错误,比如重复列,必填项为空等(不包含警告),主要看DTO的设置
// import.HasError.ShouldBeTrue();//标识导入的数据有错误
// returnResult.errSize = import.RowErrors.Count;
// returnResult.errTemplate = Path.GetFileNameWithoutExtension(FileOriginName) + "_.xlsx";//返回错误模板名称作为参数
// returnResult.errMessage = "RowErrors";
// }
// else
// {
// import.HasError.ShouldBeFalse();//标识导入的数据没有错误了
// if (import.Data.Count > 0)
// {
// ImportList.AddRange(import.Data.ToList());
// }
// returnResult.errMessage = "SccessData";
// }
// }
// }
// if (_errorList.Count > 0)
// {
// throw new BusinessException("8989", string.Join("\r\n", _errorList));
// }
// return ImportList;//返回客户端
// }
public virtual async Task<List<T>> UploadExcelImportByHeadDesc<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService)
where T : class, new()
{
Type type = typeof(T);
var ImportList = new List<T>();
ExcelImportResult returnResult = new ExcelImportResult();
List<string> _errorList = new List<string>();
foreach (var file in files)
{
if (file == null)
{
throw new BusinessException("上传附件不能为空!");
}
string FileOriginName = file.FileName;
string getFileName = Path.GetFileName(FileOriginName);//获取附件名称
using (var memoryStream = new MemoryStream())
{
//保存成物理文件
await file.CopyToAsync(memoryStream);
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = Path.GetFileName(FileOriginName),
Content = memoryStream.ToArray()
}
);
}
//读取文件保存的根目录
string fileSaveRootDir = ConfigDirHelper.GetAppSetting("App", "FileRootPath");
//读取WMS文件保存的模块的根目录
string fileSaveDir = ConfigDirHelper.GetAppSetting("App", "WMSFiles");
//文件保存的相对文件夹(保存到wwwroot目录下)
string absoluteFileDir = fileSaveRootDir + @"\" + fileSaveDir;
//文件保存的路径(应用的工作目录+文件夹相对路径);
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container" + absoluteFileDir;
var filePath = fileSavePath + getFileName;//获取到导入的excel
//var import = await _importer.Import<T>(filePath);
var import = new ImportResult<T>();
using (var importer = new ImportHelper<T>(filePath, null))
{
import = await importer.Import(null);
Stream Stream = new FileStream(filePath, FileMode.Open);
using (Stream)
{
IWorkbook wk = new XSSFWorkbook(Stream);
//读取当前表数据
ISheet sheet = wk.GetSheetAt(0);
var excelImporterHeadDescAttributeProperties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty)
.Where(o => o.GetCustomAttribute<ExcelImporterHeadDescAttribute>(true) != null);
foreach (var item in excelImporterHeadDescAttributeProperties)
{
string propertyName = item.Name;
var excelImporterHeadDesc = item.GetCustomAttribute<ExcelImporterHeadDescAttribute>();
var row = excelImporterHeadDesc.Row;
var cell = excelImporterHeadDesc.Cell;
var value = sheet.GetRow(row).GetCell(cell).ToString();
if (import.Data != null)
{
foreach (var item2 in import.Data)
{
item2.GetType().GetProperty(propertyName).SetValue(item2, value);
}
}
}
}
}
if (import.Exception != null)
{
if (import.Exception.Message.ToString() == "导入文件不存在!")
{
throw new BusinessException("8989", "文件容器配置的路径错误,请检查!");
}
else
{
throw new BusinessException("8989", import.Exception.Message.ToString());
}
}
else
{
if (import.TemplateErrors.Count > 0)
{
throw new BusinessException("8989", "模板错误!当前模板中字段不匹配!!请正确上传模板数据!导入不对的列名:" + import.TemplateErrors.FirstOrDefault().RequireColumnName);
}
import.ShouldNotBeNull();
if (import.Exception != null)
{
//导入的数据有异常
throw new BusinessException(import.Exception.ToString());
}
returnResult.totalSize = import.Data.Count;
if (import.RowErrors.Count > 0)
{
foreach (var itm in import.RowErrors)
{
string error = string.Empty;
foreach (var dic in itm.FieldErrors)
{
error += (dic.Key + dic.Value + "|");
}
_errorList.Add(string.Format("第{0}行{1}", itm.RowIndex.ToString(), error));
}
//自动保存“{ 目标文件名称}_.xlsx”的标注文件到目标位置
//导入的数据有错误,比如重复列,必填项为空等(不包含警告),主要看DTO的设置
import.HasError.ShouldBeTrue();//标识导入的数据有错误
returnResult.errSize = import.RowErrors.Count;
returnResult.errTemplate = Path.GetFileNameWithoutExtension(FileOriginName) + "_.xlsx";//返回错误模板名称作为参数
returnResult.errMessage = "RowErrors";
}
else
{
import.HasError.ShouldBeFalse();//标识导入的数据没有错误了
if (import.Data.Count > 0)
{
ImportList.AddRange(import.Data.ToList());
}
returnResult.errMessage = "SccessData";
}
}
}
if (_errorList.Count > 0)
{
throw new BusinessException("8989", string.Join("\r\n", _errorList));
}
return ImportList;//返回客户端
}
// public virtual async Task<List<T>> UploadExcelImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService, ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> repository=null)
//where T : class, new()
// {
// Type type = typeof(T);
// var ImportList = new List<T>();
// ExcelImportResult returnResult = new ExcelImportResult();
// List<string> _errorList = new List<string>();
// //if (repository != null)
// //{
// // var importAttrib = type.GetCustomAttribute<ImportProjectAttribute>();
// // if (importAttrib != null)
// // {
// // var _columnList = repository.Where(p => p.ProjectName == importAttrib.Name);
// // if (_columnList.Count() > 0)
// // {
// // foreach (var itm in type.GetProperties())
// // {
// // var attrib = itm.GetCustomAttribute<ImporterHeaderAttribute>();
// // if (attrib != null)
// // {
// // var newColumn = _columnList.FirstOrDefault(p => p.OldColumnName == attrib.Name);
// // if (newColumn != null && !string.IsNullOrEmpty(newColumn.NewColumnName))
// // {
// // attrib.Name = !string.IsNullOrEmpty(newColumn.NewColumnName)? newColumn.NewColumnName:attrib.Name;
// // }
// // }
// // }
// // }
// // }
// //}
// foreach (var file in files)
// {
// if (file == null)
// {
// throw new BusinessException("上传附件不能为空!");
// }
// string FileOriginName = file.FileName;
// string getFileName = Path.GetFileName(FileOriginName);//获取附件名称
// using (var memoryStream = new MemoryStream())
// {
// //保存成物理文件
// await file.CopyToAsync(memoryStream);
// await _excelImportService.SaveBlobAsync(
// new SaveExcelImportInputDto
// {
// Name = Path.GetFileName(FileOriginName),
// Content = memoryStream.ToArray()
// }
// );
// }
// //读取文件保存的根目录
// string fileSaveRootDir = ConfigDirHelper.GetAppSetting("App", "FileRootPath");
// //读取WMS文件保存的模块的根目录
// string fileSaveDir = ConfigDirHelper.GetAppSetting("App", "WMSFiles");
// //文件保存的相对文件夹(保存到wwwroot目录下)
// string absoluteFileDir = fileSaveRootDir + @"\" + fileSaveDir;
// //文件保存的路径(应用的工作目录+文件夹相对路径);
// string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container" + absoluteFileDir;
// var filePath = fileSavePath + getFileName;//获取到导入的excel
// var import = await _importer.Import<T>(filePath);
// if (import.Exception != null)
// {
// if (import.Exception.Message.ToString() == "导入文件不存在!")
// {
// throw new BusinessException("8989", "文件容器配置的路径错误,请检查!");
// }
// else
// {
// throw new BusinessException("8989", import.Exception.Message.ToString());
// }
// }
// else
// {
// if (import.TemplateErrors.Count > 0)
// {
// throw new BusinessException("8989", "模板错误!当前模板中字段不匹配!!请正确上传模板数据!");
// }
// import.ShouldNotBeNull();
// if (import.Exception != null)
// {
// //导入的数据有异常
// throw new BusinessException(import.Exception.ToString());
// }
// returnResult.totalSize = import.Data.Count;
// if (import.RowErrors.Count > 0)
// {
// foreach (var itm in import.RowErrors)
// {
// string error = string.Empty;
// foreach (var dic in itm.FieldErrors)
// {
// error += (dic.Key + dic.Value + "|");
// }
// _errorList.Add(string.Format("第{0}行{1}", itm.RowIndex.ToString(), error));
// }
// //自动保存“{ 目标文件名称}_.xlsx”的标注文件到目标位置
// //导入的数据有错误,比如重复列,必填项为空等(不包含警告),主要看DTO的设置
// import.HasError.ShouldBeTrue();//标识导入的数据有错误
// returnResult.errSize = import.RowErrors.Count;
// returnResult.errTemplate = Path.GetFileNameWithoutExtension(FileOriginName) + "_.xlsx";//返回错误模板名称作为参数
// returnResult.errMessage = "RowErrors";
// }
// else
// {
// import.HasError.ShouldBeFalse();//标识导入的数据没有错误了
// if (import.Data.Count > 0)
// {
// ImportList.AddRange(import.Data.ToList());
// }
// returnResult.errMessage = "SccessData";
// }
// }
// }
// if (_errorList.Count > 0)
// {
// throw new BusinessException("8989", string.Join("\r\n", _errorList));
// }
// return ImportList;//返回客户端
// }
@ -305,7 +446,7 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
public virtual async Task<List<T>> ExtendExcelImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService, List<ImportColumnMap> p_list=null)
public virtual async Task<List<T>> ExtendExcelImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService, List<ImportColumnMap> p_list = null)
where T : class, new()
{
@ -432,40 +573,40 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
/// 获取配置下面的具体属性的值
/// </summary>
public class GetSetting
{
public string option1 { get; }
public GetSetting(IConfiguration Configuration)
{
public string option1 { get; }
public GetSetting(IConfiguration Configuration)
{
this.option1 = Configuration.GetSection("option1").Value;
}
this.option1 = Configuration.GetSection("option1").Value;
}
}
public class ExcelImportResult
{
/// <summary>
/// 导入的数据总数
/// </summary>
public long totalSize { get; set; }
/// <summary>
/// 成功的个数
/// </summary>
public long succeessSize { get; set; }
/// <summary>
/// 错误数据个数
/// </summary>
public long errSize { get; set; }
/// <summary>
/// 导入错误生成的模板名称
/// </summary>
public string errTemplate { get; set; }
/// <summary>
/// 返回错误信息
/// </summary>
public string errMessage { get; set; }
}
public class ExcelImportResult
{
/// <summary>
/// 导入的数据总数
/// </summary>
public long totalSize { get; set; }
/// <summary>
/// 成功的个数
/// </summary>
public long succeessSize { get; set; }
/// <summary>
/// 错误数据个数
/// </summary>
public long errSize { get; set; }
/// <summary>
/// 导入错误生成的模板名称
/// </summary>
public string errTemplate { get; set; }
/// <summary>
/// 返回错误信息
/// </summary>
public string errMessage { get; set; }
}

7
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -1,4 +1,4 @@
using AutoMapper;
using AutoMapper;
using Win.Sfs.SettleAccount.EstimatedStockDiffReports;
using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.Entities.Boms;
@ -488,7 +488,8 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.Price, y => y.MapFrom(y => y.TotalPrice))
.ForMember(x => x.BeginTime, y => y.MapFrom(y => y.ValidFrom))
.ForMember(x => x.EndTime, y => y.MapFrom(y => y.ValidTo))
.ForMember(x => x.ClientCode, y => y.MapFrom(y => y.Plant));
.ForMember(x => x.ClientCode, y => y.MapFrom(y => y.Plant))
.ForMember(x => x.Date, y => y.MapFrom(y => DateTime.ParseExact(y.Date, "dd.MM.yyyy", System.Globalization.CultureInfo.CurrentCulture)));
CreateMap<PriceList, PriceListExportDto>();
@ -978,7 +979,7 @@ namespace Win.Sfs.SettleAccount
CreateMap<PUB_SA_DETAIL, PUB_NOT_SA_DETAIL>()
.ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum));
CreateMap<ZGJ_PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
CreateMap<PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SA.cs

@ -1,7 +1,8 @@
using SettleAccount.Bases;
using SettleAccount.Bases;
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
using Win.Sfs.SettleAccount;
namespace SettleAccount.Domain.BQ;
[Display(Name = "公用结算导入主表")]
@ -19,6 +20,12 @@ public class PUB_SA : FullAuditedAggregateRoot<Guid>
[Display(Name = "状态")]
public string State { get; set; } = null!;
/// <summary>
/// 业务分类
/// </summary>
[Display(Name = "业务分类")]
public EnumBusinessType BusinessType { get; set; }
public PUB_SA(Guid guid, int version, string billNum, string state)
{
Version = version;

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/MaterialRelationships/MaterialRelationship.cs

@ -97,11 +97,12 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
AppraisalCategory = appraisalCategory;
}
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode) : base(id)
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode, string appraisalCategory) : base(id)
{
ErpMaterialCode = erpMaterialCode;
MaterialDesc = materialDesc;
SettleMaterialCode = settlMaterialCode;
AppraisalCategory = appraisalCategory;
}
}
}

13
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@ -36,6 +36,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
CustomerCode = customerCode;
}
public PriceList(Guid Id, string lu, decimal price, DateTime beginDate, DateTime endDate, string clientCode, DateTime date, string contractNo) : base(Id)
{
LU = lu;
Price = price;
BeginTime = beginDate;
EndTime = endDate;
ClientCode = clientCode;
Date = date;
ContractNo = contractNo;
}
public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type, string customerCode)
{
BeginTime = beginDate;

10
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

@ -1,4 +1,4 @@
using EFCore.BulkExtensions;
using EFCore.BulkExtensions;
using System;
using System.Collections.Generic;
using System.Linq;
@ -85,9 +85,9 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var update = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.MaterialCode,itm1.CustomerCode } equals new { itm2.Type, itm2.MaterialCode, itm2.CustomerCode }
on new { itm1.ClientCode, itm1.LU, itm1.BeginTime, itm1.EndTime } equals new { itm2.ClientCode, itm2.LU, itm2.BeginTime, itm2.EndTime }
where itm1.Price != itm2.Price
select new PriceList(itm2.Id, itm2.BeginTime, itm2.EndTime, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode);
select new PriceList(itm2.Id, itm2.LU, itm1.Price, itm2.BeginTime, itm2.EndTime, itm2.ClientCode, itm2.Date, itm2.ContractNo);
if (update.Count() > 0)
{
@ -99,8 +99,8 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{
var add = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.MaterialCode }
equals new { itm2.Type, itm2.MaterialCode }
on new { itm1.ClientCode, itm1.LU, itm1.BeginTime, itm1.EndTime }
equals new { itm2.ClientCode, itm2.LU, itm2.BeginTime, itm2.EndTime }
into temp
from itm3 in temp.DefaultIfEmpty()
where itm3 == null

17
code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBusinessType.cs

@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace Win.Sfs.SettleAccount
{
@ -8,31 +8,31 @@ namespace Win.Sfs.SettleAccount
public enum EnumBusinessType
{
/// <summary>
///未定义
/// 未定义
/// </summary>
[Display(Name = "未定义")]
None = 0,
/// <summary>
///直供件
/// 直供件
/// </summary>
[Display(Name = "直供件")]
ZhiGongJian = 1,
/// <summary>
///买单件
/// 买单件
/// </summary>
[Display(Name = "买单件")]
MaiDanJian = 2,
/// <summary>
///备件
/// 备件
/// </summary>
[Display(Name = "备件")]
BeiJian = 3,
/// <summary>
///印度件
/// 印度件
/// </summary>
[Display(Name = "印度件")]
YingDuJian = 4,
@ -44,12 +44,9 @@ namespace Win.Sfs.SettleAccount
HBPO = 5,
/// <summary>
///印度件
/// 印度件
/// </summary>
[Display(Name = "BBAC-JIS")]
BBAC = 6
}
}

4038
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719022720_20230719-2.Designer.cs

File diff suppressed because it is too large

24
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719022720_20230719-2.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307192 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "BusinessType",
table: "Set_PUB_SA",
type: "int",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BusinessType",
table: "Set_PUB_SA");
}
}
}

3
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -2778,6 +2778,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("BusinessType")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)

Loading…
Cancel
Save