diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs index da208b2d..45b238c2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs @@ -5,14 +5,18 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; using Castle.Core.Internal; +using DocumentFormat.OpenXml.Bibliography; +using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.Mvc; using SettleAccount.Bases; using SettleAccount.Domain.BQ; +using SettleAccount.Job.Services; using Shouldly; using SqlSugar; +using TaskJob.EventArgs; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Uow; @@ -22,6 +26,7 @@ using Win.Sfs.SettleAccount.Bases.DomainServices; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; +using Win.Sfs.SettleAccount.Entities.BQ.Syncs; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; @@ -47,6 +52,7 @@ namespace Win.Sfs.SettleAccount.Bases protected readonly INV_MNG _invMng; private readonly TaskJobService _service; private readonly BaseDomainService _baseservice; + protected BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -429,6 +435,34 @@ namespace Win.Sfs.SettleAccount.Bases [HttpPost] public virtual async Task ReceivedAsync(List p_ins) { + var inv=await _invMng.GetInvoiceAsync(p_ins.FirstOrDefault()).ConfigureAwait(false); +#if DEBUG + //if (inv.BusinessType == EnumBusinessType.JisBBAC || inv.BusinessType == EnumBusinessType.JisHBPO) + //{ + // var invstrs=string.Join(',', p_ins); + // var entities= await _invMng.GetInvoiceListAsync(p_ins).ConfigureAwait(false); + // foreach (var itm in entities) + // { + // itm.State = SettleBillState.扣减单生成中; + // } + // //await _repository.DbContext.BulkUpdateAsync(entities); + // var customConditionList =new List() + // { new CustomCondition() { Name = "invs", Value = invstrs }}; + // var _taskid = await _service.ExportEnqueueAsync($"{inv.BusinessType.ToString()}生成待扣减单任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PDMakeService),customConditionList, (rs) => + // { + // }).ConfigureAwait(false); + // return new JsonResult(new { Code = 200, Message = "收票成功" }); + //} + //else + //{ + // bool issuc = await _invMng.ReceivedAsync(p_ins).ConfigureAwait(false); + // if (issuc == true) + // { + // return new JsonResult(new { Code = 200, Message = "收票成功" }); + // } + // return new JsonResult(new { Code = 400, Message = "收票失败" }); + //} +#endif bool issuc = await _invMng.ReceivedAsync(p_ins).ConfigureAwait(false); if (issuc == true) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PDMakeService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PDMakeService.cs new file mode 100644 index 00000000..bb6302b0 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PDMakeService.cs @@ -0,0 +1,343 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using SettleAccount.Domain.BQ; +using TaskJob.EventArgs; +using TaskJob.Interfaces; +using Volo.Abp; +using Volo.Abp.DependencyInjection; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Bases; +using Win.Sfs.SettleAccount.CommonManagers; + +namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs +{ + public class PDMakeService : BASE_SERVICE, ITransientDependency, IExportJob + { + protected readonly SettleAccountDbContext _dbcontext; + public PDMakeService( + SettleAccountDbContext dbcontext, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager) : base(excelImportService, snowflakeIdGenerator, commonManager) + { + _dbcontext = dbcontext; + } + + public string ExportFile(Guid id, List exportName, List property) + { + + var billList = property.Where(p => p.Name == "invoiceBillNum").FirstOrDefault().Value.Split(',').ToList(); + var invList = _dbcontext.Set().Where(p => billList.Contains(p.InvbillNum)).ToList();//所有提交发票信息 + int count = invList.Select(p => p.InvGroupNum).Distinct().Count(); + if (count > 1) + { + throw new UserFriendlyException($"发票不属于一个发票分组"); + } + var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.报废 || p.State != SettleBillState.财务已审核).ToList(); + if (lostlist.Count > 0) + { + var invs = lostlist.Select(p => p.InvbillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",", invs)}已经报废或不是财务审核状态!", "400"); + } + var inv = invList.FirstOrDefault(); + if (inv.BusinessType == EnumBusinessType.JisBBAC) + { + var pdlist = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList();//包含发票号的代扣减单 + if (pdlist != null && pdlist.Count > 0) + { + var invs = pdlist.Select(p => p.BillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交", "400"); + } + var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号 + List oldinvs = new List(); + oldinvs.AddRange(billList); + if (parentList != null && parentList.Count > 0) + { + oldinvs.AddRange(parentList); + } + List oldlist = new List();//以前提交过的发票 + List newlist = new List();//没有提交过的发票 + var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList(); + if (pdoldlist != null && pdoldlist.Count > 0) + { + oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号 + } + newlist = billList.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号 + List entityList = new List();//结算明细 + var namelist = invList.Select(p => p.InvbillNum).ToList(); + if (oldlist.Count > 0) + { + var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); + var involdname = involdList.Select(p => p.InvbillNum); + var adjlist = _dbcontext.Set().Where(p => involdname.Contains(p.InvBillNum)); + + if (adjlist != null && adjlist.Any()) + { + foreach (var itm in adjlist) + { + var detail = 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: 0, + category: itm.BusinessType, + isReturn: itm.Qty > 0 ? false : true, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + contactid: itm.Extend1,//生产号 + invbillnum: itm.InvBillNum, + partcode: itm.PartCode); + detail.ErpLoc = itm.ErpLoc; + detail.RealPartCode = itm.RealPartCode; + entityList.Add(detail); + } + } + } + if (newlist.Count > 0) + { + var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList(); + var entityDetail = _dbcontext.Set().Where(p => newlist.Contains(p.InvbillNum)).ToList();//结算明细 + var adjlist = _dbcontext.Set().Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细 + if (adjlist != null && adjlist.Count > 0) + { + foreach (var itm in adjlist) + { + var detail = 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: 0, + category: itm.BusinessType, + isReturn: itm.Qty > 0 ? false : true, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + contactid: itm.Extend1,//生产号 + invbillnum: itm.InvBillNum, + partcode: itm.PartCode + ); + detail.ErpLoc = itm.ErpLoc; + detail.RealPartCode = itm.RealPartCode; + entityDetail.Add(detail); + } + } + entityList.AddRange(entityDetail); + } + var bbacmainlist = new List(); + foreach (var itm in invList) + { + var bbac = new BBAC_PD( + guid: itm.Id, + version: int.Parse(DateTime.Now.ToString("yyyyMM")), + billNum: itm.InvbillNum, + settleBillNum: itm.InvGroupNum, + state: SettleBillState.客户已收票, + invGroupNum: itm.InvGroupNum, + site: string.Empty + ); + bbacmainlist.Add(bbac); + } + var bbacDetail = new List(); + foreach (var itm in entityList) + { + var detail = new BBAC_PD_DETAIL( + guid: itm.Id, + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvbillNum, + lU: itm.LU, + rELU: string.Empty, + pN: itm.PN, + rEPN: string.Empty, + site: itm.Site, + qty: itm.Qty, + price: 0, + invGroupNum: itm.InvGroupNum, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + extend1: string.Empty, + extend2: string.Empty, + extend3: string.Empty, + extend4: itm.PartCode, + p_businessType: itm.BusinessType + );//厂内实际零件号 + detail.RELU = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode;//厂内替换零件号 + detail.Extend2 = itm.ErpLoc;//ERP库位 + bbacDetail.Add(detail); + } + + _dbcontext.BulkInsert(bbacmainlist); + _dbcontext.BulkInsert(bbacDetail); + foreach (var itm in invList) + { + itm.State = SettleBillState.客户已收票; + }; + _dbcontext.BulkUpdate(invList); + + } + else if (inv.BusinessType == EnumBusinessType.JisHBPO || inv.BusinessType == EnumBusinessType.MaiDanJianHBPO) + { + var pdlist = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList();//包含发票号的代扣减单 + if (pdlist != null && pdlist.Count > 0) + { + var invs = pdlist.Select(p => p.BillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交", "400"); + } + var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号 + List oldinvs = new List(); + oldinvs.AddRange(billList); + if (parentList != null && parentList.Count > 0) + { + oldinvs.AddRange(parentList); + } + List oldlist = new List();//以前提交过的发票 + List newlist = new List();//没有提交过的发票 + var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList(); + if (pdoldlist != null && pdoldlist.Count > 0) + { + oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号 + } + newlist = billList.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号 + List entityList = new List();//结算明细 + var namelist = invList.Select(p => p.InvbillNum).ToList(); + if (oldlist.Count > 0) + { + var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); + var involdname = involdList.Select(p => p.InvbillNum); + var adjlist = _dbcontext.Set().Where(p => involdname.Contains(p.InvBillNum)); + if (adjlist != null && adjlist.Any()) + { + foreach (var itm in adjlist) + { + var detail = new HBPO_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: 0, + businessType: itm.BusinessType, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + invbillnum: itm.InvBillNum, + partcode: itm.PartCode + ); + detail.ErpLoc = itm.ErpLoc; + detail.RealPartCode = itm.RealPartCode; + entityList.Add(detail); + } + } + } + if (newlist.Count > 0) + { + var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList(); + var entityDetail = _dbcontext.Set().Where(p => newlist.Contains(p.InvbillNum)).ToList();//结算明细 + var adjlist = _dbcontext.Set().Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细 + if (adjlist != null && adjlist.Count > 0) + { + foreach (var itm in adjlist) + { + var entity = new HBPO_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: 0, + businessType: itm.BusinessType, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + invbillnum: itm.InvBillNum, + partcode: itm.PartCode); + entity.ErpLoc = itm.ErpLoc;//补字段库位 + entity.PartCode = itm.RealPartCode;//真实零件号 + entityDetail.Add(entity); + } + } + entityList.AddRange(entityDetail); + } + var bbacmainlist = new List(); + foreach (var itm in invList) + { + var bbac = new HBPO_PD( + guid: itm.Id, + version: int.Parse(DateTime.Now.ToString("yyyyMM")), + billNum: itm.InvbillNum, + settleBillNum: itm.InvGroupNum, + state: SettleBillState.客户已收票, + invGroupNum: itm.InvGroupNum, + site: string.Empty + ); + bbacmainlist.Add(bbac); + } + var bbacDetail = new List(); + foreach (var itm in entityList) + { + var entity = new HBPO_PD_DETAIL( + guid: itm.Id, + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvbillNum, + lU: itm.LU, + rELU: string.Empty, + pN: itm.PN, + rEPN: string.Empty, + site: itm.Site, + qty: itm.Qty, + price: 0, + invGroupNum: itm.InvGroupNum, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + extend1: string.Empty, + extend2: string.Empty, + extend3: string.Empty, + extend4: itm.PartCode, + p_businessType: itm.BusinessType + ); + entity.RELU = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode;//厂内替换零件号 + entity.Extend2 = itm.ErpLoc;//ERP库位 + bbacDetail.Add(entity + ); + } + _dbcontext.BulkInsert(bbacmainlist); + _dbcontext.BulkInsert(bbacDetail); + foreach (var itm in invList) + { + itm.State = SettleBillState.客户已收票; + }; + _dbcontext.BulkUpdate(invList); + + } + return id.ToString(); + + } + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index 462b2da1..f3a52dad 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -75,7 +75,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _codeRepository; private readonly INormalEfCoreRepository _vmiBalanceSumDetailRepository; private readonly INormalEfCoreRepository _vmiBalanceSumRepository; - + private readonly INormalEfCoreRepository _balanceSumRepository; private readonly IBlobContainer _fileContainer; private readonly IHubContext _hubContext; @@ -93,6 +93,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ INormalEfCoreRepository logRepository, INormalEfCoreRepository codeRepository, INormalEfCoreRepository vmiBalanceSumDetailRepository, + INormalEfCoreRepository balanceSumRepository, + + + IBlobContainer fileContainer, Volo.Abp.ObjectMapping.IObjectMapper maper, IHubContext hubContext, @@ -105,6 +109,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ) { + _balanceSumRepository = balanceSumRepository; _vmiBalanceSumRepository = vmiBalanceSumRepository; _vmiBalanceSumDetailRepository = vmiBalanceSumDetailRepository; _maper = maper; @@ -194,7 +199,35 @@ namespace Win.Sfs.SettleAccount.Entities.BQ + /// + /// 1.库存余额查询 + /// + /// + /// + [HttpPost] + public async Task> BalanceSumByVersion(RequestDto input) + { + var entities = await _balanceSumRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); + var totalCount = await _balanceSumRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); + //var dtos = _maper.Map, List>(entities); + //dtos = dtos.OrderByDescending(p => p.BillTime).ToList(); + return new PagedResultDto(totalCount, entities); + } + /// + /// 1.1库存余额导出 + /// + [HttpPost] + public async Task BalanceSumByVersionExport(RequestDto input) + { + var entities = await _balanceSumRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount, true).ConfigureAwait(false); + + + var fileName = $"库存余额_期间_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; + var content = this.GetContent(entities, "库存余额"); + await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); + return fileName; + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs index db0a0a16..f226dea0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs @@ -106,9 +106,12 @@ namespace Win.Sfs.SettleAccount return implementationFactory.GetService(); } - - + if (key.Equals(typeof(PDMakeService).FullName)) + { + return implementationFactory.GetService(); + } + else { 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 81869fa2..f4f75bc0 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 @@ -363,6 +363,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { return await _repository.Where(p => invs.Contains(p.InvbillNum)).ToListAsync().ConfigureAwait(false); } + + + + + /// /// 客户已收票 /// @@ -821,11 +826,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers itm.State = SettleBillState.客户已收票; }; await _repository.DbContext.BulkUpdateAsync(invList).ConfigureAwait(false); - return true; - } - } public virtual async Task Reject(INVOICE_GRP p_entity) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs index 76c2cba7..8501fc94 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs @@ -35,6 +35,10 @@ namespace Win.Sfs.SettleAccount 红冲发票 = 9, [Description("发票生成中")] 发票生成中 = 10, + [Description("扣减单生成中")] + 扣减单生成中 = 11, + + } public enum PDBillState diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs index 1629ba01..b1c60e13 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs @@ -346,7 +346,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "isnull(a.[{0}09],0)+\n" + "isnull(a.[{0}10],0)+\n" + "isnull(a.[{0}11],0)+\n" + - "isnull(a.[{0}12],0) BalanceQty ,\n" + + "isnull(a.[{0}12],0) BalanceQty ,\n" + "isnull(b.[{0}01],0) +\n" + "isnull(b.[{0}02],0) +\n" + "isnull(b.[{0}03],0) +\n" + @@ -421,7 +421,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "select * from (\n" + "select\n" + "ISNULL(a.PN,b.PN) PN,\n" + - "ISNULL(a.LU,a.LU) LU,A.BillTime,\n" + + "ISNULL(a.LU,b.LU) LU,A.BillTime,\n" + "B.EDITime,\n" + "ISNULL(A.qty,0) ShippingQty,\n" + "ISNULL(b.qty,0) EdiQty ,\n" + @@ -431,7 +431,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "from\n" + "(select PN,LU,CustomerPartCodeNoSpace,sum(Qty) qty ,MAX(BillTime) BillTime from Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace,LU) a full join\n" + "(select PN,LU,CustomerPartCodeNoSpace,sum(Qty) qty ,MAX(CreationTime) EDITime from Set_BBAC_SE_EDI group by PN,CustomerPartCodeNoSpace,LU) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace\n" + - "WHERE A.qty<>B.qty ) temp order by EDITime,BillTime\n"; + "WHERE isnull(A.qty,0)<>isnull(B.qty,0) ) temp order by EDITime,BillTime\n"; var entities = DbConnection.Query(sql, null, null, false, 1200, null).ToList(); foreach(var itm in entities) { @@ -451,7 +451,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "select * from (\n" + "select\n" + "ISNULL(a.PN,b.PN) PN,\n" + - "ISNULL(a.LU,a.LU) LU,A.BillTime,\n" + + "ISNULL(a.LU,b.LU) LU,A.BillTime,\n" + "B.EDITime,\n" + "ISNULL(A.qty,0) ShippingQty,\n" + "ISNULL(b.qty,0) EdiQty ,\n" + @@ -461,7 +461,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "from\n" + "(select PN,LU,CustomerPartCodeNoSpace,sum(Qty) qty ,MAX(BillTime) BillTime from Set_HBPO_SE_DETAIL where BusinessType=2 group by PN,CustomerPartCodeNoSpace,LU) a full join\n" + "(select PN,LU,CustomerPartCodeNoSpace,sum(Qty) qty ,MAX(CreationTime) EDITime from Set_HBPO_SE_EDI group by PN,CustomerPartCodeNoSpace,LU) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace\n" + - "WHERE A.qty<>B.qty ) temp order by EDITime,BillTime\n"; + "WHERE isnull(A.qty,0)<>isnull(B.qty,0) ) temp order by EDITime,BillTime\n"; var entities = DbConnection.Query(sql, null, null, false, 1200, null).ToList(); foreach (var itm in entities) {