diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
index a85496a0..f0ed0977 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
@@ -163,4 +163,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public string GroupNum { get; set; }
}
+ ///
+ /// Pub结算与发运对比请求
+ ///
+ public class PubSaSeCompareRequestDto
+ {
+ ///
+ /// 期间
+ ///
+ [Display(Name = "期间")]
+ [Required(ErrorMessage = "{0}不能为空")]
+ public string Version { get; set; }
+
+ ///
+ /// 业务类型
+ ///
+ public EnumBusinessType BusinessType { get; set; }
+ }
}
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
index cc70f85f..a1857ead 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
@@ -42,6 +42,9 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase
///
private readonly INormalEfCoreRepository _pubSaRepository;
+ ///
+ /// 任务服务
+ ///
private readonly TaskJobService _taskJobService;
///
@@ -103,12 +106,14 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase
/// Pub结算与发运比对
///
[HttpPost]
- public async Task PubSaSeCompare(string version)
+ public async Task PubSaSeCompare(PubSaSeCompareRequestDto pubSaSeCompareRequestDto)
{
List customConditionList = new List();
- customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty });
- customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "结算与开票数据对比" });
- var _taskid = await _taskJobService.ExportEnqueueAsync("Pub结算与发运核对汇总表", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(PubSaSeCompareExportService), customConditionList, (rs) =>
+ customConditionList.Add(new CustomCondition() { Name = "Version", Value = pubSaSeCompareRequestDto.Version });
+ customConditionList.Add(new CustomCondition() { Name = "BusinessType", Value = pubSaSeCompareRequestDto.BusinessType.ToString() });
+
+ customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "结算与发运数据对比" });
+ var _taskid = await _taskJobService.ExportEnqueueAsync("Pub结算与发运核对汇总表", ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(PubSaSeCompareExportService), customConditionList, (rs) =>
{
Console.WriteLine("TaskJob 回调了");
});
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiService.cs
index b56f27a2..970f81a3 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiService.cs
@@ -18,6 +18,7 @@ public interface IVmiService : IApplicationService, ITransientDependency, IJobSe
IQueryable Query();
}
+[ApiExplorerSettings(IgnoreApi = true)]
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class VmiService : IVmiService
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj b/code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj
index 113ed56d..9084e5c7 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj
@@ -34,4 +34,8 @@
+
+
+
+
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SA.cs
index 3cc4bf0f..2852c1aa 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SA.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SA.cs
@@ -111,6 +111,12 @@ public class PUB_SA_DETAIL:SA_BASE
//[Display(Name = "结算分组")]
//public string GroupNum { get; set; } = null!;
+ ///
+ /// 业务分类
+ ///
+ [Display(Name = "业务分类")]
+ public EnumBusinessType BusinessType { get; set; }
+
public PUB_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, string extend1, string extend2, string extend3, string groupNum)
{
Id=guid;
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
new file mode 100644
index 00000000..e502a7e8
--- /dev/null
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
@@ -0,0 +1,50 @@
+using Magicodes.ExporterAndImporter.Core;
+using Magicodes.ExporterAndImporter.Excel;
+
+namespace Win.Sfs.SettleAccount.Reports;
+
+[ExcelExporter(MaxRowNumberOnASheet = 900000)]
+public class PubSaSeCompareDiff
+{
+ ///
+ /// 零件号
+ ///
+ [ExporterHeader(DisplayName = "零件号")]
+ public string SeLU { set; get; }
+
+ ///
+ /// 生产号
+ ///
+ [ExporterHeader(DisplayName = "生产号")]
+ public string SePN { set; get; }
+
+ ///
+ /// 零件号
+ ///
+ [ExporterHeader(DisplayName = "零件号")]
+ public string SaLU { set; get; }
+
+ ///
+ /// 生产号
+ ///
+ [ExporterHeader(DisplayName = "生产号")]
+ public string SaPN { set; get; }
+
+ ///
+ /// 结算数量
+ ///
+ [ExporterHeader(DisplayName = "结算数量")]
+ public decimal SaQty { set; get; }
+
+ ///
+ /// 发运数量
+ ///
+ [ExporterHeader(DisplayName = "发运数量")]
+ public decimal SeQty { set; get; }
+
+ ///
+ /// 差异数量
+ ///
+ [ExporterHeader(DisplayName = "差异数量")]
+ public decimal DiffQty { set; get; }
+}
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
new file mode 100644
index 00000000..629c05d6
--- /dev/null
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
@@ -0,0 +1,162 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using Dapper;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Repositories.Dapper;
+using Volo.Abp.EntityFrameworkCore;
+using Win.Sfs.SettleAccount.Entities;
+using Win.Sfs.SettleAccount.Reports;
+using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs;
+
+namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
+
+///
+/// Pub结算与发运对比Dapper仓储
+///
+public class PubSaSeCompareDapperRepository : DapperRepository, ITransientDependency
+{
+ public PubSaSeCompareDapperRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider)
+ {
+ }
+
+ ///
+ /// 获取差异
+ ///
+ public virtual List GetDetailDiffReportList(string version, string businessType)
+ {
+ string strSqlText = @$"
+ SELECT
+ A.LU SeLU,
+ A.PN SePN,
+ SeQty,
+ B.LU SaLU,
+ B.PN SaPN,
+ SaQty,
+ (SaQty - SeQty) DiffQty
+ FROM
+ (SELECT SUM(QTY) SeQty, LU, PN FROM Set_PUB_SE_DETAIL WHERE GROUP BY LU, PN) A
+ FULL JOIN (SELECT SUM(QTY) SaQty, LU, PN FROM Set_PUB_SA_DETAIL GROUP BY LU, PN) B ON A.LU= B.LU AND A.PN= B.PN
+ ";
+ return DbConnection.Query(strSqlText, null, null, true, 1200, null).ToList();
+ }
+
+ public virtual List GetInvoiceSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string cp7begin, string cp7end, string kennCode, string chassisNumber, string materialGroup)
+ {
+ List _list = new List();
+
+ if (CacheManager.CacheMaterials != null && CacheManager.CacheInvoiceSettledDetailDiff.Count(p => p.Version == version) > 0)
+ {
+ _list = CacheManager.CacheInvoiceSettledDetailDiff.Where(p => p.Version == version).ToList();
+ _list = _list.GroupBy(p => new { p.ChassisNumber, p.MaterialCode, p.ParentSapMaterialCode }).Select(p => p.FirstOrDefault()).ToList();
+ }
+ else
+ {
+
+ //string isExistSql = string.Format("SELECT count(1) lincount FROM [Set_Settle_RAM] WITH(SNAPSHOT) where Version = '{0}'", version);
+ //int _count = DbConnection.ExecuteScalar(isExistSql);
+ int _count = 0;
+
+ string condition = " where 1=1 ";
+ if (!string.IsNullOrEmpty(begin))
+ {
+ condition += string.Format(" and a.BeginTime>='{0}' ", begin);
+ }
+ if (!string.IsNullOrEmpty(end))
+ {
+ condition += string.Format(" and a.BeginTime<='{0}' ", end);
+ }
+ if (!string.IsNullOrEmpty(cp7begin))
+ {
+ condition += string.Format(" and B.cp7>='{0}' ", cp7begin);
+ }
+ if (!string.IsNullOrEmpty(cp7end))
+ {
+ condition += string.Format(" and B.cp7<='{0}' ", cp7end);
+ }
+
+
+ string tablestr = (_count == 0) ?
+ " ( SELECT * FROM Set_Settle b WHERE b.Version = '{0}' ) b\n" :
+
+ " (SELECT * FROM [Set_Settle_RAM] WITH(SNAPSHOT) where Version = '{0}') b \n";
+ string str =
+ "SELECT\n" +
+ string.Format(" '{0}' version ,\n", version) +
+" temp1.*,\n" +
+" TEMP2.Price,(\n" +
+" Isnull( temp2.Price, 0 ) * isnull( temp1.Qty, 0 )) Amt \n" +
+"FROM\n" +
+" (\n" +
+" SELECT\n" +
+" b.YEAR,\n" +
+" a.OrderBillNum Kenncode,\n" +
+" b.MaterialCode,\n" +
+" b.Model,\n" +
+" a.ChassisNumber,\n" +
+" a.Qty,\n" +
+" a.BeginTime CP5Time,\n" +
+" a.ChassisNumber2,\n" +
+" B.CP7 CP7Time,\n" +
+" a.QTY SettledQty,\n" +
+" a.ErpMaterialCode ParentSapMaterialCode,\n" +
+" a.WMSState,\n" +
+" a.WMSBillNum,\n" +
+" d.MaterialCode SapMaterialCode,\n" +
+" d.MaterialDesc MaterialDesc,\n" +
+" d.EstimateTypeDesc MaterialGroup,\n" +
+" e.MaterialDesc ParentMaterialDesc,\n" +
+" c.InvoicePrice,\n" +
+" Round( c.InvoicePrice * a.qty,2 ) InvoiceAmt,\n" +
+" Round( c.InvoicePrice * a.Qty,2 ) SettleAmt,\n" +
+" 0 DiffSettleFisQty,\n" +
+" 0 DiffSettleInvQty, \n" +
+" a.Qty InvoiceQty ,\n" +
+" IsNull( B.Qty, 0 ) SettleReadyQty, \n" +
+" a.UnSettleVersion \n" +
+" FROM\n" +
+tablestr +
+
+" INNER JOIN Set_fis a ON b.ChassisNumber = a.ChassisNumber2 \n" +
+" AND b.KENNCode = a.KENNCode \n" +
+" AND b.MaterialCode = a.ItemCode\n" +
+" LEFT JOIN ( SELECT SUM( amt )/ SUM( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) c ON a.ItemCode = c.MaterialCode\n" +
+" LEFT JOIN set_material d ON a.ItemCode = d.CustomerPartCode\n" +
+" LEFT JOIN (select max(Id) Id,MaterialCode,MaterialDesc from Set_material group by MaterialCode,MaterialDesc) e ON a.ErpMaterialCode = e.MaterialCode {1} \n" +
+" ) TEMP1\n" +
+" LEFT JOIN (\n" +
+" SELECT\n" +
+" Price,\n" +
+" MaterialCode \n" +
+" FROM\n" +
+" Set_PriceList \n" +
+" WHERE\n" +
+" version = ( SELECT Max( Version ) FROM Set_PriceList ) and type=10 ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode";
+ var _sql = string.Format(str, version, condition);
+
+ var _query = DbConnection.Query(_sql, null, null, true, 1200, null);
+
+ _list = _query.ToList();
+
+ if (CacheManager.CacheMaterials != null && CacheManager.CacheInvoiceSettledDetailDiff.Count(p => p.Version == version) > 0)
+ {
+ _list = CacheManager.CacheInvoiceSettledDetailDiff.Where(p => p.Version == version).ToList();
+ _list = _list.GroupBy(p => new { p.ChassisNumber, p.MaterialCode, p.ParentSapMaterialCode }).Select(p => p.FirstOrDefault()).ToList();
+ }
+ else
+ {
+ if (CacheManager.CacheInvoiceSettledDetailDiff == null)
+ {
+ CacheManager.CacheInvoiceSettledDetailDiff = new List();
+ }
+ CacheManager.CacheInvoiceSettledDetailDiff.AddRange(_list);
+ }
+
+
+
+ }
+ return _list;
+
+ }
+}
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Dispatcher/JobDispatcher.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Dispatcher/JobDispatcher.cs
index 06654c4c..89f9f0bb 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Dispatcher/JobDispatcher.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Dispatcher/JobDispatcher.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
index ead0104d..dd79f808 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
@@ -1,8 +1,16 @@
using System;
using System.Collections.Generic;
+using Magicodes.ExporterAndImporter.Excel;
+using System.Linq;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.DependencyInjection;
+using Win.Sfs.BaseData.ImportExcelCommon;
+using Win.Sfs.Shared.RepositoryBase;
+using SettleAccount.Domain.BQ;
+using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
+using Shouldly;
+using Volo.Abp.BlobStoring;
namespace SettleAccount.Job.Services.Report
{
@@ -11,14 +19,270 @@ namespace SettleAccount.Job.Services.Report
///
public class PubSaSeCompareExportService: ITransientDependency, IExportJob
{
- public PubSaSeCompareExportService() { }
+ ///
+ /// Pub结算明细仓储
+ ///
+ private readonly INormalEfCoreRepository _pubSaDetailRepository;
+
+ ///
+ /// Pub发运数据仓储
+ ///
+ private readonly INormalEfCoreRepository _pubSeDetailRepository;
+
+ private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository;
+
+ private readonly IBlobContainer _fileContainer;
+
+ ///
+ /// 构造
+ ///
+ public PubSaSeCompareExportService(INormalEfCoreRepository pubSaDetailRepository,
+ INormalEfCoreRepository pubSeDetailRepository,
+ PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
+ IBlobContainer fileContainer)
+ {
+ _pubSaDetailRepository = pubSaDetailRepository;
+ _pubSeDetailRepository = pubSeDetailRepository;
+ _pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository;
+ _fileContainer = fileContainer;
+ }
///
/// 导出
///
public string ExportFile(Guid id, List exportName, List property)
{
+ var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
+ var businessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value;
+ var filename = exportName.FirstOrDefault();
+ var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(version, businessType);
+
+ ExcelExporter excelExporter = new ExcelExporter();
+
+ var result = excelExporter
+ .Append(pubSaSeCompareDiffs, "差异明细表")
+ .SeparateBySheet()
+ .Append(pubSaSeCompareDiffs, "数量差异汇总表")
+ .SeparateBySheet()
+ .Append(pubSaSeCompareDiffs, "按物料价格差异明细表")
+ .SeparateBySheet()
+ .Append(pubSaSeCompareDiffs, "差异汇总验证表")
+ .ExportAppendDataAsByteArray();
+ result.ShouldNotBeNull();
+ _fileContainer.SaveAsync(filename, result.Result, true);
+
+ return id.ToString();
+
+ //结算
+
+ //var _lsSum = _ls.GroupBy(p => new { p.MaterialCode, p.SapMaterialCode, p.MaterialGroup, p.InvoicePrice }).Select(p => new UnInvoiceSettledDetailSum
+ //{
+ // MaterialCode = p.Key.MaterialCode,
+ // SapMaterailCode = p.Key.SapMaterialCode,
+ // MaterialGroup = p.Key.MaterialGroup,
+ // SettleQty = p.Sum(itm => itm.SettledQty),
+ // FisQty = 0,
+ // DiffQty = -p.Sum(itm => itm.SettledQty),
+ // Price = p.Key.InvoicePrice,
+ // DiffAmt = p.Sum(itm => itm.SettledQty) * p.Key.InvoicePrice
+ //}).ToList();
+
+ //var _sumTotal = new UnInvoiceSettledDetailSum()
+ //{
+
+ // SettleQty = _lsSum.Sum(p => p.SettleQty),
+ // DiffQty = _lsSum.Sum(p => p.DiffQty),
+ // Price = _lsSum.Sum(p => p.Price),
+ // DiffAmt = _lsSum.Sum(p => p.DiffAmt)
+
+
+ //};
+ //_lsSum.Add(_sumTotal);
+
+
+
+ //var _ls1 = DiffPrice(id, exportName, p_list);
+
+ //var report1List = _ls1.Where(p => p.DiffPrice != 0).GroupBy(p => new { p.MaterialGroup, p.MaterialCode, p.MaterialDesc, p.Price, p.InvoicePrice, p.DiffPrice, p.SapMaterialCode })
+ // .Select(t => new SettleDoorPanelExport { MaterialGroup = t.FirstOrDefault().MaterialGroup, MaterialCode = t.FirstOrDefault().MaterialCode, MaterialDesc = t.FirstOrDefault().MaterialDesc, Price = t.FirstOrDefault().Price, InvoicePrice = t.FirstOrDefault().InvoicePrice, InvoiceDiffPrice = t.FirstOrDefault().DiffPrice, SAPCode = t.FirstOrDefault().SapMaterialCode }).ToList();
+
+
+
+ //var report2List = _ls1.Where(p => p.DiffPrice != 0).Select(p => new { p.MaterialGroup, DiffAmt = p.DiffPrice * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version });
+
+ //var list1 = LSettleSum(id, exportName, p_list);
+
+ //var report1 = report2List.ToList();
+
+ //foreach (var itm in list1)
+ //{
+ // itm.MaterialGroup = itm.MaterialGroup + "(漏结)";
+ //}
+
+ //report1.AddRange(list1);
+
+ //ExcelExporter _exporter = new ExcelExporter();//导出Excel
+
+ //var result = _exporter
+ //.Append(_ls, "差异明细表")
+ //.SeparateBySheet()
+ //.Append(_lsSum, "数量差异汇总表")
+ //.SeparateBySheet()
+ //.Append(report1List, "按物料价格差异明细表")
+ //.SeparateBySheet()
+ //.Append(report1, "差异汇总验证表")
+ //.ExportAppendDataAsByteArray();
+ //result.ShouldNotBeNull();
+ //_fileContainer.SaveAsync(_filename, result.Result, true);
+
+ ////_outputService.Export(id, string.Format("大众结算未发运核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _ls);
+
+ //return id.ToString();
+
return this.GetType().FullName;
}
+
+ ///
+ /// 导出
+ ///
+ public string ExportFile333(Guid id, List exportName, List property)
+ {
+ return "";
+// var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
+
+// var _filename = exportName.FirstOrDefault();
+
+// var _ls = _dapperRepository.GetDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber, materialGroup);
+// var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version);
+// foreach (var itm in _ls)
+// {
+// itm.InvoiceAmt = Math.Round(itm.InvoiceQty * itm.InvoicePrice, 2);
+// itm.DiffPrice = itm.Price - itm.InvoicePrice;
+// itm.DiffSettleFisQty = itm.SettledQty;
+// }
+// _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList();
+
+
+
+// if (!string.IsNullOrEmpty(materialGroup))
+// {
+// var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
+// if (_groupList.Count() > 0)
+// {
+// _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList();
+// }
+// }
+// if (!string.IsNullOrEmpty(kenncode))
+// {
+// var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList();
+// if (_groupList.Count() > 0)
+// {
+// _ls = _ls.Where(p => _groupList.Contains(p.KENNCode)).ToList();
+// }
+// }
+// if (!string.IsNullOrEmpty(chassisNumber))
+// {
+// var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList();
+// if (_groupList.Count() > 0)
+// {
+// _ls = _ls.Where(p => _groupList.Contains(p.ChassisNumber)).ToList();
+// }
+// }
+// if (!string.IsNullOrEmpty(sapCode))
+// {
+// var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
+// if (_groupList.Count() > 0)
+// {
+// _ls = _ls.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
+// }
+// }
+// if (!string.IsNullOrEmpty(materialCode))
+// {
+// var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList();
+// if (_groupList.Count() > 0)
+// {
+// _ls = _ls.Where(p => _groupList.Contains(p.MaterialCode)).ToList();
+// }
+// }
+
+
+// var _checkList = _erpdapperRepository.GetErrorBillList();
+
+// var query = from itm in _ls
+// join itm1 in _checkList on new { ChassisNumber = itm.ChassisNumber, MaterialCode = itm.MaterialCode, WmsBillNum = itm.WmsBillNum }
+//equals new { ChassisNumber = itm1.BillNum, MaterialCode = itm1.MaterialCode, WmsBillNum = itm1.WmsBillNum } into temp1
+// from tm1 in temp1.DefaultIfEmpty()
+// where tm1 == null
+// select itm;
+
+
+// _ls = query.ToList();
+
+
+
+// var _lsSum = _ls.GroupBy(p => new { p.MaterialCode, p.SapMaterialCode, p.MaterialGroup, p.InvoicePrice }).Select(p => new UnInvoiceSettledDetailSum
+// {
+// MaterialCode = p.Key.MaterialCode,
+// SapMaterailCode = p.Key.SapMaterialCode,
+// MaterialGroup = p.Key.MaterialGroup,
+// SettleQty = p.Sum(itm => itm.SettledQty),
+// FisQty = 0,
+// DiffQty = -p.Sum(itm => itm.SettledQty),
+// Price = p.Key.InvoicePrice,
+// DiffAmt = p.Sum(itm => itm.SettledQty) * p.Key.InvoicePrice
+// }).ToList();
+
+// var _sumTotal = new UnInvoiceSettledDetailSum()
+// {
+
+// SettleQty = _lsSum.Sum(p => p.SettleQty),
+// DiffQty = _lsSum.Sum(p => p.DiffQty),
+// Price = _lsSum.Sum(p => p.Price),
+// DiffAmt = _lsSum.Sum(p => p.DiffAmt)
+
+
+// };
+// _lsSum.Add(_sumTotal);
+
+
+
+// var _ls1 = DiffPrice(id, exportName, p_list);
+
+// var report1List = _ls1.Where(p => p.DiffPrice != 0).GroupBy(p => new { p.MaterialGroup, p.MaterialCode, p.MaterialDesc, p.Price, p.InvoicePrice, p.DiffPrice, p.SapMaterialCode })
+// .Select(t => new SettleDoorPanelExport { MaterialGroup = t.FirstOrDefault().MaterialGroup, MaterialCode = t.FirstOrDefault().MaterialCode, MaterialDesc = t.FirstOrDefault().MaterialDesc, Price = t.FirstOrDefault().Price, InvoicePrice = t.FirstOrDefault().InvoicePrice, InvoiceDiffPrice = t.FirstOrDefault().DiffPrice, SAPCode = t.FirstOrDefault().SapMaterialCode }).ToList();
+
+
+
+// var report2List = _ls1.Where(p => p.DiffPrice != 0).Select(p => new { p.MaterialGroup, DiffAmt = p.DiffPrice * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version });
+
+// var list1 = LSettleSum(id, exportName, p_list);
+
+// var report1 = report2List.ToList();
+
+// foreach (var itm in list1)
+// {
+// itm.MaterialGroup = itm.MaterialGroup + "(漏结)";
+// }
+
+// report1.AddRange(list1);
+
+// ExcelExporter _exporter = new ExcelExporter();//导出Excel
+
+// var result = _exporter
+// .Append(_ls, "差异明细表")
+// .SeparateBySheet()
+// .Append(_lsSum, "数量差异汇总表")
+// .SeparateBySheet()
+// .Append(report1List, "按物料价格差异明细表")
+// .SeparateBySheet()
+// .Append(report1, "差异汇总验证表")
+// .ExportAppendDataAsByteArray();
+// result.ShouldNotBeNull();
+// _fileContainer.SaveAsync(_filename, result.Result, true);
+
+// //_outputService.Export(id, string.Format("大众结算未发运核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _ls);
+
+// return id.ToString();
+ }
}
}