Browse Source

更新版本

FoShanPG
Administrator 2 years ago
parent
commit
fb1e20f614
  1. 145
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettledPartAndErpPartPriceDiffRepository.cs

145
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettledPartAndErpPartPriceDiffRepository.cs

@ -21,35 +21,70 @@ namespace Win.Sfs.SettleAccount.Repository.Report
public virtual List<SettledPartAndErpPartPriceDiff> GetDiffReport(string year, string customcode, string version)
{
string sqlString = "SELECT\n" +
" t1.ErpMaterialCode,\n" +
" t1.Price SumPrice,\n" +
" t2.Price,\n" +
" t3.MaterialDesc,\n" +
" t3.EstimateTypeDesc ,\n" +
"t1.ErpMaterialCode,\n" +
"t1.Price SumPrice,\n" +
"t2.Price,\n" +
"t3.MaterialDesc,\n" +
"t3.EstimateTypeDesc ,\n" +
"(ISNULL(t1.price,0)-ISNULL(t2.price,0)) DiffPrice\n" +
"FROM\n" +
"(\n" +
"SELECT\n" +
"ErpMaterialCode,\n" +
"SUM( amt ) Price\n" +
"FROM\n" +
"(\n" +
"SELECT\n" +
"ErpMaterialCode,\n" +
"SettleMaterialCode,(\n" +
"Qty * isnull( b.Price, 0 )) amt\n" +
"FROM\n" +
"(\n" +
"\n" +
"select MaterialCode,ErpMaterialCode,Qty,SettleMaterialCode from\n" +
"Set_MaterialRelationshipDetail_pg ab inner join Set_material ac\n" +
"on ab.SettleMaterialCode=ac.CustomerPartCode\n" +
") a\n" +
"LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) b ON a.MaterialCode = b.MaterialCode\n" +
") temp1\n" +
"GROUP BY\n" +
"ErpMaterialCode\n" +
") t1\n" +
"LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) t2 ON t1.ErpMaterialCode = t2.MaterialCode\n" +
"LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) t3 ON t1.ErpMaterialCode = t3.MaterialCode;\n";
" (ISNULL(t1.price,0)-ISNULL(t2.price,0)) DiffPrice\n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" ErpMaterialCode,\n" +
" SUM( amt ) Price \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" ErpMaterialCode,\n" +
" SettleMaterialCode,(\n" +
" Qty * isnull( b.Price, 0 )) amt \n" +
" FROM\n" +
" Set_MaterialRelationshipDetail_pg a\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) b ON a.SettleMaterialCode = b.MaterialCode \n" +
" ) temp1 \n" +
" GROUP BY\n" +
" ErpMaterialCode \n" +
" ) t1\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) t2 ON t1.ErpMaterialCode = t2.MaterialCode\n" +
" LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) t3 ON t1.ErpMaterialCode = t3.MaterialCode";
// string sqlString = "SELECT\n" +
//" t1.ErpMaterialCode,\n" +
//" t1.Price SumPrice,\n" +
//" t2.Price,\n" +
//" t3.MaterialDesc,\n" +
//" t3.EstimateTypeDesc ,\n" +
//" (ISNULL(t1.price,0)-ISNULL(t2.price,0)) DiffPrice\n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
//" ErpMaterialCode,\n" +
//" SUM( amt ) Price \n" +
//" FROM\n" +
//" (\n" +
//" SELECT\n" +
//" ErpMaterialCode,\n" +
//" SettleMaterialCode,(\n" +
//" Qty * isnull( b.Price, 0 )) amt \n" +
//" FROM\n" +
//" Set_MaterialRelationshipDetail_pg a\n" +
//" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) b ON a.SettleMaterialCode = b.MaterialCode \n" +
//" ) temp1 \n" +
//" GROUP BY\n" +
//" ErpMaterialCode \n" +
//" ) t1\n" +
//" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) t2 ON t1.ErpMaterialCode = t2.MaterialCode\n" +
//" LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) t3 ON t1.ErpMaterialCode = t3.MaterialCode";
string _sql = string.Format(sqlString, version, customcode);
@ -60,22 +95,48 @@ namespace Win.Sfs.SettleAccount.Repository.Report
public virtual List<PartCodeDiff> GetDiffDetailReport(string year, string customcode, string version)
{
string sqlString = "select a.ErpMaterialCode,isnull(d.materialCode,SettleMaterialCode) MaterialCode,a.ShipMaterailCode,d.MaterialDesc,d.EstimateTypeDesc from\n" +
" Set_MaterialRelationshipDetail_pg a left join\n" +
" (\n" +
" SELECT\n" +
" Price,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_PriceList \n" +
" WHERE\n" +
" version = ( SELECT Max( Version ) FROM Set_PriceList ) and type=10 )\n" +
" b on a.SettleMaterialCode=b.MaterialCode \n" +
" left join \n" +
" set_material d ON a.ShipMaterailCode = d.CustomerPartCode\n" +
" \n" +
" \n" +
" where b.MaterialCode is null";
string sqlString =
"select\n" +
"a.ErpMaterialCode,\n" +
"isnull(d.materialCode,\n" +
"SettleMaterialCode) MaterialCode,\n" +
"a.SettleMaterialCode,\n" +
"d.MaterialDesc,\n" +
"d.EstimateTypeDesc\n" +
"from\n" +
"(\n" +
"select\n" +
"MaterialCode,\n" +
"ErpMaterialCode,\n" +
"Qty,\n" +
"SettleMaterialCode\n" +
"from\n" +
"Set_MaterialRelationshipDetail_pg ab\n" +
"inner join Set_material ac\n" +
"on\n" +
"ab.SettleMaterialCode = ac.CustomerPartCode) a\n" +
"left join\n" +
"(\n" +
"SELECT\n" +
"Price,\n" +
"MaterialCode\n" +
"FROM\n" +
"Set_PriceList\n" +
"WHERE\n" +
"version = (\n" +
"SELECT\n" +
"Max(Version)\n" +
"FROM\n" +
"Set_PriceList )\n" +
"and type = 10 )\n" +
"b on\n" +
"a.SettleMaterialCode = b.MaterialCode\n" +
"left join\n" +
"set_material d ON\n" +
"a.SettleMaterialCode = d.CustomerPartCode\n" +
"where\n" +
"b.MaterialCode is null\n";
string _sql = string.Format(sqlString, version, customcode);
var _query = DbConnection.Query<PartCodeDiff>(_sql, null, null, true, 1200, null);

Loading…
Cancel
Save