mahao 1 year ago
parent
commit
7eaa07d10a
  1. 11
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj
  2. 66
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  3. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  4. 11
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/start.cmd
  5. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/stop.cmd
  6. 18
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  7. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js
  8. 145
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs
  9. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IINVOICE_SERVICE.cs
  10. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BASE_SERVICE.cs
  11. 151
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  12. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  13. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs
  14. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  15. 496
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  16. 63
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  17. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs
  18. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
  19. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  20. 36
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  21. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs
  22. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
  23. 204
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs
  24. 140
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs
  25. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  26. 27
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  27. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs
  28. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
  29. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  30. 125
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_ADJ_DETAIL.cs
  31. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs
  32. 70
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs
  33. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs
  34. 43
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  35. 37
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  36. 4874
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727085151_202307270004.Designer.cs
  37. 93
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727085151_202307270004.cs
  38. 106
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

11
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj

@ -1,5 +1,4 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\common.props" /> <Import Project="..\..\common.props" />
@ -87,8 +86,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="wwwroot\" /> <None Update="start.cmd">
<Folder Include="wwwroot\files\vmi\" /> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="stop.cmd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions> <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

66
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs

@ -1,8 +1,4 @@
using System;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Coravel;
using Coravel.Invocable;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.ApplicationModels;
@ -11,10 +7,9 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NUglify.Helpers;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs; using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount; namespace Win.Sfs.SettleAccount;
@ -23,14 +18,12 @@ public class Startup
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddSignalR(o => o.EnableDetailedErrors = true); services.AddSignalR(o => o.EnableDetailedErrors = true);
AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes()) JobHostdService.AddService(services);
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService))) services.AddSingleton<JobHostdService>();
.ForEach(o => services.AddTransient(o)); services.AddHostedService(o => o.GetRequiredService<JobHostdService>());
services.AddScheduler();
services.AddTransient<HBPOSeSyncAppService>(); services.AddTransient<HBPOSeSyncAppService>();
services.AddTransient<BBACSeSyncAppService>(); services.AddTransient<BBACSeSyncAppService>();
services.AddTransient<ZhiGongBBACSeSyncAppService>(); services.AddTransient<ZhiGongBBACSeSyncAppService>();
services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer)); services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer));
services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer()))); services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer())));
services.AddApplication<SettleAccountHttpApiHostModule>(); services.AddApplication<SettleAccountHttpApiHostModule>();
@ -51,57 +44,6 @@ public class Startup
{ {
app.UseRouting(); app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapHub<PageHub>("/api/hub")); app.UseEndpoints(endpoints => endpoints.MapHub<PageHub>("/api/hub"));
app.ApplicationServices.UseScheduler(scheduler =>
{
//scheduler.Schedule<HBPOSeSyncAppService>().EveryMinute();
scheduler.Schedule<ZhiGongBBACSeSyncAppService>().EveryMinute();
using var scope = app.ApplicationServices.CreateScope();
var jobs = scope.ServiceProvider.GetService<SettleAccountDbContext>().Set<JobItem>().ToList();
jobs?.ForEach(job =>
{
var jobId = job.Id;
using var scope = app.ApplicationServices.CreateScope();
var serviceType = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).FirstOrDefault(o => o.FullName == job.Service);
if (serviceType != null)
{
if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService)
{
scheduler.Schedule(() =>
{
using var scope = app.ApplicationServices.CreateScope();
var db = scope.ServiceProvider.GetService<SettleAccountDbContext>();
var jobItemRepository = db.Set<JobItem>();
var jobLogRepository = db.Set<JobLog>();
var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId);
if (!jobItem.IsDisabled)
{
jobItem.IsRunning = true;
db.SaveChanges();
var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now };
try
{
jobService.Invoke();
jobLog.Success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
jobLog.Exception = ex.ToString();
}
finally
{
jobLog.End = DateTime.Now;
jobLogRepository.Add(jobLog);
jobItem.IsRunning = false;
db.SaveChanges();
}
}
}).Cron(job.Cron);
}
}
});
});
var contentTypeProvider = new FileExtensionContentTypeProvider(); var contentTypeProvider = new FileExtensionContentTypeProvider();
contentTypeProvider.Mappings.Add(".mjs", "text/javascript"); contentTypeProvider.Mappings.Add(".mjs", "text/javascript");
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = contentTypeProvider }); app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = contentTypeProvider });

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json

@ -69,8 +69,7 @@
"AuthServer": { "AuthServer": {
"Authority": "http://dev.ccwin-in.com:10580", "Authority": "http://*:10582",
//"Authority": "http://localhost:10130",
"ClientId": "basic-web", "ClientId": "basic-web",
"ClientSecret": "1q2w3e*" "ClientSecret": "1q2w3e*"
}, },

11
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/start.cmd

@ -0,0 +1,11 @@
@echo off
tasklist|find /i "SettleAccount.HttpApi.Host.exe"
if %errorlevel% == 0 (
  exit
)
%1 start mshta vbscript:createobject("wscript.shell").run("""%~0"" ::",0)(window.close)&&exit
start /b SettleAccount.HttpApi.Host.exe --urls http://dev.ccwin-in.com:10582

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/stop.cmd

@ -0,0 +1,3 @@
@ECHO OFF
taskkill /im SettleAccount.HttpApi.Host.exe /f /t

18
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -197,7 +197,7 @@ export default {
<el-scrollbar> <el-scrollbar>
<app-list <app-list
v-if="subDrawer" v-if="subDrawer"
:query="subListQuery.query" :query="subListQuery"
:buttons="subListQuery.buttons" :buttons="subListQuery.buttons"
:config="subListQuery.config" :config="subListQuery.config"
/> />
@ -383,14 +383,13 @@ export default {
const columns = ref([]); const columns = ref([]);
const filterDrawer = ref(false); const filterDrawer = ref(false);
const subDrawer = ref(false); const subDrawer = ref(false);
const subListQuery = ref({}); const subListQuery = ref(props.query ?? {});
const tableLoading = ref(false); const tableLoading = ref(false);
const selectedRows = ref([]); const selectedRows = ref([]);
const dialogVisible = ref(false); const dialogVisible = ref(false);
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStore();
// 注释一下代码暂停权限验证 // 注释一下代码暂停权限验证
// const buttons = ref(props.buttons ?? route.meta.children.filter((o) => o.meta.hasPermission)); // const buttons = ref(props.buttons ?? route.meta.children.filter((o) => o.meta.hasPermission));
// 添加下行代码暂停权限验证 // 添加下行代码暂停权限验证
@ -704,14 +703,11 @@ export default {
const showList = (value, nav, config) => { const showList = (value, nav, config) => {
if (!subDrawer.value) { if (!subDrawer.value) {
const targetRoute = router.getRoutes().find((o) => o.meta?.path === nav); const targetRoute = router.getRoutes().find((o) => o.meta?.path === nav);
// subListQuery.value = { subListQuery.value = {
// query: value, query: value,
// buttons: targetRoute.meta.children, buttons: targetRoute.meta.children,
// config, config,
// }; };
subListQuery.value.query = value;
subListQuery.value.buttons = targetRoute.meta.children;
subListQuery.value.config = config;
subDrawer.value = true; subDrawer.value = true;
} }
}; };

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js

@ -14,8 +14,8 @@ export default {
console.log(item.path, item, rows); console.log(item.path, item, rows);
console.log(showList); console.log(showList);
const config = useConfig2(); const config = useConfig2();
// config.query.schema.properties.filters.default[0].value = rows[0].id; config.query.schema.properties.filters.default[0].value = rows[0].id;
showList({ jobId: rows[0].id }, "/base-data/job-log", config); showList({ test: "test" }, "/base-data/job-log", config);
}; };
return { config, onCommand }; return { config, onCommand };
}, },

145
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Core;
using Volo.Abp.Application.Dtos;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos;
public class PUB_ADJ_DETAIL_DTO : EntityDto<Guid>
{
/// <summary>
///工厂地点
/// </summary>
[Display(Name = "工厂地点")]
public string Site { get; set; }
/// <summary>
///扩展1
/// </summary>
[Display(Name = "扩展1")]
public string Extend1 { get; set; }
/// <summary>
///作废发票号
/// </summary>
[Display(Name = "作废发票号")]
public string OldInvBillNum { get; set; }
/// <summary>
///发票号
/// </summary>
[Display(Name = "发票号")]
public string InvBillNum { get; set; }
public decimal Price { get; set; }
public int Version { get; set; }
public string SettleBillNum { get; set; }
public DateTime SettleDate { get; set; }
public string InvGroupNum { get; set; }
public string LU { get; set; }
public string PN { get; set; }
public string KeyCode { get; set; }
public decimal Qty { get; set; }
public string GroupNum { get; set; }
}
public class PUB_ADJ_DETAIL_EXP_DTO
{
/// <summary>
///工厂地点
/// </summary>
[ExporterHeader(DisplayName = "工厂地点")]
public string Site { get; set; }
/// <summary>
///扩展1
/// </summary>
[ExporterHeader(DisplayName = "扩展1")]
public string Extend1 { get; set; }
/// <summary>
///作废发票号
/// </summary>
[ExporterHeader(DisplayName = "作废发票号")]
public string OldInvBillNum { get; set; }
/// <summary>
///发票号
/// </summary>
[ExporterHeader(DisplayName = "发票号")]
public string InvBillNum { get; set; }
public decimal Price { get; set; }
public int Version { get; set; }
public string SettleBillNum { get; set; }
public DateTime SettleDate { get; set; }
public string InvGroupNum { get; set; }
public string LU { get; set; }
public string PN { get; set; }
public string KeyCode { get; set; }
public decimal Qty { get; set; }
public string GroupNum { get; set; }
}
public class PUB_ADJ_DETAIL_IMP_DTO
{
/// <summary>
///工厂地点
/// </summary>
[ImporterHeader(Name = "工厂地点")]
public string Site { get; set; }
/// <summary>
///扩展1
/// </summary>
[ImporterHeader(Name = "扩展1")]
public string Extend1 { get; set; }
/// <summary>
///作废发票号
/// </summary>
[ImporterHeader(Name = "作废发票号")]
public string OldInvBillNum { get; set; }
/// <summary>
///发票号
/// </summary>
[ImporterHeader(Name = "发票号")]
public string InvBillNum { get; set; }
public decimal Price { get; set; }
public int Version { get; set; }
public string SettleBillNum { get; set; }
public DateTime SettleDate { get; set; }
public string InvGroupNum { get; set; }
public string LU { get; set; }
public string PN { get; set; }
public string KeyCode { get; set; }
public decimal Qty { get; set; }
public string GroupNum { get; set; }
}
public class PUB_ADJ_DETAIL_REQ_DTO : RequestInputBase
{
[Display(Name = "工厂地点")]
public string Site { get; set; }
[Display(Name = "扩展1")]
public string Extend1 { get; set; }
[Display(Name = "作废发票号")]
public string OldInvBillNum { get; set; }
[Display(Name = "发票号")]
public string InvBillNum { get; set; }
public string InvGroupNum { get; set; }
public string LU { get; set; }
public string PN { get; set; }
public string KeyCode { get; set; }
public string GroupNum { get; set; }
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IINVOICE_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.Text; using System.Text;
@ -10,12 +10,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
public interface IINVOICE_SERVICE public interface IINVOICE_SERVICE
{ {
//Import
//ApprovalPassed
//Reject
//MainQuery
//DetailQuery
//Sync_QAD
Task<bool> ApprovalPassed(INVOICE_GRP_REQ_DTO input); Task<bool> ApprovalPassed(INVOICE_GRP_REQ_DTO input);
Task<PagedResultDto<INVOICE_GRP_DTO>> MainQueryAsync(INVOICE_GRP_REQ_DTO input); Task<PagedResultDto<INVOICE_GRP_DTO>> MainQueryAsync(INVOICE_GRP_REQ_DTO input);
Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input); Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input);

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BASE_SERVICE.cs

@ -23,7 +23,7 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
private readonly IExcelImportAppService _excelImportService; protected readonly IExcelImportAppService _excelImportService;
protected readonly ISnowflakeIdGenerator _snowflakeIdGenerator; protected readonly ISnowflakeIdGenerator _snowflakeIdGenerator;

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

@ -1,3 +1,5 @@
using CodeArts.Db.Lts;
using DocumentFormat.OpenXml.Bibliography;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Csv;
@ -20,11 +22,14 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
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.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.Migrations;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases namespace Win.Sfs.SettleAccount.Bases
@ -32,39 +37,41 @@ namespace Win.Sfs.SettleAccount.Bases
public abstract class BA_SERVICE: BASE_SERVICE public abstract class BA_SERVICE: BASE_SERVICE
{ {
protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository; protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository;
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository; protected readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository; protected readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository;
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _mRepository; protected readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _mRepository;
private readonly BBAC_CAN_SA_MNG _pubMng; protected readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly HBPO_CAN_SA_MNG _bbacMng; protected readonly HBPO_CAN_SA_MNG _pubMng;
private readonly PUB_CAN_SA_MNG _hbpoMng; protected readonly BBAC_CAN_SA_MNG _bbacMng;
private readonly INV_MNG _invMng; protected readonly PUB_CAN_SA_MNG _hbpoMng;
protected readonly INV_MNG _invMng;
//private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
protected BA_SERVICE( protected BA_SERVICE(
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
BBAC_CAN_SA_MNG pubMng, HBPO_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng, BBAC_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng INV_MNG invMng
//INormalEfCoreRepository<TEntityDetail, Guid> detailRepository //INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
) )
{ {
_excelImportService = excelImportService;
_repository = repository; _repository = repository;
_wRepository = wRepository; _wRepository = wRepository;
_mRepository = mRepository; _mRepository = mRepository;
_sRepository = sRepository; _sRepository = sRepository;
_adjRepository = adjRepository;
_pubMng = pubMng; _pubMng = pubMng;
_bbacMng = bbacMng; _bbacMng = bbacMng;
_hbpoMng = hbpoMng; _hbpoMng = hbpoMng;
@ -72,18 +79,45 @@ namespace Win.Sfs.SettleAccount.Bases
} }
/// <summary> protected BA_SERVICE(IExcelImportAppService excelImportService,
/// 审核发票通过 ISnowflakeIdGenerator snowflakeIdGenerator,
/// </summary> ICommonManager commonManager,
/// <param name="input"></param> INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository,
/// <returns></returns> INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng
) :
base(excelImportService, snowflakeIdGenerator, commonManager)
{
}
public virtual async Task<string> GenerateInvoice(INVOICE_GRP_REQ_DTO input) public virtual async Task<string> GenerateInvoice(INVOICE_GRP_REQ_DTO input)
{ {
await _invMng.SetForwardState(input.InvGroupNum, SettleBillState.); await _invMng.SetForwardState(input.InvGroupNum, SettleBillState.);
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 发票重开
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<string> ReissueInvoice(INVOICE_GRP_REQ_DTO input)
{
// await _invMng.SetForwardState(input.InvGroupNum, SettleBillState.商务已审核);
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
@ -111,18 +145,16 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
INVOICE_GRP_DETAIL_DTO entity=new INVOICE_GRP_DETAIL_DTO(); INVOICE_GRP_DETAIL_DTO entity=new INVOICE_GRP_DETAIL_DTO();
var m= await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var m= await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting,int.MaxValue, input.SkipCount);
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m); var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
var w=await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); 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 s=await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var s=await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
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);
entity.INVOICE_NOT_SETTLE = sdtos; entity.INVOICE_NOT_SETTLE = sdtos;
entity.INVOICE_WAIT_DETAIL = wdtos; entity.INVOICE_WAIT_DETAIL = wdtos;
entity.INVOICE_MAP_GROUP = mdtos; entity.INVOICE_MAP_GROUP = mdtos;
return entity; return entity;
} }
/// <summary> /// <summary>
/// 导出文件 /// 导出文件
@ -196,5 +228,80 @@ namespace Win.Sfs.SettleAccount.Bases
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input)
{
var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
return mdtos;
}
protected virtual async Task<List<INVOICE_WAIT_DETAIL_DTO>> GetDetailAsync(INVOICE_GRP_REQ_DTO input)
{
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);
return wdtos;
}
protected virtual async Task<List<INVOICE_NOT_SETTLE_DTO>> GetNotDetailAsync(INVOICE_GRP_REQ_DTO input)
{
var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);
return sdtos;
}
protected virtual async Task<List<INVOICE_NOT_SETTLE>> GetNotDetailAsync(string p_invbillNum)
{
List<FilterCondition> filters = new List<FilterCondition>();
filters.Add(new FilterCondition("InvBillNum", p_invbillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
return await _sRepository.GetListByFilterAsync(filters);
}
protected virtual async Task<List<PUB_ADJ_DETAIL_DTO>> GetAjdmentDetail(INVOICE_GRP_REQ_DTO input)
{
var s = await _adjRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var sdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(s);
return sdtos;
}
protected virtual async Task<List<PUB_ADJ_DETAIL_DTO>> GetAjdmentDetail(string p_invbillNum)
{
List<FilterCondition> filters = new List<FilterCondition>();
filters.Add(new FilterCondition("InvBillNum", p_invbillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
var s = await _adjRepository.GetListByFilterAsync(filters);
var sdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(s);
return sdtos;
}
protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(string p_invbillNum)
{
List<FilterCondition> filters = new List<FilterCondition>();
filters.Add(new FilterCondition("InvBillNum", p_invbillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
var m = await _mRepository.GetListByFilterAsync(filters);
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
return mdtos;
}
/// <summary>
/// 通过发票号获取发票
/// </summary>
/// <param name="p_invbillNum"></param>
/// <returns></returns>
protected virtual async Task<INVOICE_GRP> GetInvoiceGroupByInvBillNum(string p_invbillNum)
{
List<FilterCondition> filters = new List<FilterCondition>();
filters.Add(new FilterCondition("InvBillNum", p_invbillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
var ls= await _repository.GetListByFilterAsync(filters);
if(ls!=null && ls.Count()>0)
{
return ls.FirstOrDefault();
}
return null;
}
} }
} }

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

@ -22,6 +22,7 @@ using Volo.Abp.ObjectMapping;
using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore;
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.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.Dtos;
@ -139,34 +140,30 @@ namespace Win.Sfs.SettleAccount.Bases
where TRequestDetailInput : RequestInputBase where TRequestDetailInput : RequestInputBase
where TEntityDetailExportDto : class, new() where TEntityDetailExportDto : class, new()
{ {
protected readonly INormalEfCoreRepository<TEntity, Guid> _repository; protected readonly INormalEfCoreRepository<TEntity, Guid> _repository;
protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository; protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
protected readonly INV_MNG _invmng; protected readonly INV_MNG _invmng;
//private readonly CAN_SA_MNG<TEntity, TEntityDetail> _bbacMng;
protected CAN_SA_SERVICE( protected CAN_SA_SERVICE(
INormalEfCoreRepository<TEntity, Guid> repository,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<TEntity, Guid> repository,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository, INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
//CAN_SA_MNG<TEntity, TEntityDetail> bbacMng,
INV_MNG invmng INV_MNG invmng
) )
: base(excelImportService, snowflakeIdGenerator, commonManager)
{ {
_invmng = invmng; _invmng = invmng;
_excelImportService = excelImportService; _excelImportService = excelImportService;
_repository = repository; _repository = repository;
_detailRepository = detailRepository; _detailRepository = detailRepository;
} }
/// <summary> /// <summary>
///查询明细 ///查询明细
/// </summary> /// </summary>

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs

@ -1,4 +1,4 @@
using AutoMapper; using AutoMapper;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
@ -17,6 +17,7 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
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.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
@ -37,19 +38,19 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository; protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
protected readonly IExcelImportAppService _excelImportService;
protected NOT_SA_SERVICE( protected NOT_SA_SERVICE(
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
) )
: base(excelImportService, snowflakeIdGenerator, commonManager)
{ {
_excelImportService = excelImportService;
_detailRepository = detailRepository;
} }
/// <summary> /// <summary>
/// 查询明细 /// 查询明细
/// </summary> /// </summary>

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

@ -18,6 +18,7 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
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.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
@ -38,21 +39,18 @@ namespace Win.Sfs.SettleAccount.Bases
private readonly INormalEfCoreRepository<TEntity, Guid> _repository; private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository; private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
public PD_SERVICE(
protected PD_SERVICE(
INormalEfCoreRepository<TEntity, Guid> repository,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<TEntity, Guid> repository,
) INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager)
{ {
_excelImportService = excelImportService;
_repository = repository; _repository = repository;
_detailRepository = detailRepository; _detailRepository = detailRepository;
} }
/// <summary> /// <summary>

496
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs

@ -1,15 +1,26 @@
using DocumentFormat.OpenXml.Bibliography;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Policy;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
@ -21,8 +32,491 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class BBAC_BA_SERVICE : BA_SERVICE public class BBAC_BA_SERVICE : BA_SERVICE
{ {
public BBAC_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, BBAC_CAN_SA_MNG pubMng, HBPO_CAN_SA_MNG bbacMng, PUB_CAN_SA_MNG hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng)
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
public BBAC_BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, pubMng, bbacMng, hbpoMng, invMng)
{
_adjRepository = adjRepository;
_priceRepository = priceRepository;
}
/// <summary>
/// 发票重开
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<string> ReissueInvoice(string p_invbillnum)
{
var mappingList= await GetMapGroupAsync(p_invbillnum);//结算分组
if (mappingList != null && mappingList.Count() > 0)
{
var version=int.Parse(DateTime.Now.ToString("yyyymm"));
var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv= await GetInvoiceGroupByInvBillNum(p_invbillnum);
if (inv != null)
{
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件
var adjlist=await _adjRepository.Where(p=>p.InvBillNum==inv.InvbillNum).ToListAsync();
if(adjlist!=null && adjlist.Count()>0)
{
foreach (var itm in adjlist)
{
bbaclist.Add(new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: itm.Price,
category: itm.BusinessType,
isReturn: itm.Qty > 0 ? false : true,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1//生产号
));
}
}
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var priceList = _priceRepository.ToList();//价格单
var inner = from d in dto1s
join p in priceList on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = "业务类别BBAC", Version = version.ToString(), Message = "LU:{0}PN:{1},下线日期:{2}没有对应区间销售价格表!" });
}
if (errorList.Count() > 0)
{
return await ExportErrorReportAsync(errorList);
}
var q = from d in dto1s
join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select new TEMP_CAN_SA_DETAIL
{
SettleBillNum = d.SettleBillNum,
Site = d.Site,
Version = d.Version,
Price = p.Price,
BillNum = d.BillNum,
SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum,
LU = d.LU,
MaterialDesc = d.MaterialDesc,
PN = d.PN,
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = d.ContractDocID,
BeginDate = p.BeginTime,
EndDate = p.EndTime
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (p_invbillnum.Substring(0, 1) == "INV")//一次开票
{
// dtos = dtos.OrderBy(p => p.SettleDate).ToList();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).OrderBy(p => p.Amt);
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
//List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList(); //初始LU种类
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除已经开票分组
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
// string str = JsonConvert.SerializeObject(invoiceMap);
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.ContractDocID, p.BeginDate, p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = itm.Sum(p => p.Amt),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum: inv.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
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: version,
invbillNum: key,
invGroupNum:inv.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisHBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContactDocID,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{ {
detailList.AddRange(_entityDetailList);
} }
#region 原有新发票生成时
//var notls = notList.GroupBy(p => new { p.GroupNum, p.LU })
// .Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
//var innotls = new List<INVOICE_NOT_SETTLE>();
//foreach (var nitm in notls)
//{
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: main.Version,
// invGroupNum: main.InvGroupNum,
// settleGroupNum: nitm.GroupNum,
// lU: string.Empty,
// lU1: nitm.LU,
// extend1: string.Empty,
// extend2: string.Empty,
// qty: nitm.Qty
// ));
//}
//if (innotls.Count > 0)
//{
// notDetialList.AddRange(innotls);
//}
#endregion
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisBBAC,
invGroupNum: inv.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax:0,
parent:inv.InvbillNum
);
invlist.Add(invbill);
}
var notlist=await GetNotDetailAsync(p_invbillnum);
if (notlist != null && notlist.Count > 0)
{
foreach (var nitm in notlist)
{
notDetialList.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: version,
invGroupNum: nitm.InvGroupNum,
settleGroupNum: nitm.SettleGroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU
&& p.ContractDocID == group.ContractDocID
&& p.BeginDate == group.BeginDate
&& p.EndDate == group.EndDate
);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
sum += group1.Amt;
if (sum > 10000000)
{
break;
}
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.ContractDocID, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.ContractDocID, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp
where tm == null
select new TMEP_INV
{
LU = itm.LU,
ContractDocID = itm.ContractDocID,
Price = itm.Price,
Amt = itm.Amt,
Qty = itm.Qty,
BeginDate = itm.BeginDate,
EndDate = itm.EndDate
};
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum: inv.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisBBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum: inv.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisBBAC,
invGroupNum: inv.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: inv.InvbillNum
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
}
}
else
{
throw new BusinessException("8989", $"不存发票号为:{p_invbillnum}发票");
}
}
else
{
throw new BusinessException("8989", $"不存发票号:{p_invbillnum}对应的结算分组号");
}
return ApplicationConsts.SuccessStr;
}
} }
} }

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

@ -26,15 +26,13 @@ using Newtonsoft.Json;
using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Win.Abp.Snowflakes;
using Win.Sfs.SettleAccount.CommonManagers;
using Volo.Abp;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
/// <summary> /// <summary>
/// BBAC-JIS可结算单 /// BBAC-JIS可结算单
/// </summary> /// </summary>
@ -57,22 +55,25 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly BBAC_CAN_SA_MNG _bbacMng; private readonly BBAC_CAN_SA_MNG _bbacMng;
public BBAC_CAN_SA_SERVICE(IExcelImportAppService excelImportService,
public BBAC_CAN_SA_SERVICE( ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository, INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository, INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
BBAC_CAN_SA_MNG bbacMng,
INV_MNG invmng, INV_MNG invmng,
INormalEfCoreRepository<PriceList, Guid> priceRepository INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
) : base(repository, excelImportService, detailRepository, invmng) INormalEfCoreRepository<PriceList, Guid> priceRepository,
BBAC_CAN_SA_MNG bbacMng
)
: base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
{ {
_notRepository = notRepository; _notRepository = notRepository;
_bbacMng = bbacMng; _bbacMng = bbacMng;
_priceRepository = priceRepository; _priceRepository = priceRepository;
} }
/// <summary> /// <summary>
/// 生成发票 /// 生成发票
/// </summary> /// </summary>
@ -100,9 +101,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
where where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d; select d;
var left= from d in dto1s join p in inner on new { d.LU,d.PN } equals new {p.LU,p.PN} var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp from tm in temp.DefaultIfEmpty()//校验错误项 into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null where tm == null
select d; select d;
@ -163,7 +166,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
List<string> List = new List<string>(); List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额 decimal sum = itm.Value;//初始分组合计金额
//List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList(); //初始LU种类 //List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList(); //初始LU种类
foreach (var _itm1 in copyDic) foreach (var _itm1 in copyDic)
{ {
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化 if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
@ -297,7 +299,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: EnumBusinessType.JisBBAC, businessType: EnumBusinessType.JisBBAC,
invGroupNum: main.InvGroupNum, invGroupNum: main.InvGroupNum,
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState. invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
); );
invlist.Add(invbill); invlist.Add(invbill);
} }
@ -311,7 +315,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{ {
BeginDate=p.Key.BeginDate, EndDate=p.Key.EndDate, BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU, LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID, ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt), Amt = p.Sum(itm => itm.Amt),
@ -370,10 +375,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var query = from itm in groups1 var query = from itm in groups1
join itm1 in tempList join itm1 in tempList
on new { itm.LU, itm.ContractDocID, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.ContractDocID, itm1.BeginDate, itm1.EndDate } into temp on new { itm.LU, itm.ContractDocID, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.ContractDocID, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp where tm==null from tm in temp
where tm == null
select new TMEP_INV select new TMEP_INV
{ LU = itm.LU, ContractDocID = itm.ContractDocID, {
Amt = itm.Amt, Qty = itm.Qty,BeginDate=itm.BeginDate, LU = itm.LU,
ContractDocID = itm.ContractDocID,
Amt = itm.Amt,
Qty = itm.Qty,
BeginDate = itm.BeginDate,
EndDate = itm.EndDate EndDate = itm.EndDate
}; };
groups1 = query.ToList(); groups1 = query.ToList();
@ -407,8 +417,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
extend2: string.Empty, extend2: string.Empty,
beginDate: detail.BeginDate, beginDate: detail.BeginDate,
endDate: detail.EndDate endDate: detail.EndDate
)); ));
} }
if (_entityDetailList.Count > 0) if (_entityDetailList.Count > 0)
@ -450,7 +458,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: EnumBusinessType.JisBBAC, businessType: EnumBusinessType.JisBBAC,
invGroupNum: main.InvGroupNum, invGroupNum: main.InvGroupNum,
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState. invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
); );
invlist.Add(invbill); invlist.Add(invbill);
} }
@ -464,7 +474,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
} }
} }
}
else
{
throw new BusinessException("8989", string.Format("{0}不存在该可结算单号", input.BillNum));
} }
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }

15
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs

@ -10,8 +10,10 @@ using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
@ -35,14 +37,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly BBAC_NOT_SA_MNG _bbacNotMng; private readonly BBAC_NOT_SA_MNG _bbacNotMng;
public BBAC_NOT_SA_SERVICE(
BBAC_NOT_SA_MNG bbacNotMng,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> detailRepository) : base(excelImportService, detailRepository) public BBAC_NOT_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager, INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> detailRepository, BBAC_NOT_SA_MNG bbacNotMng) :
base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository)
{ {
_bbacNotMng = bbacNotMng; _bbacNotMng = bbacNotMng;
} }
[HttpPost] [HttpPost]
public override async Task<string> GenerateSettlementOrder(BBAC_NOT_SA_DETAIL_REQ_DTO input) public override async Task<string> GenerateSettlementOrder(BBAC_NOT_SA_DETAIL_REQ_DTO input)
{ {

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

@ -7,8 +7,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -23,7 +25,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BBAC_PD_DETAIL, BBAC_PD_DETAIL_DTO, BBAC_PD_REQ_DTO, BBAC_PD_DETAIL, BBAC_PD_DETAIL_DTO, BBAC_PD_REQ_DTO,
BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO> BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO>
{ {
protected BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_PD, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository) : base(repository, excelImportService, detailRepository) public BBAC_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository)
{ {
} }
} }

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

@ -7,8 +7,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -18,7 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class HBPO_BA_SERVICE : BA_SERVICE public class HBPO_BA_SERVICE : BA_SERVICE
{ {
public HBPO_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, BBAC_CAN_SA_MNG pubMng, HBPO_CAN_SA_MNG bbacMng, PUB_CAN_SA_MNG hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng) public HBPO_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, BBAC_CAN_SA_MNG pubMng, HBPO_CAN_SA_MNG bbacMng, PUB_CAN_SA_MNG hbpoMng, INV_MNG invMng) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, pubMng, bbacMng, hbpoMng, invMng)
{ {
} }
} }

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

@ -11,8 +11,10 @@ using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
@ -39,22 +41,35 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
HBPO_CAN_SA_DETAIL_EXP_DTO HBPO_CAN_SA_DETAIL_EXP_DTO
> >
{ {
private INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository; private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly HBPO_CAN_SA_MNG _hbpoMng; private readonly HBPO_CAN_SA_MNG _hbpoMng;
public HBPO_CAN_SA_SERVICE(INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
public HBPO_CAN_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository, INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository,
INV_MNG invmng, INV_MNG invmng,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository, INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
HBPO_CAN_SA_MNG hbpoMng, INormalEfCoreRepository<PriceList, Guid> priceRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository HBPO_CAN_SA_MNG hbpoMng
) : base(repository, excelImportService, detailRepository, invmng)
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
{ {
_priceRepository = priceRepository; _priceRepository = priceRepository;
_notRepository = notRepository; _notRepository = notRepository;
_hbpoMng = hbpoMng; _hbpoMng = hbpoMng;
} }
/// <summary> /// <summary>
/// 生成发票 /// 生成发票
/// </summary> /// </summary>
@ -278,8 +293,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: EnumBusinessType.JisHBPO, businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum, invGroupNum: main.InvGroupNum,
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState. invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
); );
invlist.Add(invbill); invlist.Add(invbill);
} }
@ -419,7 +435,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: EnumBusinessType.JisHBPO, businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum, invGroupNum: main.InvGroupNum,
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState. invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
); );
invlist.Add(invbill); invlist.Add(invbill);
} }

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs

@ -10,8 +10,10 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
@ -32,13 +34,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
private readonly HBPO_NOT_SA_MNG _hbpoNotMng; private readonly HBPO_NOT_SA_MNG _hbpoNotMng;
public HBPO_NOT_SA_SERVICE(IExcelImportAppService excelImportService, public HBPO_NOT_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> detailRepository, INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> detailRepository,
HBPO_NOT_SA_MNG hbpoNotMng HBPO_NOT_SA_MNG hbpoNotMng
) : base(excelImportService, detailRepository) ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository)
{ {
_hbpoNotMng = hbpoNotMng; _hbpoNotMng = hbpoNotMng;
} }
public override async Task<string> GenerateSettlementOrder(HBPO_NOT_SA_DETAIL_REQ_DTO input) public override async Task<string> GenerateSettlementOrder(HBPO_NOT_SA_DETAIL_REQ_DTO input)
{ {
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);

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

@ -7,8 +7,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -21,7 +23,7 @@ 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>
{ {
protected HBPO_PD_SERVICE(INormalEfCoreRepository<HBPO_PD, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository) : base(repository, excelImportService, detailRepository) public HBPO_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository)
{ {
} }
} }

204
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs

@ -0,0 +1,204 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Cronos;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount.Entities.BQ;
public class JobHostdService : BackgroundService
{
private readonly object _lockObj = new object();
private readonly IServiceProvider _serviceProvider;
private CancellationToken _stoppingToken;
public JobHostdService(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
}
public static List<Type> ServiceTypes { get; private set; }
public ConcurrentDictionary<JobItem, Tuple<CancellationTokenSource, Thread>> Jobs { get; } = new();
public static void AddService(IServiceCollection services)
{
ServiceTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes())
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService)))
.ToList();
ServiceTypes.ForEach(o =>
{
services.AddTransient(typeof(IJobService), o);
services.AddTransient(o);
});
}
public void AddJob(JobItem job)
{
lock (_lockObj)
{
if (!Jobs.Keys.Any(o => o.Id == job.Id))
{
try
{
var source = new CancellationTokenSource();
var token = source.Token;
var thread = new Thread(async () =>
{
try
{
var expression = CronExpression.Parse(job.Cron, job.Cron.Split(' ').Length == 5 ? CronFormat.Standard : CronFormat.IncludeSeconds);
var serviceType = ServiceTypes.FirstOrDefault(o => o.FullName == job.Service);
if (serviceType != null)
{
while (!_stoppingToken.IsCancellationRequested && !token.IsCancellationRequested)
{
try
{
var now = DateTime.UtcNow;
var nextUtc = expression.GetNextOccurrence(now);
var span = nextUtc - now;
await Task.Delay(span.Value).ConfigureAwait(false);
Debug.WriteLine($"{job.Name} 定时任务开始执行");
using var scope = this._serviceProvider.CreateScope();
if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService)
{
if (!job.IsDisabled)
{
var jobItem = this.GetJobItem(job.Id);
if (!jobItem.IsRunning)
{
this.JobItemStart(job.Id);
}
try
{
jobService.Invoke();
this.JobItemSuccess(job.Id);
Debug.WriteLine($"{job.Name} 定时任务执行成功");
}
catch (Exception ex)
{
Debug.WriteLine($"{job.Name} 定时任务执行失败:{ex.Message}");
Console.WriteLine(ex.ToString());
this.JobItemFaild(job.Id, ex);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
});
thread.IsBackground = true;
if (this.Jobs.TryAdd(job, new Tuple<CancellationTokenSource, Thread>(source, thread)))
{
thread.Start();
Debug.WriteLine($"{job.Name} 定时任务线程启动");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
private void JobItemFaild(Guid id, Exception ex)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var entity = db.Set<JobItem>().FirstOrDefault(o => o.Id == id);
if (entity != null)
{
entity.IsRunning = false;
var log = db.Set<JobLog>().FirstOrDefault(o => o.JobId == id);
log.End = DateTime.Now;
log.Success = false;
log.Exception = ex.ToString();
db.SaveChanges();
}
}
private void JobItemSuccess(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var entity = db.Set<JobItem>().FirstOrDefault(o => o.Id == id);
if (entity != null)
{
entity.IsRunning = false;
var log = db.Set<JobLog>().FirstOrDefault(o => o.JobId == id);
log.End = DateTime.Now;
log.Success = true;
db.SaveChanges();
}
}
private void JobItemStart(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var entity = db.Set<JobItem>().FirstOrDefault(o => o.Id == id);
if (entity != null)
{
entity.IsRunning = true;
var log = db.Set<JobLog>().Add(new JobLog { Start = DateTime.Now, JobId = entity.Id });
db.SaveChanges();
}
}
private JobItem GetJobItem(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
return scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>().Set<JobItem>().AsNoTracking().FirstOrDefault(o => o.Id == id);
}
public void RemoveJob(JobItem item)
{
lock (_lockObj)
{
var key = this.Jobs.Keys.FirstOrDefault(o => o.Id == item.Id);
if (key != null)
{
try
{
if (this.Jobs.TryRemove(key, out var value))
{
value.Item1.Cancel();
value.Item2.Interrupt();
value.Item2.Join();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
this._stoppingToken = stoppingToken;
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var jobs = db.Set<JobItem>().AsNoTracking().ToList();
jobs.ForEach(this.AddJob);
return Task.CompletedTask;
}
}

140
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Threading; using System.Threading;
@ -20,145 +21,6 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ; namespace Win.Sfs.SettleAccount.Entities.BQ;
public class JobHostdService : BackgroundService
{
private readonly object _lockObj = new object();
private readonly IServiceProvider _serviceProvider;
private CancellationToken _stoppingToken;
public JobHostdService(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
}
public ConcurrentDictionary<JobItem, Tuple<CancellationTokenSource, Thread>> Jobs { get; } = new();
public static List<Type> ServiceTypes { get; private set; }
public static void AddService(IServiceCollection services)
{
ServiceTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes())
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService)))
.ToList();
ServiceTypes.ForEach(o =>
{
services.AddTransient(typeof(IJobService), o);
services.AddTransient(o);
});
}
public void AddJob(JobItem job)
{
lock (_lockObj)
{
if (!Jobs.Keys.Any(o => o.Id == job.Id))
{
try
{
var source = new CancellationTokenSource();
var token = source.Token;
var thread = new Thread(async () =>
{
var expression = CronExpression.Parse(job.Cron);
using var scope1 = this._serviceProvider.CreateScope();
var serviceType = ServiceTypes.FirstOrDefault(o => o.FullName == job.Service);
if (serviceType != null)
{
while (!_stoppingToken.IsCancellationRequested && !token.IsCancellationRequested)
{
try
{
var nextUtc = expression.GetNextOccurrence(DateTime.UtcNow);
var span = nextUtc - DateTime.UtcNow;
await Task.Delay(span.Value).ConfigureAwait(false);
using var scope = this._serviceProvider.CreateScope();
if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService)
{
var db = scope.ServiceProvider.GetService<SettleAccountDbContext>();
var jobItemRepository = db.Set<JobItem>();
var jobLogRepository = db.Set<JobLog>();
var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == job.Id);
if (!jobItem.IsDisabled)
{
jobItem.IsRunning = true;
db.SaveChanges();
var jobLog = new JobLog { JobId = job.Id, Start = DateTime.Now };
try
{
jobService.Invoke();
jobLog.Success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
jobLog.Exception = ex.ToString();
}
finally
{
jobLog.End = DateTime.Now;
jobLogRepository.Add(jobLog);
jobItem.IsRunning = false;
db.SaveChanges();
}
}
}
}
catch (Exception)
{
throw;
}
}
}
});
thread.IsBackground = true;
if (this.Jobs.TryAdd(job, new Tuple<CancellationTokenSource, Thread>(source, thread)))
{
thread.Start();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
public void RemoveJob(JobItem item)
{
lock (_lockObj)
{
var key = this.Jobs.Keys.FirstOrDefault(o => o.Id == item.Id);
if (key != null)
{
try
{
if (this.Jobs.TryRemove(key, out var value))
{
value.Item1.Cancel();
value.Item2.Interrupt();
value.Item2.Join();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
this._stoppingToken = stoppingToken;
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var jobs = db.Set<JobItem>().AsNoTracking().ToList();
jobs.ForEach(this.AddJob);
return Task.CompletedTask;
}
}
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class JobItemAppService : ApplicationService, ITransientDependency public class JobItemAppService : ApplicationService, ITransientDependency

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

@ -7,8 +7,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -18,7 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class PUB_BA_SERVICE : BA_SERVICE public class PUB_BA_SERVICE : BA_SERVICE
{ {
public PUB_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, BBAC_CAN_SA_MNG pubMng, HBPO_CAN_SA_MNG bbacMng, PUB_CAN_SA_MNG hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng) public PUB_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, BBAC_CAN_SA_MNG pubMng, HBPO_CAN_SA_MNG bbacMng, PUB_CAN_SA_MNG hbpoMng, INV_MNG invMng) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, pubMng, bbacMng, hbpoMng, invMng)
{ {
} }
} }

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

@ -6,8 +6,10 @@ using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
@ -38,18 +40,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly PUB_CAN_SA_MNG _pubMng; private readonly PUB_CAN_SA_MNG _pubMng;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository; private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository;
public PUB_CAN_SA_SERVICE(INormalEfCoreRepository<PUB_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService, public PUB_CAN_SA_SERVICE
(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_CAN_SA, Guid> repository,
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository,
INV_MNG invmng,
INormalEfCoreRepository<PriceList, Guid> priceRepository, INormalEfCoreRepository<PriceList, Guid> priceRepository,
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository, INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository,
INV_MNG invmng, PUB_CAN_SA_MNG pubMng
PUB_CAN_SA_MNG pubMng) : base(repository, excelImportService, detailRepository, invmng)
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
{ {
_pubMng = pubMng; _pubMng = pubMng;
_priceRepository = priceRepository; _priceRepository = priceRepository;
_pricebjRepository = pricebjRepository; _pricebjRepository = pricebjRepository;
} }
[HttpPost] [HttpPost]
public async override Task<string> GenerateInvoice(PUB_CAN_SA_REQ_DTO input) public async override Task<string> GenerateInvoice(PUB_CAN_SA_REQ_DTO input)
{ {
@ -274,7 +284,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: EnumBusinessType.JisHBPO, businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum, invGroupNum: main.InvGroupNum,
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState. invoiceBillState: InvoiceBillState.,
tax:0,
parent:string.Empty
); );
invlist.Add(invbill); invlist.Add(invbill);
@ -416,7 +429,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: EnumBusinessType.JisHBPO, businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum, invGroupNum: main.InvGroupNum,
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState. invoiceBillState: InvoiceBillState.,
tax:0,
parent:string.Empty
); );
invlist.Add(invbill); invlist.Add(invbill);
} }

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs

@ -10,8 +10,10 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
@ -28,14 +30,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PUB_NOT_SA_DETAIL_EXP_DTO> PUB_NOT_SA_DETAIL_EXP_DTO>
{ {
private readonly PUB_NOT_SA_MNG _pubNotMng; private readonly PUB_NOT_SA_MNG _pubNotMng;
public PUB_NOT_SA_SERVICE(
IExcelImportAppService excelImportService,
public PUB_NOT_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> detailRepository, INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> detailRepository,
PUB_NOT_SA_MNG pubNotMng PUB_NOT_SA_MNG pubNotMng
) : base(excelImportService, detailRepository) ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository)
{ {
_pubNotMng = pubNotMng;
} }
public override async Task<string> GenerateSettlementOrder(PUB_NOT_SA_DETAIL_REQ_DTO input) public override async Task<string> GenerateSettlementOrder(PUB_NOT_SA_DETAIL_REQ_DTO input)
{ {
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);

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

@ -7,8 +7,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -21,7 +23,7 @@ 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>
{ {
protected PUB_PD_SERVICE(INormalEfCoreRepository<PUB_PD, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository) : base(repository, excelImportService, detailRepository) public PUB_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository)
{ {
} }
} }

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

@ -75,7 +75,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
using var dbContext = new VmiSqliteContext(connectionString); using var dbContext = new VmiSqliteContext(connectionString);
if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated()) if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
{ {
var list = this._balanceRepository.AsNoTracking().ToList(); var list = this._balanceRepository.ToList();
foreach (var item in list) foreach (var item in list)
{ {
dbContext.Set<VmiBalance>().Add(item); dbContext.Set<VmiBalance>().Add(item);

125
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_ADJ_DETAIL.cs

@ -1,125 +0,0 @@
using SettleAccount.Bases;
using System;
using System.ComponentModel.DataAnnotations;
using Win.Sfs.SettleAccount;
namespace SettleAccount.Domain.BQ;
[Display(Name = "BBAC不可结算导入明细")]
public class BBAC_ADJ_DETAIL:SA_NOT_BASE
{
///// <summary>
///// 对应字段(Material+ExternalCalNumber)
///// </summary>
//[Display(Name = "LU+生产码")]
//public string KeyCode { get; set; } = null!;
///// <summary>
///// 期间
///// </summary>
//[Display(Name = "期间")]
//public int Version { get; set; }
///// <summary>
///// 结算单号
///// </summary>
//[Display(Name = "结算单号")]
//public string SettleBillNum { get; set; } = null!;
///// <summary>
///// 对应字段Material
///// </summary>
//[Display(Name = "零件号")]
//public string LU { get; set; } = null!;
///// <summary>
///// 对应字段ExternalCalNumber
///// </summary>
//[Display(Name = "生产码")]
//public string PN { get; set; } = null!;
/// <summary>
/// 选择工厂导入
/// </summary>
[Display(Name = "工厂地点")]
public string Site { get; set; } = null!;
/// <summary>
/// 对应字段Quantity
/// </summary>
//[Display(Name = "结算数量")]
//public decimal Qty { get; set; }
///// <summary>
///// 匹配价格表对应区间对应地点带出
///// </summary>
//[Display(Name = "单价")]
//public decimal Price { get; set; }
/// <summary>
/// ExternalCallNumber包含(R0)为买单件 1为JIS 2.为买单件
/// </summary>
[Display(Name = "业务类别")]
public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 对应字段MovementType,996正常,997为退货
/// </summary>
[Display(Name = "是否退货")]
public string IsReturn { get; set; } = null!;
//[Display(Name = "发票分组号")]
//public string InvGroupNum { get; set; } = null!;
///// <summary>
///// 对应字段PostingDate
///// </summary>
//[Display(Name = "结算日期(收货日期)")]
//public DateTime SettleDate { get; set; }
/// <summary>
/// 对应字段Reference
/// </summary>
//[Display(Name = "结算分组")]
//public string GroupNum { get; set; } = null!;
[Display(Name = "合同号")]
public string ContractDocID { get; set; }
[Display(Name = "作废发票号")]
public string OldInvBillNum { get; set; }
[Display(Name = "发票号")]
public string InvBillNum { get; set; }
public BBAC_ADJ_DETAIL()
{
}
public BBAC_ADJ_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, string isReturn, string invGroupNum, DateTime settleDate, string groupNum,string contractDocID, string oldinv, string inv)
{
Id = guid;
KeyCode = keyCode;
Version = version;
SettleBillNum = settleBillNum;
LU = lU;
PN = pN;
Site = site;
Qty = qty;
Price = price;
BusinessType = category;
IsReturn = isReturn;
InvGroupNum = invGroupNum;
SettleDate = settleDate;
GroupNum = groupNum;
ContractDocID = contractDocID;
OldInvBillNum = oldinv;
InvBillNum =inv;
}
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs

@ -110,7 +110,7 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE
/// 对应字段MovementType,996正常,997为退货 /// 对应字段MovementType,996正常,997为退货
/// </summary> /// </summary>
[Display(Name = "是否退货")] [Display(Name = "是否退货")]
public string IsReturn { get; set; } = null!; public bool IsReturn { get; set; } =false;
@ -137,7 +137,7 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE
} }
public BBAC_CAN_SA_DETAIL(Guid guid,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, string isReturn, public BBAC_CAN_SA_DETAIL(Guid guid,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn,
DateTime settleDate, string groupNum, string invGroupNum DateTime settleDate, string groupNum, string invGroupNum
,string contactid ,string contactid
):base(guid) ):base(guid)

70
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs

@ -19,6 +19,13 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
[Display(Name = "税后金额")] [Display(Name = "税后金额")]
public decimal TaxAmt { get; set; } public decimal TaxAmt { get; set; }
[Display(Name = "税额")]
public decimal Tax { get; set; }
[Display(Name = "原发票号")]
public string ParentInvbillNum{ get; set; }
[Display(Name = "发票分组号")] [Display(Name = "发票分组号")]
public string InvGroupNum { get; set; } = null!; public string InvGroupNum { get; set; } = null!;
@ -40,7 +47,7 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, string invGroupNum, string fileName, EnumBusinessType businessType, SettleBillState state,InvoiceBillState invoiceBillState) public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, string invGroupNum, string fileName, EnumBusinessType businessType, SettleBillState state,InvoiceBillState invoiceBillState,decimal tax,string parent)
{ {
Id= guid; Id= guid;
RealnvBillNum = realnvBillNum; RealnvBillNum = realnvBillNum;
@ -52,6 +59,9 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
BusinessType = businessType; BusinessType = businessType;
State = state; State = state;
InvoiceState = invoiceBillState; InvoiceState = invoiceBillState;
ParentInvbillNum = parent;
Tax = tax;
} }
@ -61,61 +71,3 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
} }
} }
//[ShangWuShenHeGroup]
//[Hidden]
//[Display(Name = "财务管理审核明细")]
//public class INVOICE_DETAIL : BaseEntity
//{
// [Display(Name = "零件号")]
// public string LU { get; set; } = null!;
// [Display(Name = "单价")]
// public decimal PRICE { get; set; }
// [Display(Name = "数量")]
// public decimal Qty { get; set; }
// [Display(Name = "金额")]
// public decimal Amt { get; set; }
// [Display(Name = "发票号")]
// public string InvbillNum { get; set; } = null!;
// [Display(Name = "发票分组号")]
// public string InvGroupNum { get; set; } = null!;
//[ShangWuShenHeGroup]
//[Display(Name = "待开票明细")]
//public class INVOICE_WAIT_DETAIL : BaseEntity
//{
// [Display(Name = "发票号")]
// public string InvbillNum { get; set; } = null!;
// [Display(Name = "零件号")]
// public string LU { get; set; } = null!;
// [Display(Name = "单价")]
// public decimal PRICE { get; set; }
// [Display(Name = "数量")]
// public decimal Qty { get; set; }
// [Display(Name = "金额")]
// public decimal Amt { get; set; }
// [Display(Name = "扩展字段1")]
// public string Extend1 { get; set; } = null!;
// [Display(Name = "扩展字段2")]
// public string Extend2 { get; set; } = null!;
// [Display(Name = "扩展字段3")]
// public string Extend3 { get; set; } = null!;
// [Display(Name = "扩展字段4")]
// public string Extend4 { get; set; } = null!;
// [Display(Name = "期间")]
// public int Version { get; set; }
// [Display(Name = "发票分组号")]
// public string InvGroupNum { get; set; } = null!;
// [Display(Name = "业务分类")]
// public string BussiessType { get; set; } = null!;
//}

10
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs

@ -247,6 +247,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync(); return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
} }
/// <summary>
/// 获取发票对应结算分组所有零件
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<BBAC_CAN_SA_DETAIL>> GetContainsAsync(string p_canSettleBillNum, List<string> p_list)
{
return await _detailRepository.Where(p =>p.InvGroupNum==p_canSettleBillNum && p_list.Contains(p.GroupNum)).ToListAsync();
}

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

@ -25,6 +25,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository; private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository;
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository; private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository; private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository;
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly PUB_CAN_SA_MNG _pubMng; private readonly PUB_CAN_SA_MNG _pubMng;
private readonly BBAC_CAN_SA_MNG _bbacMng; private readonly BBAC_CAN_SA_MNG _bbacMng;
private readonly HBPO_CAN_SA_MNG _hbpoMng; private readonly HBPO_CAN_SA_MNG _hbpoMng;
@ -39,7 +42,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository
) )
{ {
//_canRepository = canRepository; //_canRepository = canRepository;
@ -47,6 +51,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_detailRepository = detailRepository; _detailRepository = detailRepository;
_groupRepository = groupRepository; _groupRepository = groupRepository;
_notRepository = notRepository; _notRepository = notRepository;
_adjRepository = adjRepository;
_pubMng = pubMng; _pubMng = pubMng;
_bbacMng = bbacMng; _bbacMng = bbacMng;
_hbpoMng = hbpoMng; _hbpoMng = hbpoMng;
@ -217,8 +222,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
break; break;
} }
var flag = await SetSettleState(p_entiy, p_State,false); var flag = await SetSettleState(p_entiy, p_State,false);
if (flag == false) if (flag == false)
{ {
@ -226,7 +229,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
await _repository.UpdateAsync(p_entiy); await _repository.UpdateAsync(p_entiy);
return true; return true;
} }
@ -244,6 +246,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
return await _repository.Where(p => p.InvbillNum == p_groupbillNum).FirstOrDefaultAsync(); return await _repository.Where(p => p.InvbillNum == p_groupbillNum).FirstOrDefaultAsync();
} }
/// <summary>
/// 获得发票主表
/// </summary>
/// <param name="p_billNum"></param>
/// <returns></returns>
public virtual async Task<INVOICE_GRP> GetInvoiceAsync(string p_invbillNum)
{
return await _repository.Where(p => p.InvbillNum == p_invbillNum).FirstOrDefaultAsync();
}
/// <summary> /// <summary>
/// 客户已收票 /// 客户已收票
/// </summary> /// </summary>
@ -270,10 +286,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
); );
var bbacDetail = new List<BBAC_PD_DETAIL>(); var bbacDetail = new List<BBAC_PD_DETAIL>();
foreach (var itm in entityDetail) foreach (var itm in entityDetail)
{ {
bbacDetail.Add( bbacDetail.Add(
@ -297,8 +309,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
extend3: string.Empty, extend3: string.Empty,
extend4: string.Empty extend4: string.Empty
)); ));
await _repository.DbContext.BulkInsertAsync(new List<BBAC_PD>() { bbac }); await _repository.DbContext.BulkInsertAsync(new List<BBAC_PD>() { bbac });
await _repository.DbContext.BulkInsertAsync(bbacDetail); await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true; return true;
@ -408,14 +418,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
public virtual async Task<bool> Reject(INVOICE_GRP p_entity) public virtual async Task<bool> Reject(INVOICE_GRP p_entity)
{ {
if (await Reject(p_entity.InvGroupNum)) if (await Reject(p_entity.InvGroupNum))
return true; return true;
else else
return false; return false;
} }
/// <summary> /// <summary>
/// 退回 /// 退回
@ -448,28 +455,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _repository.DbContext.BulkDeleteAsync(notList); await _repository.DbContext.BulkDeleteAsync(notList);
await _repository.DbContext.BulkDeleteAsync(detailList); await _repository.DbContext.BulkDeleteAsync(detailList);
//await _repository.DbContext.BulkUpdateAsync(canList); //await _repository.DbContext.BulkUpdateAsync(canList);
} }
if (p_entity.State == SettleBillState.) if (p_entity.State == SettleBillState.)
{ {
} }
} }
} }
else else
{ {
} }
return true; return true;
} }
/// <summary> /// <summary>
/// 返回到财务审核状态 /// 返回到财务审核状态

37
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -60,6 +60,7 @@ namespace Win.Sfs.SettleAccount
builder.ConfigureTB_RePartsRelationship(options); builder.ConfigureTB_RePartsRelationship(options);
//同步位置标记 //同步位置标记
builder.ConfigureSyncPositionFlag(options); builder.ConfigureSyncPositionFlag(options);
#endregion 基础数据 #endregion 基础数据
#region 北汽结算 #region 北汽结算
@ -1211,24 +1212,24 @@ namespace Win.Sfs.SettleAccount
private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {
builder.Entity<BBAC_ADJ_DETAIL>(b => //builder.Entity<BBAC_ADJ_DETAIL>(b =>
{ //{
b.ToTable($"{options.TablePrefix}_BBAC_ADJ_DETAIL", options.Schema); // b.ToTable($"{options.TablePrefix}_BBAC_ADJ_DETAIL", options.Schema);
b.ConfigureByConvention(); // b.ConfigureByConvention();
b.Property(x => x.Site).HasMaxLength(50); // b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.IsReturn).HasMaxLength(50); // b.Property(x => x.IsReturn).HasMaxLength(50);
b.Property(x => x.ContractDocID).HasMaxLength(50); // b.Property(x => x.ContractDocID).HasMaxLength(50);
b.Property(x => x.OldInvBillNum).HasMaxLength(50); // b.Property(x => x.OldInvBillNum).HasMaxLength(50);
b.Property(x => x.InvBillNum).HasMaxLength(50); // b.Property(x => x.InvBillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50); // b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50); // b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.LU).HasMaxLength(50); // b.Property(x => x.LU).HasMaxLength(50);
b.Property(x => x.PN).HasMaxLength(50); // b.Property(x => x.PN).HasMaxLength(50);
b.Property(x => x.KeyCode).HasMaxLength(50); // b.Property(x => x.KeyCode).HasMaxLength(50);
b.Property(x => x.GroupNum).HasMaxLength(50); // b.Property(x => x.GroupNum).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); // b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
}); //});
} }
private static void ConfigureVmi(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureVmi(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
@ -1281,7 +1282,7 @@ namespace Win.Sfs.SettleAccount
}); });
//seed //seed
builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "库存快照", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService" }); builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "库存快照", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("发运入库".ToGuid()) { Type = VmiType.In, Name = "发运入库", Number = "100" }); builder.Entity<VmiCategory>().HasData(new VmiCategory("发运入库".ToGuid()) { Type = VmiType.In, Name = "发运入库", Number = "100" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("结算出库".ToGuid()) { Type = VmiType.Out, Name = "结算出库", Number = "200" }); builder.Entity<VmiCategory>().HasData(new VmiCategory("结算出库".ToGuid()) { Type = VmiType.Out, Name = "结算出库", Number = "200" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("客户退货".ToGuid()) { Type = VmiType.Out, Name = "客户退货", Number = "300" }); builder.Entity<VmiCategory>().HasData(new VmiCategory("客户退货".ToGuid()) { Type = VmiType.Out, Name = "客户退货", Number = "300" });

4874
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727085151_202307270004.Designer.cs

File diff suppressed because it is too large

93
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727085151_202307270004.cs

@ -0,0 +1,93 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307270004 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Set_BBAC_ADJ_DETAIL");
migrationBuilder.AddColumn<string>(
name: "ParentInvbillNum",
table: "Set_INVOICE_GRP",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "Tax",
table: "Set_INVOICE_GRP",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AlterColumn<bool>(
name: "IsReturn",
table: "Set_BBAC_CAN_SA_DETAIL",
type: "bit",
maxLength: 50,
nullable: false,
defaultValue: false,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50,
oldNullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ParentInvbillNum",
table: "Set_INVOICE_GRP");
migrationBuilder.DropColumn(
name: "Tax",
table: "Set_INVOICE_GRP");
migrationBuilder.AlterColumn<string>(
name: "IsReturn",
table: "Set_BBAC_CAN_SA_DETAIL",
type: "nvarchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(bool),
oldType: "bit",
oldMaxLength: 50);
migrationBuilder.CreateTable(
name: "Set_BBAC_ADJ_DETAIL",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
BusinessType = table.Column<int>(type: "int", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
ContractDocID = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
GroupNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
InvBillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
InvGroupNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
IsReturn = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
KeyCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
LU = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
OldInvBillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
PN = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Qty = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
SettleBillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
SettleDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Site = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Version = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_BBAC_ADJ_DETAIL", x => x.Id);
});
}
}
}

106
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -21,102 +21,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasAnnotation("ProductVersion", "5.0.17") .HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("SettleAccount.Domain.BQ.BBAC_ADJ_DETAIL", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("BusinessType")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ContractDocID")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("GroupNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("InvBillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("InvGroupNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("IsReturn")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("KeyCode")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("LU")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("OldInvBillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("PN")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<decimal>("Price")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)");
b.Property<string>("SettleBillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("SettleDate")
.HasColumnType("datetime2");
b.Property<string>("Site")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Set_BBAC_ADJ_DETAIL");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.BBAC_CAN_SA", b => modelBuilder.Entity("SettleAccount.Domain.BQ.BBAC_CAN_SA", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -221,9 +125,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.Property<string>("IsReturn") b.Property<bool>("IsReturn")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("bit");
b.Property<string>("KeyCode") b.Property<string>("KeyCode")
.HasMaxLength(50) .HasMaxLength(50)
@ -2072,6 +1976,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<string>("ParentInvbillNum")
.HasColumnType("nvarchar(max)");
b.Property<string>("RealnvBillNum") b.Property<string>("RealnvBillNum")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
@ -2079,6 +1986,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<int>("State") b.Property<int>("State")
.HasColumnType("int"); .HasColumnType("int");
b.Property<decimal>("Tax")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("TaxAmt") b.Property<decimal>("TaxAmt")
.HasColumnType("decimal(18,2)"); .HasColumnType("decimal(18,2)");

Loading…
Cancel
Save