Browse Source

红旗未结+有发货有结算相关更改

FoShanPG
44673626 3 years ago
parent
commit
d61a46387b
  1. 145
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

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

@ -651,7 +651,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" AND b.MaterialCode IS NULL {1}\n" + " AND b.MaterialCode IS NULL {1}\n" +
" ) AS temp1\n" + " ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) 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 ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + " LEFT JOIN (select * from set_backQty WHERE Version='{2}') tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" AND temp1.订货看板编号 = tt.Code \n" + " AND temp1.订货看板编号 = tt.Code \n" +
" ) UNION1 UNION ALL\n" + " ) UNION1 UNION ALL\n" +
"SELECT\n" + "SELECT\n" +
@ -675,9 +675,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
" isnull( tt.Qty, 0 ) 退货数量,\n" + " isnull( tt.Qty, 0 ) 退货数量,\n" +
" isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) AS 数量差异,\n" + " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 )- isnull( tt.Qty, 0 ) AS 数量差异,\n" +
" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + " temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" + " ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" +
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
@ -691,24 +691,24 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" isnull( a.Qty, 0 ) AS 发货数量,\n" + " isnull( a.Qty, 0 ) AS 发货数量,\n" +
" '' AS 外部验收单号,\n" + " '' AS 外部验收单号,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" + " isnull( b.Qty, 0 ) AS 结算数量,\n" +
" 0 AS 结算单价,\n" + " isnull( b.Price, 0 ) AS 结算单价,\n" +
" 0 AS 结算金额 ,\n" + " isnull( b.Qty, 0 ) * isnull( b.Price, 0 ) AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组 \n" + " C.EstimateTypeDesc AS 物料组 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, LastModificationTime ) AS a\n" + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, LastModificationTime ) AS a\n" +
" INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) AS b ON a.Kanban = b.HQHKanBan \n" + " INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode,Price FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode,Price ) AS b ON a.Kanban = b.HQHKanBan \n" +
" AND a.MaterialCode = b.MaterialCode\n" + " AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" + " WHERE\n" +
" a.Qty> b.Qty {1}\n" + " a.Qty> b.Qty {1}\n" +
" ) AS temp1\n" + " ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) 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 ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + " LEFT JOIN (select * from set_backQty WHERE Version='{2}') tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" AND temp1.订货看板编号 = tt.Code \n" + " AND temp1.订货看板编号 = tt.Code \n" +
" ) UNION2"; " ) UNION2";
var _sql = string.Format(str, contion, condition); var _sql = string.Format(str, contion, condition,version);
@ -746,35 +746,52 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var listCompare1 = DbConnection.Query<CompareExtend>(sql3); var listCompare1 = DbConnection.Query<CompareExtend>(sql3);
string contionCompare = string.Empty;
//选中,是否过滤掉当期结算数据
if (iscontionversion == "0")
{
contionCompare += string.Format(" WHERE Version <'{0}' AND HQHKanBan <> 'BJ' ", version);
}
else
{
contionCompare += " WHERE 1=1 ";
}
//红旗结算数据中,看板号+物料号没有重复的数据 //红旗结算数据中,看板号+物料号没有重复的数据
var sql10 = "SELECT DISTINCT\n" + var sql10 = "SELECT DISTINCT\n" +
" t1.* \n" + " t1.* \n" +
"FROM\n" + "FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" +
" a.KanbanNumber AS KanbanNumber,\n" + " a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" + " CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" + " HQHKanBan,\n" +
" b2.MaterialCode \n" + " b2.MaterialCode \n" +
" FROM\n" + " FROM\n" +
" Set_HQ_H_Platform a \n" + " Set_HQ_H_Platform a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
" left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + " {0} \n" +
" ) t1\n" +
" WHERE\n" + " LEFT JOIN (\n" +
" Version = '{0}' \n" + " SELECT\n" +
" AND HQHKanBan <> 'BJ' \n" + " HQHKanBan,\n" +
" ) t1\n" + " MaterialCode \n" +
" LEFT JOIN ( SELECT HQHKanBan, MaterialCode FROM Set_HQ_H_Platform a WHERE Version = '{0}' AND HQHKanBan <> 'BJ' GROUP BY HQHKanBan, MaterialCode HAVING count(*)> 1 ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" + " FROM\n" +
" AND t1.MaterialCode = t2.MaterialCode \n" + " Set_HQ_H_Platform a \n" +
"WHERE\n" + " {0} \n" +
" t2.HQHKanBan IS NULL"; " GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"WHERE\n" +
" t2.HQHKanBan IS NULL";
var list_leftjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql10, version)); var list_leftjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql10, contionCompare));
@ -791,37 +808,53 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" HQHKanBan,\n" + " HQHKanBan,\n" +
" b2.MaterialCode \n" + " b2.MaterialCode \n" +
" FROM\n" + " FROM\n" +
" Set_HQ_H_Platform a \n" + " Set_HQ_H_Platform a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
" left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + " {0}\n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" ) t1\n" + " ) t1\n" +
" INNER JOIN ( SELECT HQHKanBan, MaterialCode FROM Set_HQ_H_Platform a WHERE Version = '{0}' AND HQHKanBan <> 'BJ' GROUP BY HQHKanBan, MaterialCode HAVING count(*)> 1 ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" + " INNER JOIN (\n" +
" SELECT\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \n" +
" {0}\n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" + " AND t1.MaterialCode = t2.MaterialCode \n" +
"ORDER BY\n" + "ORDER BY\n" +
" t1.HQHKanBan,\n" + " t1.HQHKanBan,\n" +
" t1.MaterialCode"; " t1.MaterialCode";
var list_innerjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql11, version)); var list_innerjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql11, contionCompare));
var sql12 = "SELECT\n" + string contionCompareBJ = string.Empty;
" a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + //选中,是否过滤掉当期结算数据
" a.KanbanNumber AS KanbanNumber,\n" + if (iscontionversion == "0")
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" + {
" HQHKanBan,\n" + contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version);
" b2.MaterialCode \n" + }
"FROM\n" + else
" Set_HQ_H_Platform a \n" + {
" left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + contionCompareBJ += " WHERE 1=1 ";
}
"WHERE\n" + var sql12 = "SELECT\n" +
" Version = '{0}' \n" + " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" +
" AND HQHKanBan = 'BJ'"; " a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" b2.MaterialCode \n" +
"FROM\n" +
" Set_HQ_H_Platform a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
"{0}";
var list_hplaform_bj = DbConnection.Query<CompareExtend1>(string.Format(sql12, version)); var list_hplaform_bj = DbConnection.Query<CompareExtend1>(string.Format(sql12, contionCompareBJ));
//结算数据比较 //结算数据比较
@ -1525,6 +1558,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "发货总金额")] [ExporterHeader(DisplayName = "发货总金额")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "退货数量")]
public decimal 退 { set; get; }
[ExporterHeader(DisplayName = "数量差异")] [ExporterHeader(DisplayName = "数量差异")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "单价差异")] [ExporterHeader(DisplayName = "单价差异")]

Loading…
Cancel
Save