Browse Source

Merge branch 'master' of http://dev.ccwin-in.com:3000/BoXu.Zheng/BeiJinSettleAccount

master
wanggang 1 year ago
parent
commit
74a816d4cb
  1. 112
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  3. 117
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  4. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
  5. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  6. 32
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
  7. 53
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  8. 54
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  9. 31
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
  10. 344
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  11. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
  12. 49
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  13. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

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

@ -242,13 +242,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public List<INVOICE_WAIT_DETAIL_BBAC_DTO> INVOICE_WAIT_DETAIL_BBAC { get; set; } public List<INVOICE_WAIT_DETAIL_BBAC_DTO> INVOICE_WAIT_DETAIL_BBAC { get; set; }
/// <summary>
/// 发票明细备件
/// </summary>
public List<INVOICE_WAIT_DETAIL_BJ_DTO> INVOICE_WAIT_DETAIL_BJ { get; set; } public List<INVOICE_WAIT_DETAIL_BJ_DTO> INVOICE_WAIT_DETAIL_BJ { get; set; }
/// <summary> /// <summary>
/// 发票和结算分组对应关系 /// 发票和结算分组对应关系
/// </summary> /// </summary>
public List<INVOICE_MAP_GROUP_DTO> INVOICE_MAP_GROUP { get; set; } public List<INVOICE_MAP_GROUP_DTO> INVOICE_MAP_GROUP { get; set; }
/// <summary>
/// 买单发票和结算分组对应关系
/// </summary>
public List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO> MAIDAN_HBPO_INVOICE_MAP_GROUP { get; set; }
/// <summary> /// <summary>
/// 已结分组包含不可结算零件 /// 已结分组包含不可结算零件
/// </summary> /// </summary>
@ -257,22 +266,45 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// 发票调整明细 /// 发票调整明细
/// </summary> /// </summary>
public List<PUB_ADJ_DETAIL_DTO> ADJ_DETAIL { get; set; } public List<PUB_ADJ_DETAIL_DTO> ADJ_DETAIL { get; set; }
/// <summary>
/// JIT全部未结明细
/// </summary>
public List<JIT_UNSETTLED_DETAIL_DTO> JIT_UNSETTLED_DETAIL { get; set; }
/// <summary>
/// JIT全部未结明细
/// </summary>
public List<MAIDAN_HBPO_UNSETTLED_DETAIL_DTO> MAIDAN_HBPO_UNSETTLED_DETAIL { get; set; }
/// <summary> /// <summary>
/// 全部未结明细 /// JIT全部未结明细
/// </summary> /// </summary>
public List<UNSETTLED_DETAIL_DTO> UNSETTLED_DETAIL { get; set; } public List<JIT_UNSETTLED_DETAIL_DTO> UNSETTLED_DETAIL { get; set; }
}
public class JIT_UNSETTLED_DETAIL_DTO
{
[Display(Name = "结算分组号")]
public string GroupNum { set; get; }
[Display(Name = "零件号")]
public string LU { set; get; }
[Display(Name = "数量")]
public decimal Qty { set; get; }
} }
public class UNSETTLED_DETAIL_DTO public class MAIDAN_HBPO_UNSETTLED_DETAIL_DTO
{ {
[Display(Name = "结算分组号")] [Display(Name = "五联单号")]
public string GroupNum { set; get; } public string GroupNum { set; get; }
[Display(Name = "生产码")]
public string PN { set; get; }
[Display(Name = "零件号")] [Display(Name = "零件号")]
public string LU { set; get; } public string LU { set; get; }
[Display(Name = "数量")] [Display(Name = "数量")]
@ -283,33 +315,49 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public class INVOICE_WAIT_DETAIL_BJ_DTO public class INVOICE_WAIT_DETAIL_BJ_DTO
{ {
///// <summary>
/////期间
///// </summary>
//[Display(Name = "行号")]
//public int LineCode { get; set; }
/// <summary>
///期间
/// </summary>
[Display(Name = "期间")]
public int Version { get; set; } public int Version { get; set; }
[Display(Name = "金税发票号")] [Display(Name = "金税发票号")]
public string RealInvbillNum { get; set; } public string RealInvbillNum { get; set; }
[Display(Name = "发票日期")] [Display(Name = "发票日期")]
public DateTime? InvDate { set; get; } public DateTime? InvDate { set; get; }
/// <summary> /// <summary>
///扩展字段1 ///扩展字段1
/// </summary> /// </summary>
[Display(Name = "凭证号")] [Display(Name = "凭证号")]
public string Extend1 { get; set; } public string Extend1 { get; set; }
[Display(Name = "交货号")]
public string DeliveryNumber { get; set; }
/// <summary> /// <summary>
///发票号 ///发票号
/// </summary> /// </summary>
[Display(Name = "发票号")] [Display(Name = "发票号")]
public string InvbillNum { get; set; } public string InvbillNum { get; set; }
[Display(Name = "供应商代码")]
public string VendorCode { get; set; }
[Display(Name = "供应商名称")]
public string VendorName { get; set; }
[Display(Name = "PurchaseOrderNumber")]
public string PurchaseOrderNumber { get; set; }
[Display(Name = "业务分类")]
public string DeliveryIndexNumber { get; set; }
/// <summary>
///零件号
/// </summary>
[Display(Name = "零件号")]
public string PartCode { get; set; }
[Display(Name = "PartName")]
public string PartName { get; set; }
/// <summary> /// <summary>
///发票分组号 ///发票分组号
/// </summary> /// </summary>
@ -321,15 +369,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "客户零件号")] [Display(Name = "客户零件号")]
public string LU { get; set; } public string LU { get; set; }
/// <summary>
///零件号
/// </summary>
[Display(Name = "零件号")]
public string PartCode { get; set; }
[Display(Name = "零件描述")] [Display(Name = "零件描述")]
public string PartDesc { get; set; } public string PartDesc { get; set; }
/// <summary> /// <summary>
///单价 ///单价
/// </summary> /// </summary>
@ -348,9 +389,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary> /// <summary>
///业务分类 ///业务分类
/// </summary> /// </summary>
[Display(Name = "业务分类")]
public string BussiessType { get; set; }
/// <summary> /// <summary>
///扩展字段3 ///扩展字段3
@ -587,6 +625,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary> /// </summary>
[Display(Name = "结算分组号")] [Display(Name = "结算分组号")]
public string SettleGroupNum { get; set; } public string SettleGroupNum { get; set; }
/// <summary> /// <summary>
///金额 ///金额
/// </summary> /// </summary>
@ -607,6 +649,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
} }
public class MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO
{
/// <summary>
///发票分组号
/// </summary>
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
/// <summary>
///结算分组号
/// </summary>
[Display(Name = "五联单号")]
public string SettleGroupNum { get; set; }
[Display(Name = "现生产码")]
public string Extend1 { get; set; }
}
public class INVOICE_MAP_GROUP_EXP_DTO public class INVOICE_MAP_GROUP_EXP_DTO
{ {

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -158,7 +158,7 @@ namespace Win.Sfs.SettleAccount.Bases
PRICE = itm.PRICE, PRICE = itm.PRICE,
Qty = itm.Qty, Qty = itm.Qty,
Amt = itm.Amt, Amt = itm.Amt,
BussiessType = itm.BussiessType,
Extend1 = itm.Extend1, Extend1 = itm.Extend1,
BeginDate = itm.BeginDate, BeginDate = itm.BeginDate,
EndDate = itm.EndDate, EndDate = itm.EndDate,
@ -188,7 +188,7 @@ namespace Win.Sfs.SettleAccount.Bases
PRICE = itm.PRICE, PRICE = itm.PRICE,
Qty = itm.Qty, Qty = itm.Qty,
Amt = itm.Amt, Amt = itm.Amt,
BussiessType = itm.BussiessType,
Extend1 = itm.Extend1, Extend1 = itm.Extend1,
BeginDate = itm.BeginDate, BeginDate = itm.BeginDate,
EndDate = itm.EndDate, EndDate = itm.EndDate,

117
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -1,22 +1,39 @@
using System; using AutoMapper;
using System.Collections.Generic; using DocumentFormat.OpenXml.Bibliography;
using System.ComponentModel.DataAnnotations; using DocumentFormat.OpenXml.Drawing.Charts;
using System.Linq; using DocumentFormat.OpenXml.Office2010.Excel;
using System.Reflection; using EFCore.BulkExtensions;
using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases; using SettleAccount.Bases;
using SettleAccount.Job.Services;
using Shouldly; using Shouldly;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TaskJob.EventArgs;
using TaskJob.Services;
using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases namespace Win.Sfs.SettleAccount.Bases
@ -37,7 +54,7 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> _bbacSecRepository; protected readonly INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> _bbacSecRepository;
protected readonly INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> _hbpoSecRepository; protected readonly INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> _hbpoSecRepository;
protected readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSecRepository; protected readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSecRepository;
private readonly TaskJobService _service;
public PD_SERVICE( public PD_SERVICE(
INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository,
@ -48,9 +65,11 @@ namespace Win.Sfs.SettleAccount.Bases
ICommonManager commonManager, ICommonManager commonManager,
INormalEfCoreRepository<TEntity, Guid> repository, INormalEfCoreRepository<TEntity, Guid> repository,
VmiAppService vimservice, VmiAppService vimservice,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
TaskJobService service
) : base(excelImportService, snowflakeIdGenerator, commonManager) ) : base(excelImportService, snowflakeIdGenerator, commonManager)
{ {
_service = service;
_vimservice = vimservice; _vimservice = vimservice;
_repository = repository; _repository = repository;
_detailRepository = detailRepository; _detailRepository = detailRepository;
@ -114,11 +133,78 @@ namespace Win.Sfs.SettleAccount.Bases
return _fileName; return _fileName;
} }
[HttpPost] [HttpPost]
//[Route("generateinvoice")] [UnitOfWork(false)]
public virtual async Task<string> ApprovalPassed(List<string> p_list) public virtual async Task<string> ApprovalPassed(List<string> p_list)
{ {
return ApplicationConsts.SuccessStr; return await InvokePD(p_list, _service, false);
}
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<string> RejectAsync(List<string> p_list)
{
return await InvokePD(p_list, _service, true);
}
protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false)
{
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
var first=detailist.FirstOrDefault();
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
customConditionList.Add(new CustomCondition() { Name = "Type", Value =first.BusinessType.ToString() });
if (isback == false)
{
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
}
else
{
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "in" });
}
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var lst=new List<TEntity>();
if (isback == false)
{
lst = ls.Where(p => (p.State == SettleBillState. || p.State == SettleBillState.)).ToList();
}
else
{
lst = ls.Where(p => (p.State == SettleBillState.|| p.State == SettleBillState.)).ToList();
}
if (lst.Count() > 0)
{
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
}
foreach (var item in ls)
{
if (isback == false)
{
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
}
await _repository.DbContext.BulkUpdateAsync(ls);
var _taskid = await p_service.ExportEnqueueAsync($"{first.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
{
});
return _taskid;
} }
/// <summary> /// <summary>
/// 查询主表 /// 查询主表
/// </summary> /// </summary>
@ -133,16 +219,7 @@ namespace Win.Sfs.SettleAccount.Bases
var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys); var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys);
return new PagedResultDto<TEntityDto>(totalCount, dtos); return new PagedResultDto<TEntityDto>(totalCount, dtos);
} }
/// <summary>
/// 退回
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public virtual async Task<string> RejectAsync(TRequestMainInput input)
{
return ApplicationConsts.SuccessStr;
}
protected virtual async Task<TEntity> GetMainAsync([FromBody] string billNum) protected virtual async Task<TEntity> GetMainAsync([FromBody] string billNum)
{ {
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync().ConfigureAwait(false); return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync().ConfigureAwait(false);

38
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs

@ -31,41 +31,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO> BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO>
{ {
private readonly TaskJobService _service;
public BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, VmiAppService vimservice,
INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository,
TaskJobService service
) :
base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository)
{
_service = service;
}
[UnitOfWork(false)]
public override async Task<string> ApprovalPassed(List<string> p_list)
{
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
customConditionList.Add(new CustomCondition() { Name = "Type", Value = EnumBusinessType.JisBBAC.ToString() });
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var lst = ls.Where(p => (p.State == SettleBillState. || p.State == SettleBillState.));
if (lst.Any())
{
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
}
foreach (var item in ls)
{
item.State = SettleBillState.;
}
await _repository.DbContext.BulkUpdateAsync(ls).ConfigureAwait(false);
var _taskid = await _service.ExportEnqueueAsync("BBAC待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
{
}).ConfigureAwait(false);
return _taskid;
}
//[HttpPost] //[HttpPost]
//public virtual async Task<string> RejectAsync(List<string> p_list) //public virtual async Task<string> RejectAsync(List<string> p_list)
//{ //{
@ -91,6 +59,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
// return _taskid; // return _taskid;
//} //}
public BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
{
}
} }
} }

7
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs

@ -368,7 +368,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//} //}
var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号 where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {
@ -441,9 +441,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result }); return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
} }
var invBilllist = new List<INVOICE_REPEAT_DTO>(); var invBilllist = new List<INVOICE_REPEAT_DTO>();
var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list); var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
@ -518,7 +515,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//} //}
var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号 where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {

32
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs

@ -25,38 +25,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO, HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO,
HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO> HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO>
{ {
private readonly TaskJobService _service; public HBPO_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
public HBPO_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository)
{ {
_service = service;
} }
[UnitOfWork(false)]
public override async Task<string> ApprovalPassed(List<string> p_list)
{
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
customConditionList.Add(new CustomCondition() { Name = "Type", Value = EnumBusinessType.JisHBPO.ToString() });
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var lst = ls.Where(p => (p.State == SettleBillState. || p.State == SettleBillState.));
if (lst.Any())
{
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
}
foreach (var item in ls)
{
item.State = SettleBillState.;
}
await _repository.DbContext.BulkUpdateAsync(ls).ConfigureAwait(false);
var _taskid = await _service.ExportEnqueueAsync("HBPO待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
{
}).ConfigureAwait(false);
return _taskid;
}
} }
} }

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

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
@ -12,9 +12,12 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using ShardingCore.Extensions;
using Shouldly; using Shouldly;
using SqlSugar; using SqlSugar;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
@ -187,8 +190,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);
B.OrderBy(p => p.LineCode); B.OrderBy(p => p.LineCode);
var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
List<INVOICE_WAIT_DETAIL_BJ_DTO> BMap = new List<INVOICE_WAIT_DETAIL_BJ_DTO>();
foreach (var itm in B)
{
INVOICE_WAIT_DETAIL_BJ_DTO bj = new INVOICE_WAIT_DETAIL_BJ_DTO();
bj.LU = itm.LU;
bj.PartCode = itm.PartCode;
bj.PRICE = itm.PRICE;
//bj.InvGroupNum = itm.InvGroupNum;
//bj.DeliveryNumber= itm.GetProperty("DeliveryNumber", "");//交货号
//bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号
//bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码
//bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称
//bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
//bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
//bj.PartName = itm.GetProperty("PartName", "");//零件名称
}
//var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
var wquery = from itm in BMap var wquery = from itm in BMap
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
@ -207,7 +228,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PRICE = itm.PRICE, PRICE = itm.PRICE,
Qty = itm.Qty, Qty = itm.Qty,
Amt = itm.Amt, Amt = itm.Amt,
BussiessType = itm.BussiessType, DeliveryNumber = itm.DeliveryNumber ,
VendorCode = itm.VendorCode ,
VendorName = itm.VendorName ,
PurchaseOrderNumber = itm.PurchaseOrderNumber,
DeliveryIndexNumber =itm.DeliveryIndexNumber ,
Extend1 = itm.Extend1, Extend1 = itm.Extend1,
BeginDate = itm.BeginDate, BeginDate = itm.BeginDate,
EndDate = itm.EndDate, EndDate = itm.EndDate,
@ -217,7 +242,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
else else
{ {
var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w); var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w);
var wquery = from itm in wdtos var wquery = from itm in wdtos
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
@ -226,7 +251,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
select select
new INVOICE_WAIT_DETAIL_DTO() new INVOICE_WAIT_DETAIL_DTO()
{ {
PartDesc = tm == null ? string.Empty : itm.PartDesc, PartDesc = tm == null ? string.Empty : itm.PartDesc,
InvDate = itm1.CreationTime, InvDate = itm1.CreationTime,
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum,
@ -304,15 +328,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
SettleGroupNum = p.FirstOrDefault().SettleGroupNum, SettleGroupNum = p.FirstOrDefault().SettleGroupNum,
} }
); );
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)//BBAC直供未结
{ {
//var all = entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号 //var all = entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号
//var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号 //var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号
//var unsettled = all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结 //var unsettled = all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结
var unsettledList = sdtos var unsettledList = sdtos
.GroupBy(p => new { p.LU, p.SettleGroupNum }) .GroupBy(p => new { p.LU, p.SettleGroupNum })
.Select(p => new UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); .Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) });
entity.UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList();
}
if (first.BusinessType == EnumBusinessType.JisHBPO)
{
entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
} }
if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC) if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC)
@ -323,8 +351,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
entity.INVOICE_MAP_GROUP = mdtos; entity.INVOICE_MAP_GROUP = mdtos;
} }
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList();
return entity; return entity;
} }
[HttpPost] [HttpPost]
@ -386,6 +414,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var bj = invdetail.INVOICE_WAIT_DETAIL_BJ;//备件明细 var bj = invdetail.INVOICE_WAIT_DETAIL_BJ;//备件明细
var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细 var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name; var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name;
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx";
@ -408,7 +437,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
_excel.Append(m, "发票结算分组对应");//发票分组对应结算号 _excel.Append(m, "发票结算分组对应");//发票分组对应结算号
} }
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC )
{ {
_excel.Append(unsettle, "未结零件结算汇总"); _excel.Append(unsettle, "未结零件结算汇总");
} }
@ -509,7 +538,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet();
} }
var result = _excel.ExportAppendDataAsByteArray(); var result = _excel.ExportAppendDataAsByteArray();
result.ShouldNotBeNull(); result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制 //保存导出文件到服务器存成二进制

54
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.LinqAsync; using System.LinqAsync;
@ -61,13 +61,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (errorlist.Count > 0) if (errorlist.Count > 0)
{ {
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorlist).ConfigureAwait(false) }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorlist) });
} }
var first = p_list.FirstOrDefault(); var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum; var invbillnum = first.InvBillNum;
List<INVOICE_WAIT_DETAIL_DTO> ls = new List<INVOICE_WAIT_DETAIL_DTO>(); List<INVOICE_WAIT_DETAIL_DTO> ls = new List<INVOICE_WAIT_DETAIL_DTO>();
var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list); var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
if (adjlist == null && adjlist.Count == 0) if (adjlist == null && adjlist.Count == 0)
@ -266,29 +264,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) });
} }
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys); // var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in entitys var q = from d in entitys
join p in priceList on d.PartCode equals p.LU join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {
SettleBillNum = d.SettleBillNum, SettleBillNum = d.SettleBillNum,
Site = d.Site, Site = d.Site,
Version = d.Version, Version = d.Version,
Price = p.Price, Price = p.Price,
BillNum = d.BillNum, BillNum = d.BillNum,
SettleDate = d.SettleDate, SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum, InvGroupNum = d.InvGroupNum,
LU = d.LU, LU = d.LU,
// MaterialDesc = d.MaterialDesc, // MaterialDesc = d.MaterialDesc,
PN = d.PN, PN = d.PN,
Qty = d.Qty, Qty = d.Qty,
GroupNum = d.GroupNum, GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2), Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = "n", ContractDocID = "n",
BeginDate = p.BeginTime, BeginDate = p.BeginTime,
EndDate = p.EndTime, EndDate = p.EndTime,
PartCode = d.PartCode PartCode= d.PartCode
}; };
var dtos = q.ToList(); var dtos = q.ToList();
@ -401,7 +399,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//} //}
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号 where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {

31
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs

@ -26,37 +26,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO, PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO,
PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO> PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO>
{ {
private readonly TaskJobService _service; public PUB_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
public PUB_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository)
{ {
_service = service;
}
[UnitOfWork(false)]
public override async Task<string> ApprovalPassed(List<string> p_list)
{
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
var first = detailist.FirstOrDefault();
customConditionList.Add(new CustomCondition() { Name = "Type", Value = first.BusinessType.ToString() });
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var lst = ls.Where(p => (p.State == SettleBillState. || p.State == SettleBillState.));
if (lst.Any())
{
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
}
foreach (var item in ls)
{
item.State = SettleBillState.;
}
await _repository.DbContext.BulkUpdateAsync(ls).ConfigureAwait(false);
var _taskid = await _service.ExportEnqueueAsync("PUB待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
{
}).ConfigureAwait(false);
return _taskid;
} }
} }
} }

344
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
@ -30,52 +30,52 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
_emailSender = emailSender; _emailSender = emailSender;
_dbcontext = dbcontext; _dbcontext = dbcontext;
} }
[UnitOfWork(false)] [UnitOfWork(false)]
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{ {
var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value; var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value;
var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value; var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value;
var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value; var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value;
var email = string.Empty; var email = string.Empty;
// property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value; // property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value;
var list = billList.Split(","); var list = billList.Split(",");
var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位"); var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位");
if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian") if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian")
{
var jisdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis
if (jisdetail != null && jisdetail.Count() > 0)
{ {
var jisdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis foreach (var itm in jisdetail)
if (jisdetail != null && jisdetail.Any())
{ {
foreach (var itm in jisdetail) if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2))
{ {
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description;
{ }
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; else
} {
else itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description;
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description;
}
} }
Sync(jisdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
} }
var mdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianBBAC);//买单件 Sync(jisdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
if (mdetail != null && mdetail.Any()) }
var mdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianBBAC);//买单件
if (mdetail != null && mdetail.Count() > 0)
{
foreach (var itm in jisdetail)
{ {
foreach (var itm in jisdetail) if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2))
{ {
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description;
{ }
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; else
} {
else itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description;
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description;
}
} }
Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
} }
Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
}
var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList(); var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList();
@ -175,184 +175,176 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
select new VmiLog() select new VmiLog()
{ {
CodeType = string.Empty, CodeType = string.Empty,
BillTime = DateTime.Now, BillTime = DateTime.Now,
ChangedTime = DateTime.Now, ChangedTime = DateTime.Now,
Qty = itm.Qty, Qty = itm.Qty,
RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU
RealCode = itm.RELU, RealCode = itm.RELU,
LogType = Entities.BQ.Vmi.VmiLogType.Type200, LogType = Entities.BQ.Vmi.VmiLogType.Type200,
ChangedQty = (flag == true) ? -itm.Qty : itm.Qty, ChangedQty = (flag == true) ? -itm.Qty : itm.Qty,
ChangedType = VmiType.Out, ChangedType = VmiType.Out,
//SubBillType = EnumDeliverSubBillType.小件BBAC, //SubBillType = EnumDeliverSubBillType.小件BBAC,
//BillType = EnumDeliverBjBmpBillType.JIS件, //BillType = EnumDeliverBjBmpBillType.JIS件,
CustPartCode = itm.LU, CustPartCode = itm.LU,
SettlementVinCode = itm.PN, SettlementVinCode = itm.PN,
DeliverBillType = bussinessType, DeliverBillType = bussinessType,
VinCode = itm.PN, VinCode = itm.PN,
OrderNum = itm.GroupNum, OrderNum = itm.GroupNum,
ErpToLoc = itm.Extend2, //寄售库 ErpToLoc = itm.Extend2, //寄售库
}; };
var ls = query.ToList(); var ls = query.ToList();
foreach (var itm in ls) foreach (var itm in ls)
{ {
itm.SetId(GuidGenerator.Create()); itm.SetId(GuidGenerator.Create());
} }
var _first = p_ls.FirstOrDefault(); var _first = p_ls.FirstOrDefault();
bool issucess = true;
bool issucess = true; using (var transaction = _dbcontext.Database.BeginTransaction())
{
using (var transaction = _dbcontext.Database.BeginTransaction()) try
{ {
try // 执行批量数据操作
if (ls != null && ls.Count > 0)
{ {
// 执行批量数据操作 var messagelist = new List<VmiMessage>();
if (ls != null && ls.Count > 0) foreach (var item in ls)
{ {
var messagelist = new List<VmiMessage>(); var message = new VmiMessage
foreach (var item in ls)
{ {
var message = new VmiMessage Message = System.Text.Json.JsonSerializer.Serialize(item),
{ };
Message = System.Text.Json.JsonSerializer.Serialize(item), messagelist.Add(message);
}; }
messagelist.Add(message); _dbcontext.BulkInsert(messagelist);
} _dbcontext.BulkInsert(ls, new BulkConfig() { });
_dbcontext.BulkInsert(messagelist); var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();
_dbcontext.BulkInsert(ls, new BulkConfig() { }); var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); if (pdList.Count > 0)
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); {
if (pdList.Count > 0) foreach (var item in pdList)
{ {
foreach (var item in pdList) if (flag == true)
{ {
if (flag == true) item.State = SettleBillState.;
{ }
item.State = SettleBillState.; else
} {
else item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(pdList);
} }
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); _dbcontext.BulkUpdate(pdList);
if (bbacList.Count > 0) }
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (bbacList.Count > 0)
{
foreach (var item in bbacList)
{ {
foreach (var item in bbacList) if (flag == true)
{
item.State = SettleBillState.;
}
else
{ {
if (flag == true) item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(bbacList);
} }
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); _dbcontext.BulkUpdate(bbacList);
if (hbpoList.Count > 0) }
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (hbpoList.Count > 0)
{
foreach (var item in hbpoList)
{ {
foreach (var item in hbpoList) if (flag == true)
{ {
if (flag == true) item.State = SettleBillState.;
{ }
item.State = SettleBillState.; else
} {
else item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(hbpoList);
} }
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList(); _dbcontext.BulkUpdate(hbpoList);
if (invoiceList.Count > 0) }
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (invoiceList.Count > 0)
{
foreach (var item in invoiceList)
{ {
foreach (var item in invoiceList) if (flag == true)
{ {
if (flag == true) item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(invoiceList);
} }
_dbcontext.BulkUpdate(invoiceList);
} }
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
issucess = false;
// 回滚事务
transaction.Rollback();
} }
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
} }
if (issucess == false) catch (Exception)
{ {
issucess = false;
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); // 回滚事务
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); transaction.Rollback();
if (pdList.Count > 0) }
}
if (issucess ==false)
{
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (pdList.Count > 0)
{
foreach (var item in pdList)
{ {
foreach (var item in pdList) if (flag == true)
{ {
if (flag == true) item.State = SettleBillState.;
{ }
item.State = SettleBillState.; else
} {
else item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(pdList);
} }
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); _dbcontext.BulkUpdate(pdList);
if (bbacList.Count > 0) }
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (bbacList.Count > 0)
{
foreach (var item in bbacList)
{ {
foreach (var item in bbacList) if (flag == true)
{ {
if (flag == true) item.State = SettleBillState.;
{ }
item.State = SettleBillState.; else
} {
else item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(bbacList);
} }
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); _dbcontext.BulkUpdate(bbacList);
if (hbpoList.Count > 0) }
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (hbpoList.Count > 0)
{
foreach (var item in hbpoList)
{ {
foreach (var item in hbpoList) if (flag == true)
{ {
if (flag == true) item.State = SettleBillState.;
{ }
item.State = SettleBillState.; else
} {
else item.State = SettleBillState.;
{
item.State = SettleBillState.;
}
} }
_dbcontext.BulkUpdate(hbpoList);
} }
_dbcontext.BulkUpdate(hbpoList);
} }
} }
}
} }
} }

6
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -55,9 +55,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
errors.Add($"生产号{itm.PN}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据"); errors.Add($"生产号{itm.PN}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
} }
} }
if (first.BusinessType == EnumBusinessType.JisHBPO) if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.MaiDanJianHBPO)
{ {
var ls = p_list.Select(p => p.Site.Substring(0, 3)).Distinct().ToList(); var ls = p_list.Select(p => p.Site.Substring(0, 3)).Distinct().ToList();
if (ls.Count > 1) if (ls.Count > 1)
{ {
@ -67,7 +66,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
return errors; return errors;
} }
} }
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new HBPO_CAN_SA(); var _entity = new HBPO_CAN_SA();

49
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -353,7 +353,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <returns></returns> /// <returns></returns>
public virtual async Task<bool> ReceivedAsync(List<string> p_invs) public virtual async Task<bool> ReceivedAsync(List<string> p_invs)
{ {
var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息 var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
int count = invList.Select(p => p.InvGroupNum).Distinct().Count(); int count = invList.Select(p => p.InvGroupNum).Distinct().Count();
if (count > 1) if (count > 1)
{ {
@ -874,7 +876,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
//await _repository.DbContext.BulkUpdateAsync(canList); //await _repository.DbContext.BulkUpdateAsync(canList);
} }
} }
} }
else else
@ -892,14 +893,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public virtual async Task<bool> BackAsync(string billNum) public virtual async Task<bool> BackAsync(string billNum)
{ {
var _ls = await _repository.Where(p => p.InvGroupNum == billNum).ToListAsync().ConfigureAwait(false); var _ls = await _repository.Where(p => p.InvGroupNum == billNum).ToListAsync();
if (_ls != null && _ls.Count > 0) if (_ls != null && _ls.Count > 0)
{ {
foreach (var p_entity in _ls) foreach (var p_entity in _ls)
{ {
} }
} }
//if (_ls != null && _ls.Count > 0) //if (_ls != null && _ls.Count > 0)
//{ //{
@ -943,7 +943,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
[UnitOfWork(false)] [UnitOfWork(false)]
public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
where TDetail : SA_CAN_BASE where TDetail : SA_CAN_BASE
{ {
List<string> _invls = new List<string>(); List<string> _invls = new List<string>();
var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
@ -1159,6 +1158,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
); );
invbill.ClientCode = clientCode; invbill.ClientCode = clientCode;
invbill.Site = dtos.FirstOrDefault().Site; invbill.Site = dtos.FirstOrDefault().Site;
invlist.Add(invbill); invlist.Add(invbill);
} }
@ -1455,6 +1456,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_invls = invlist.Select(p => p.InvbillNum).ToList(); _invls = invlist.Select(p => p.InvbillNum).ToList();
} }
return _invls; return _invls;
} }
@ -1608,7 +1610,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
invGroupNum: p_InvGroupNum, invGroupNum: p_InvGroupNum,
settleGroupNum: groupnum.GroupNum, settleGroupNum: groupnum.GroupNum,
amt: 0, amt: 0,
extend1: groupnum.PN, extend1: groupnum.PN,//生产码
extend2: string.Empty extend2: string.Empty
) )
); );
@ -1617,9 +1619,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
groupList.AddRange(mapList); groupList.AddRange(mapList);
} }
var notsettle = _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求 var notsettle= _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求
if (notsettle != null && notsettle.Any()) if (notsettle != null && notsettle.Count() > 0)
{ {
var innotls = new List<INVOICE_NOT_SETTLE>(); var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notsettle) foreach (var nitm in notsettle)
@ -1671,6 +1673,37 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
detailList.AddRange(_entityDetailList); detailList.AddRange(_entityDetailList);
} }
if (p_first == true)
{
var notsettle = _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求
if (notsettle != null && notsettle.Count() > 0)
{
var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notsettle)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: nitm.LU,
lU1: nitm.LU,
extend1: nitm.PN,
extend2: string.Empty,
qty: nitm.Qty,
p_invbillnum: string.Empty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
}
}
decimal amt = detailList.Sum(k => k.Amt);//金额 decimal amt = detailList.Sum(k => k.Amt);//金额
decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额 decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额 decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额

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

@ -26,7 +26,9 @@ namespace Win.Sfs.SettleAccount
[Description("客户已收票")] [Description("客户已收票")]
= 4, = 4,
[Description("已提交扣减")] [Description("已提交扣减")]
= 6 = 6,
[Description("已提交撤销扣减")]
= 7
} }
public enum PDBillState public enum PDBillState

Loading…
Cancel
Save