diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs index 1934be47..81c63175 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs @@ -99,26 +99,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { foreach (var itm in adjlist) { - bbaclist.Add(new BBAC_CAN_SA_DETAIL( - guid: itm.Id, - 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,//生产号 - invbillnum: string.Empty, - partcode: itm.PartCode - )); + + var entity = new BBAC_CAN_SA_DETAIL( + guid: itm.Id, + 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,//生产号 + invbillnum: string.Empty, + partcode: itm.PartCode + ); + entity.IsMaiDan = itm.IsMaiDan; + + + bbaclist.Add(entity); } } var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据 @@ -260,7 +265,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var dto1s = ObjectMapper.Map, List>(entitys); var q = from d in dto1s - join p in priceList on d.PartCode equals p.LU + join p in priceList on d.LU equals p.LU where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号 select new TEMP_CAN_SA_DETAIL { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs index 0472def5..60a9700e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs @@ -242,7 +242,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } // var dto1s = ObjectMapper.Map, List>(entitys); var q = from d in entitys - join p in priceList on d.PartCode equals p.LU + join p in priceList on d.LU equals p.LU where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime select new TEMP_CAN_SA_DETAIL { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs index 38594b5d..df27c98d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs @@ -51,18 +51,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ public override async Task GenerateSettlementOrder(HBPO_NOT_SA_DETAIL_REQ_DTO input) { var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - var errors=await _hbpoNotMng.GenerateSettlementOrder(entitys); + var errors = await _hbpoNotMng.GenerateSettlementOrder(entitys); if (errors.Count > 0) { - List errorlist = new List(); foreach (var itm in errors) { errorlist.Add(new ERR_EXP_DTO() { Message = itm }); } return await ExportErrorReportAsync(errorlist); - - } return ApplicationConsts.SuccessStr; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index 9212088a..edfd8586 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -128,7 +128,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } // var dto1s = ObjectMapper.Map, List>(entitys); var q = from d in entitys - join p in priceList on d.PartCode equals p.LU + join p in priceList on d.LU equals p.LU where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime select new TEMP_CAN_SA_DETAIL { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs index 6b2e3f44..6296b015 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs @@ -40,6 +40,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ PUB_NOT_SA_MNG pubNotMng ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository) { + + _pubNotMng = pubNotMng; } public override async Task GenerateSettlementOrder(PUB_NOT_SA_DETAIL_REQ_DTO input) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs index e0f15fb8..0da57b1f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs @@ -4,9 +4,14 @@ using System.Linq; using System.ServiceModel.Channels; using System.Text; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Nito.AsyncEx; +using SettleAccount.Domain.BQ; using TaskJob.EventArgs; using TaskJob.Interfaces; using Volo.Abp.DependencyInjection; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; @@ -16,23 +21,162 @@ public class PendingDeductionService : ITransientDependency, IExportJob protected readonly INormalEfCoreRepository _bbacSecRepository; protected readonly INormalEfCoreRepository _hbpoSecRepository; protected readonly INormalEfCoreRepository _pubSecRepository; + protected readonly INormalEfCoreRepository _bbacRepository; + protected readonly INormalEfCoreRepository _hbpoRepository; + protected readonly INormalEfCoreRepository _pubRepository; public PendingDeductionService( INormalEfCoreRepository bbacSecRepository, INormalEfCoreRepository hbpoSecRepository, INormalEfCoreRepository pubSecRepository, + INormalEfCoreRepository bbacRepository, + INormalEfCoreRepository hbpoRepository, + INormalEfCoreRepository pubRepository, VmiAppService vimservice ) { + _hbpoRepository = hbpoRepository; + _bbacRepository= bbacRepository; + _pubRepository= pubRepository; _bbacSecRepository = bbacSecRepository; _hbpoSecRepository= hbpoSecRepository; _pubSecRepository= pubSecRepository; _vimservice =vimservice; } - public string ExportFile(Guid id, List exportName, List condition) + public string ExportFile(Guid id, List exportName, List property) { + var list = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value; + var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value; + if (type == "BBACJIS") + { + var jisdetail = _bbacRepository.Where(p => list.Contains(p.BillNum) && p.IsMaiDan==false); + var mdetail = _bbacRepository.Where(p => list.Contains(p.BillNum) && p.IsMaiDan ==true); + var query = from itm in jisdetail + join itm1 in _bbacSecRepository + on new { itm.PN, itm.LU } equals new { itm1.PN,LU= itm1.PrimitiveLU } into temp1 + from tm in temp1 + where tm == null + select + new + { + BillTime = DateTime.Now, + ChangedTime = DateTime.Now, + Qty = itm.Qty, + DeliverTime = itm.CreationTime, + LogType = Entities.BQ.Vmi.VmiLogType.Type200, + ChangedQty = itm.Qty, + ChangedType = VmiType.Out, + SubBillType = EnumDeliverSubBillType.小件BBAC, + BillType = EnumDeliverBjBmpBillType.JIS件, + PartCode = tm!=null?tm.ReplaceLU:itm.LU, + SettlementVinCode = itm.PN, + PartCode2 = tm != null ? tm.ReplaceLU : itm.LU, + CustomerPartCode =string.IsNullOrEmpty(itm.Extend4)?string.Empty:itm.Extend4, + VinCode = itm.PN, + OrderNum = itm.GroupNum, + ErpToLoc = "C0001" + }; + var ls=query.ToList(); + if (ls != null && ls.Count > 0) + { + foreach (var itm in ls) + { + _vimservice.Out(Entities.BQ.Vmi.VmiLogType.Type200, "1", new Entities.BQ.Vmi.VmiLog() + { + BillTime = itm.BillTime, + ChangedTime = DateTime.Now, + Qty = itm.Qty, + DeliverTime = itm.BillTime, + LogType = Entities.BQ.Vmi.VmiLogType.Type200, + ChangedQty = itm.Qty, + ChangedType = VmiType.Out, + SubBillType = EnumDeliverSubBillType.小件BBAC, + BillType = EnumDeliverBjBmpBillType.JIS件, + PartCode = itm.PartCode, + SettlementVinCode = itm.VinCode, + PartCode2 = itm.PartCode2, + CustomerPartCode = itm.CustomerPartCode, + VinCode = itm.VinCode, + OrderNum = itm.OrderNum, + ErpToLoc = "C0001" + }).ConfigureAwait(false); + } + } + } + else if (type == "HBPOJIS") + { + var detailist = _hbpoRepository.Where(p => list.Contains(p.BillNum)).ToList(); + + if (detailist != null && detailist.Count > 0) + { + foreach (var itm in detailist) + { + _vimservice.Out(Entities.BQ.Vmi.VmiLogType.Type200, "1", new Entities.BQ.Vmi.VmiLog() + { + BillTime = itm.CreationTime, + ChangedTime = DateTime.Now, + Qty = itm.Qty, + DeliverTime = itm.CreationTime, + LogType = Entities.BQ.Vmi.VmiLogType.Type200, + ChangedQty = itm.Qty, + ChangedType = VmiType.Out, + SubBillType = EnumDeliverSubBillType.小件BBAC, + BillType = EnumDeliverBjBmpBillType.JIS件, + PartCode = itm.LU, + SettlementVinCode = itm.PN, + PartCode2 = itm.LU, + CustomerPartCode = itm.LU, + VinCode = itm.PN, + OrderNum = itm.GroupNum, + ErpToLoc = "C0001" + }).ConfigureAwait(false); + } + } + + } + else + { + var detailist = _hbpoRepository.Where(p => list.Contains(p.BillNum)).ToList(); + + if (detailist != null && detailist.Count > 0) + { + foreach (var itm in detailist) + { + _vimservice.Out(Entities.BQ.Vmi.VmiLogType.Type200, "1", new Entities.BQ.Vmi.VmiLog() + { + BillTime = itm.CreationTime, + ChangedTime = DateTime.Now, + Qty = itm.Qty, + DeliverTime = itm.CreationTime, + LogType = Entities.BQ.Vmi.VmiLogType.Type200, + ChangedQty = itm.Qty, + ChangedType = VmiType.Out, + SubBillType = EnumDeliverSubBillType.小件BBAC, + BillType = EnumDeliverBjBmpBillType.JIS件, + PartCode = itm.LU, + SettlementVinCode = itm.PN, + PartCode2 = itm.LU, + CustomerPartCode = itm.LU, + VinCode = itm.PN, + OrderNum = itm.GroupNum, + ErpToLoc = "C0001" + }).ConfigureAwait(false); + } + } + + + + + } + + + return ApplicationConsts.SuccessStr; + + + + return id.ToString(); } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_PD_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_PD_DETAIL.cs index a2475713..0e67c67a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_PD_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_PD_DETAIL.cs @@ -1,4 +1,4 @@ -using SettleAccount.Bases; +using SettleAccount.Bases; using System; using System.ComponentModel.DataAnnotations; @@ -47,6 +47,7 @@ public class BBAC_PD_DETAIL:PD_BASE //public string GroupNum { get; set; } = null!; + public bool IsMaiDan { get; set; } public BBAC_PD_DETAIL(Guid guid, string keyCode, int version, string billNum, string lU, string rELU, string pN, string rEPN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, string groupNum ,string extend1,string extend2,string extend3,string extend4 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_ADJ_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_ADJ_DETAIL.cs index a56c0168..ec498fa5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_ADJ_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_ADJ_DETAIL.cs @@ -105,7 +105,11 @@ public class HBPO_ADJ_DETAIL : SA_NOT_BASE [Display(Name = "发票号")] public string InvBillNum { get; set; } - + /// + /// 是否是买单件 + /// + [Display(Name = "是否是买单件")] + public bool IsMaiDan { get; set; } public HBPO_ADJ_DETAIL(Guid guid ,string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType, string oldinv, string inv) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs index f1f17945..f97ba14c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs @@ -479,6 +479,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers contactid: itm.Extend1,//生产号 invbillnum: itm.InvBillNum, partcode:itm.PartCode + )); } } @@ -509,6 +510,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers version: itm.Version, billNum: itm.InvbillNum, lU: itm.LU, + + rELU: string.Empty, pN: itm.PN, rEPN: string.Empty, @@ -521,7 +524,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers extend1: string.Empty, extend2: string.Empty, extend3: string.Empty, - extend4: string.Empty + extend4: itm.PartCode )); } await _repository.DbContext.BulkInsertAsync(bbacmainlist); @@ -664,7 +667,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers extend1: string.Empty, extend2: string.Empty, extend3: string.Empty, - extend4: string.Empty + extend4: itm.PartCode )); } await _repository.DbContext.BulkInsertAsync(bbacmainlist); @@ -807,7 +810,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers extend1: string.Empty, extend2: string.Empty, extend3: string.Empty, - extend4: string.Empty + extend4: itm.PartCode )); } await _repository.DbContext.BulkInsertAsync(bbacmainlist); @@ -1530,7 +1533,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers //更新结算记录更新 var query = from itm in dtos join itm1 in ls - on new { LU=itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } + on new { LU=itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } join itm2 in details on new { itm.LU,itm.PartCode,itm.PN, itm.SettleDate } equals new { itm2.LU,itm2.PartCode,itm2.PN,itm2.SettleDate } select itm2; foreach (var itm in query) @@ -1542,7 +1545,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { var query1 = from itm in dtos join itm1 in ls - on new {LU= itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } + on new {LU= itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } join itm2 in p_adjlist on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate } select itm2; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs index 6ae5ec15..3708c69e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs @@ -233,7 +233,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// public virtual async Task> GetDetalListAsync(string billNum) { - return await _detailRepository.Where(p=>p.InvGroupNum==billNum).ToListAsync(); + return await _detailRepository.Where(p=>p.BillNum==billNum).ToListAsync(); } /// /// 获得主表信息 @@ -242,7 +242,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// public virtual async Task GetMainAsync(string billNum) { - return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync(); + return await _repository.Where(p => p.BillNum == billNum).FirstOrDefaultAsync(); } /// /// 获取发票对应结算分组所有零件 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs index 1167139b..80fe064b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs @@ -70,7 +70,9 @@ public class PUB_ADJ_DETAIL : SA_NOT_BASE [Display(Name = "发票号")] public string InvBillNum { get; set; } - + [Display(Name = "是否是买单件")] + public bool IsMaiDan { get; set; } + public PUB_ADJ_DETAIL(Guid id, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, string extend1, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, string groupNum,string oldinv,string inv,string partcode)