Browse Source

更新版本

master
zhaoxinyu 4 months ago
parent
commit
61b4246dc7
  1. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs
  2. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_CAN_SA_DTO.cs
  3. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs
  4. 20
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  5. 155
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  6. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  7. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  8. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

17
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs

@ -33,6 +33,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
[Display(Name = "来源可结算单号")]
public string ParentBillNum { get; set; }
[Display(Name = "来源发票号")]
public string InvBillNum { get; set; }
[Display(Name = "是否退回单")]
public string IsReturn { get; set; }
}
public class BBAC_CAN_SA_DETAIL_DTO : EntityDto<Guid>
{

9
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_CAN_SA_DTO.cs

@ -33,6 +33,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
[Display(Name = "来源可结算单号")]
public string ParentBillNum { get; set; }
[Display(Name = "来源发票号")]
public string InvBillNum { get; set; }
[Display(Name = "是否退回单")]
public string IsReturn { get; set; }
}
public class HBPO_CAN_SA_DETAIL_DTO : EntityDto<Guid>
{

12
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs

@ -38,6 +38,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "明细记录行数")]
public string InvGroupNum { get; set; }
[Display(Name = "来源可结算单号")]
public string ParentBillNum { get; set; }
[Display(Name = "来源发票号")]
public string InvBillNum { get; set; }
[Display(Name = "是否退回单")]
public string IsReturn { get; set; }
}
public class PUB_CAN_SA_REQ_DTO : RequestInputBase

20
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -8,6 +8,7 @@ using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc;
using Omu.ValueInjecter;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using Shouldly;
@ -86,10 +87,22 @@ namespace Win.Sfs.SettleAccount.Bases
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var dtoDetails = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailExportDto>>(entities);
var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(TEntityDetailExportDto).Name;
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx";
byte[] result = null;
@ -142,6 +155,11 @@ namespace Win.Sfs.SettleAccount.Bases
var entitys = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys);
return new PagedResultDto<TEntityDto>(totalCount, dtos);
}
[UnitOfWork(false)]

155
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -188,22 +188,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_globalConfigOptions.IsSyncInvoiceQadState = true;
var invoiceGrps1 = _settleAccountDbContext.Set<INVOICE_GRP>()
.Where(t => invbillNums.Contains(t.InvbillNum) && t.State == SettleBillState.);
var grouplist=invoiceGrps1.Select(p => p.InvGroupNum).ToList();//发票分组
var invList=_settleAccountDbContext.Set<INVOICE_GRP>().Where(p => grouplist.Contains(p.InvGroupNum)).ToList();
var query =from itm in invList join itm1 in invoiceGrps1 on new { itm.InvGroupNum, itm.InvbillNum } equals new { itm1.InvGroupNum, itm1.InvbillNum }
into temp
from tm in temp.DefaultIfEmpty()
where tm == null
select itm;
var invoices = query.ToList();
if (invoices.Count > 0)
{
var invbilllist=invoices.Select(p => p.InvGroupNum).ToList();
var invs = invoiceGrps1.Where(p => invbilllist.Contains(p.InvGroupNum)).Select(p => p.InvbillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs.ToArray())}对应结算单(发票分组)有其他发票状态不在撤销状态,不能退回", "400");
}
//var grouplist=invoiceGrps1.Select(p => p.InvGroupNum).ToList();//发票分组
//var invList=_settleAccountDbContext.Set<INVOICE_GRP>().Where(p => grouplist.Contains(p.InvGroupNum)).ToList();
//var query =from itm in invList join itm1 in invoiceGrps1 on new { itm.InvGroupNum, itm.InvbillNum } equals new { itm1.InvGroupNum, itm1.InvbillNum }
// into temp
// from tm in temp.DefaultIfEmpty()
// where tm == null
// select itm;
//var invoices = query.ToList();
//if (invoices.Count > 0)
//{
// var invbilllist=invoices.Select(p => p.InvGroupNum).ToList();
// var invs = invoiceGrps1.Where(p => invbilllist.Contains(p.InvGroupNum)).Select(p => p.InvbillNum).ToList();
// throw new UserFriendlyException($"发票{string.Join(",", invs.ToArray())}对应结算单(发票分组)有其他发票状态不在撤销状态,不能退回", "400");
//}
foreach (var itm in invoiceGrps1)
{
itm.State = SettleBillState.QAD退回到已开票;
@ -2001,67 +2000,78 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return new JsonResult(new { Code = 200, Message = "退回成功" }); ;
}
//[HttpPost]
//public virtual async Task<IActionResult> RejectAsync(INVOICE_GRP_DTO p_dto)
//{
// var invgrouplist=_repository.Where(p=>p.InvGroupNum==p_dto.InvGroupNum);
// if (invgrouplist.Count(p => p.State < SettleBillState.财务已审核) == invgrouplist.Count())//所有发票分组下的放票全为财务已审核的
// {
// await RejectAsync(p_dto.InvGroupNum).ConfigureAwait(false);
// }
// else
// {
// var inv= _repository.FirstOrDefault(p => p.InvbillNum == p_dto.InvbillNum);
// if (inv == null)
// {
// return new JsonResult(new { Code = 500, Message = "发票不存在" });
// }
// }
private async Task RejectionAsync<Tmain, Tdetail>(Tmain main,List<Tdetail> details)
where Tdetail: SA_CAN_BASE, new() where Tmain : SA_CAN_BASE_MAIN, new()
{
var billNum = string.Empty;
if (main.BillNum.Substring(0,1)=="N")
{
billNum = OrderNumberGenerator.GenerateOrderNumber("N");
}
if (main.BillNum.Substring(0, 1) == "C")
{
billNum = OrderNumberGenerator.GenerateOrderNumber("C");
}
Tmain newmain = new Tmain();
newmain.InjectFrom(main);
newmain.SetId(Guid.NewGuid());
newmain.BillNum = billNum;
newmain.CreationTime = DateTime.Now;
newmain.State = SettleBillState.退;
newmain.ExtraProperties.TryAdd("ParentBillNum", main.BillNum);
newmain.ExtraProperties.TryAdd("InvBillNum", details.FirstOrDefault().InvbillNum);
newmain.ExtraProperties.TryAdd("IsReturn", "是");
var _dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
var list = details;
foreach (var item in list)
{
item.InvbillNum = billNum;
}
await _dbcontext.BulkInsertAsync(new List<Tmain>() { newmain }).ConfigureAwait(false);
await _dbcontext.BulkUpdateAsync(list).ConfigureAwait(false);
}
[HttpPost]
public virtual async Task<IActionResult> ReturnAsync(INVOICE_GRP_DTO p_dto)
{
var invgrouplist = _repository.Where(p => p.InvGroupNum == p_dto.InvGroupNum);
if (invgrouplist.Count(p => p.State < SettleBillState.) == invgrouplist.Count())//所有发票分组下的发票全为财务已审核的
{
await RejectAsync(p_dto.InvGroupNum).ConfigureAwait(false);
}
else
{
var inv = _repository.FirstOrDefault(p => p.InvbillNum == p_dto.InvbillNum);
if (inv == null)
{
return new JsonResult(new { Code = 500, Message = "发票不存在" });
}
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
switch(inv.BusinessType)
{
case EnumBusinessType.JisBBAC:
var bbaclist = await dbcontext.Set<BBAC_CAN_SA_DETAIL>().Where(p => p.InvbillNum == p_dto.InvbillNum).AsNoTracking().ToListAsync().ConfigureAwait(false);
var bbacfirst = await dbcontext.Set<BBAC_CAN_SA>().FirstOrDefaultAsync(p => p.BillNum == p_dto.InvGroupNum).ConfigureAwait(false);
await RejectionAsync<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL>(bbacfirst, bbaclist.ToList()).ConfigureAwait(false);
break;
case EnumBusinessType.JisHBPO:
var hbpolist = await dbcontext.Set<HBPO_CAN_SA_DETAIL>().Where(p => p.InvbillNum == p_dto.InvbillNum).AsNoTracking().ToListAsync().ConfigureAwait(false);
var hbpofirst = await dbcontext.Set<HBPO_CAN_SA>().FirstOrDefaultAsync(p => p.BillNum == p_dto.InvGroupNum).ConfigureAwait(false);
await RejectionAsync<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL>(hbpofirst, hbpolist.ToList()).ConfigureAwait(false);
break;
default:
var publist = await dbcontext.Set<PUB_CAN_SA_DETAIL>().Where(p => p.InvbillNum == p_dto.InvbillNum).ToListAsync().ConfigureAwait(false);
var pubfirst = await dbcontext.Set<PUB_CAN_SA>().FirstOrDefaultAsync(p => p.BillNum == p_dto.InvGroupNum).ConfigureAwait(false);
await RejectionAsync<PUB_CAN_SA, PUB_CAN_SA_DETAIL>(pubfirst, publist.ToList()).ConfigureAwait(false);
break;
}
}
// //var entities = await _invMng.GetMainListAsync(p_invGroupNum).ConfigureAwait(false);
// //var entity = entities.FirstOrDefault();
// //bool state = await _invMng.Reject(p_invGroupNum).ConfigureAwait(false);
// //if (state == true)
// //{
// // switch (entity.BusinessType)
// // {
// // case EnumBusinessType.BeiJian:
// // await _pubMng.SetNewState(p_invGroupNum).ConfigureAwait(false);
// // break;
// // case EnumBusinessType.ZhiGongJianBBAC:
// // await _pubMng.SetNewState(p_invGroupNum).ConfigureAwait(false);
// // break;
// // case EnumBusinessType.ZhiGongJianHBPO:
// // await _pubMng.SetNewState(p_invGroupNum).ConfigureAwait(false);
// // break;
// // case EnumBusinessType.YinDuJian:
// // await _pubMng.SetNewState(p_invGroupNum).ConfigureAwait(false);
// // break;
// // case EnumBusinessType.JisBBAC:
// // await _bbacMng.SetNewState(p_invGroupNum).ConfigureAwait(false);
// // break;
// // case EnumBusinessType.JisHBPO:
// // await _hbpoMng.SetNewState(p_invGroupNum).ConfigureAwait(false);
// // break;
// // }
// //}
// return new JsonResult(new { Code = 200, Message = "退回成功" }); ;
//}
return new JsonResult(new { Code = 200, Message = "退回成功" }); ;
}
@ -2115,7 +2125,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var newinv1 = result.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault();
var newinv = ls.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault();
inv.Tax = 0.13m;
inv.RealnvBillNum = newinv.RealnvBillNum;
inv.TaxDiff = newinv.PreTaxDiff;

11
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -272,10 +272,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var first = input.Filters.FirstOrDefault(p => p.Column == "BillTime");
var first = input.Filters.FirstOrDefault(p => p.Column == "BillTime");
if (first != null)
{
input.Filters.Remove(first);
@ -303,7 +300,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var entities = await _vmiBalanceSumDetailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount, true).ConfigureAwait(false);
var dtos = _maper.Map<List<VmiBalanceSumDetail>, List<VmiBalanceSumDetailDto>>(entities);
dtos = dtos.OrderByDescending(p => p.BillTime).ToList();
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.zip";
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos).ConfigureAwait(false);
result.ShouldNotBeNull();
@ -2264,7 +2261,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var datas = data.Skip((i - 1) * 1000000).Take(1000000).ToList();
var chunks = datas.ChunkBy(chunkSize);
Parallel.ForEach(chunks, async chunk =>
Parallel.ForEach(chunks, chunk =>
{
var fileName = $"{sheetName}_{i - 1}_{Guid.NewGuid()}.xlsx";
var fileinfogroup = new FileInfoGroup((fileName), $"{sheetName}_{i - 1}");
@ -2282,8 +2279,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
}
//for (var i = 0; i < count; i++)
//{
// var filelist = excelFiles.Where(p => p.Grpup == $"{sheetName}_{i}").Select(p => p.FileName).ToList();

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

@ -190,7 +190,13 @@ namespace Win.Sfs.SettleAccount
private void CreateMapBBAC_CAN_SA()
{
CreateMap<BBAC_CAN_SA, BBAC_CAN_SA_DTO>().ReverseMap();
// CreateMap<BBAC_CAN_SA, BBAC_CAN_SA_DTO>().ReverseMap();
CreateMap<BBAC_CAN_SA, BBAC_CAN_SA_DTO>()
.ForMember(dest => dest.ParentBillNum, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("ParentBillNum") == true ? src.ExtraProperties.GetOrDefault("ParentBillNum").ToString() : string.Empty))
.ForMember(dest => dest.InvBillNum, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("InvBillNum") == true ? src.ExtraProperties.GetOrDefault("InvBillNum").ToString() : string.Empty))
.ForMember(dest => dest.IsReturn, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("IsReturn") == true ? src.ExtraProperties.GetOrDefault("IsReturn").ToString() : string.Empty));
CreateMap<BBAC_CAN_SA, BBAC_CAN_SA_REQ_DTO>().ReverseMap();
}
@ -213,8 +219,15 @@ namespace Win.Sfs.SettleAccount
private void CreateMapHBPO_CAN_SA()
{
CreateMap<HBPO_CAN_SA, HBPO_CAN_SA_DTO>().ReverseMap();
CreateMap<HBPO_CAN_SA, HBPO_CAN_SA_REQ_DTO>().ReverseMap();
CreateMap<HBPO_CAN_SA, HBPO_CAN_SA_DTO>()
.ForMember(dest => dest.ParentBillNum, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("ParentBillNum") == true ? src.ExtraProperties.GetOrDefault("ParentBillNum").ToString() : string.Empty))
.ForMember(dest => dest.InvBillNum, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("InvBillNum") == true ? src.ExtraProperties.GetOrDefault("InvBillNum").ToString() : string.Empty))
.ForMember(dest => dest.IsReturn, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("IsReturn")==true? src.ExtraProperties.GetOrDefault("IsReturn").ToString() : string.Empty));
CreateMap<HBPO_CAN_SA, HBPO_CAN_SA_REQ_DTO>().ReverseMap();
}
private void CreateMapHBPO_CAN_SA_DETAIL()
@ -274,7 +287,11 @@ namespace Win.Sfs.SettleAccount
private void CreateMapPUB_CAN_SA()
{
CreateMap<PUB_CAN_SA, PUB_CAN_SA_DTO>().ReverseMap();
CreateMap<PUB_CAN_SA, PUB_CAN_SA_DTO>()
.ForMember(dest => dest.ParentBillNum, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("ParentBillNum") == true ? src.ExtraProperties.GetOrDefault("ParentBillNum").ToString() : string.Empty))
.ForMember(dest => dest.InvBillNum, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("InvBillNum") == true ? src.ExtraProperties.GetOrDefault("InvBillNum").ToString() : string.Empty))
.ForMember(dest => dest.IsReturn, opt => opt.MapFrom(src => src.ExtraProperties.ContainsKey("IsReturn") == true ? src.ExtraProperties.GetOrDefault("IsReturn").ToString() : string.Empty));
CreateMap<PUB_CAN_SA, PUB_CAN_SA_REQ_DTO>().ReverseMap();
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

@ -43,6 +43,8 @@ namespace Win.Sfs.SettleAccount
退 = 13,
[Description("提交QAD退回到已开票")]
QAD退回到已开票 = 14,
[Description("已退回")]
退 = 15,

Loading…
Cancel
Save