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) public virtual List<SettledPartAndErpPartPriceDiff> GetDiffReport(string year, string customcode, string version)
{ {
string sqlString = "SELECT\n" + string sqlString = "SELECT\n" +
" t1.ErpMaterialCode,\n" + "t1.ErpMaterialCode,\n" +
" t1.Price SumPrice,\n" + "t1.Price SumPrice,\n" +
" t2.Price,\n" + "t2.Price,\n" +
" t3.MaterialDesc,\n" + "t3.MaterialDesc,\n" +
" t3.EstimateTypeDesc ,\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" + // string sqlString = "SELECT\n" +
" (\n" + //" t1.ErpMaterialCode,\n" +
" SELECT\n" + //" t1.Price SumPrice,\n" +
" ErpMaterialCode,\n" + //" t2.Price,\n" +
" SUM( amt ) Price \n" + //" t3.MaterialDesc,\n" +
" FROM\n" + //" t3.EstimateTypeDesc ,\n" +
" (\n" +
" SELECT\n" + //" (ISNULL(t1.price,0)-ISNULL(t2.price,0)) DiffPrice\n" +
" ErpMaterialCode,\n" +
" SettleMaterialCode,(\n" + //"FROM\n" +
" Qty * isnull( b.Price, 0 )) amt \n" + //" (\n" +
" FROM\n" + //" SELECT\n" +
" Set_MaterialRelationshipDetail_pg a\n" + //" ErpMaterialCode,\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" + //" SUM( amt ) Price \n" +
" ) temp1 \n" + //" FROM\n" +
" GROUP BY\n" + //" (\n" +
" ErpMaterialCode \n" + //" SELECT\n" +
" ) t1\n" + //" ErpMaterialCode,\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" + //" SettleMaterialCode,(\n" +
" LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) t3 ON t1.ErpMaterialCode = t3.MaterialCode"; //" 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); 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) 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" + string sqlString =
" Set_MaterialRelationshipDetail_pg a left join\n" +
" (\n" + "select\n" +
" SELECT\n" + "a.ErpMaterialCode,\n" +
" Price,\n" + "isnull(d.materialCode,\n" +
" MaterialCode \n" + "SettleMaterialCode) MaterialCode,\n" +
" FROM\n" + "a.SettleMaterialCode,\n" +
" Set_PriceList \n" + "d.MaterialDesc,\n" +
" WHERE\n" + "d.EstimateTypeDesc\n" +
" version = ( SELECT Max( Version ) FROM Set_PriceList ) and type=10 )\n" + "from\n" +
" b on a.SettleMaterialCode=b.MaterialCode \n" + "(\n" +
" left join \n" + "select\n" +
" set_material d ON a.ShipMaterailCode = d.CustomerPartCode\n" + "MaterialCode,\n" +
" \n" + "ErpMaterialCode,\n" +
" \n" + "Qty,\n" +
" where b.MaterialCode is null"; "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); string _sql = string.Format(sqlString, version, customcode);
var _query = DbConnection.Query<PartCodeDiff>(_sql, null, null, true, 1200, null); var _query = DbConnection.Query<PartCodeDiff>(_sql, null, null, true, 1200, null);

Loading…
Cancel
Save