From e8c9606e970e58954d848c003a6163dd89527fb3 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sun, 17 Apr 2022 11:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/ERPShpping/ERPShppingDto.cs | 187 ++++++++ .../Entities/HQExtend/HQKBExtendDto.cs | 273 ++++++++++++ ...SettleAccount.Application.Contracts.csproj | 4 + .../BTCarConsignAppService.cs | 334 +++++++++++++++ .../BTCarKBFirstAppService.cs | 369 ++++++++++++++++ .../ErpShipping/ErpShippingAppService.cs | 398 ++++++++++++++++++ .../Entities/HQExtend/HQKBExtendAppService.cs | 347 +++++++++++++++ .../HQExtend/HQKBSettleExtendAppService.cs | 346 +++++++++++++++ .../SettleAccount.Application.csproj | 4 - .../Entities/ERPShipping/ERPShippingDetail.cs | 60 ++- .../ERPShipping/ERPShippingVersion.cs | 49 ++- .../Entities/HQExtend/HQKBExtend.cs | 52 +++ .../Entities/HQExtend/HQKBExtendVersion.cs | 55 +++ .../Entities/HQExtend/HQKBSettleExtend.cs | 52 +++ .../HQExtend/HQKBSettleExtendVersion.cs | 55 +++ 15 files changed, 2578 insertions(+), 7 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/ERPShpping/ERPShppingDto.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/HQExtend/HQKBExtendDto.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarConsigns_HS/BTCarConsignAppService.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarKBFirsts_HS/BTCarKBFirstAppService.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErpShipping/ErpShippingAppService.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBExtendAppService.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBSettleExtendAppService.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtend.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtendVersion.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtend.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtendVersion.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/ERPShpping/ERPShppingDto.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/ERPShpping/ERPShppingDto.cs new file mode 100644 index 00000000..1c1b3a66 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/ERPShpping/ERPShppingDto.cs @@ -0,0 +1,187 @@ +using Magicodes.ExporterAndImporter.Core; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win.Sfs.Shared; +using Win.Sfs.Shared.DtoBase; + +namespace Win.Sfs.SettleAccount.Entities.ERPShpping +{ + public class ERPShippingDetailDto + { + + + [ImporterHeader(Name = "保管")] + public string Person { set; get; } + [ImporterHeader(Name = "成本")] + public decimal Cost { set; get; } + [ImporterHeader(Name = "单据编号")] + public string BillNum { set; get; } + + [ImporterHeader(Name = "单位")] + public string Unit { set; get; } + + [ImporterHeader(Name = "调拨数量")] + public decimal Qty { set; get; } + [ImporterHeader(Name = "调出仓库")] + public string Output { set; get; } + [ImporterHeader(Name = "调出仓库代码")] + public string OutputCode { set; get; } + [ImporterHeader(Name = "调入仓库")] + + public string Input { set; get; } + [ImporterHeader(Name = "调入仓库代码")] + public string InputCode { set; get; } + [ImporterHeader(Name = "辅助出库关联数量")] + public decimal OutputAssQty { set; get; } + [ImporterHeader(Name = "规格型号")] + public string Model { set; get; } + [ImporterHeader(Name = "基本出库关联数量")] + public decimal OutputQty { set; get; } + [ImporterHeader(Name = "批号")] + public string BatchNum { set; get; } + [ImporterHeader(Name = "日期")] + public DateTime BillDate { set; get; } + [ImporterHeader(Name = "审核标志")] + public string Flag { get; set; } + [ImporterHeader(Name = "物料长代码")] + public string ErpMaterialCode { set; get; } + [ImporterHeader(Name = "期间")] + public string Version { get; set; } + } + public class ERPShippingDetailRequestDto: RequestDtoBase, IBranch + { + + + [ImporterHeader(Name = "保管")] + public string Person { set; get; } + [ImporterHeader(Name = "成本")] + public decimal Cost { set; get; } + [ImporterHeader(Name = "单据编号")] + public string BillNum { set; get; } + + [ImporterHeader(Name = "单位")] + public string Unit { set; get; } + + [ImporterHeader(Name = "调拨数量")] + public decimal Qty { set; get; } + [ImporterHeader(Name = "调出仓库")] + public string Output { set; get; } + [ImporterHeader(Name = "调出仓库代码")] + public string OutputCode { set; get; } + [ImporterHeader(Name = "调入仓库")] + + public string Input { set; get; } + [ImporterHeader(Name = "调入仓库代码")] + public string InputCode { set; get; } + [ImporterHeader(Name = "辅助出库关联数量")] + public decimal OutputAssQty { set; get; } + [ImporterHeader(Name = "规格型号")] + public string Model { set; get; } + [ImporterHeader(Name = "基本出库关联数量")] + public decimal OutputQty { set; get; } + [ImporterHeader(Name = "批号")] + public string BatchNum { set; get; } + [ImporterHeader(Name = "日期")] + public DateTime BillDate { set; get; } + [ImporterHeader(Name = "审核标志")] + public string Flag { get; set; } + [ImporterHeader(Name = "物料长代码")] + public string ErpMaterialCode { set; get; } + [ImporterHeader(Name = "期间")] + public string Version { get; set; } + public Guid BranchId { get; set; } + } + public class ERPShippingDetailExportDto + { + + + [Display(Name = "保管")] + public string Person { set; get; } + [Display(Name = "成本")] + public decimal Cost { set; get; } + [Display(Name = "单据编号")] + public string BillNum { set; get; } + + [Display(Name = "单位")] + public string Unit { set; get; } + + [Display(Name = "调拨数量")] + public decimal Qty { set; get; } + [Display(Name = "调出仓库")] + public string Output { set; get; } + [Display(Name = "调出仓库代码")] + public string OutputCode { set; get; } + [Display(Name = "调入仓库")] + + public string Input { set; get; } + [Display(Name = "调入仓库代码")] + public string InputCode { set; get; } + [Display(Name = "辅助出库关联数量")] + public decimal OutputAssQty { set; get; } + [Display(Name = "规格型号")] + public string Model { set; get; } + [Display(Name = "基本出库关联数量")] + public decimal OutputQty { set; get; } + [Display(Name = "批号")] + public string BatchNum { set; get; } + [Display(Name = "日期")] + public DateTime BillDate { set; get; } + [Display(Name = "审核标志")] + public string Flag { get; set; } + [Display(Name = "物料长代码")] + public string ErpMaterialCode { set; get; } + [Display(Name = "期间")] + public string Version { get; set; } + } + + + + public class ERPShippingVersionRequestDto : RequestDtoBase, IBranch + { + + public string Year { get; private set; } + /// + /// 期间 + /// + public string Period { get; private set; } + /// + /// 版本号 + /// + public string Version { get; private set; } + + /// + /// 客户号 + /// + public string CustomerCode { private set; get; } + public Guid BranchId { get; set; } + } + + + public class ERPShippingVersionDto + { + public string Year { get; set; } + /// + /// 期间 + /// + public string Period { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + /// + /// 客户号 + /// + public string CustomerCode { set; get; } + + + public string Factory { set; get; } + + } + + +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/HQExtend/HQKBExtendDto.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/HQExtend/HQKBExtendDto.cs new file mode 100644 index 00000000..6038f52e --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/HQExtend/HQKBExtendDto.cs @@ -0,0 +1,273 @@ +using Magicodes.ExporterAndImporter.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win.Sfs.Shared; +using Win.Sfs.Shared.DtoBase; + +namespace Win.Sfs.SettleAccount.Entities.HQExtend +{ + public class HQKBExtendDto + { + + + [ImporterHeader(Name = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ImporterHeader(Name = "采购申请单号")] + public string BillNum { get; set; } + [ImporterHeader(Name = "零件名称")] + public string MaterialDesc { get; set; } + [ImporterHeader(Name = "零件号")] + public string MaterialCode { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "无税单价")] + public decimal Price { get; set; } + + [ImporterHeader(Name = "无税金额")] + public decimal Amt { get; set; } + [ImporterHeader(Name = "税率")] + public decimal Tax { get; set; } + [ImporterHeader(Name = "税额合计")] + public decimal TaxAmt { get; set; } + [ImporterHeader(Name = "价税合计")] + public decimal TotalAmt { get; set; } + [ImporterHeader(Name = "版本号", IsIgnore = false)] + public string Version { get; set; } + } + + + public class HQKBExtendRequestDto : RequestDtoBase, IBranch + { + [ImporterHeader(Name = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ImporterHeader(Name = "采购申请单号")] + public string BillNum { get; set; } + [ImporterHeader(Name = "零件名称")] + public string MaterialDesc { get; set; } + [ImporterHeader(Name = "零件号")] + public string MaterialCode { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "无税单价")] + public decimal Price { get; set; } + + [ImporterHeader(Name = "无税金额")] + public decimal Amt { get; set; } + [ImporterHeader(Name = "税率")] + public decimal Tax { get; set; } + [ImporterHeader(Name = "税额合计")] + public decimal TaxAmt { get; set; } + [ImporterHeader(Name = "价税合计")] + public decimal TotalAmt { get; set; } + [ImporterHeader(Name = "版本号", IsIgnore = false)] + public string Version { get; set; } + public Guid BranchId { get; set; } + } + + public class HQKBExtendExportDto + { + [ExporterHeader(DisplayName = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ExporterHeader(DisplayName = "采购申请单号")] + public string BillNum { get; set; } + [ExporterHeader(DisplayName = "零件名称")] + public string MaterialDesc { get; set; } + [ExporterHeader(DisplayName = "零件号")] + public string MaterialCode { get; set; } + [ExporterHeader(DisplayName = "数量")] + public decimal Qty { get; set; } + [ExporterHeader(DisplayName = "无税单价")] + public decimal Price { get; set; } + + [ExporterHeader(DisplayName = "无税金额")] + public decimal Amt { get; set; } + [ExporterHeader(DisplayName = "税率")] + public decimal Tax { get; set; } + [ExporterHeader(DisplayName = "税额合计")] + public decimal TaxAmt { get; set; } + [ExporterHeader(DisplayName = "价税合计")] + public decimal TotalAmt { get; set; } + [ExporterHeader(DisplayName = "版本号")] + public string Version { get; set; } + } + public class HQKBExtendVersionRequestDto : RequestDtoBase, IBranch + { + + public string Year { get; private set; } + /// + /// 期间 + /// + public string Period { get; private set; } + /// + /// 版本号 + /// + public string Version { get; private set; } + + /// + /// 客户号 + /// + public string CustomerCode { private set; get; } + public Guid BranchId { get; set; } + } + + + public class HQKBExtendVersionDto + { + public string Year { get; set; } + /// + /// 期间 + /// + public string Period { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + /// + /// 客户号 + /// + public string CustomerCode { set; get; } + + + public string Factory { set; get; } + + } + + public class HQKBSettleExtendDto + { + + + [ImporterHeader(Name = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ImporterHeader(Name = "采购申请单号")] + public string BillNum { get; set; } + [ImporterHeader(Name = "零件名称")] + public string MaterialDesc { get; set; } + [ImporterHeader(Name = "零件号")] + public string MaterialCode { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "无税单价")] + public decimal Price { get; set; } + + [ImporterHeader(Name = "无税金额")] + public decimal Amt { get; set; } + [ImporterHeader(Name = "税率")] + public decimal Tax { get; set; } + [ImporterHeader(Name = "税额合计")] + public decimal TaxAmt { get; set; } + [ImporterHeader(Name = "价税合计")] + public decimal TotalAmt { get; set; } + [ImporterHeader(Name = "版本号", IsIgnore = false)] + public string Version { get; set; } + } + + + public class HQKBSettleExtendRequestDto : RequestDtoBase, IBranch + { + [ImporterHeader(Name = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ImporterHeader(Name = "采购申请单号")] + public string BillNum { get; set; } + [ImporterHeader(Name = "零件名称")] + public string MaterialDesc { get; set; } + [ImporterHeader(Name = "零件号")] + public string MaterialCode { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "无税单价")] + public decimal Price { get; set; } + + [ImporterHeader(Name = "无税金额")] + public decimal Amt { get; set; } + [ImporterHeader(Name = "税率")] + public decimal Tax { get; set; } + [ImporterHeader(Name = "税额合计")] + public decimal TaxAmt { get; set; } + [ImporterHeader(Name = "价税合计")] + public decimal TotalAmt { get; set; } + [ImporterHeader(Name = "版本号", IsIgnore = false)] + public string Version { get; set; } + public Guid BranchId { get; set; } + } + + public class HQKBSettleExtendExportDto + { + [ExporterHeader(DisplayName = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ExporterHeader(DisplayName = "采购申请单号")] + public string BillNum { get; set; } + [ExporterHeader(DisplayName = "零件名称")] + public string MaterialDesc { get; set; } + [ExporterHeader(DisplayName = "零件号")] + public string MaterialCode { get; set; } + [ExporterHeader(DisplayName = "数量")] + public decimal Qty { get; set; } + [ExporterHeader(DisplayName = "无税单价")] + public decimal Price { get; set; } + + [ExporterHeader(DisplayName = "无税金额")] + public decimal Amt { get; set; } + [ExporterHeader(DisplayName = "税率")] + public decimal Tax { get; set; } + [ExporterHeader(DisplayName = "税额合计")] + public decimal TaxAmt { get; set; } + [ExporterHeader(DisplayName = "价税合计")] + public decimal TotalAmt { get; set; } + [ExporterHeader(DisplayName = "版本号")] + public string Version { get; set; } + } + public class HQKBSettleExtendVersionRequestDto : RequestDtoBase, IBranch + { + + public string Year { get; private set; } + /// + /// 期间 + /// + public string Period { get; private set; } + /// + /// 版本号 + /// + public string Version { get; private set; } + + /// + /// 客户号 + /// + public string CustomerCode { private set; get; } + public Guid BranchId { get; set; } + } + + + public class HQKBSettleExtendVersionDto + { + public string Year { get; set; } + /// + /// 期间 + /// + public string Period { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + /// + /// 客户号 + /// + public string CustomerCode { set; get; } + + + public string Factory { set; get; } + + } + + +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/SettleAccount.Application.Contracts.csproj b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/SettleAccount.Application.Contracts.csproj index 5ff1ef4f..3f026584 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/SettleAccount.Application.Contracts.csproj +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/SettleAccount.Application.Contracts.csproj @@ -24,5 +24,9 @@ + + + + diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarConsigns_HS/BTCarConsignAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarConsigns_HS/BTCarConsignAppService.cs new file mode 100644 index 00000000..e2f61a79 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarConsigns_HS/BTCarConsignAppService.cs @@ -0,0 +1,334 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Distributed; +using Shouldly; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.BTCarConsigns; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.BTCarConsigns; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.Shared.CacheBase; +using Win.Sfs.Shared.Filter; +using Win.Utils; + +namespace Win.Sfs.SettleAccount.BTCarConsigns +{ + + /// + /// Ӧ÷ + /// + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + [Route("api/settleaccount/BTCarConsign")] + public class BTCarConsignAppService : SettleAccountApplicationBase, IBTCarConsignAppService + { + private readonly IGuidGenerator _guidGenerator; + + private readonly IObjectMapper _objectMapper; + + private readonly IExcelImportAppService _excelImportService; + + + private readonly ISettleAccountBranchEfCoreRepository _repository; + + private readonly ISettleAccountBranchEfCoreRepository _versionRepository; + /// + /// + /// + /// UID + /// Զmap + /// ִӿ + /// + public BTCarConsignAppService(IGuidGenerator guidGenerator, + IObjectMapper objectMapper, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ISettleAccountBranchEfCoreRepository repository, + ISettleAccountBranchEfCoreRepository versionRepository, + IDistributedCache cache + ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) + { + _guidGenerator = guidGenerator; + _objectMapper = objectMapper; + _repository = repository; + _excelImportService = excelImportService; + _versionRepository = versionRepository; + } + + #region 뵼 + /// + /// 빦 + /// + /// ϴļ(ǰѾֻϴһ) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + public async Task BTCarConsignUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode,DateTime datetime) + { + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var entityList = ObjectMapper.Map, List>(result); + + + var _versionQuery = _versionRepository.Where(p => p.Version == version && p.CustomerCode==customerCode); + await _versionQuery.BatchDeleteAsync(); + var _query = _repository.Where(p => p.Version == version && p.CustomerCode==customerCode); + await _query.BatchDeleteAsync(); + var _id = GuidGenerator.Create(); + var _BTCarConsignList = new List(); + _BTCarConsignList.Add(new BTCarConsignVersion(_id, branchId, period, version, customerCode, datetime)); + foreach (var itm in entityList) + { + itm.SetValue(GuidGenerator.Create(), branchId, period, version, customerCode, datetime, _id); + } + var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 10000 }; + await _repository.GetDbContext().BulkInsertAsync(entityList); + await _versionRepository.GetDbContext().BulkInsertAsync(_BTCarConsignList); + return ApplicationConsts.SuccessStr; + } + + + #endregion + + /// + /// IDȡΨһʵ + /// + /// + /// ʵȫ + /// + /// ID + /// ʵDTO + [HttpGet] + [Route("{id}")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + virtual public async Task GetAsync(Guid id) + { + var result = await _repository.GetAsync(id); + var dto = _objectMapper.Map(result); + return dto; + } + + + private async Task GetFromCacheAsync(Guid id) + { + var result = + await _repository.GetAsync(id) + ; + + return result; + } + + private async Task GetCountAsync(BTCarConsignRequestDto input) + { + return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + private async Task GetCountAsync(BTCarConsignVersionRequestDto input) + { + return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + /// + /// ȡʵ + /// + /// ʵ + [HttpGet] + [Route("count")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + virtual public async Task GetTotalCountAsync(Guid branchId) + { + return await _repository.GetCountAsync(branchId); + } + + /// + /// ɾʵ + /// + /// ID + /// + [HttpDelete] + [Route("{id}")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Delete)] + virtual public async Task DeleteAsync(Guid id) + { + //var entity = await GetFromCacheAsync(id); + //await Cache.DeleteAsync(id.ToString()); + await _repository.DeleteAsync(id); + } + + /// + /// IDsɾʵб + /// + /// IDs + /// Ƿִгɹ + [HttpPost] + [Route("delete")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Delete)] + virtual public async Task DeleteListAsync(List ids) + { + //foreach (var id in ids) + //{ + // var entity = await GetFromCacheAsync(id); + + //} + + return await _repository.DeleteListAsync(ids); + } + + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("list")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + + + public async Task> GetListAsync(Guid parentId,BTCarConsignRequestDto input) + { + if (input.ParentId != Guid.Empty) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); + } + else + { + return new PagedResultDto(0, new List()); + } + + 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>(entities); + + return new PagedResultDto(totalCount, dtos); + } + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("listVersion")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + public async Task> GetVersionListAsync(BTCarConsignVersionRequestDto input) + { + var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + input.SkipCount, true); + + var totalCount = await GetCountAsync(input); + var dtos = _objectMapper.Map, List>(entities); + foreach (var itm in dtos) + { + itm.Version = itm.Version + string.Format("({0})", itm.CustomerCode); + } + return new PagedResultDto(totalCount, dtos); + } + /// + /// ļ + /// + /// + /// + [HttpPost] + [Route("Export")] + //[AuthorizeSettleAccountPermissions.BTCarConsigns.Default)] + virtual public async Task ExportAsync(BTCarConsignRequestDto input) + { + + IExporter _csv = new CsvExporter(); + + IExporter _excel = new ExcelExporter(); + + if (input.ParentId != Guid.Empty) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); + } + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + 0, true); + + var dtoDetails = ObjectMapper.Map, List>(entities); + + string _fileName = string.Empty; + // + + //byte[] result = null; + //_fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.Sec_BTCarConsignFileName, CurrentUser.Id?.ToString(), ApplicationConsts.FileExtension); + + byte[] result = null; + switch (input.FileType) + { + case 0: + _fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.Sec_BTCarConsignFileName, CurrentUser.Id?.ToString(), ".csv"); + result = await _csv.ExportAsByteArray(dtoDetails); + break; + case 1: + _fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.Sec_BTCarConsignFileName, CurrentUser.Id?.ToString(),ApplicationConsts.FileExtension); + result = await _excel.ExportAsByteArray(dtoDetails); + break; + } + + result.ShouldNotBeNull(); + + //浼ļɶ + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + [HttpPost] + [Route("btupdate")] + + [UnitOfWork(isTransactional: false)] + public async Task UPdateFisAsync() + { + + await _repository.GetDbContext().Database.ExecuteSqlRawAsync( + "EXEC sp_bt_update" + ); + return true; + + + + } + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarKBFirsts_HS/BTCarKBFirstAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarKBFirsts_HS/BTCarKBFirstAppService.cs new file mode 100644 index 00000000..b6b8e1ce --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BTCarKBFirsts_HS/BTCarKBFirstAppService.cs @@ -0,0 +1,369 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Distributed; +using Shouldly; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.BTCarKBs; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.BTCarKBFirsts; +using Win.Sfs.SettleAccount.Entities.BTCarKBs; +using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.SettleAccount.MaterialRelationships; +using Win.Sfs.Shared.CacheBase; +using Win.Sfs.Shared.Filter; +using Win.Utils; + +namespace Win.Sfs.SettleAccount.BTCarKBFirsts +{ + + /// + /// Ӧ÷ + /// + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + [Route("api/settleaccount/BTCarKBFirst")] + public class BTCarKBFirstAppService : SettleAccountApplicationBase, IBTCarKBFirstAppService + { + private readonly IGuidGenerator _guidGenerator; + + private readonly IObjectMapper _objectMapper; + + private readonly IExcelImportAppService _excelImportService; + + + private readonly ISettleAccountBranchEfCoreRepository _repository; + + private readonly ISettleAccountBranchEfCoreRepository _versionRepository; + private readonly ISettleAccountBranchEfCoreRepository _MaterialRepository; + /// + /// + /// + /// UID + /// Զmap + /// ִӿ + /// + public BTCarKBFirstAppService(IGuidGenerator guidGenerator, + IObjectMapper objectMapper, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ISettleAccountBranchEfCoreRepository repository, + ISettleAccountBranchEfCoreRepository versionRepository, + ISettleAccountBranchEfCoreRepository MaterialRepository, + IDistributedCache cache + ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) + { + _guidGenerator = guidGenerator; + _objectMapper = objectMapper; + _repository = repository; + _excelImportService = excelImportService; + _versionRepository = versionRepository; + _MaterialRepository = MaterialRepository; + } + + #region 뵼 + /// + /// 빦 + /// + /// ϴļ(ǰѾֻϴһ) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + + public async Task BTCarKBFirstUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode) + { + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var entityList = ObjectMapper.Map, List>(result); + + var checkList = new List(); + + bool _iscreate = false; + var _versionQuery = _versionRepository.FirstOrDefault(p => p.Version == version && p.CustomerCode == customerCode); + if (_versionQuery == null) + { + _iscreate = true; + } + Guid _id = Guid.Empty; + if (_iscreate == true) + { + _id = GuidGenerator.Create(); + } + else + { + _id = _versionQuery.Id; + } + //List errorList = new List(); + DateTime datetime= entityList[0].DeliveryDateTime; + foreach (var itm in entityList) + { + //ͨϵƥñ֤Ϻ + if (!_MaterialRepository.Any(p => p.ShipMaterailCode == itm.MaterialCode)) + { + checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("Ϻ:{0}ڡϵƥñв!", itm.MaterialCode), string.Empty)); + //errorList.Add(string.Format("Ϻ:{0}ڡϵƥñв!", itm.MaterialCode)); + } + else + { + datetime = itm.DeliveryDateTime; + var _entity = _repository.FirstOrDefault(p => p.CustomerCode == customerCode && p.Version == version && p.MaterialCode == itm.MaterialCode && p.OrderKBCode == itm.OrderKBCode); + if (_entity == null) + { + _entity = new BTCarKB(GuidGenerator.Create(), GuidGenerator.Create(), period, customerCode, datetime, version, itm.MaterialCode, itm.MaterialDesc + , itm.NeedQty, itm.OrderKBCode, itm.ReceiveAreaCode, itm.ReceiveAreaName, itm.DeliveryDateTime, itm.ConsignQty, itm.State, _id); + await _repository.InsertAsync(_entity); + } + else + { + _entity.SetValue(_entity.Id, branchId, period, version, customerCode, datetime, _id); + await _repository.UpdateAsync(_entity); + } + } + } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } + //var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 10000 }; + // await _repository.GetDbContext().BulkInsertAsync(entityList); + if (_iscreate == true) + { + var _BTCarKBFirstList = new List(); + _BTCarKBFirstList.Add(new BTCarKBVersion(_id, branchId, period, version, customerCode, datetime)); + await _versionRepository.GetDbContext().BulkInsertAsync(_BTCarKBFirstList); + } + //st.Stop(); + return ApplicationConsts.SuccessStr; + } + + + #endregion + + /// + /// IDȡΨһʵ + /// + /// + /// ʵȫ + /// + /// ID + /// ʵDTO + [HttpGet] + [Route("{id}")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + virtual public async Task GetAsync(Guid id) + { + var result = await _repository.GetAsync(id); + var dto = _objectMapper.Map(result); + return dto; + } + + + private async Task GetFromCacheAsync(Guid id) + { + var result = + await _repository.GetAsync(id) + ; + + return result; + } + + private async Task GetCountAsync(BTCarKBRequestDto input) + { + return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + private async Task GetCountAsync(BTCarKBVersionRequestDto input) + { + return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + /// + /// ȡʵ + /// + /// ʵ + [HttpGet] + [Route("count")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + virtual public async Task GetTotalCountAsync(Guid branchId) + { + return await _repository.GetCountAsync(branchId); + } + + /// + /// ɾʵ + /// + /// ID + /// + [HttpDelete] + [Route("{id}")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Delete)] + virtual public async Task DeleteAsync(Guid id) + { + //var entity = await GetFromCacheAsync(id); + //await Cache.DeleteAsync(id.ToString()); + await _repository.DeleteAsync(id); + } + + /// + /// IDsɾʵб + /// + /// IDs + /// Ƿִгɹ + [HttpPost] + [Route("delete")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Delete)] + virtual public async Task DeleteListAsync(List ids) + { + //foreach (var id in ids) + //{ + // var entity = await GetFromCacheAsync(id); + + //} + + return await _repository.DeleteListAsync(ids); + } + + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("list")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + + + public async Task> GetListAsync(Guid parentId, BTCarKBRequestDto input) + { + if (input.ParentId!=Guid.Empty) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); + } + else + { + return new PagedResultDto(0, new List()); + } + + 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>(entities); + + return new PagedResultDto(totalCount, dtos); + } + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("listVersion")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + public async Task> GetVersionListAsync(BTCarKBVersionRequestDto input) + { + var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + input.SkipCount, true); + + var totalCount = await GetCountAsync(input); + var dtos = _objectMapper.Map, List>(entities); + foreach (var itm in dtos) + { + itm.Version = itm.Version + string.Format("({0})", itm.CustomerCode); + } + + return new PagedResultDto(totalCount, dtos); + } + /// + /// ļ + /// + /// + /// + [HttpPost] + [Route("Export")] + //[AuthorizeSettleAccountPermissions.BTCarKBFirsts.Default)] + virtual public async Task ExportAsync(BTCarKBRequestDto input) + { + + IExporter _csv = new CsvExporter(); + + IExporter _excel = new ExcelExporter(); + if (input.ParentId != Guid.Empty) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); + } + + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + 0, true); + + var dtoDetails = ObjectMapper.Map, List>(entities); + + string _fileName = string.Empty; + // + + + byte[] result = null; + switch (input.FileType) + { + case 0: + _fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.Sec_BTCarFirstKBFileName, CurrentUser.Id?.ToString(),".csv" ); + result = await _csv.ExportAsByteArray(dtoDetails); + break; + case 1: + _fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.Sec_BTCarFirstKBFileName, CurrentUser.Id?.ToString(), ApplicationConsts.FileExtension); + result = await _excel.ExportAsByteArray(dtoDetails); + break; + } + + + //_fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.Sec_BTCarFirstKBFileName, CurrentUser.Id?.ToString(), ApplicationConsts.FileExtension); + //result = await _excel.ExportAsByteArray(dtoDetails); + result.ShouldNotBeNull(); + + //浼ļɶ + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErpShipping/ErpShippingAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErpShipping/ErpShippingAppService.cs new file mode 100644 index 00000000..e2e77be6 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErpShipping/ErpShippingAppService.cs @@ -0,0 +1,398 @@ + + + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Distributed; +using Shouldly; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.ERPShipping; +using Win.Sfs.SettleAccount.Entities.ERPShpping; +using Win.Sfs.SettleAccount.Entities.ImportMap; +using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.Shared.CacheBase; +using Win.Sfs.Shared.Filter; +using Win.Utils; + +namespace Win.Sfs.SettleAccount.ERPShippingDetails +{ + + /// + /// Ӧ÷ + /// + [Authorize(SettleAccountPermissions.Boms.Default)] + //[AllowAnonymous] + [Route("api/settleaccount/ErpShipping")] + public class ErpShippingAppService : SettleAccountApplicationBase + { + private readonly IGuidGenerator _guidGenerator; + + private readonly IObjectMapper _objectMapper; + + private readonly IExcelImportAppService _excelImportService; + + + private readonly ISettleAccountBranchEfCoreRepository _repository; + + + private readonly ISettleAccountBranchEfCoreRepository _materialRepository; + + private readonly ISettleAccountBranchEfCoreRepository _importColumnMapRepository; + + private readonly ISettleAccountBranchEfCoreRepository _versionRepository; + /// + /// + /// + /// UID + /// Զmap + /// ִӿ + /// + public ErpShippingAppService(IGuidGenerator guidGenerator, + IObjectMapper objectMapper, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ISettleAccountBranchEfCoreRepository repository, + ISettleAccountBranchEfCoreRepository versionRepository, + ISettleAccountBranchEfCoreRepository materialRepository, + ISettleAccountBranchEfCoreRepository importColumnMapRepository, + IDistributedCache cache + ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) + { + _guidGenerator = guidGenerator; + _objectMapper = objectMapper; + _repository = repository; + _excelImportService = excelImportService; + _versionRepository = versionRepository; + _materialRepository = materialRepository; + _importColumnMapRepository = importColumnMapRepository; + } + + #region 뵼 + + /// + /// 빦 + /// + /// ϴļ(ǰѾֻϴһ) + /// + //[HttpPost] + //[Route("ExcelImport-Map")] + //[DisableRequestSizeLimit] + //[Authorize(SettleAccountPermissions.ERPShippingDetails.Create)] + + //public async Task ERPShippingDetailUploadExcelImportMap([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory) + //{ + // var _mapList=_importColumnMapRepository.Where(p => p.ProjectName ==SettleAccountModuleName.ERPShippingDetail ).ToList(); + + // ExportImporter _exportImporter = new ExportImporter(); + // var result = await _exportImporter.ExtendExcelImport(files, _excelImportService,_mapList); + // var entityList = ObjectMapper.Map, List>(result); + // var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Factory == factory); + // await _versionQuery.BatchDeleteAsync(); + // var _query = _repository.Where(p => p.Version == version && p.Factory == factory); + // await _query.BatchDeleteAsync(); + // var checkList = new List(); + // var _matList = await _materialRepository.GetAllAsync(GuidGenerator.Create()); + // var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(), ParentItmeCode = p.Key.ParentItemCode, ChildItemCode = p.Key.ChildItemCode }); + // foreach (var itm in _group) + // { + // if (itm.Count > 1) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ܵ븸{0},ӱ{1}ظ", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); + // } + // } + // var _id = GuidGenerator.Create(); + // var _ERPShippingDetailList = new List(); + // _ERPShippingDetailList.Add(new ERPShippingVersion(_id, branchId, year, period, version, customerCode, factory)); + // foreach (var itm in entityList) + // { + // if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode)) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("ݲϺ{0}", itm.ParentItemCode), string.Empty)); + // continue; + // } + // itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, _id, factory); + // } + // if (checkList.Count > 0) + // { + // return await ExportErrorReportAsync(checkList); + // } + // await _repository.GetDbContext().BulkInsertAsync(entityList); + // await _versionRepository.GetDbContext().BulkInsertAsync(_ERPShippingDetailList); + // //st.Stop(); + // return ApplicationConsts.SuccessStr; + //} + + + + + /// + /// 빦 + /// + /// ϴļ(ǰѾֻϴһ) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + + + public async Task ERPShippingDetailUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode,string factory) + { + + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var entityList = ObjectMapper.Map, List>(result); + var _versionQuery = _versionRepository.Where(p => p.Version == version ); + await _versionQuery.BatchDeleteAsync(); + var _query = _repository.Where(p => p.Version == version ); + await _query.BatchDeleteAsync(); + //var checkList = new List(); + //var _matList =await _materialRepository.GetAllAsync(GuidGenerator.Create()); + // var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(),ParentItmeCode=p.Key.ParentItemCode, ChildItemCode=p.Key.ChildItemCode }); + //foreach (var itm in _group) + //{ + // if (itm.Count > 1) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ܵ븸{0},ӱ{1}ظ", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); + // } + //} + //var _id = GuidGenerator.Create(); + //var _ERPShippingDetailList = new List(); + //_ERPShippingDetailList.Add(new ERPShippingVersion(_id, branchId, year, period, version, customerCode,factory)); + //foreach (var itm in entityList) + //{ + // if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode)) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("ݲϺ{0}", itm.ParentItemCode), string.Empty)); + // continue; + // } + // itm.SetValue(GuidGenerator.Create(),branchId,year,period,version,_id,factory); + //} + //if (checkList.Count > 0) + //{ + // return await ExportErrorReportAsync(checkList); + //} + await _repository.GetDbContext().BulkInsertAsync(entityList); + + await _versionRepository.GetDbContext().BulkInsertAsync(new List { new ERPShippingVersion(Guid.NewGuid(), branchId, year, period, version, customerCode, factory) }); + + //st.Stop(); + return ApplicationConsts.SuccessStr; + } + /// + /// ļ + /// + /// + /// + [HttpPost] + [Route("Export")] + + virtual public async Task ExportAsync(ERPShippingDetailRequestDto input) + { + IExporter _csv = new CsvExporter(); + IExporter _excel = new ExcelExporter(); + //ϰ汾ȫ + if (!string.IsNullOrEmpty(input.Version )) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version.ToString() }); + } + //else + //{ + // return new PagedResultDto(0, new List()); + //} + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + string _fileName = string.Empty; + // + + byte[] result = null; + + + + _fileName = string.Format("ERP_{0}.xlsx", Guid.NewGuid().ToString("N")); + result = await _excel.ExportAsByteArray(dtoDetails); + + + result.ShouldNotBeNull(); + + //浼ļɶ + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + #endregion + + /// + /// IDȡΨһʵ + /// + /// + /// ʵȫ + /// + /// ID + /// ʵDTO + [HttpGet] + [Route("{id}")] + + virtual public async Task GetAsync(Guid id) + { + var result = await _repository.GetAsync(id); + var dto = _objectMapper.Map(result); + return dto; + } + + + private async Task GetFromCacheAsync(Guid id) + { + var result = await _repository.GetAsync(id); + return result; + } + + + private async Task GetCountAsync(ERPShippingDetailRequestDto input) + { + return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + + private async Task GetCountAsync(ERPShippingVersionRequestDto input) + { + return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + /// + /// ȡʵ + /// + /// ʵ + [HttpGet] + [Route("count")] + + virtual public async Task GetTotalCountAsync(Guid branchId) + { + return await _repository.GetCountAsync(branchId); + } + + + + /// + /// ɾʵ + /// + /// ID + /// + [HttpDelete] + [Route("{id}")] + + virtual public async Task DeleteAsync(Guid id) + { + //var entity = await GetFromCacheAsync(id); + //await Cache.DeleteAsync(id.ToString()); + await _repository.DeleteAsync(id); + } + + /// + /// IDsɾʵб + /// + /// IDs + /// Ƿִгɹ + [HttpPost] + [Route("delete")] + + virtual public async Task DeleteListAsync(List ids) + { + //foreach (var id in ids) + //{ + // var entity = await GetFromCacheAsync(id); + + //} + + return await _repository.DeleteListAsync(ids); + } + + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("list")] + + public async Task> GetListAsync(Guid parentId, ERPShippingDetailRequestDto input) + { + if (!string.IsNullOrEmpty(input.Version) ) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); + } + else + { + return new PagedResultDto(0,new List()); + } + 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>(entities); + return new PagedResultDto(totalCount, dtos); + } + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("listVersion")] + + public async Task> GetVersionListAsync(ERPShippingVersionRequestDto input) + { + var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + input.SkipCount, true); + + var totalCount = await GetCountAsync(input); + var dtos = _objectMapper.Map, List>(entities); + //foreach (var itm in dtos) + //{ + // itm.Version = itm.Version + string.Format("({0})", itm.Factory); + //} + return new PagedResultDto(totalCount, dtos); + } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBExtendAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBExtendAppService.cs new file mode 100644 index 00000000..3548daed --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBExtendAppService.cs @@ -0,0 +1,347 @@ + + + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Distributed; +using Shouldly; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.ERPShipping; +using Win.Sfs.SettleAccount.Entities.ERPShpping; +using Win.Sfs.SettleAccount.Entities.HQExtend; +using Win.Sfs.SettleAccount.Entities.ImportMap; +using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.Shared.CacheBase; +using Win.Sfs.Shared.Filter; +using Win.Utils; + +namespace Win.Sfs.SettleAccount.HQKBExtends +{ + + /// + /// Ӧ÷ + /// + [Authorize(SettleAccountPermissions.Boms.Default)] + //[AllowAnonymous] + [Route("api/settleaccount/ErpShipping")] + public class HQKBExtendAppService : SettleAccountApplicationBase + { + private readonly IGuidGenerator _guidGenerator; + + private readonly IObjectMapper _objectMapper; + + private readonly IExcelImportAppService _excelImportService; + + + private readonly ISettleAccountBranchEfCoreRepository _repository; + + + private readonly ISettleAccountBranchEfCoreRepository _materialRepository; + + private readonly ISettleAccountBranchEfCoreRepository _importColumnMapRepository; + + private readonly ISettleAccountBranchEfCoreRepository _versionRepository; + /// + /// + /// + /// UID + /// Զmap + /// ִӿ + /// + public HQKBExtendAppService(IGuidGenerator guidGenerator, + IObjectMapper objectMapper, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ISettleAccountBranchEfCoreRepository repository, + ISettleAccountBranchEfCoreRepository versionRepository, + ISettleAccountBranchEfCoreRepository materialRepository, + ISettleAccountBranchEfCoreRepository importColumnMapRepository, + IDistributedCache cache + ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) + { + _guidGenerator = guidGenerator; + _objectMapper = objectMapper; + _repository = repository; + _excelImportService = excelImportService; + _versionRepository = versionRepository; + _materialRepository = materialRepository; + _importColumnMapRepository = importColumnMapRepository; + } + + #region 뵼 + + + + + + /// + /// 빦 + /// + /// ϴļ(ǰѾֻϴһ) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + + + public async Task HQKBExtendUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode,string factory) + { + + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var entityList = ObjectMapper.Map, List>(result); + var _versionQuery = _versionRepository.Where(p => p.Version == version ); + await _versionQuery.BatchDeleteAsync(); + var _query = _repository.Where(p => p.Version == version ); + await _query.BatchDeleteAsync(); + //var checkList = new List(); + //var _matList =await _materialRepository.GetAllAsync(GuidGenerator.Create()); + // var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(),ParentItmeCode=p.Key.ParentItemCode, ChildItemCode=p.Key.ChildItemCode }); + //foreach (var itm in _group) + //{ + // if (itm.Count > 1) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ܵ븸{0},ӱ{1}ظ", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); + // } + //} + //var _id = GuidGenerator.Create(); + //var _HQKBExtendList = new List(); + //_HQKBExtendList.Add(new HQKBExtendVersion(_id, branchId, year, period, version, customerCode,factory)); + //foreach (var itm in entityList) + //{ + // if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode)) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("ݲϺ{0}", itm.ParentItemCode), string.Empty)); + // continue; + // } + // itm.SetValue(GuidGenerator.Create(),branchId,year,period,version,_id,factory); + //} + //if (checkList.Count > 0) + //{ + // return await ExportErrorReportAsync(checkList); + //} + await _repository.GetDbContext().BulkInsertAsync(entityList); + + await _versionRepository.GetDbContext().BulkInsertAsync(new List { new HQKBExtendVersion(Guid.NewGuid(), branchId, year, period, version, customerCode, factory) }); + + //st.Stop(); + return ApplicationConsts.SuccessStr; + } + /// + /// ļ + /// + /// + /// + [HttpPost] + [Route("Export")] + + virtual public async Task ExportAsync(HQKBExtendRequestDto input) + { + IExporter _csv = new CsvExporter(); + IExporter _excel = new ExcelExporter(); + //ϰ汾ȫ + if (!string.IsNullOrEmpty(input.Version )) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version.ToString() }); + } + //else + //{ + // return new PagedResultDto(0, new List()); + //} + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + string _fileName = string.Empty; + // + + byte[] result = null; + + + + _fileName = string.Format("ERP_{0}.xlsx", Guid.NewGuid().ToString("N")); + result = await _excel.ExportAsByteArray(dtoDetails); + + + result.ShouldNotBeNull(); + + //浼ļɶ + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + #endregion + + /// + /// IDȡΨһʵ + /// + /// + /// ʵȫ + /// + /// ID + /// ʵDTO + [HttpGet] + [Route("{id}")] + + virtual public async Task GetAsync(Guid id) + { + var result = await _repository.GetAsync(id); + var dto = _objectMapper.Map(result); + return dto; + } + + + private async Task GetFromCacheAsync(Guid id) + { + var result = await _repository.GetAsync(id); + return result; + } + + + private async Task GetCountAsync(HQKBExtendRequestDto input) + { + return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + + private async Task GetCountAsync(HQKBExtendVersionRequestDto input) + { + return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + /// + /// ȡʵ + /// + /// ʵ + [HttpGet] + [Route("count")] + + virtual public async Task GetTotalCountAsync(Guid branchId) + { + return await _repository.GetCountAsync(branchId); + } + + + + /// + /// ɾʵ + /// + /// ID + /// + [HttpDelete] + [Route("{id}")] + + virtual public async Task DeleteAsync(Guid id) + { + //var entity = await GetFromCacheAsync(id); + //await Cache.DeleteAsync(id.ToString()); + await _repository.DeleteAsync(id); + } + + /// + /// IDsɾʵб + /// + /// IDs + /// Ƿִгɹ + [HttpPost] + [Route("delete")] + + virtual public async Task DeleteListAsync(List ids) + { + //foreach (var id in ids) + //{ + // var entity = await GetFromCacheAsync(id); + + //} + + return await _repository.DeleteListAsync(ids); + } + + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("list")] + + public async Task> GetListAsync(Guid parentId, HQKBExtendRequestDto input) + { + if (!string.IsNullOrEmpty(input.Version) ) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); + } + else + { + return new PagedResultDto(0,new List()); + } + 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>(entities); + return new PagedResultDto(totalCount, dtos); + } + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("listVersion")] + + public async Task> GetVersionListAsync(HQKBExtendVersionRequestDto input) + { + var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + input.SkipCount, true); + + var totalCount = await GetCountAsync(input); + var dtos = _objectMapper.Map, List>(entities); + //foreach (var itm in dtos) + //{ + // itm.Version = itm.Version + string.Format("({0})", itm.Factory); + //} + return new PagedResultDto(totalCount, dtos); + } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBSettleExtendAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBSettleExtendAppService.cs new file mode 100644 index 00000000..9b3f16f6 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/HQExtend/HQKBSettleExtendAppService.cs @@ -0,0 +1,346 @@ + + + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Distributed; +using Shouldly; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.ERPShipping; +using Win.Sfs.SettleAccount.Entities.ERPShpping; +using Win.Sfs.SettleAccount.Entities.HQExtend; +using Win.Sfs.SettleAccount.Entities.ImportMap; +using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.Shared.CacheBase; +using Win.Sfs.Shared.Filter; +using Win.Utils; + +namespace Win.Sfs.SettleAccount.HQKBExtends +{ + + /// + /// Ӧ÷ + /// + [Authorize(SettleAccountPermissions.Boms.Default)] + //[AllowAnonymous] + [Route("api/settleaccount/ErpShipping")] + public class HQKBSettleExtendAppService : SettleAccountApplicationBase + { + private readonly IGuidGenerator _guidGenerator; + + private readonly IObjectMapper _objectMapper; + + private readonly IExcelImportAppService _excelImportService; + + + private readonly ISettleAccountBranchEfCoreRepository _repository; + + + private readonly ISettleAccountBranchEfCoreRepository _materialRepository; + + private readonly ISettleAccountBranchEfCoreRepository _importColumnMapRepository; + + private readonly ISettleAccountBranchEfCoreRepository _versionRepository; + /// + /// + /// + /// UID + /// Զmap + /// ִӿ + /// + public HQKBSettleExtendAppService(IGuidGenerator guidGenerator, + IObjectMapper objectMapper, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ISettleAccountBranchEfCoreRepository repository, + ISettleAccountBranchEfCoreRepository versionRepository, + ISettleAccountBranchEfCoreRepository materialRepository, + ISettleAccountBranchEfCoreRepository importColumnMapRepository, + IDistributedCache cache + ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) + { + _guidGenerator = guidGenerator; + _objectMapper = objectMapper; + _repository = repository; + _excelImportService = excelImportService; + _versionRepository = versionRepository; + _materialRepository = materialRepository; + _importColumnMapRepository = importColumnMapRepository; + } + + #region 뵼 + + + + + /// + /// 빦 + /// + /// ϴļ(ǰѾֻϴһ) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + + + public async Task HQKBSettleExtendUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode,string factory) + { + + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var entityList = ObjectMapper.Map, List>(result); + var _versionQuery = _versionRepository.Where(p => p.Version == version ); + await _versionQuery.BatchDeleteAsync(); + var _query = _repository.Where(p => p.Version == version ); + await _query.BatchDeleteAsync(); + //var checkList = new List(); + //var _matList =await _materialRepository.GetAllAsync(GuidGenerator.Create()); + // var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(),ParentItmeCode=p.Key.ParentItemCode, ChildItemCode=p.Key.ChildItemCode }); + //foreach (var itm in _group) + //{ + // if (itm.Count > 1) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ܵ븸{0},ӱ{1}ظ", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); + // } + //} + //var _id = GuidGenerator.Create(); + //var _HQKBSettleExtendList = new List(); + //_HQKBSettleExtendList.Add(new HQKBSettleExtendVersion(_id, branchId, year, period, version, customerCode,factory)); + //foreach (var itm in entityList) + //{ + // if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode)) + // { + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("ݲϺ{0}", itm.ParentItemCode), string.Empty)); + // continue; + // } + // itm.SetValue(GuidGenerator.Create(),branchId,year,period,version,_id,factory); + //} + //if (checkList.Count > 0) + //{ + // return await ExportErrorReportAsync(checkList); + //} + await _repository.GetDbContext().BulkInsertAsync(entityList); + + await _versionRepository.GetDbContext().BulkInsertAsync(new List { new HQKBSettleExtendVersion(Guid.NewGuid(), branchId, year, period, version, customerCode, factory) }); + + //st.Stop(); + return ApplicationConsts.SuccessStr; + } + /// + /// ļ + /// + /// + /// + [HttpPost] + [Route("Export")] + + virtual public async Task ExportAsync(HQKBSettleExtendRequestDto input) + { + IExporter _csv = new CsvExporter(); + IExporter _excel = new ExcelExporter(); + //ϰ汾ȫ + if (!string.IsNullOrEmpty(input.Version )) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version.ToString() }); + } + //else + //{ + // return new PagedResultDto(0, new List()); + //} + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + string _fileName = string.Empty; + // + + byte[] result = null; + + + + _fileName = string.Format("ERP_{0}.xlsx", Guid.NewGuid().ToString("N")); + result = await _excel.ExportAsByteArray(dtoDetails); + + + result.ShouldNotBeNull(); + + //浼ļɶ + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + #endregion + + /// + /// IDȡΨһʵ + /// + /// + /// ʵȫ + /// + /// ID + /// ʵDTO + [HttpGet] + [Route("{id}")] + + virtual public async Task GetAsync(Guid id) + { + var result = await _repository.GetAsync(id); + var dto = _objectMapper.Map(result); + return dto; + } + + + private async Task GetFromCacheAsync(Guid id) + { + var result = await _repository.GetAsync(id); + return result; + } + + + private async Task GetCountAsync(HQKBSettleExtendRequestDto input) + { + return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + + private async Task GetCountAsync(HQKBSettleExtendVersionRequestDto input) + { + return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + /// + /// ȡʵ + /// + /// ʵ + [HttpGet] + [Route("count")] + + virtual public async Task GetTotalCountAsync(Guid branchId) + { + return await _repository.GetCountAsync(branchId); + } + + + + /// + /// ɾʵ + /// + /// ID + /// + [HttpDelete] + [Route("{id}")] + + virtual public async Task DeleteAsync(Guid id) + { + //var entity = await GetFromCacheAsync(id); + //await Cache.DeleteAsync(id.ToString()); + await _repository.DeleteAsync(id); + } + + /// + /// IDsɾʵб + /// + /// IDs + /// Ƿִгɹ + [HttpPost] + [Route("delete")] + + virtual public async Task DeleteListAsync(List ids) + { + //foreach (var id in ids) + //{ + // var entity = await GetFromCacheAsync(id); + + //} + + return await _repository.DeleteListAsync(ids); + } + + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("list")] + + public async Task> GetListAsync(Guid parentId, HQKBSettleExtendRequestDto input) + { + if (!string.IsNullOrEmpty(input.Version) ) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); + } + else + { + return new PagedResultDto(0,new List()); + } + 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>(entities); + return new PagedResultDto(totalCount, dtos); + } + + ///// + + /// + /// ɸѡȡʵб + /// + /// + /// :ɸѡб,,,ҳ + /// + /// + /// ʵDTOб + [HttpPost] + [Route("listVersion")] + + public async Task> GetVersionListAsync(HQKBSettleExtendVersionRequestDto input) + { + var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + input.SkipCount, true); + + var totalCount = await GetCountAsync(input); + var dtos = _objectMapper.Map, List>(entities); + //foreach (var itm in dtos) + //{ + // itm.Version = itm.Version + string.Format("({0})", itm.Factory); + //} + return new PagedResultDto(totalCount, dtos); + } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj index 696d38f5..0db67178 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj @@ -162,9 +162,5 @@ PreserveNewest - - - - diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingDetail.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingDetail.cs index 62974065..8695180f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingDetail.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingDetail.cs @@ -1,4 +1,5 @@ -using System; +using Magicodes.ExporterAndImporter.Core; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,6 +10,63 @@ namespace Win.Sfs.SettleAccount.Entities.ERPShipping { public class ERPShippingDetail : FullAuditedAggregateRootBase, ISettleAccountEntityBase { + public ERPShippingDetail(Guid id,string person, decimal cost, string billNum, string unit, decimal qty, string output, string outputCode, string input, string inputCode, decimal outputAssQty, string model, decimal outputQty, string batchNum, DateTime billDate, string flag, string erpMaterialCode, string version):base(id) + { + Person = person; + Cost = cost; + BillNum = billNum; + Unit = unit; + Qty = qty; + Output = output; + OutputCode = outputCode; + Input = input; + InputCode = inputCode; + OutputAssQty = outputAssQty; + Model = model; + OutputQty = outputQty; + BatchNum = batchNum; + BillDate = billDate; + Flag = flag; + ErpMaterialCode = erpMaterialCode; + Version = version; + } + + [ImporterHeader(Name = "保管")] + public string Person { set; get; } + [ImporterHeader(Name = "成本")] + public decimal Cost { set; get; } + [ImporterHeader(Name = "单据编号")] + public string BillNum { set; get; } + + [ImporterHeader(Name = "单位")] + public string Unit { set; get; } + + [ImporterHeader(Name = "调拨数量")] + public decimal Qty { set; get; } + [ImporterHeader(Name = "调出仓库")] + public string Output { set; get; } + [ImporterHeader(Name = "调出仓库代码")] + public string OutputCode { set; get; } + [ImporterHeader(Name = "调入仓库")] + + public string Input { set; get; } + [ImporterHeader(Name = "调入仓库代码")] + public string InputCode { set; get; } + [ImporterHeader(Name = "辅助出库关联数量")] + public decimal OutputAssQty { set; get; } + [ImporterHeader(Name = "规格型号")] + public string Model { set; get; } + [ImporterHeader(Name = "基本出库关联数量")] + public decimal OutputQty { set; get; } + [ImporterHeader(Name = "批号")] + public string BatchNum { set; get; } + [ImporterHeader(Name = "日期")] + public DateTime BillDate { set; get; } + [ImporterHeader(Name = "审核标志")] + public string Flag { get; set; } + [ImporterHeader(Name = "物料长代码")] + public string ErpMaterialCode { set; get; } + [ImporterHeader(Name = "期间")] public string Version { get; set; } } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingVersion.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingVersion.cs index 3f2dac57..1c146b10 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingVersion.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ERPShipping/ERPShippingVersion.cs @@ -7,8 +7,53 @@ using Win.Sfs.Shared.DomainBase; namespace Win.Sfs.SettleAccount.Entities.ERPShipping { - public class ERPShippingVersion : FullAuditedAggregateRootBase, ISettleAccountEntityBase + + public class ERPShippingVersion : FullAuditedAggregateRootBase { - public string Version { get; set; } + + public ERPShippingVersion() + { } + + public string Year { get; private set; } + /// + /// 期间 + /// + public string Period { get; private set; } + /// + /// 版本号 + /// + public string Version { get; private set; } + + + /// + /// 工厂 + /// + public string Factory { set; get; } + + /// + /// 客户号 + /// + public string CustomerCode { private set; get; } + + + public ERPShippingVersion( + Guid id, + Guid branchId, + string year, string period, string version, string customerCode, string factory) : base(id) + { + BranchId = branchId; + Year = year; + Period = period; + Version = version; + CustomerCode = customerCode; + Factory = factory; + + } + + } + + + + } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtend.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtend.cs new file mode 100644 index 00000000..8fe70293 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtend.cs @@ -0,0 +1,52 @@ +using Magicodes.ExporterAndImporter.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win.Sfs.Shared.DomainBase; + +namespace Win.Sfs.SettleAccount.Entities.HQExtend +{ + public class HQKBExtend: FullAuditedAggregateRootBase, ISettleAccountEntityBase + { + public HQKBExtend(string taskBillNum, string billNum, string materialDesc, string materialCode, decimal qty, decimal price, decimal amt, decimal tax, decimal taxAmt, decimal totalAmt) + { + TaskBillNum = taskBillNum; + BillNum = billNum; + MaterialDesc = materialDesc; + MaterialCode = materialCode; + Qty = qty; + Price = price; + Amt = amt; + Tax = tax; + TaxAmt = taxAmt; + TotalAmt = totalAmt; + } + + [ImporterHeader(Name = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ImporterHeader(Name = "采购申请单号")] + public string BillNum { get; set; } + [ImporterHeader(Name = "零件名称")] + public string MaterialDesc { get; set; } + [ImporterHeader(Name = "零件号")] + public string MaterialCode { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "无税单价")] + public decimal Price { get; set; } + + [ImporterHeader(Name = "无税金额")] + public decimal Amt { get; set; } + [ImporterHeader(Name = "税率")] + public decimal Tax { get; set; } + [ImporterHeader(Name = "税额合计")] + public decimal TaxAmt { get; set; } + [ImporterHeader(Name = "价税合计")] + public decimal TotalAmt { get; set; } + [ImporterHeader(Name = "版本号",IsIgnore =false)] + public string Version { get ; set ; } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtendVersion.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtendVersion.cs new file mode 100644 index 00000000..e667ce0c --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBExtendVersion.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win.Sfs.Shared.DomainBase; + +namespace Win.Sfs.SettleAccount.Entities.HQExtend +{ + public class HQKBExtendVersion : FullAuditedAggregateRootBase, ISettleAccountEntityBase + { + + + + + public HQKBExtendVersion() + { } + + public string Year { get; set; } + /// + /// 期间 + /// + public string Period { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + + /// + /// 工厂 + /// + public string Factory { set; get; } + + /// + /// 客户号 + /// + public string CustomerCode { private set; get; } + + + public HQKBExtendVersion( + Guid id, + Guid branchId, + string year, string period, string version, string customerCode, string factory) : base(id) + { + BranchId = branchId; + Year = year; + Period = period; + Version = version; + CustomerCode = customerCode; + Factory = factory; + + } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtend.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtend.cs new file mode 100644 index 00000000..7a3f40e3 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtend.cs @@ -0,0 +1,52 @@ +using Magicodes.ExporterAndImporter.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win.Sfs.Shared.DomainBase; + +namespace Win.Sfs.SettleAccount.Entities.HQExtend +{ + public class HQKBSettleExtend : FullAuditedAggregateRootBase, ISettleAccountEntityBase + { + public HQKBSettleExtend(string taskBillNum, string billNum, string materialDesc, string materialCode, decimal qty, decimal price, decimal amt, decimal tax, decimal taxAmt, decimal totalAmt) + { + TaskBillNum = taskBillNum; + BillNum = billNum; + MaterialDesc = materialDesc; + MaterialCode = materialCode; + Qty = qty; + Price = price; + Amt = amt; + Tax = tax; + TaxAmt = taxAmt; + TotalAmt = totalAmt; + } + + [ImporterHeader(Name = "试制任务单编号")] + + public string TaskBillNum { get; set; } + [ImporterHeader(Name = "采购申请单号")] + public string BillNum { get; set; } + [ImporterHeader(Name = "零件名称")] + public string MaterialDesc { get; set; } + [ImporterHeader(Name = "零件号")] + public string MaterialCode { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "无税单价")] + public decimal Price { get; set; } + + [ImporterHeader(Name = "无税金额")] + public decimal Amt { get; set; } + [ImporterHeader(Name = "税率")] + public decimal Tax { get; set; } + [ImporterHeader(Name = "税额合计")] + public decimal TaxAmt { get; set; } + [ImporterHeader(Name = "价税合计")] + public decimal TotalAmt { get; set; } + [ImporterHeader(Name = "版本号", IsIgnore = false)] + public string Version { get; set; } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtendVersion.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtendVersion.cs new file mode 100644 index 00000000..e21f237d --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/HQExtend/HQKBSettleExtendVersion.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win.Sfs.Shared.DomainBase; + +namespace Win.Sfs.SettleAccount.Entities.HQExtend +{ + public class HQKBSettleExtendVersion : FullAuditedAggregateRootBase, ISettleAccountEntityBase + { + + + + + public HQKBSettleExtendVersion() + { } + + public string Year { get; set; } + /// + /// 期间 + /// + public string Period { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + + /// + /// 工厂 + /// + public string Factory { set; get; } + + /// + /// 客户号 + /// + public string CustomerCode { private set; get; } + + + public HQKBSettleExtendVersion( + Guid id, + Guid branchId, + string year, string period, string version, string customerCode, string factory) : base(id) + { + BranchId = branchId; + Year = year; + Period = period; + Version = version; + CustomerCode = customerCode; + Factory = factory; + + } + } +}