Browse Source

更新

master
zhaoxinyu 5 months ago
parent
commit
1f823282e4
  1. 36
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  2. 51
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  3. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  4. 78
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ReturnCanSettlement.cs
  5. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs
  6. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  7. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs
  8. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

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

@ -146,28 +146,42 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[UnitOfWork(false)] [UnitOfWork(false)]
public virtual async Task<IActionResult> BackCanSettlement([FromBody] string selttleBilNum) public virtual async Task<IActionResult> BackCanSettlement([FromBody] string selttleBilNum)
{ {
if (selttleBilNum.Substring(0, 1) == "N") if (selttleBilNum.Substring(0, 1) == "N")
{ {
List<BBAC_NOT_SA_DETAIL> notList = new List<BBAC_NOT_SA_DETAIL>(); List<BBAC_NOT_SA_DETAIL> notList = new List<BBAC_NOT_SA_DETAIL>();
var entites = _repository.Where(p => p.BillNum == selttleBilNum).ToList(); var entites = _detailRepository.Where(p => p.BillNum == selttleBilNum).ToList();
var main = _repository.Where(p => p.BillNum == selttleBilNum).ToList(); var main = _repository.FirstOrDefault(p => p.BillNum == selttleBilNum);
foreach (var itm in entites)
if (main.State != SettleBillState.)
{ {
var detail = new BBAC_NOT_SA_DETAIL(); throw new UserFriendlyException("当前状态不是未结状态无法退回!", "400");
detail.InjectFrom(itm);
notList.Add(detail);
} }
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false); if (entites.Count == 0)
await dbcontext.BulkDeleteAsync(main).ConfigureAwait(false); {
await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false); throw new UserFriendlyException("当前表单明细无数据无法退回!", "400");
await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false); }
return new JsonResult(new { Code = 200, Message = "退回成功" }); main.State = SettleBillState.退;
await _repository.UpdateAsync(main).ConfigureAwait(false);
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = selttleBilNum });
customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
var _taskid = await _service.ExportEnqueueAsync("可结退回不可结", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(ReturnCanSettlement), customConditionList, (rs) =>
{
}).ConfigureAwait(false);
} }
else else
{ {
throw new UserFriendlyException("单据不是从不可结算单生成", "400"); throw new UserFriendlyException("单据不是从不可结算单生成", "400");
} }
return new JsonResult(new { Code = 200, Message = "开始退回" });
} }

51
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -201,24 +201,53 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (selttleBilNum.Substring(0, 1) == "N") if (selttleBilNum.Substring(0, 1) == "N")
{ {
List<HBPO_NOT_SA_DETAIL> notList = new List<HBPO_NOT_SA_DETAIL>(); List<HBPO_NOT_SA_DETAIL> notList = new List<HBPO_NOT_SA_DETAIL>();
var entites = _repository.Where(p => p.BillNum == selttleBilNum).ToList(); var entites = _detailRepository.Where(p => p.BillNum == selttleBilNum).ToList();
var main = _repository.Where(p => p.BillNum == selttleBilNum).ToList(); var main = _repository.FirstOrDefault(p => p.BillNum == selttleBilNum);
foreach (var itm in entites)
if (main.State != SettleBillState.)
{
throw new UserFriendlyException("当前状态不是未结状态无法退回!", "400");
}
if (entites.Count == 0)
{ {
var detail = new HBPO_NOT_SA_DETAIL(); throw new UserFriendlyException("当前表单明细无数据无法退回!", "400");
detail.InjectFrom(itm);
notList.Add(detail);
} }
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false); main.State = SettleBillState.退;
await dbcontext.BulkDeleteAsync(main).ConfigureAwait(false); await _repository.UpdateAsync(main).ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false);
await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false); List<CustomCondition> customConditionList = new List<CustomCondition>();
return new JsonResult(new { Code = 200, Message = "退回成功" }); customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = selttleBilNum });
customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
var _taskid = await _service.ExportEnqueueAsync("可结退回不可结", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(ReturnCanSettlement), customConditionList, (rs) =>
{
}).ConfigureAwait(false);
//foreach (var itm in entites)
//{
// var detail = new HBPO_NOT_SA_DETAIL();
// detail.InjectFrom(itm);
// detail.SetId(detail.Id);
// foreach (var extra in itm.ExtraProperties)
// {
// detail.ExtraProperties.Add(extra.Key, extra.Value);
// }
// notList.Add(detail);
//}
//var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
//await dbcontext.BulkDeleteAsync(new List<HBPO_CAN_SA>() { main }).ConfigureAwait(false);
//await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false);
//await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false);
//return new JsonResult(new { Code = 200, Message = "退回成功" });
} }
else else
{ {
throw new UserFriendlyException("单据不是从不可结算单生成", "400"); throw new UserFriendlyException("单据不是从不可结算单生成", "400");
} }
return new JsonResult(new { Code = 200, Message = "退回开始!" });
} }
} }

18
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -258,16 +258,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (selttleBilNum.Substring(0, 1) == "N") if (selttleBilNum.Substring(0, 1) == "N")
{ {
List<PUB_NOT_SA_DETAIL> notList = new List<PUB_NOT_SA_DETAIL>(); List<PUB_NOT_SA_DETAIL> notList = new List<PUB_NOT_SA_DETAIL>();
var entites = _repository.Where(p => p.BillNum == selttleBilNum).ToList(); var entites = _detailRepository.Where(p => p.BillNum == selttleBilNum).ToList();
var main = _repository.Where(p => p.BillNum == selttleBilNum).ToList(); var main = _repository.FirstOrDefault(p => p.BillNum == selttleBilNum);
if (main.State != SettleBillState.)
{
throw new UserFriendlyException("当前状态不是未结状态无法退回!", "400");
}
foreach (var itm in entites) foreach (var itm in entites)
{ {
var detail = new PUB_NOT_SA_DETAIL(); var detail = new PUB_NOT_SA_DETAIL();
detail.InjectFrom(itm); detail.InjectFrom(itm);
detail.SetId(itm.Id);
foreach (var extra in itm.ExtraProperties)
{
detail.ExtraProperties.Add(extra.Key, extra.Value);
}
notList.Add(detail); notList.Add(detail);
} }
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false); var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(main).ConfigureAwait(false); await dbcontext.BulkDeleteAsync(new List<PUB_CAN_SA>() { main }).ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false); await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false);
await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false); await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "退回成功" }); return new JsonResult(new { Code = 200, Message = "退回成功" });

78
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ReturnCanSettlement.cs

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Omu.ValueInjecter;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{
public class ReturnCanSettlement : ApplicationService, ITransientDependency, IExportJob
{
protected readonly SettleAccountDbContext _dbcontext;
public ReturnCanSettlement(SettleAccountDbContext dbcontext)
{
_dbcontext = dbcontext;
}
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
var billNum = property.Where(p => p.Name == "BillNum").FirstOrDefault().Value;
var BussinessType = property.Where(p => p.Name == "BussinessType").FirstOrDefault().Value;
if (BussinessType == "JisBBAC")
{
var entites = _dbcontext.Set<BBAC_CAN_SA_DETAIL>().Where(p => p.BillNum == billNum).ToList();
var main = _dbcontext.Set<BBAC_CAN_SA>().FirstOrDefault(p => p.BillNum == billNum);
Execute(main, entites);
}
if (BussinessType == "JisHBPO")
{
var entites = _dbcontext.Set<HBPO_CAN_SA_DETAIL>().Where(p => p.BillNum == billNum).ToList();
var main = _dbcontext.Set<HBPO_CAN_SA>().FirstOrDefault(p => p.BillNum == billNum);
Execute(main, entites);
}
return id.ToString();
}
public void Execute<TMain,TDetail>(TMain p_main,List<TDetail> p_detailList) where TMain : SA_CAN_BASE_MAIN, new()
where TDetail : SA_CAN_BASE, new()
{
List<TDetail> notList = new List<TDetail>();
var entites = p_detailList;
var main = p_main;
foreach (var itm in entites)
{
var detail = new TDetail();
detail.InjectFrom(itm);
detail.SetId(detail.Id);
foreach (var extra in itm.ExtraProperties)
{
detail.ExtraProperties.Add(extra.Key, extra.Value);
}
notList.Add(detail);
}
_dbcontext.BulkDelete(new List<TMain>() { main });
_dbcontext.BulkDelete(entites);
_dbcontext.BulkInsert(notList);
}
}
}

6
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs

@ -114,6 +114,12 @@ namespace Win.Sfs.SettleAccount
{ {
return implementationFactory.GetService<MakeCanSettlementService>(); return implementationFactory.GetService<MakeCanSettlementService>();
} }
if (key.Equals(typeof(ReturnCanSettlement).FullName))
{
return implementationFactory.GetService<ReturnCanSettlement>();
}
else else
{ {
throw new ArgumentException($"Not Support key:{key}"); throw new ArgumentException($"Not Support key:{key}");

12
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs

@ -462,6 +462,10 @@ namespace SettleAccount.Bases
public string RealPartCode { get; set; } public string RealPartCode { get; set; }
public string Site { get; set; } public string Site { get; set; }
public virtual void SetId(Guid guid)
{
Id = guid;
}
//public SA_CAN_BASE(int version, decimal price, string billNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //public SA_CAN_BASE(int version, decimal price, string billNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum)
//{ //{
@ -542,6 +546,14 @@ namespace SettleAccount.Bases
public string ErpLoc { get; set; } public string ErpLoc { get; set; }
public virtual void SetId(Guid guid)
{
Id = guid;
}
//public SA_NOT_BASE(decimal price, int version, string settleBillNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //public SA_NOT_BASE(decimal price, int version, string settleBillNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum)
//{ //{
// Price = price; // Price = price;

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs

@ -91,6 +91,7 @@ namespace SettleAccount.Domain.BQ
} }
public BBAC_NOT_SA_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, string invGroupNum, DateTime settleDate, string groupNum, string contractDocID, string partcode) public BBAC_NOT_SA_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, string invGroupNum, DateTime settleDate, string groupNum, string contractDocID, string partcode)
{ {
Id = guid; Id = guid;

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

@ -39,6 +39,11 @@ namespace Win.Sfs.SettleAccount
= 11, = 11,
[Description("发票同步中")] [Description("发票同步中")]
= 12, = 12,
[Description("可结退回不可结同步中")]
退 = 13,
} }

Loading…
Cancel
Save