Browse Source

更新版本

FoShanPG
Administrator 2 years ago
parent
commit
6c2bef61d7
  1. 12
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  2. 11
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs
  3. 145
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs

12
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -160,8 +160,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{ {
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService); var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>();
_checkls.Add("100001");
_checkls.Add("100053");
_checkls.Add("100113");
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result); var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(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()); 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(); _ls=_ls.Where(p => p.Type == 20).ToList();
await _mng.ImportAsync(_ls.ToList(), version); await _mng.ImportAsync(_ls.ToList(), version);
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;

11
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 var update = from itm1 in entities
join itm2 in pricelist 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 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); 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 var update = from itm1 in entities
join itm2 in pricelist 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 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); 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) if (update.Count() > 0)
{ {
await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
} }
else else
@ -268,12 +267,6 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
await _repository.GetDbContext().BulkInsertAsync<PriceListBJ>(add.ToList()); await _repository.GetDbContext().BulkInsertAsync<PriceListBJ>(add.ToList());
} }
var _first = _versionRepository.FirstOrDefault(p => p.Version == version); var _first = _versionRepository.FirstOrDefault(p => p.Version == version);
if (_first == null) if (_first == null)
{ {

145
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" + string str = "SELECT\n" +
" temp1.*,\n" + "temp1.*,\n" +
" isnull( temp2.Price, 0 ) 定价,\n" + "isnull( temp2.Price, 0 ) 定价,\n" +
" ISNULL( temp3.Price, 0 ) 结算单价,\n" + "ISNULL( temp3.Price, 0 ) 结算单价,\n" +
" ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" + "( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" +
" ( temp3.Price * temp1.结算数量 ) 结算金额,\n" + "( temp3.Price * temp1.结算数量 ) 结算金额,\n" +
" ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" + "( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额\n" +
"FROM\n" + "FROM\n" +
" (\n" + "(\n" +
" SELECT\n" + "SELECT\n" +
" ISNULL( A.Qty, 0 ) 结算数量,\n" + "ISNULL( A.Qty, 0 ) 结算数量,\n" +
" A.MaterialCode 结算物料号,\n" + "A.MaterialCode 结算物料号,\n" +
" C.EstimateTypeDesc 物料组,\n" + "C.EstimateTypeDesc 物料组,\n" +
" C.MaterialCode Sap编码,\n" + "C.MaterialCode Sap编码,\n" +
" C.MaterialDesc 物料描述,\n" + "C.MaterialDesc 物料描述,\n" +
" 0 寄销库数量 \n" + "0 寄销库数量\n" +
" FROM\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" + "( 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" + "LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode\n" +
" ) temp1\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 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" + "LEFT JOIN (\n" +
" SELECT SUM\n" + "SELECT\n" +
" ( Amt ) / SUM ( Qty ) AS Price,\n" + "\n" +
" MaterialCode,\n" + "case SUM(Qty) when 0 then 0 else\n" +
" Version \n" + "SUM( Amt ) / SUM ( Qty )\n" +
" FROM\n" + "\n" +
" Set_BT_Car_Platform \n" + "end AS Price,\n" +
" WHERE\n" + "MaterialCode,\n" +
" version = '{0}' \n" + "Version\n" +
" AND StorageLocationDesc NOT LIKE '%备品%' \n" + "FROM\n" +
" GROUP BY\n" + "Set_BT_Car_Platform\n" +
" MaterialCode,\n" + "WHERE\n" +
" Version \n" + "version = '{0}'\n" +
" ) AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode"; "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" + string str = "SELECT\n" +
" temp1.*,\n" + "temp1.*,\n" +
" isnull( temp2.Price, 0 ) 定价,\n" + "isnull( temp2.Price, 0 ) 定价,\n" +
" ISNULL( temp3.Price, 0 ) 结算单价,\n" + "ISNULL( temp3.Price, 0 ) 结算单价,\n" +
" ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" + "( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) 价格差异,\n" +
" ( temp3.Price * temp1.结算数量 ) 结算金额,\n" + "( temp3.Price * temp1.结算数量 ) 结算金额,\n" +
" ( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" + "( isnull( temp3.Price, 0 ) - isnull( temp2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额\n" +
"FROM\n" + "FROM\n" +
" (\n" + "(\n" +
" SELECT\n" + "SELECT\n" +
" ISNULL( A.Qty, 0 ) 结算数量,\n" + "ISNULL( A.Qty, 0 ) 结算数量,\n" +
" A.MaterialCode 结算物料号,\n" + "A.MaterialCode 结算物料号,\n" +
" C.EstimateTypeDesc 物料组,\n" + "C.EstimateTypeDesc 物料组,\n" +
" C.MaterialCode Sap编码,\n" + "C.MaterialCode Sap编码,\n" +
" C.MaterialDesc 物料描述,\n" + "C.MaterialDesc 物料描述,\n" +
" 0 寄销库数量 \n" + "0 寄销库数量\n" +
" FROM\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" + "( 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" + "LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode\n" +
" ) temp1\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 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" + "LEFT JOIN (\n" +
" SELECT SUM\n" + "SELECT\n" +
" ( Amt ) / SUM ( Qty ) AS Price,\n" + "case SUM(Qty) when 0 then 0 else\n" +
" MaterialCode,\n" + "\n" +
" Version \n" + "SUM\n" +
" FROM\n" + "( Amt ) / SUM ( Qty )\n" +
" Set_BT_Car_Platform \n" + "end\n" +
" WHERE\n" + "AS Price,\n" +
" version = '{0}' \n" + "MaterialCode,\n" +
" AND StorageLocationDesc LIKE '%备品%' \n" + "Version\n" +
" GROUP BY\n" + "FROM\n" +
" MaterialCode,\n" + "Set_BT_Car_Platform\n" +
" Version \n" + "WHERE\n" +
" ) AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode"; "version = '{0}'\n" +
"AND StorageLocationDesc LIKE '%备品%'\n" +
"GROUP BY\n" +
"MaterialCode,\n" +
"Version\n" +
") AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode\n";

Loading…
Cancel
Save