From 6c2bef61d7f6551a7794c17bac3433add5a6c05d Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 23 Jun 2022 12:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Prices/PriceListAppServiceBJ.cs | 12 ++ .../Entities/Prices/PriceListManager.cs | 11 +- .../HQCarSettledDetailDapperRepository.cs | 145 ++++++++++-------- 3 files changed, 91 insertions(+), 77 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs index d5159240..e1613f35 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs @@ -160,8 +160,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices { ExportImporter _exportImporter = new ExportImporter(); + + + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + + List _checkls = new List(); + _checkls.Add("100001"); + _checkls.Add("100053"); + _checkls.Add("100113"); + var entityList = ObjectMapper.Map, List>(result); var _ls = entityList.Where(p=>p.EndDate.ToString().Contains("9999")).OrderByDescending(p => p.BeginDate).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault()); @@ -171,6 +180,9 @@ namespace Win.Sfs.SettleAccount.Entities.Prices } _ls=_ls.Where(p => p.Type == 20).ToList(); + + + await _mng.ImportAsync(_ls.ToList(), version); return ApplicationConsts.SuccessStr; diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs index 0ac4dec9..827f2e3d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs @@ -85,7 +85,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices var update = from itm1 in entities join itm2 in pricelist - on new { itm1.Type, itm1.MaterialCode } equals new { itm2.Type, itm2.MaterialCode } + on new { itm1.Type, itm1.MaterialCode,itm1.CustomerCode } equals new { itm2.Type, itm2.MaterialCode, itm2.CustomerCode } where itm1.Price != itm2.Price select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode); @@ -246,13 +246,12 @@ namespace Win.Sfs.SettleAccount.Entities.Prices var update = from itm1 in entities join itm2 in pricelist - on new { itm1.Type, itm1.MaterialCode } equals new { itm2.Type, itm2.MaterialCode } + on new { itm1.Type, itm1.MaterialCode ,itm1.CustomerCode} equals new { itm2.Type, itm2.MaterialCode ,itm2.CustomerCode} where itm1.Price != itm2.Price select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode); if (update.Count() > 0) { - await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); } else @@ -268,12 +267,6 @@ namespace Win.Sfs.SettleAccount.Entities.Prices await _repository.GetDbContext().BulkInsertAsync(add.ToList()); } - - - - - - var _first = _versionRepository.FirstOrDefault(p => p.Version == version); if (_first == null) { diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs index 35a5136f..04e8b9d2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs @@ -142,40 +142,44 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //} string str = "SELECT\n" + - " temp1.*,\n" + - " isnull( temp2.Price, 0 ) 定价,\n" + - " ISNULL( temp3.Price, 0 ) 结算单价,\n" + - " ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" + - " ( temp3.Price * temp1.结算数量 ) 结算金额,\n" + - " ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " ISNULL( A.Qty, 0 ) 结算数量,\n" + - " A.MaterialCode 结算物料号,\n" + - " C.EstimateTypeDesc 物料组,\n" + - " C.MaterialCode Sap编码,\n" + - " C.MaterialDesc 物料描述,\n" + - " 0 寄销库数量 \n" + - " FROM\n" + - " ( SELECT SUM ( Qty ) Qty, MaterialCode, Version FROM Set_BT_Car_Platform WHERE version = '{0}' AND StorageLocationDesc NOT LIKE '%备品%' GROUP BY MaterialCode, Version ) A\n" + - " LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + - " ) temp1\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n" + - " LEFT JOIN (\n" + - " SELECT SUM\n" + - " ( Amt ) / SUM ( Qty ) AS Price,\n" + - " MaterialCode,\n" + - " Version \n" + - " FROM\n" + - " Set_BT_Car_Platform \n" + - " WHERE\n" + - " version = '{0}' \n" + - " AND StorageLocationDesc NOT LIKE '%备品%' \n" + - " GROUP BY\n" + - " MaterialCode,\n" + - " Version \n" + - " ) AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode"; +"temp1.*,\n" + +"isnull( temp2.Price, 0 ) 定价,\n" + +"ISNULL( temp3.Price, 0 ) 结算单价,\n" + +"( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" + +"( temp3.Price * temp1.结算数量 ) 结算金额,\n" + +"( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额\n" + +"FROM\n" + +"(\n" + +"SELECT\n" + +"ISNULL( A.Qty, 0 ) 结算数量,\n" + +"A.MaterialCode 结算物料号,\n" + +"C.EstimateTypeDesc 物料组,\n" + +"C.MaterialCode Sap编码,\n" + +"C.MaterialDesc 物料描述,\n" + +"0 寄销库数量\n" + +"FROM\n" + +"( SELECT SUM ( Qty ) Qty, MaterialCode, Version FROM Set_BT_Car_Platform WHERE version = '{0}' AND StorageLocationDesc NOT LIKE '%备品%' GROUP BY MaterialCode, Version ) A\n" + +"LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode\n" + +") temp1\n" + +"LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n" + +"LEFT JOIN (\n" + +"SELECT\n" + +"\n" + +"case SUM(Qty) when 0 then 0 else\n" + +"SUM( Amt ) / SUM ( Qty )\n" + +"\n" + +"end AS Price,\n" + +"MaterialCode,\n" + +"Version\n" + +"FROM\n" + +"Set_BT_Car_Platform\n" + +"WHERE\n" + +"version = '{0}'\n" + +"AND StorageLocationDesc NOT LIKE '%备品%'\n" + +"GROUP BY\n" + +"MaterialCode,\n" + +"Version\n" + +") AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode\n"; @@ -283,40 +287,45 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //} string str = "SELECT\n" + - " temp1.*,\n" + - " isnull( temp2.Price, 0 ) 定价,\n" + - " ISNULL( temp3.Price, 0 ) 结算单价,\n" + - " ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" + - " ( temp3.Price * temp1.结算数量 ) 结算金额,\n" + - " ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " ISNULL( A.Qty, 0 ) 结算数量,\n" + - " A.MaterialCode 结算物料号,\n" + - " C.EstimateTypeDesc 物料组,\n" + - " C.MaterialCode Sap编码,\n" + - " C.MaterialDesc 物料描述,\n" + - " 0 寄销库数量 \n" + - " FROM\n" + - " ( SELECT SUM ( Qty ) Qty, MaterialCode, Version FROM Set_BT_Car_Platform WHERE version = '{0}' AND StorageLocationDesc LIKE '%备品%' GROUP BY MaterialCode, Version ) A\n" + - " LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + - " ) temp1\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n" + - " LEFT JOIN (\n" + - " SELECT SUM\n" + - " ( Amt ) / SUM ( Qty ) AS Price,\n" + - " MaterialCode,\n" + - " Version \n" + - " FROM\n" + - " Set_BT_Car_Platform \n" + - " WHERE\n" + - " version = '{0}' \n" + - " AND StorageLocationDesc LIKE '%备品%' \n" + - " GROUP BY\n" + - " MaterialCode,\n" + - " Version \n" + - " ) AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode"; +"temp1.*,\n" + +"isnull( temp2.Price, 0 ) 定价,\n" + +"ISNULL( temp3.Price, 0 ) 结算单价,\n" + +"( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" + +"( temp3.Price * temp1.结算数量 ) 结算金额,\n" + +"( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额\n" + +"FROM\n" + +"(\n" + +"SELECT\n" + +"ISNULL( A.Qty, 0 ) 结算数量,\n" + +"A.MaterialCode 结算物料号,\n" + +"C.EstimateTypeDesc 物料组,\n" + +"C.MaterialCode Sap编码,\n" + +"C.MaterialDesc 物料描述,\n" + +"0 寄销库数量\n" + +"FROM\n" + +"( SELECT SUM ( Qty ) Qty, MaterialCode, Version FROM Set_BT_Car_Platform WHERE version = '{0}' AND StorageLocationDesc LIKE '%备品%' GROUP BY MaterialCode, Version ) A\n" + +"LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode\n" + +") temp1\n" + +"LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n" + +"LEFT JOIN (\n" + +"SELECT\n" + +"case SUM(Qty) when 0 then 0 else\n" + +"\n" + +"SUM\n" + +"( Amt ) / SUM ( Qty )\n" + +"end\n" + +"AS Price,\n" + +"MaterialCode,\n" + +"Version\n" + +"FROM\n" + +"Set_BT_Car_Platform\n" + +"WHERE\n" + +"version = '{0}'\n" + +"AND StorageLocationDesc LIKE '%备品%'\n" + +"GROUP BY\n" + +"MaterialCode,\n" + +"Version\n" + +") AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode\n";