|
|
@ -1,22 +1,39 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using AutoMapper; |
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts; |
|
|
|
using DocumentFormat.OpenXml.Office2010.Excel; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Magicodes.ExporterAndImporter.Core; |
|
|
|
using Magicodes.ExporterAndImporter.Csv; |
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using SettleAccount.Bases; |
|
|
|
using SettleAccount.Job.Services; |
|
|
|
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.Uow; |
|
|
|
using Win.Abp.Snowflakes; |
|
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
|
using Win.Sfs.SettleAccount.CommonManagers; |
|
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
|
using Win.Sfs.SettleAccount.Entities.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; |
|
|
|
|
|
|
|
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<HBPO_SEC_DETAIL, Guid> _hbpoSecRepository; |
|
|
|
protected readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSecRepository; |
|
|
|
|
|
|
|
private readonly TaskJobService _service; |
|
|
|
public PD_SERVICE( |
|
|
|
|
|
|
|
INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, |
|
|
@ -48,9 +65,11 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
ICommonManager commonManager, |
|
|
|
INormalEfCoreRepository<TEntity, Guid> repository, |
|
|
|
VmiAppService vimservice, |
|
|
|
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository |
|
|
|
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository, |
|
|
|
TaskJobService service |
|
|
|
) : base(excelImportService, snowflakeIdGenerator, commonManager) |
|
|
|
{ |
|
|
|
_service = service; |
|
|
|
_vimservice = vimservice; |
|
|
|
_repository = repository; |
|
|
|
_detailRepository = detailRepository; |
|
|
@ -114,11 +133,78 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
return _fileName; |
|
|
|
} |
|
|
|
[HttpPost] |
|
|
|
//[Route("generateinvoice")]
|
|
|
|
[UnitOfWork(false)] |
|
|
|
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>
|
|
|
@ -133,16 +219,7 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys); |
|
|
|
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) |
|
|
|
{ |
|
|
|
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync().ConfigureAwait(false); |
|
|
|