wanggang 1 year ago
parent
commit
25fc3b60f9
  1. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  3. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_CAN_SA_DTO.cs
  4. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  5. 86
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs
  6. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  7. 98
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  8. 131
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  9. 192
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPOSeSyncAppService.cs
  10. 126
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  11. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  12. 399
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  13. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj
  14. 31
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  15. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_WAIT_DETAIL.cs
  16. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs
  17. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  18. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/SyncPositionFlag.cs
  19. 104
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs
  20. 126
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs
  21. 19
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  22. 16
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs
  23. 38
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs
  24. 5001
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064841_20230726-2.Designer.cs
  25. 24
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064841_20230726-2.cs
  26. 5001
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064930_20230726-3.Designer.cs
  27. 34
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064930_20230726-3.cs
  28. 4991
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727011426_202307270001.Designer.cs
  29. 58
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727011426_202307270001.cs
  30. 5007
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727024321_20230727-1.Designer.cs
  31. 46
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727024321_20230727-1.cs
  32. 57
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

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

@ -2,6 +2,7 @@ using System;
using System.Linq;
using System.Text.RegularExpressions;
using Coravel;
using Coravel.Invocable;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
@ -12,6 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NUglify.Helpers;
using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount;
@ -25,6 +27,7 @@ public class Startup
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService)))
.ForEach(o => services.AddTransient(o));
services.AddScheduler();
services.AddTransient<HBPOSeSyncAppService>();
services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer));
services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer())));
services.AddApplication<SettleAccountHttpApiHostModule>();
@ -47,6 +50,7 @@ public class Startup
app.UseEndpoints(endpoints => endpoints.MapHub<PageHub>("/api/hub"));
app.ApplicationServices.UseScheduler(scheduler =>
{
scheduler.Schedule<HBPOSeSyncAppService>().EveryMinute();
using var scope = app.ApplicationServices.CreateScope();
var jobs = scope.ServiceProvider.GetService<SettleAccountDbContext>().Set<JobItem>().ToList();
jobs?.ForEach(job =>

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

@ -4,7 +4,8 @@
},
"ConnectionStrings": {
"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;",
"WMSBJBMPT": "Server=dev.ccwin-in.com,6208;Database=WMS_BJBMPT_2;User ID=sa;Password=ChangkeTec@2021;Trusted_Connection=False;TrustServerCertificate=True;"
},
"Serilog": {
"Using": [],

4
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_CAN_SA_DTO.cs

@ -75,7 +75,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
public string LU { get; set; }
/// <summary>
/// 物料描述
/// </summary>
public string MaterialDesc { get; set; }

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

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
@ -215,12 +215,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
///扩展字段3
/// </summary>
[Display(Name = "扩展字段3")]
public string Extend3 { get; set; }
public DateTime BeginDate { get; set; }
/// <summary>
///扩展字段4
/// </summary>
[Display(Name = "扩展字段4")]
public string Extend4 { get; set; }
public DateTime EndDate { get; set; }
}
public class INVOICE_WAIT_DETAIL_REQ_DTO : RequestInputBase
@ -328,7 +328,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
}
public class INVOICE_MAP_GROUPRequestDto : PagedAndSortedResultRequestDto
public class INVOICE_MAP_GROUP_REQ_DTO : PagedAndSortedResultRequestDto
{
public int Version { get; set; }
[Display(Name = "发票号")]

86
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
@ -64,46 +65,51 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
}
public class PUB_CAN_SA_DETAIL_DTO : EntityDto<Guid>
{
public class PUB_CAN_SA_DETAIL_DTO : EntityDto<Guid>
{
/// <summary>
///关联结算单号
/// </summary>
[Display(Name = "关联结算单号")]
public string SettleBillNum { get; set; }
/// <summary>
///工厂地点
/// </summary>
[Display(Name = "工厂地点")]
public string Site { get; set; }
/// <summary>
///业务类别
/// </summary>
[Display(Name = "业务类别")]
public EnumBusinessType BusinessType { get; set; }
[Display(Name ="期间")]
public int Version { get; set; }
[Display(Name = "价格")]
public decimal Price { get; set; }
[Display(Name = "发票分组号")]
public string BillNum { get; set; }
[Display(Name = "下线日期")]
public DateTime SettleDate { get; set; }
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
[Display(Name = "发票分组号")]
public string LU { get; set; }
[Display(Name = "")]
public string PN { get; set; }
[Display(Name = "键值")]
public string KeyCode { get; set; }
[Display(Name = "结算数量")]
public decimal Qty { get; set; }
[Display(Name = "结算分组号")]
public string GroupNum { get; set; }
}
/// <summary>
///关联结算单号
/// </summary>
[Display(Name = "关联结算单号")]
public string SettleBillNum { get; set; }
/// <summary>
///工厂地点
/// </summary>
[Display(Name = "工厂地点")]
public string Site { get; set; }
/// <summary>
///业务类别
/// </summary>
[Display(Name = "业务类别")]
public EnumBusinessType BusinessType { get; set; }
[Display(Name = "期间")]
public int Version { get; set; }
[Display(Name = "价格")]
public decimal Price { get; set; }
[Display(Name = "发票分组号")]
public string BillNum { get; set; }
[Display(Name = "下线日期")]
public DateTime SettleDate { get; set; }
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
[Display(Name = "发票分组号")]
public string LU { get; set; }
[Display(Name = "")]
public string PN { get; set; }
[Display(Name = "键值")]
public string KeyCode { get; set; }
[Display(Name = "结算数量")]
public decimal Qty { get; set; }
[Display(Name = "结算分组号")]
public string GroupNum { get; set; }
[Display(Name = "金额")]
public decimal Amt { get; set; }
public string MaterialDesc { set; get; }
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs

@ -129,7 +129,7 @@ public class PriceListImportDto
/// </summary>
[Display(Name = "零件号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "Part No.")]
[ImporterHeader(Name = "*Part No.")]
public string PartNo { get; set; }
/// <summary>

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

@ -32,6 +32,104 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases
{
public class TMEP_INV
{
public string LU { set; get; }
public string ContractDocID { set; get; }
public decimal Amt { set; get; }
public decimal Qty { set; get; }
public decimal Price { set; get; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime BeginDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
}
public class TEMP_CAN_SA_DETAIL
{
/// <summary>
///关联结算单号
/// </summary>
public string SettleBillNum { get; set; }
/// <summary>
///工厂地点
/// </summary>
public string Site { get; set; }
/// <summary>
/// 版本
/// </summary>
public int Version { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 结算单号(发票分组号)
/// </summary>
public string BillNum { get; set; }
/// <summary>
/// 结算日期
/// </summary>
public DateTime SettleDate { get; set; }
/// <summary>
///发票组号
/// </summary>
public string InvGroupNum { get; set; }
/// <summary>
/// 零件号
/// </summary>
public string LU { get; set; }
/// <summary>
/// 物料描述
/// </summary>
public string MaterialDesc { get; set; }
/// <summary>
/// 生产号
/// </summary>
public string PN { get; set; }
/// <summary>
/// 结算数量
/// </summary>
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
public string GroupNum { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Amt { get; set; }
/// <summary>
/// 合同号
/// </summary>
public string ContractDocID { set; get; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime BeginDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
}
public abstract class CAN_SA_SERVICE<TEntity, TEntityDto, TEntityDetail, TEntityDetailDto, TRequestMainInput, TRequestDetailInput, TEntityDetailExportDto> : BASE_SERVICE
where TEntity : SA_CAN_BASE_MAIN
where TEntityDetail:SA_CAN_BASE

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

@ -23,19 +23,16 @@ using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase;
using System.Text.Json;
using Newtonsoft.Json;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
public class TMEP_INV
{
public string LU { set; get; }
public string ContractDocID { set; get; }
public decimal Amt { set; get; }
public decimal Qty { set; get; }
public decimal Price { set; get; }
}
/// <summary>
@ -55,6 +52,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
>
{
private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly BBAC_CAN_SA_MNG _bbacMng;
@ -63,11 +63,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
IExcelImportAppService excelImportService,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
BBAC_CAN_SA_MNG bbacMng,
INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
BBAC_CAN_SA_MNG bbacMng,
INV_MNG invmng,
INormalEfCoreRepository<PriceList, Guid> priceRepository
) : base(repository, excelImportService, detailRepository, invmng)
{
_notRepository = notRepository;
_bbacMng = bbacMng;
_priceRepository = priceRepository;
}
/// <summary>
@ -88,17 +91,61 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
var notList = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算
var dtos = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
dtos.ForEach(dto =>
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)
{
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
errorList.Add(new ERR_EXP_DTO() { ItemCode=error.LU, CustomCode="业务类别BBAC", Version=main.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 (input.BillNum.Substring(0, 1) != "C")//一次开票
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
// 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);
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())
@ -136,7 +183,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
@ -153,21 +200,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
// string str = JsonConvert.SerializeObject(invoiceMap);
// 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 })
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)
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);
@ -208,8 +257,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
pRICE: detail.Price,
extend1: detail.ContactDocID,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
@ -259,16 +309,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price }).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,
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 }).Select(p => new TMEP_INV
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),
@ -278,7 +331,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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);
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");
@ -287,7 +344,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID)
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
@ -308,9 +369,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.ContractDocID } equals new { itm1.LU, itm1.ContractDocID } into temp
from tm in temp
select new TMEP_INV { LU = itm.LU, ContractDocID = itm.ContractDocID, Amt = itm.Amt, Qty = itm.Qty };
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,
Amt = itm.Amt, Qty = itm.Qty,BeginDate=itm.BeginDate,
EndDate=itm.EndDate
};
groups1 = query.ToList();
}
}
@ -340,8 +405,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)

192
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPOSeSyncAppService.cs

@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Coravel.Invocable;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ;
/// <summary>
/// HBPO发运数据同步服务
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
{
/// <summary>
/// WMS数据上下文
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 同步位置标记
/// </summary>
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository;
/// <summary>
/// HBPO发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> _hbpoSeDetailRepository;
/// <summary>
/// 构造
/// </summary>
public HBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_hbpoSeDetailRepository = hbpoSeDetailRepository;
}
//private readonly IRepository<TM_BJBMPT_JIT_RECORD> _TMBJBMPTJITRECORDRepository;
//public HBPOSeSyncAppService(IRepository<TM_BJBMPT_JIT_RECORD> TMBJBMPTJITRECORDRepository)
//{
// _TMBJBMPTJITRECORDRepository = TMBJBMPTJITRECORDRepository;
//}
[HttpPost]
public async Task Invoke()
{
//await SyncJitRecord();
//await SyncJisRecord();
//if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
//{
// this._balanceRepository.AsNoTracking().ForEachAsync(o =>
// {
// dbContext.Set<VmiBalance>().Add(o);
// });
// dbContext.SaveChanges();
// var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
// this._snapshotRepository.InsertAsync(snapshot).Wait();
//}
//using (var context = new HouseDbContext(optionsBuilder.Options))
//{
// var one = context.Notices.FirstOrDefault(n => n.Id == notice.Id);
// // 当然你也可以直接初始化其他的Service
// var nService = new NoticeService(context, null);
// var one = nService.FindOne(notice.Id);
//}
//var TM_BJBMPT_JIT_RECORDs = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
// .Where(b => b.UID > 3)
// .OrderBy(b => b.BillTime)
// .ToList();
//foreach (var TM_BJBMPT_JIT_RECORD in TM_BJBMPT_JIT_RECORDs)
//{
// Console.WriteLine($"{TM_BJBMPT_JIT_RECORD.UID}");
//}
//using (var db = new WMSBJBMPTDbContext())
//{
// var blogs = db.TM_BJBMPT_JIT_RECORD
// .Where(b => b.UID > 3)
// .OrderBy(b => b.BillTime)
// .ToList();
// foreach (var blog in blogs)
// {
// Console.WriteLine($"{blog.UID}");
// }
//}
Console.WriteLine($"{this.GetType().FullName}执行了");
}
/// <summary>
/// 同步JitRecord
/// </summary>
/// <returns></returns>
private async Task SyncJitRecord()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIT_RECORD";
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => true;
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName);
if (syncPositionFlag != null)
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position);
}
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
.Where(predicate)
.OrderBy(b => b.UID)
.ToList();
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(jitRecords);
if (hbpoSeDetails.Any())
{
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jitRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jitRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
private async Task SyncJisRecord()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIS_RECORD";
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => true;
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName);
if (syncPositionFlag != null)
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position);
}
var jisRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD
.Where(predicate)
.OrderBy(b => b.UID)
.ToList();
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(jisRecords);
if (hbpoSeDetails.Any())
{
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jisRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jisRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
}

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

@ -16,6 +16,8 @@ using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -38,17 +40,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
>
{
private INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
public HBPO_CAN_SA_SERVICE(INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository,
INV_MNG invmng,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
HBPO_CAN_SA_MNG hbpoMng
HBPO_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<PriceList, Guid> priceRepository
) : base(repository, excelImportService, detailRepository, invmng)
{
_priceRepository = priceRepository;
_notRepository = notRepository;
_hbpoMng = hbpoMng;
}
@ -63,29 +66,69 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var main =await _hbpoMng.GetMainAsync(input.BillNum);
if (main != null)
{
if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{
var entitys = await _hbpoMng.GetDetalListAsync(input.BillNum);
if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notList = _notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();//不能结算
var dtos = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
dtos.ForEach(dto =>
{
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
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 = "业务类别HBPO", Version = main.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),
BeginDate = p.BeginTime,
EndDate = p.EndTime
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (input.BillNum.Substring(0, 1) != "C")//一次开票
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
@ -113,13 +156,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invoiceGroupNumList.Add(itm.Key);
continue;
}
var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
luList.AddRange(grouplist);
luList = luList.Distinct().ToList();
if (luList.Count > 20)//累加零件不超过20种
{
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
@ -145,14 +188,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
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 })
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price,p.BeginDate,p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty)
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
@ -194,8 +239,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
beginDate:detail.BeginDate,
endDate:detail.EndDate
));
}
if (_entityDetailList.Count > 0)
@ -246,24 +291,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price }).Select(p => new TMEP_INV
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price,p.BeginDate,p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
Price = p.Key.Price,
BeginDate=p.Key.BeginDate,
EndDate=p.Key.EndDate
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price }).Select(p => new TMEP_INV
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).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);
int i = groups1.Count(p => p.LU == group.LU &&p.BeginDate==group.BeginDate && p.EndDate==group.EndDate );
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
@ -272,7 +322,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID)
if (group.LU == group1.LU && group.BeginDate == group1.BeginDate && group.EndDate == group1.EndDate)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
@ -293,9 +343,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.ContractDocID } equals new { itm1.LU, itm1.ContractDocID } into temp
from tm in temp
select new TMEP_INV { LU = itm.LU, ContractDocID = itm.ContractDocID, Amt = itm.Amt, Qty = itm.Qty };
on new { itm.LU, itm.BeginDate,itm.EndDate} equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp where tm==null
select new TMEP_INV { LU = itm.LU, Amt = itm.Amt, Qty = itm.Qty ,BeginDate=itm.BeginDate,EndDate=itm.EndDate };
groups1 = query.ToList();
}
}
@ -323,10 +374,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
bussiessType: EnumBusinessType.BBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
@ -365,7 +416,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.BBAC,
businessType: EnumBusinessType.HBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
@ -380,8 +431,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
}
}
}
}
}

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

@ -30,9 +30,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository;
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _mRepository;
private readonly CAN_SA_MNG<PUB_CAN_SA,PUB_CAN_SA_DETAIL> _pubMng;
private readonly CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> _bbacMng;
private readonly CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> _hbpoMng;
private readonly PUB_CAN_SA_MNG _pubMng;
private readonly BBAC_CAN_SA_MNG _bbacMng;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
private readonly INV_MNG _invMng;
//private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
@ -43,9 +43,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
IExcelImportAppService excelImportService,
CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng,
CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng,
CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng,
PUB_CAN_SA_MNG pubMng,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
INV_MNG invMng
)
{

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

@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
@ -8,7 +11,10 @@ using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
using static Win.Sfs.SettleAccount.SettleAccountPermissions;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
@ -29,12 +35,403 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PUB_CAN_SA_DETAIL_EXP_DTO
>
{
public PUB_CAN_SA_SERVICE(INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
private readonly PUB_CAN_SA_MNG _pubMng;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository;
public PUB_CAN_SA_SERVICE(INormalEfCoreRepository<PUB_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository,
INV_MNG invmng,
PUB_CAN_SA_MNG pubMng) : base(repository, excelImportService, detailRepository, invmng)
{
_pubMng = pubMng;
_priceRepository = priceRepository;
_pricebjRepository = pricebjRepository;
}
[HttpPost]
public async override Task<string> GenerateInvoice(PUB_CAN_SA_REQ_DTO input)
{
var main = await _pubMng.GetMainAsync(input.BillNum);
if (main != null)
{
if (await _pubMng.SetForwardState(main, SettleBillState.))
{
var entitys = await _pubMng.GetDetalListAsync(input.BillNum);
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
List<PriceList> priceList=new List<PriceList>();
if (main.BusinessType == EnumBusinessType.BeiJian)
{
var priceListbj = _pricebjRepository.ToList();//价格单
foreach (var itm in priceListbj)
{
priceList.Add(new PriceList() {LU=itm.LU,BeginTime=itm.BeginDate,EndTime=itm.EndDate });
}
}
else
{
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;
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = "", Version = main.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),
BeginDate = p.BeginTime,
EndDate = p.EndTime
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.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)
{
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).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
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).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>();
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.BeginDate, p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
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), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.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: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.HBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
// 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);
//}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.HBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add(invbill);
}
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.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).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.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 && group.BeginDate == group1.BeginDate && group.EndDate == group1.EndDate)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
if (sum > 10000000)
{
break;
}
sum += group1.Amt;
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp
where tm == null
select new TMEP_INV { LU = itm.LU, 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: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.BBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
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.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: main.Version,
invbillNum: key,
invGroupNum: main.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.HBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
}
}
}
return ApplicationConsts.SuccessStr;
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj

@ -116,6 +116,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Coravel" Version="4.2.1" />
<PackageReference Include="ClosedXML" Version="0.102.0" />
<PackageReference Include="Cronos" Version="0.7.1" />
<PackageReference Include="EFCore.BulkExtensions" Version="5.3.0" />

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

@ -58,6 +58,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using SettleAccount.Domain.BQ;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
namespace Win.Sfs.SettleAccount
{
@ -151,6 +152,8 @@ namespace Win.Sfs.SettleAccount
CreateMapPUB_SA();
CreateMapPUB_SA_DETAIL();
CreateMapSeSync();
CreateMapBBAC_CAN_SA();
@ -1020,5 +1023,33 @@ namespace Win.Sfs.SettleAccount
CreateMap<PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
}
/// <summary>
/// 发运同步
/// </summary>
private void CreateMapSeSync()
{
CreateMap<TM_BJBMPT_JIT_RECORD, HBPO_SE_DETAIL>()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
.ForMember(x => x.AssemblyCode, y => y.MapFrom(d => d.RealPartCode))
.ForMember(x => x.InjectionCode, y => y.MapFrom(d => d.DeliverCode))
.ForMember(x => x.BeginDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.PartCode))
.ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap<TM_BJBMPT_JIS_RECORD, HBPO_SE_DETAIL>()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
.ForMember(x => x.AssemblyCode, y => y.MapFrom(d => d.RealPartCode))
.ForMember(x => x.InjectionCode, y => y.MapFrom(d => d.DeliverCode))
.ForMember(x => x.BeginDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.PartCode))
.ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
}
}
}

16
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_WAIT_DETAIL.cs

@ -41,13 +41,14 @@ public class INVOICE_WAIT_DETAIL :FullAuditedAggregateRoot<Guid>
[Display(Name = "扩展字段2")]
public string Extend2 { get; set; } = null!;
[Display(Name = "扩展字段3")]
public string Extend3 { get; set; } = null!;
[Display(Name = "价格开始日期")]
public DateTime BeginDate { get; set; }
[Display(Name = "价格结束日期")]
public DateTime EndDate { get; set; }
[Display(Name = "扩展字段4")]
public string Extend4 { get; set; } = null!;
public INVOICE_WAIT_DETAIL(Guid guid, int version, string invbillNum, string invGroupNum, string lU, decimal pRICE, decimal qty, decimal amt, EnumBusinessType bussiessType, string extend1, string extend2, string extend3, string extend4)
public INVOICE_WAIT_DETAIL(Guid guid, int version, string invbillNum, string invGroupNum, string lU, decimal pRICE, decimal qty, decimal amt, EnumBusinessType bussiessType, string extend1, string extend2,DateTime beginDate,DateTime endDate)
{
Id = guid;
Version = version;
@ -60,8 +61,9 @@ public class INVOICE_WAIT_DETAIL :FullAuditedAggregateRoot<Guid>
BussiessType = bussiessType;
Extend1 = extend1;
Extend2 = extend2;
Extend3 = extend3;
Extend4 = extend4;
BeginDate = beginDate;
EndDate = endDate;
}
public INVOICE_WAIT_DETAIL()

11
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs

@ -40,7 +40,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public HBPO_CAN_SA_MNG()
{
}
/// <summary>
/// 发票正向流程
/// </summary>
/// <param name="p_entiy"></param>
/// <param name="state"></param>
/// <returns></returns>
public virtual async Task<bool> SetForwardState(HBPO_CAN_SA p_entiy, SettleBillState state)
{
if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
@ -55,7 +60,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <summary>
/// 向前流程
///正向流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
@ -130,7 +135,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false;
}
/// <summary>
/// 向流程
/// 向流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>

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

@ -25,16 +25,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository;
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository;
private readonly CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> _pubMng;
private readonly CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> _bbacMng;
private readonly CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> _hbpoMng;
private readonly PUB_CAN_SA_MNG _pubMng;
private readonly BBAC_CAN_SA_MNG _bbacMng;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
public INV_MNG
(
CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng,
CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng,
CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng,
//INormalEfCoreRepository<TCAN_SA, Guid> canRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
PUB_CAN_SA_MNG pubMng,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository

28
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/SyncPositionFlag.cs

@ -0,0 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 同步位置标记
/// </summary>
public class SyncPositionFlag : AuditedAggregateRoot<Guid>
{
/// <summary>
/// 表名称
/// </summary>
[Display(Name = "表名称")]
public string TableName { get; set; }
/// <summary>
/// 位置(可排序)
/// </summary>
[Display(Name = "位置")]
public string Position { get; set; }
/// <summary>
/// 构造
/// </summary>
public SyncPositionFlag() { }
}

104
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs

@ -0,0 +1,104 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
public class TM_BJBMPT_JIS_RECORD
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UID { get; set; }
[DisplayName("JIS单据编号")]
public string JISNum { get; set; }
[DisplayName("发货时间")]
public DateTime? BillTime { get; set; }
[DisplayName("发货人")]
public string Oper { get; set; }
[DisplayName("JIS排序单号")]
public string OrderNum { get; set; }
[DisplayName("订单序号")]
public string Seq { get; set; }
[DisplayName("JIS实际生产码")]
public string RealCode { get; set; }
[DisplayName("订单生产码")]
public string VinCode { get; set; }
[DisplayName("JIS生产码类型")]
public string CodeType { get; set; }
[DisplayName("订单零件号")]
public string PartCode { get; set; }
[DisplayName("数量")]
public decimal? Qty { get; set; }
[DisplayName("发货单号")]
public string BillNum { get; set; }
public string MESConfigCode { get; set; }
[DisplayName("来源库位")]
public string FromLoc { get; set; }
[DisplayName("目标库位")]
public string ToLoc { get; set; }
public string RealPartCode { get; set; }
public string Batch { get; set; }
[DisplayName("参照订单生产码")]
public string RefVinCode { get; set; }
//[DisplayName("单据类型")]
//public EnumBillType BillType { get; set; }
//[DisplayName("子单据类型")]
//public EnumSubBillType SubBillType { get; set; }
[DisplayName("单据性质")]
public string BillCharacter { get; set; }
public int? TransType { get; set; }
public int? DeliverBillType { get; set; }
public int? DeliverSubBillType { get; set; }
[DisplayName("发货关联单号")]
public string RefBillNum { get; set; }
[DisplayName("Erp目标库位")]
public string ErpToLoc { get; set; }
[DisplayName("原生产码")]
public string OrigiCode { get; set; }
[DisplayName("备注")]
public string Remark { get; set; }
[DisplayName("塑件唯一码")]
public string UniqueCode { get; set; }
[DisplayName("PJS顺序号")]
public string PjsNum { get; set; }
[DisplayName("虚拟小总成")]
public string MatchNumber { get; set; }
//[DisplayName("业务类型")]
//public EnumProTpe ProType { get; set; }
public string DeliverCode { get; set; }
public string Position { get; set; }
}

126
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs

@ -0,0 +1,126 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
public class TM_BJBMPT_JIT_RECORD
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UID { get; set; }
[DisplayName("JIT订单号")]
public string JISNum { get; set; }
[DisplayName("JIT排序生产码")]
public string VinCode { get; set; }
[DisplayName("JIT排序生产码类型")]
public string CodeType { get; set; }
[DisplayName("订单零件号")]
public string PartCode { get; set; }
[DisplayName("订单零件号")]
public string RealPartCode { get; set; }
[DisplayName("订单序号")]
public string Seq { get; set; }
[DisplayName("发货条码")]
public string DeliverCode { get; set; }
[DisplayName("数量")]
public decimal? Qty { get; set; }
[DisplayName("发货单号")]
public string BillNum { get; set; }
[DisplayName("发货时间")]
public DateTime? BillTime { get; set; }
[DisplayName("发货人")]
public string Oper { get; set; }
[DisplayName("客户位置")]
public string Position { get; set; }
public string MESConfigCode { get; set; }
[DisplayName("生产线")]
public string Line { get; set; }
[DisplayName("目标库位")]
public string ToLoc { get; set; }
[DisplayName("备注")]
public string Remark { get; set; }
//[DisplayName("单据类型")]
//public EnumBillType BillType { get; set; }
//[DisplayName("子单据类型")]
//public EnumSubBillType SubBillType { get; set; }
public int? TransType { get; set; }
public int? DeliverBillType { get; set; }
public int? DeliverSubBillType { get; set; }
[DisplayName("单据性质")]
public string BillCharacter { get; set; }
//[DisplayName("业务类型")]
//public EnumProTpe ProType { get; set; }
public string OrderNum { get; set; }
public string RealCode { get; set; }
public string FromLoc { get; set; }
public string RefBillNum { get; set; }
public string ErpToLoc { get; set; }
public string UniqueCode { get; set; }
public string PjsNum { get; set; }
public string MatchNumber { get; set; }
public string RefVinCode { get; set; }
}
public enum EnumProTpe
{
= 0,
Jit发货 = 1,
Jit补发订单 = 2,
Jit备件 = 3,
Jit买单件 = 4,
Jit匹配件 = 5,
Jis发货 = 6,
Jis备件 = 7,
Jis买单件 = 8,
Jis匹配件 = 9,
Jis补发订单 = 10,
Jis退货 = 11,
Jis备件退货 = 12,
Jis买单件退货 = 13,
Jis匹配件退货 = 14,
Jis补发订单退货 = 15,
Jit退货 = 16,
Jit备件退货 = 17,
Jit买单件退货 = 18,
Jit匹配件退货 = 19,
Jit补发订单退货 = 20,
}
public enum EnumBillType { }
public enum EnumSubBillType { }

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

@ -7,6 +7,7 @@ using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.Entities;
using Win.Sfs.SettleAccount.Entities.Boms;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.Controls;
@ -57,7 +58,8 @@ namespace Win.Sfs.SettleAccount
builder.ConfigurePURCHASE_PRICE(options);
//客户替换件关系
builder.ConfigureTB_RePartsRelationship(options);
//同步位置标记
builder.ConfigureSyncPositionFlag(options);
#endregion 基础数据
#region 北汽结算
@ -299,6 +301,18 @@ namespace Win.Sfs.SettleAccount
});
}
/// <summary>
/// 同步位置标记
/// </summary>
private static void ConfigureSyncPositionFlag(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<SyncPositionFlag>(b =>
{
b.ToTable($"{options.TablePrefix}_SyncPositionFlag", options.Schema);
b.ConfigureByConvention();
});
}
#endregion 基础数据
#region 北汽
@ -996,8 +1010,7 @@ namespace Win.Sfs.SettleAccount
b.Property(x => x.BussiessType).HasMaxLength(50);
b.Property(x => x.Extend1).HasMaxLength(50);
b.Property(x => x.Extend2).HasMaxLength(50);
b.Property(x => x.Extend3).HasMaxLength(50);
b.Property(x => x.Extend4).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}

16
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs

@ -1,4 +1,6 @@
using System.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Dapper;
@ -55,15 +57,21 @@ namespace Win.Sfs.SettleAccount
//options.AddDefaultRepositories(includeAllEntities: true);
});
context.Services.AddAbpDbContext<UnInterfaceDbContext>(options =>
{
options.AddDefaultRepositories();
});
context.Services.AddDbContext<WMSBJBMPTDbContext>(options =>
{
//IConfiguration config = new ConfigurationBuilder()
// .SetBasePath(Directory.GetCurrentDirectory())
// .AddJsonFile("appsettings.json")
// .Build();
//var ConnectStr = config.GetConnectionString("WMSBJBMPT");
//optionsBuilder.UseSqlServer(ConnectStr);
options.UseSqlServer("Server=dev.ccwin-in.com,6208;Database=WMS_BJBMPT_2;User ID=sa;Password=ChangkeTec@2021;Trusted_Connection=False;TrustServerCertificate=True;");
});
// context.Services.AddTransient(typeof(IInventoryDetailRepository),
//typeof(InventoryDetailRepository));

38
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
namespace Win.Sfs.SettleAccount.EntityFrameworkCore;
[ConnectionStringName("WMSBJBMPT")]
public class WMSBJBMPTDbContext : DbContext
{
public DbSet<TM_BJBMPT_JIT_RECORD> TM_BJBMPT_JIT_RECORD { get; set; }
public DbSet<TM_BJBMPT_JIS_RECORD> TM_BJBMPT_JIS_RECORD { get; set; }
public WMSBJBMPTDbContext()
{
}
public WMSBJBMPTDbContext(DbContextOptions<WMSBJBMPTDbContext> options) : base(options)
{
}
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//{
// if (!optionsBuilder.IsConfigured)
// {
// IConfiguration config = new ConfigurationBuilder()
// .SetBasePath(Directory.GetCurrentDirectory())
// .AddJsonFile("appsettings.json")
// .Build();
// var ConnectStr = config.GetConnectionString("WMSBJBMPT");
// optionsBuilder.UseSqlServer(ConnectStr);
// }
//}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}

5001
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064841_20230726-2.Designer.cs

File diff suppressed because it is too large

24
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064841_20230726-2.cs

@ -0,0 +1,24 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307262 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "Set_JobItem",
columns: new[] { "Id", "ConcurrencyStamp", "Cron", "IsRunning", "Name", "Service" },
values: new object[] { new Guid("92cce083-20a8-5335-31ea-e390c57cac1f"), null, "0 0/1 * * * ?", false, "HBPO发运数据同步", "Win.Sfs.SettleAccount.Entities.BQ.HBPOSeSyncAppService" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("92cce083-20a8-5335-31ea-e390c57cac1f"));
}
}
}

5001
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064930_20230726-3.Designer.cs

File diff suppressed because it is too large

34
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726064930_20230726-3.cs

@ -0,0 +1,34 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307263 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("92cce083-20a8-5335-31ea-e390c57cac1f"));
migrationBuilder.InsertData(
table: "Set_JobItem",
columns: new[] { "Id", "ConcurrencyStamp", "Cron", "IsRunning", "Name", "Service" },
values: new object[] { new Guid("d50400b0-b0d4-38d1-fcdf-b1e7ac1d3a68"), null, "0 0/1 * * * ?", false, "HBPO发运数据同步", "Win.Sfs.SettleAccount.Entities.BQ.HBPOSeSyncAppService" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("d50400b0-b0d4-38d1-fcdf-b1e7ac1d3a68"));
migrationBuilder.InsertData(
table: "Set_JobItem",
columns: new[] { "Id", "ConcurrencyStamp", "Cron", "IsRunning", "Name", "Service" },
values: new object[] { new Guid("92cce083-20a8-5335-31ea-e390c57cac1f"), null, "0 0/1 * * * ?", false, "HBPO发运数据同步", "Win.Sfs.SettleAccount.Entities.BQ.HBPOSeSyncAppService" });
}
}
}

4991
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727011426_202307270001.Designer.cs

File diff suppressed because it is too large

58
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727011426_202307270001.cs

@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307270001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Extend3",
table: "Set_INVOICE_WAIT_DETAIL");
migrationBuilder.DropColumn(
name: "Extend4",
table: "Set_INVOICE_WAIT_DETAIL");
migrationBuilder.AddColumn<DateTime>(
name: "BeginDate",
table: "Set_INVOICE_WAIT_DETAIL",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "EndDate",
table: "Set_INVOICE_WAIT_DETAIL",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BeginDate",
table: "Set_INVOICE_WAIT_DETAIL");
migrationBuilder.DropColumn(
name: "EndDate",
table: "Set_INVOICE_WAIT_DETAIL");
migrationBuilder.AddColumn<string>(
name: "Extend3",
table: "Set_INVOICE_WAIT_DETAIL",
type: "nvarchar(50)",
maxLength: 50,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend4",
table: "Set_INVOICE_WAIT_DETAIL",
type: "nvarchar(50)",
maxLength: 50,
nullable: true);
}
}
}

5007
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727024321_20230727-1.Designer.cs

File diff suppressed because it is too large

46
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727024321_20230727-1.cs

@ -0,0 +1,46 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307271 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("d50400b0-b0d4-38d1-fcdf-b1e7ac1d3a68"));
migrationBuilder.CreateTable(
name: "Set_SyncPositionFlag",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TableName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Position = table.Column<string>(type: "nvarchar(max)", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_SyncPositionFlag", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Set_SyncPositionFlag");
migrationBuilder.InsertData(
table: "Set_JobItem",
columns: new[] { "Id", "ConcurrencyStamp", "Cron", "IsDisabled", "IsRunning", "Name", "Service" },
values: new object[] { new Guid("d50400b0-b0d4-38d1-fcdf-b1e7ac1d3a68"), null, "0 0/1 * * * ?", false, false, "HBPO发运数据同步", "Win.Sfs.SettleAccount.Entities.BQ.HBPOSeSyncAppService" });
}
}
}

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

@ -2254,6 +2254,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<decimal>("Amt")
.HasColumnType("decimal(18,2)");
b.Property<DateTime>("BeginDate")
.HasColumnType("datetime2");
b.Property<int>("BussiessType")
.HasMaxLength(50)
.HasColumnType("int");
@ -2280,6 +2283,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<DateTime>("EndDate")
.HasColumnType("datetime2");
b.Property<string>("Extend1")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
@ -2288,14 +2294,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Extend3")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Extend4")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
@ -3731,6 +3729,49 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_PUB_SEC_DETAIL");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Syncs.SyncPositionFlag", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
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<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Position")
.HasColumnType("nvarchar(max)");
b.Property<string>("TableName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Set_SyncPositionFlag");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.JobItem", b =>
{
b.Property<Guid>("Id")

Loading…
Cancel
Save