Browse Source

提交

master
学 赵 2 months ago
parent
commit
912f28f1c3
  1. 16
      code/src/Modules/BaseService/BaseService.Host/BaseServiceHostModule.cs
  2. 49
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  4. 273
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  5. 549
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs
  6. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

16
code/src/Modules/BaseService/BaseService.Host/BaseServiceHostModule.cs

@ -1,4 +1,4 @@
using BaseService.EntityFrameworkCore; using BaseService.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
@ -46,7 +46,7 @@ namespace BaseService
typeof(AbpPermissionManagementHttpApiModule), typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpTenantManagementHttpApiModule), typeof(AbpTenantManagementHttpApiModule),
typeof(AbpIdentityHttpApiModule), typeof(AbpIdentityHttpApiModule),
// typeof(BaseDataHttpApiModule), //typeof(BaseDataHttpApiModule),
//typeof(BaseDataApplicationContractsModule), //typeof(BaseDataApplicationContractsModule),
//typeof(SettleAccountHttpApiModule), //typeof(SettleAccountHttpApiModule),
typeof(AbpAspNetCoreSerilogModule) typeof(AbpAspNetCoreSerilogModule)
@ -101,9 +101,7 @@ namespace BaseService
context.Services.Configure<IdentityOptions>(options => context.Services.Configure<IdentityOptions>(options =>
{ {
options.User.RequireUniqueEmail = true; options.User.RequireUniqueEmail = true;
//options.Lockout.AllowedForNewUsers = true; options.Lockout.AllowedForNewUsers = true;
//options.Lockout.MaxFailedAccessAttempts = 2;
options.Password.RequireDigit = false; options.Password.RequireDigit = false;
options.Password.RequireLowercase = false; options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false; options.Password.RequireNonAlphanumeric = false;
@ -217,8 +215,9 @@ namespace BaseService
.ConventionalControllers .ConventionalControllers
.Create(typeof(BaseServiceApplicationModule).Assembly, opts .Create(typeof(BaseServiceApplicationModule).Assembly, opts
=> =>
{ opts.RootPath = "base"; }) {
; opts.RootPath = "base";
});
}); });
} }
@ -232,7 +231,6 @@ namespace BaseService
app.UseCors(DefaultCorsPolicyName); app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication(); app.UseAuthentication();
app.UseMultiTenancy(); app.UseMultiTenancy();
app.Use(async (ctx, next) => app.Use(async (ctx, next) =>
{ {
var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>(); var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
@ -255,11 +253,9 @@ namespace BaseService
{ {
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API");
}); });
app.UseAuditing(); app.UseAuditing();
app.UseAbpSerilogEnrichers(); app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();
AsyncHelper.RunSync(async () => AsyncHelper.RunSync(async () =>
{ {
using (var scope = context.ServiceProvider.CreateScope()) using (var scope = context.ServiceProvider.CreateScope())

49
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs

@ -833,6 +833,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "状态")] [Display(Name = "状态")]
public string Extend1 { get; set; } public string Extend1 { get; set; }
[Display(Name = "扩展")]
public string Extend2 { get; set; }
} }
@ -863,6 +865,53 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "结算零件号")] [Display(Name = "结算零件号")]
public string SettleLU { get; set; } public string SettleLU { get; set; }
[Display(Name = "可结算数量")]
public string SettleQty { get; set; }
/// <summary>
///可结算零件号
/// </summary>
[Display(Name = "不结算零件号")]
public string NotSettleLU { get; set; }
[Display(Name = "不可结数量")]
public string Qty { get; set; }
}
public class INVOICE_NOT_SETTLE_EXT_DTO1
{
[Display(Name = "金税发票")]
public string RealInvBillNum { get; set; }
[Display(Name = "发票日期")]
public DateTime? InvDate { set; get; }
[Display(Name = "发票号")]
public string InvBillNum { get; set; }
/// <summary>
///发票分组号
/// </summary>
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
/// <summary>
///结算分组号
/// </summary>
[Display(Name = "结算分组号")]
public string SettleGroupNum { get; set; }
/// <summary>
///可结算零件号
/// </summary>
[Display(Name = "结算零件号")]
public string SettleLU { get; set; }
[Display(Name = "SA号")]
public string SA { get; set; }
[Display(Name = "可结算数量")] [Display(Name = "可结算数量")]
public string SettleQty { get; set; } public string SettleQty { get; set; }
/// <summary> /// <summary>

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -87,7 +87,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost] [HttpPost]
public async Task<IActionResult> GenerateInvoice([FromBody] string invbillNum) public async Task<IActionResult> GenerateInvoice([FromBody] string invbillNum)
{ {
var main = await _bbacMng.GetMainAsync(invbillNum).ConfigureAwait(false); var main = await _bbacMng.GetMainAsync(invbillNum).ConfigureAwait(false);
if (main != null) if (main != null)
{ {

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

@ -1201,6 +1201,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);//不可结 var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);//不可结
var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);//调整数据 var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);//调整数据
var adjdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(adjs);//调整数据DTO var adjdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(adjs);//调整数据DTO
var notquery = from itm in sdtos var notquery = from itm in sdtos
@ -1216,6 +1220,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
LU = itm.LU, LU = itm.LU,
Qty = itm.Qty, Qty = itm.Qty,
Extend1 = itm.Extend1, Extend1 = itm.Extend1,
Extend2 = itm.Extend2
}; };
var mquery = from itm in mdtos var mquery = from itm in mdtos
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
@ -1437,89 +1443,184 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
foreach (var itm in entities) foreach (var itm in entities)
{ {
var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); if (first.BusinessType == EnumBusinessType.JisBBAC && first.InvGroupNum.Substring(0, 1) == "N")
var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); {
var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList();
var lsC = nolist.Where(p => p.Extend1 == "可结算") var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList();
.GroupBy(p => new var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList();
var lsC = nolist.Where(p => p.Extend1 == "可结算")
.GroupBy(p => new
{
p.LU,
p.RealInvBillNum,
p.InvDate,
p.InvBillNum,
p.InvGroupNum,
p.Extend2
}).Select(p => new INVOICE_NOT_SETTLE_DTO()
{
LU = p.Key.LU,
RealInvBillNum = p.Key.RealInvBillNum,
InvDate = p.Key.InvDate,
InvBillNum = p.Key.InvBillNum,
InvGroupNum = p.Key.InvGroupNum,
Extend2 = p.Key.Extend2,
Qty = p.Sum(itm => itm.Qty)
}).ToList();
var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList()
.GroupBy(p => new
{
p.LU,
p.RealInvBillNum,
p.InvDate,
p.InvBillNum,
p.InvGroupNum,
}).Select(p => new INVOICE_NOT_SETTLE_DTO()
{
LU = p.Key.LU,
RealInvBillNum = p.Key.RealInvBillNum,
InvDate = p.Key.InvDate,
InvBillNum = p.Key.InvBillNum,
InvGroupNum = p.Key.InvGroupNum,
Qty = p.Sum(itm => itm.Qty)
}).ToList();
var lineC = lsC.Count;
var lineN = lsN.Count;
List<INVOICE_NOT_SETTLE_EXT_DTO1> ls = new List<INVOICE_NOT_SETTLE_EXT_DTO1>();
for (int i = 0; i < 10000; i++)
{ {
p.LU, INVOICE_NOT_SETTLE_EXT_DTO1 invnot = new INVOICE_NOT_SETTLE_EXT_DTO1();
p.RealInvBillNum, invnot.RealInvBillNum = string.Empty;
p.InvDate, invnot.InvDate = null;
p.InvBillNum, invnot.InvBillNum = string.Empty;
p.InvGroupNum, invnot.InvGroupNum = string.Empty;
}).Select(p => new INVOICE_NOT_SETTLE_DTO() invnot.SettleGroupNum = string.Empty;
invnot.SettleLU = string.Empty;
invnot.SA = string.Empty;
invnot.SettleQty = null;
invnot.NotSettleLU = string.Empty;
invnot.Qty = string.Empty;
ls.Add(invnot);
}
var entity = nolist.FirstOrDefault();
var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList();
for (int i = 0; i < lineC; i++)//更新可结信息
{ {
LU = p.Key.LU, ls[i].RealInvBillNum = entity.RealInvBillNum;
RealInvBillNum = p.Key.RealInvBillNum, ls[i].InvDate = entity.InvDate;
InvDate = p.Key.InvDate, ls[i].InvBillNum = entity.InvBillNum;
InvBillNum = p.Key.InvBillNum, ls[i].InvGroupNum = entity.InvGroupNum;
InvGroupNum = p.Key.InvGroupNum, ls[i].SA = lsC[i].Extend2;
Qty = p.Sum(itm => itm.Qty) ls[i].SettleLU = lsC[i].LU;
ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString();
}).ToList(); }
var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() for (int i = 0; i < lineN; i++)//更新不可结信息
.GroupBy(p => new {
{ ls[i].RealInvBillNum = entity.RealInvBillNum;
p.LU, ls[i].InvDate = entity.InvDate;
p.RealInvBillNum, ls[i].InvBillNum = entity.InvBillNum;
p.InvDate, ls[i].InvGroupNum = entity.InvGroupNum;
p.InvBillNum, // ls[i].SettleGroupNum = entity.SettleGroupNum;
p.InvGroupNum, ls[i].NotSettleLU = lsN[i].LU;
}).Select(p => new INVOICE_NOT_SETTLE_DTO() ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString();
{ }
LU = p.Key.LU, for (int i = 0; i < disList.Count; i++)//更新结算分组
RealInvBillNum = p.Key.RealInvBillNum, {
InvDate = p.Key.InvDate, ls[i].SettleGroupNum = disList[i];
InvBillNum = p.Key.InvBillNum, }
InvGroupNum = p.Key.InvGroupNum, _excel.Append(ls, "结算分组零件" + itm.InvbillNum);
Qty = p.Sum(itm => itm.Qty) _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet();
}).ToList();
var lineC = lsC.Count;
var lineN = lsN.Count;
List<INVOICE_NOT_SETTLE_EXT_DTO> ls = new List<INVOICE_NOT_SETTLE_EXT_DTO>();
for (int i = 0; i < 10000; i++)
{
INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO();
invnot.RealInvBillNum = string.Empty;
invnot.InvDate = null;
invnot.InvBillNum = string.Empty;
invnot.InvGroupNum = string.Empty;
invnot.SettleGroupNum = string.Empty;
invnot.SettleLU = string.Empty;
invnot.SettleQty = null;
invnot.NotSettleLU = string.Empty;
invnot.Qty = string.Empty;
ls.Add(invnot);
}
var entity = nolist.FirstOrDefault();
var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList();
for (int i = 0; i < lineC; i++)//更新可结信息
{
ls[i].RealInvBillNum = entity.RealInvBillNum;
ls[i].InvDate = entity.InvDate;
ls[i].InvBillNum = entity.InvBillNum;
ls[i].InvGroupNum = entity.InvGroupNum;
// ls[i].SettleGroupNum = entity.SettleGroupNum;
ls[i].SettleLU = lsC[i].LU;
ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString();
}
for (int i = 0; i < lineN; i++)//更新不可结信息
{
ls[i].RealInvBillNum = entity.RealInvBillNum;
ls[i].InvDate = entity.InvDate;
ls[i].InvBillNum = entity.InvBillNum;
ls[i].InvGroupNum = entity.InvGroupNum;
// ls[i].SettleGroupNum = entity.SettleGroupNum;
ls[i].NotSettleLU = lsN[i].LU;
ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString();
} }
for (int i = 0; i < disList.Count; i++)//更新结算分组 else
{ {
ls[i].SettleGroupNum = disList[i]; var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList();
var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList();
var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList();
var lsC = nolist.Where(p => p.Extend1 == "可结算")
.GroupBy(p => new
{
p.LU,
p.RealInvBillNum,
p.InvDate,
p.InvBillNum,
p.InvGroupNum,
}).Select(p => new INVOICE_NOT_SETTLE_DTO()
{
LU = p.Key.LU,
RealInvBillNum = p.Key.RealInvBillNum,
InvDate = p.Key.InvDate,
InvBillNum = p.Key.InvBillNum,
InvGroupNum = p.Key.InvGroupNum,
Qty = p.Sum(itm => itm.Qty)
}).ToList();
var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList()
.GroupBy(p => new
{
p.LU,
p.RealInvBillNum,
p.InvDate,
p.InvBillNum,
p.InvGroupNum,
}).Select(p => new INVOICE_NOT_SETTLE_DTO()
{
LU = p.Key.LU,
RealInvBillNum = p.Key.RealInvBillNum,
InvDate = p.Key.InvDate,
InvBillNum = p.Key.InvBillNum,
InvGroupNum = p.Key.InvGroupNum,
Qty = p.Sum(itm => itm.Qty)
}).ToList();
var lineC = lsC.Count;
var lineN = lsN.Count;
List<INVOICE_NOT_SETTLE_EXT_DTO> ls = new List<INVOICE_NOT_SETTLE_EXT_DTO>();
for (int i = 0; i < 10000; i++)
{
INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO();
invnot.RealInvBillNum = string.Empty;
invnot.InvDate = null;
invnot.InvBillNum = string.Empty;
invnot.InvGroupNum = string.Empty;
invnot.SettleGroupNum = string.Empty;
invnot.SettleLU = string.Empty;
invnot.SettleQty = null;
invnot.NotSettleLU = string.Empty;
invnot.Qty = string.Empty;
ls.Add(invnot);
}
var entity = nolist.FirstOrDefault();
var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList();
for (int i = 0; i < lineC; i++)//更新可结信息
{
ls[i].RealInvBillNum = entity.RealInvBillNum;
ls[i].InvDate = entity.InvDate;
ls[i].InvBillNum = entity.InvBillNum;
ls[i].InvGroupNum = entity.InvGroupNum;
//ls[i].SA = bbac.FirstOrDefault(p => p.InvbillNum == entity.InvBillNum && p.LU == lsC[i].LU).Extend1;
// ls[i].SettleGroupNum = entity.SettleGroupNum;
ls[i].SettleLU = lsC[i].LU;
ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString();
}
for (int i = 0; i < lineN; i++)//更新不可结信息
{
ls[i].RealInvBillNum = entity.RealInvBillNum;
ls[i].InvDate = entity.InvDate;
ls[i].InvBillNum = entity.InvBillNum;
ls[i].InvGroupNum = entity.InvGroupNum;
// ls[i].SettleGroupNum = entity.SettleGroupNum;
ls[i].NotSettleLU = lsN[i].LU;
ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString();
}
for (int i = 0; i < disList.Count; i++)//更新结算分组
{
ls[i].SettleGroupNum = disList[i];
}
_excel.Append(ls, "结算分组零件" + itm.InvbillNum);
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet();
} }
_excel.Append(ls, "结算分组零件" + itm.InvbillNum);
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet();
} }
} }
else//其他业务发票调整数据 else//其他业务发票调整数据
@ -1548,9 +1649,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
var entities = await _invMng.GetMainListAsync(p_invGroupNum).ConfigureAwait(false); var entities = await _invMng.GetMainListAsync(p_invGroupNum).ConfigureAwait(false);
var entity = entities.FirstOrDefault(); var entity = entities.FirstOrDefault();
bool state = await _invMng.Reject(p_invGroupNum).ConfigureAwait(false); bool state = await _invMng.Reject(p_invGroupNum).ConfigureAwait(false);
if (state == true) if (state == true)
{ {
@ -1606,7 +1704,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
newmain.ExtraProperties.TryAdd("InvBillNum", details.FirstOrDefault().InvbillNum); newmain.ExtraProperties.TryAdd("InvBillNum", details.FirstOrDefault().InvbillNum);
newmain.ExtraProperties.TryAdd("IsReturn", "是"); newmain.ExtraProperties.TryAdd("IsReturn", "是");
var _dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false); var _dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
foreach (var item in details) foreach (var item in details)
{ {
item.BillNum = billNum; item.BillNum = billNum;
@ -1614,11 +1711,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
await _dbcontext.BulkInsertAsync(new List<Tmain>() { newmain }).ConfigureAwait(false); await _dbcontext.BulkInsertAsync(new List<Tmain>() { newmain }).ConfigureAwait(false);
await _dbcontext.BulkUpdateAsync(details).ConfigureAwait(false); await _dbcontext.BulkUpdateAsync(details).ConfigureAwait(false);
} }
[UnitOfWork(false)] [UnitOfWork(false)]
[HttpPost] [HttpPost]
public virtual async Task<IActionResult> ReturnAsync(INVOICE_GRP_DTO p_dto) public virtual async Task<IActionResult> ReturnAsync(INVOICE_GRP_DTO p_dto)
@ -1660,8 +1753,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var detial=dbcontext.Set<INVOICE_WAIT_DETAIL>().Where(p => p.InvbillNum == p_dto.InvbillNum).ToList(); var detial=dbcontext.Set<INVOICE_WAIT_DETAIL>().Where(p => p.InvbillNum == p_dto.InvbillNum).ToList();
var notsettle=dbcontext.Set<INVOICE_NOT_SETTLE>().Where(p => p.InvBillNum == p_dto.InvbillNum).ToList(); var notsettle=dbcontext.Set<INVOICE_NOT_SETTLE>().Where(p => p.InvBillNum == p_dto.InvbillNum).ToList();
var detialext = dbcontext.Set<INVOICE_DETAIL_EXT>().Where(p => p.InvbillNum == p_dto.InvbillNum).ToList(); var detialext = dbcontext.Set<INVOICE_DETAIL_EXT>().Where(p => p.InvbillNum == p_dto.InvbillNum).ToList();
dbcontext.BulkDelete(invList); dbcontext.BulkDelete(invList);
dbcontext.BulkDelete(invgourp); dbcontext.BulkDelete(invgourp);
dbcontext.BulkDelete(detial); dbcontext.BulkDelete(detial);
@ -1670,10 +1761,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
dbcontext.BulkDelete(detialext); dbcontext.BulkDelete(detialext);
} }
} }
return new JsonResult(new { Code = 200, Message = "退回成功" }); ; return new JsonResult(new { Code = 200, Message = "退回成功" }); ;
} }
@ -1715,13 +1803,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
inv.TaxDiff = newinv.PreTaxDiff; inv.TaxDiff = newinv.PreTaxDiff;
inv.CreationTime = newinv1.InvoiceDate; inv.CreationTime = newinv1.InvoiceDate;
inv.FileName = newinv1.FileName; inv.FileName = newinv1.FileName;
} }
await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false); await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false);
await _repository.DbContext.BulkUpdateAsync(invdetail).ConfigureAwait(false); await _repository.DbContext.BulkUpdateAsync(invdetail).ConfigureAwait(false);
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
} }
} }

549
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs

@ -671,6 +671,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
foreach (var inv in invList) foreach (var inv in invList)
{ {
var partlist = inv.Parts; var partlist = inv.Parts;
if (partlist.Count > 0) if (partlist.Count > 0)
{ {
var query = from itm in partlist var query = from itm in partlist
@ -719,282 +723,221 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
groupList.AddRange(mapList); groupList.AddRange(mapList);
} }
var innotls = new List<INVOICE_NOT_SETTLE>(); var innotls = new List<INVOICE_NOT_SETTLE>();
var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
foreach (var sitm in sq)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: sitm.GroupNum,
lU: sitm.LU,
lU1: sitm.LU,
extend1: "可结算",
extend2: string.Empty,
qty: sitm.Qty,
p_invbillnum: inv.InvBillNum
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
#region 发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); //if (partlist is List<BBAC_CAN_SA_DETAIL>)
foreach (var detail in detailDtos) //{
{ var partlist1 = partlist as List<BBAC_CAN_SA_DETAIL>;
_entityDetailList.Add( var sq = partlist1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum})
new INVOICE_WAIT_DETAIL( .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
guid: GuidGenerator.Create(), foreach (var sitm in sq)
version: p_version, {
invbillNum: inv.InvBillNum, innotls.Add(new INVOICE_NOT_SETTLE(
invGroupNum: p_InvGroupNum, guid: GuidGenerator.Create(),
lU: detail.LU, version: p_version,
qty: detail.Qty, invGroupNum: p_InvGroupNum,
bussiessType: businessType, settleGroupNum: sitm.GroupNum,
amt: detail.Amt, lU: sitm.LU,
pRICE: detail.Price, lU1: sitm.LU,
extend1: detail.ContactDocID, extend1: "可结算",
extend2: string.Empty, extend2: string.Empty,
beginDate: detail.BeginDate, qty: sitm.Qty,
endDate: detail.EndDate, p_invbillnum: inv.InvBillNum
partcode: detail.PartCode ));
)); }
} if (innotls.Count > 0)
if (_entityDetailList.Count > 0) {
{ notDetialList.AddRange(innotls);
detailList.AddRange(_entityDetailList); }
}
#endregion #region 发票明细
#region 发票 List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
var invbill = new INVOICE_GRP foreach (var detail in detailDtos)
( {
guid: GuidGenerator.Create(), _entityDetailList.Add(
realnvBillNum: string.Empty, new INVOICE_WAIT_DETAIL(
invbillNum: inv.InvBillNum, guid: GuidGenerator.Create(),
amt: amt, version: p_version,
taxAmt: txtAmt, invbillNum: inv.InvBillNum,
fileName: string.Empty, invGroupNum: p_InvGroupNum,
businessType: businessType, lU: detail.LU,
invGroupNum: p_InvGroupNum, qty: detail.Qty,
state: SettleBillState., bussiessType: businessType,
invoiceBillState: InvoiceBillState., amt: detail.Amt,
tax: 0.13m, pRICE: detail.Price,
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, extend1: detail.ContactDocID,
preTaxDiff: 0, extend2: string.Empty,
taxDiff: 0, beginDate: detail.BeginDate,
clientCode: string.Empty, endDate: detail.EndDate,
realAmt: realAmt partcode: detail.PartCode
); ));
string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; }
string clientCode = string.Empty; if (_entityDetailList.Count > 0)
switch (site) {
{ detailList.AddRange(_entityDetailList);
case "1040": }
clientCode = "C001"; #endregion
break; #region 发票
case "1046": var invbill = new INVOICE_GRP
clientCode = "C171"; (
break; guid: GuidGenerator.Create(),
default: realnvBillNum: string.Empty,
clientCode = "C004"; invbillNum: inv.InvBillNum,
break; amt: amt,
} taxAmt: txtAmt,
invbill.ClientCode = clientCode; fileName: string.Empty,
invbill.Site = dtos.FirstOrDefault().Site; businessType: businessType,
invbill.CreationTime = DateTime.MinValue; invGroupNum: p_InvGroupNum,
invbill.LastModificationTime = DateTime.Now; state: SettleBillState.,
invlist.Add(invbill); invoiceBillState: InvoiceBillState.,
#endregion tax: 0.13m,
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: realAmt
);
string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site;
string clientCode = string.Empty;
switch (site)
{
case "1040":
clientCode = "C001";
break;
case "1046":
clientCode = "C171";
break;
default:
clientCode = "C004";
break;
}
invbill.ClientCode = clientCode;
invbill.Site = dtos.FirstOrDefault().Site;
invbill.CreationTime = DateTime.MinValue;
invbill.LastModificationTime = DateTime.Now;
invlist.Add(invbill);
#endregion
//}
//else
//{
// var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
// .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
// foreach (var sitm in sq)
// {
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: p_version,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: sitm.GroupNum,
// lU: sitm.LU,
// lU1: sitm.LU,
// extend1: "可结算",
// extend2: string.Empty,
// qty: sitm.Qty,
// p_invbillnum: inv.InvBillNum
// ));
// }
// if (innotls.Count > 0)
// {
// notDetialList.AddRange(innotls);
// }
// #region 发票明细
// List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
// foreach (var detail in detailDtos)
// {
// _entityDetailList.Add(
// new INVOICE_WAIT_DETAIL(
// guid: GuidGenerator.Create(),
// version: p_version,
// invbillNum: inv.InvBillNum,
// invGroupNum: p_InvGroupNum,
// lU: detail.LU,
// qty: detail.Qty,
// bussiessType: businessType,
// amt: detail.Amt,
// pRICE: detail.Price,
// extend1: detail.ContactDocID,
// extend2: string.Empty,
// beginDate: detail.BeginDate,
// endDate: detail.EndDate,
// partcode: detail.PartCode
// ));
// }
// if (_entityDetailList.Count > 0)
// {
// detailList.AddRange(_entityDetailList);
// }
// #endregion
// #region 发票
// var invbill = new INVOICE_GRP
// (
// guid: GuidGenerator.Create(),
// realnvBillNum: string.Empty,
// invbillNum: inv.InvBillNum,
// amt: amt,
// taxAmt: txtAmt,
// fileName: string.Empty,
// businessType: businessType,
// invGroupNum: p_InvGroupNum,
// state: SettleBillState.已开票,
// invoiceBillState: InvoiceBillState.正常,
// tax: 0.13m,
// parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
// preTaxDiff: 0,
// taxDiff: 0,
// clientCode: string.Empty,
// realAmt: realAmt
// );
// string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site;
// string clientCode = string.Empty;
// switch (site)
// {
// case "1040":
// clientCode = "C001";
// break;
// case "1046":
// clientCode = "C171";
// break;
// default:
// clientCode = "C004";
// break;
// }
// invbill.ClientCode = clientCode;
// invbill.Site = dtos.FirstOrDefault().Site;
// invbill.CreationTime = DateTime.MinValue;
// invbill.LastModificationTime = DateTime.Now;
// invlist.Add(invbill);
// #endregion
//}
} }
} }
} _dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList);
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); _dbcontext.BulkInsert(detailList);
_invls= GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
//smalllist = smalllist.OrderBy(p => p.Amt).ToList();
//var gener1 = new InvoiceGeneratorDiff();
//gener1.GenerateInvoices(smalllist);
//var invList1 = gener1.Invoices;
//foreach (var inv in invList1)//小于1000W的开票
//{
// var partlist = inv.Parts;
// var query = from part in p_list
// join part1 in partlist on
// new { part.InvGroupNum, part.PartCode, part.LU, part.Price } equals new { part1.InvGroupNum, part1.PartCode, part1.LU, part1.Price }
// select part;
// var entityList = query.ToList();
// foreach (var entity in entityList)
// {
// entity.InvbillNum = inv.InvBillNum;
// }
// salist.AddRange(entityList); if (adjlist.Count > 0)
{
// if (partlist.Count > 0) _dbcontext.BulkInsert(adjlist);
// { }
// decimal amt = partlist.Sum(k => k.Amt);//金额 if (notDetialList.Count > 0)
// decimal txtAmt = partlist.Sum(k => k.TaxAmt);//税后金额 {
// decimal realAmt = partlist.Sum(k => k.Tax);//税额 _dbcontext.BulkInsert(notDetialList);
}
// var invoicegroupls = entityList.Select(p => p.GroupNum); _invls = invlist.Select(p => p.InvbillNum).ToList();
// var mapList = new List<INVOICE_MAP_GROUP>();
// foreach (var groupnum in invoicegroupls)
// {
// mapList.Add(new INVOICE_MAP_GROUP(
// guid: GuidGenerator.Create(),
// version: p_version,
// invbillNum: inv.InvBillNum,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: groupnum,
// amt: 0,
// extend1: string.Empty,
// extend2: string.Empty
// )
// );
// }
// if (mapList.Count > 0)
// {
// groupList.AddRange(mapList);
// }
// var innotls = new List<INVOICE_NOT_SETTLE>();
// var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
// .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
// foreach (var sitm in sq)
// {
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: p_version,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: sitm.GroupNum,
// lU: sitm.LU,
// lU1: sitm.LU,
// extend1: "可结算",
// extend2: string.Empty,
// qty: sitm.Qty,
// p_invbillnum: sitm.InvBillNum
// ));
// }
// if (innotls.Count > 0)
// {
// notDetialList.AddRange(innotls);
// }
// List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
// foreach (var detail in partlist)
// {
// _entityDetailList.Add(
// new INVOICE_WAIT_DETAIL(
// guid: GuidGenerator.Create(),
// version: p_version,
// invbillNum: inv.InvBillNum,
// invGroupNum: p_InvGroupNum,
// lU: detail.LU,
// qty: detail.Qty,
// bussiessType: businessType,
// amt: detail.Amt,
// pRICE: detail.Price,
// extend1: detail.ContactDocID,
// extend2: string.Empty,
// beginDate: detail.BeginDate.Value,
// endDate: detail.EndDate.Value,
// partcode: detail.PartCode
// ));
// }
// if (_entityDetailList.Count > 0)
// {
// detailList.AddRange(_entityDetailList);
// }
// var invbill = new INVOICE_GRP
// (
// guid: GuidGenerator.Create(),
// realnvBillNum: string.Empty,
// invbillNum: inv.InvBillNum,
// amt: amt,
// taxAmt: txtAmt,
// fileName: string.Empty,
// businessType: businessType,
// invGroupNum: p_InvGroupNum,
// state: SettleBillState.已开票,
// invoiceBillState: InvoiceBillState.正常,
// tax: 0.13m,
// parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
// preTaxDiff: 0,
// taxDiff: 0,
// clientCode: string.Empty,
// realAmt: realAmt
// );
// string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site;
// string clientCode = string.Empty;
// switch (site)
// {
// case "1040":
// clientCode = "C001";
// break;
// case "1046":
// clientCode = "C171";
// break;
// default:
// clientCode = "C004";
// break;
// }
// invbill.ClientCode = clientCode;
// invbill.Site = dtos.FirstOrDefault().Site;
// invbill.CreationTime = DateTime.MinValue;
// invbill.LastModificationTime = DateTime.Now;
// invlist.Add(invbill);
// }
//}
//if (salist.Count > 0) }
//{ if (smalllist.Count > 0)
// _dbcontext.BulkUpdate(salist); {
// var detailext = salist.GroupBy(p => new { p.InvbillNum, p.InvGroupNum, p.PartCode, p.LU, p.Price, p.ErpLoc, p.BusinessType }) smalllist = smalllist.OrderBy(p => p.Amt).ToList();
// .Select(p => new INVOICE_DETAIL_EXT _invls = GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
// { }
// Version = p_version,
// InvbillNum = p.Key.InvbillNum,
// InvGroupNum = p.Key.InvGroupNum,
// PartCode = p.Key.PartCode,
// PRICE = p.Key.Price,
// ErpLoc = p.Key.ErpLoc,
// Qty = p.Sum(k => k.Qty),
// BussiessType = p.Key.BusinessType,
// Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前
// LU = p.Key.LU
// }
// ).ToList();
// foreach (var itm in detailext)
// {
// itm.SetId(GuidGenerator.Create());
// itm.CreationTime = DateTime.Now;
// }
// _dbcontext.BulkInsert(detailext);
//}
//_dbcontext.BulkInsert(invlist);
//_dbcontext.BulkInsert(groupList);
//_dbcontext.BulkInsert(detailList);
//if (adjlist.Count > 0)
//{
// _dbcontext.BulkInsert(adjlist);
//}
//if (notDetialList.Count > 0)
//{
// _dbcontext.BulkInsert(notDetialList);
//}
//_invls = invlist.Select(p => p.InvbillNum).ToList();
} }
return _invls; return _invls;
} }
@ -1058,26 +1001,64 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
groupList.AddRange(mapList); groupList.AddRange(mapList);
} }
var innotls = new List<INVOICE_NOT_SETTLE>(); var innotls = new List<INVOICE_NOT_SETTLE>();
var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
foreach (var sitm in sq)
if (entityList is List<BBAC_CAN_SA_DETAIL>)
{ {
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version, var entityList1 = entityList as List<BBAC_CAN_SA_DETAIL>;
invGroupNum: p_InvGroupNum,
settleGroupNum: sitm.GroupNum,
lU: sitm.LU, var sq = entityList1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum,p.ContractDocID })
lU1: sitm.LU, .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum,SA=p.Key.ContractDocID });
extend1: "可结算", foreach (var sitm in sq)
extend2: string.Empty, {
qty: sitm.Qty, innotls.Add(new INVOICE_NOT_SETTLE(
p_invbillnum: sitm.InvBillNum guid: GuidGenerator.Create(),
)); version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: sitm.GroupNum,
lU: sitm.LU,
lU1: sitm.LU,
extend1: "可结算",
extend2: sitm.SA,
qty: sitm.Qty,
p_invbillnum: sitm.InvBillNum
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
} }
if (innotls.Count > 0) else
{ {
notDetialList.AddRange(innotls); var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
foreach (var sitm in sq)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: sitm.GroupNum,
lU: sitm.LU,
lU1: sitm.LU,
extend1: "可结算",
extend2: string.Empty,
qty: sitm.Qty,
p_invbillnum: sitm.InvBillNum
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
} }

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

@ -263,6 +263,7 @@ namespace Win.Sfs.SettleAccount
private void CreateMapINVOICE_NOT_SETTLE() private void CreateMapINVOICE_NOT_SETTLE()
{ {
CreateMap<INVOICE_NOT_SETTLE, INVOICE_NOT_SETTLE_DTO>().ReverseMap(); CreateMap<INVOICE_NOT_SETTLE, INVOICE_NOT_SETTLE_DTO>().ReverseMap();
CreateMap<INVOICE_NOT_SETTLE, INVOICE_NOT_SETTLE_REQ_DTO>().ReverseMap(); CreateMap<INVOICE_NOT_SETTLE, INVOICE_NOT_SETTLE_REQ_DTO>().ReverseMap();

Loading…
Cancel
Save