From 50edca183158702be18c2967bfad150944db29ab Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Mon, 25 Apr 2022 15:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E6=97=97=E6=9C=AA=E7=BB=93=E3=80=81?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E6=9C=AA=E7=BB=93=E3=80=81=E5=A4=A7=E4=BC=97?= =?UTF-8?q?=E5=A4=87=E4=BB=B6=E6=9C=AA=E7=BB=93=EF=BC=8C=E8=B4=A2=E5=8A=A1?= =?UTF-8?q?=E8=A6=81=E6=B1=82=E6=94=B9=E4=B8=BA=E5=8F=91=E8=BF=90=E6=AF=94?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HQHSettledDetailDapperRepository.cs | 441 ++++++++++-------- .../Report/KanbanUnSettledDapperRepository.cs | 269 ++++++++--- .../SettleSparePartDapperReportRepository.cs | 201 +++++--- .../Report/WmsDapperRepository.cs | 43 +- .../Services/Report/KanBanUnSettledExport.cs | 8 +- .../Services/Report/UnSettledSumService.cs | 25 +- 6 files changed, 629 insertions(+), 358 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs index 266b653a..ad3f48b0 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs @@ -688,13 +688,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //选中,是否过滤掉当期结算数据 if (iscontionversion == "0") { - contion += string.Format(" WHERE Version <'{0}' ", version); + contion += string.Format(" WHERE Version <'{0}' and State = 2 ", version); } else { - contion += " WHERE 1=1 "; + contion += " WHERE 1=1 and State = 2 "; } - //更改:按照财务要求,将有发货有结算中发货数量大于结算数据的数据整合到未结报表中20220324,sum求和不带交货单号,后算出来 + //又更改规则了20220425 要求去比对出库单 string str = "SELECT\n" + " * \n" + "FROM\n" + @@ -716,7 +716,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + " isnull( tt.Qty, 0 ) 退货数量,\n" + " isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) AS 实际发货数量,\n" + - " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) AS 未结数量,\n" + + " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) AS 未结数量,\n" + " temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + " ISNULL( TEMP2.Price, 0 ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 实际发货总金额 \n" + " FROM\n" + @@ -735,69 +735,134 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " 0 AS 结算金额 ,\n" + " C.EstimateTypeDesc AS 物料组 \n" + " FROM\n" + - " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\n" + - " LEFT OUTER 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" + - " AND a.MaterialCode = b.MaterialCode\n" + - " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + " (\n" + + " SELECT\n" + + " Qty,\n" + + " Kanban,\n" + + " MaterialCode,\n" + + " sap \n" + + " FROM\n" + + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1 = 1 {1} GROUP BY kanban, MaterialCode ) temp1\n" + + " LEFT OUTER JOIN ( SELECT MaterialCode sap, CustomerPartCode FROM Set_material ) AS temp2 ON temp1.MaterialCode = temp2.CustomerPartCode \n" + + " ) a\n" + + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode\n" + + " LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_WmsHQHKanbanOutPutDetial {0} GROUP BY Kanban, MaterialCode ) AS b ON a.Kanban = b.Kanban \n" + + " AND a.sap = b.MaterialCode \n" + " WHERE\n" + - " b.HQHKanBan IS NULL \n" + + " b.Kanban IS NULL \n" + " AND b.MaterialCode IS NULL \n" + " ) AS temp1\n" + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" + - " LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + - " AND temp1.订货看板编号 = tt.Code \n" + - " ) UNION1 UNION ALL\n" + - "SELECT\n" + - " * \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " isnull( temp1.交货单号, '' ) 交货单号,\n" + - " temp1.订货看板编号,\n" + - " temp1.订货零件号,\n" + - " temp1.Sap编码,\n" + - " temp1.[客户物料号],\n" + - " temp1.物料组,\n" + - " temp1.零件中文名称,\n" + - " temp1.发货数量,\n" + - " temp1.外部单号,\n" + - " temp1.结算数量,\n" + - " temp1.结算单价,\n" + - " temp1.结算金额,\n" + - " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + - " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + - " isnull( tt.Qty, 0 ) 退货数量,\n" + - " isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) AS 实际发货数量,\n" + - " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) AS 未结数量,\n" + - " temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + - " ISNULL( TEMP2.Price, 0 ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 实际发货总金额 \n" + - " FROM\n" + - " (\n" + - " SELECT\n" + - " '' AS 交货单号,\n" + - " a.Kanban AS 订货看板编号,\n" + - " b.MaterialCode AS 订货零件号,\n" + - " c.MaterialCode Sap编码,\n" + - " c.CustomerPartCode 客户物料号,\n" + - " c.MaterialDesc AS 零件中文名称,\n" + - " isnull( a.Qty, 0 ) AS 发货数量,\n" + - " '' AS 外部单号,\n" + - " isnull( b.Qty, 0 ) AS 结算数量,\n" + - " isnull( b.Price, 0 ) AS 结算单价,\n" + - " isnull( b.Qty, 0 ) * isnull( b.Price, 0 ) AS 结算金额 ,\n" + - " C.EstimateTypeDesc AS 物料组 \n" + - " FROM\n" + - " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\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" + - " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + - " WHERE\n" + - " a.Qty> b.Qty \n" + - " ) AS temp1\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" + - " LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + + " LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + " AND temp1.订货看板编号 = tt.Code \n" + - " ) UNION2"; + " ) UNION1"; + + #region 规则又变了 + //更改:按照财务要求,将有发货有结算中发货数量大于结算数据的数据整合到未结报表中20220324,sum求和不带交货单号,后算出来 + //string str = "SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" isnull( temp1.交货单号, '' ) 交货单号,\n" + + //" temp1.订货看板编号,\n" + + //" temp1.订货零件号,\n" + + //" temp1.Sap编码,\n" + + //" temp1.[客户物料号],\n" + + //" temp1.物料组,\n" + + //" temp1.零件中文名称,\n" + + //" temp1.发货数量,\n" + + //" temp1.外部单号,\n" + + //" temp1.结算数量,\n" + + //" temp1.结算单价,\n" + + //" temp1.结算金额,\n" + + //" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + + //" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + + //" isnull( tt.Qty, 0 ) 退货数量,\n" + + //" isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) AS 实际发货数量,\n" + + // " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) AS 未结数量,\n" + + //" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + + //" ISNULL( TEMP2.Price, 0 ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 实际发货总金额 \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' AS 交货单号,\n" + + //" a.Kanban AS 订货看板编号,\n" + + //" b.MaterialCode AS 订货零件号,\n" + + //" c.MaterialCode Sap编码,\n" + + //" c.CustomerPartCode 客户物料号,\n" + + //" c.MaterialDesc AS 零件中文名称,\n" + + //" isnull( a.Qty, 0 ) AS 发货数量,\n" + + //" '' AS 外部单号,\n" + + //" isnull( b.Qty, 0 ) AS 结算数量,\n" + + //" 0 AS 结算单价,\n" + + //" 0 AS 结算金额 ,\n" + + //" C.EstimateTypeDesc AS 物料组 \n" + + //" FROM\n" + + //" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\n" + + //" LEFT OUTER 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" + + //" AND a.MaterialCode = b.MaterialCode\n" + + //" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + //" WHERE\n" + + //" b.HQHKanBan IS NULL \n" + + //" AND b.MaterialCode IS NULL \n" + + //" ) AS temp1\n" + + //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" + + //" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + + //" AND temp1.订货看板编号 = tt.Code \n" + + //" ) UNION1 UNION ALL\n" + + //"SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" isnull( temp1.交货单号, '' ) 交货单号,\n" + + //" temp1.订货看板编号,\n" + + //" temp1.订货零件号,\n" + + //" temp1.Sap编码,\n" + + //" temp1.[客户物料号],\n" + + //" temp1.物料组,\n" + + //" temp1.零件中文名称,\n" + + //" temp1.发货数量,\n" + + //" temp1.外部单号,\n" + + //" temp1.结算数量,\n" + + //" temp1.结算单价,\n" + + //" temp1.结算金额,\n" + + //" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + + //" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + + //" isnull( tt.Qty, 0 ) 退货数量,\n" + + //" isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) AS 实际发货数量,\n" + + // " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) AS 未结数量,\n" + + //" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + + //" ISNULL( TEMP2.Price, 0 ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 实际发货总金额 \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' AS 交货单号,\n" + + //" a.Kanban AS 订货看板编号,\n" + + //" b.MaterialCode AS 订货零件号,\n" + + //" c.MaterialCode Sap编码,\n" + + //" c.CustomerPartCode 客户物料号,\n" + + //" c.MaterialDesc AS 零件中文名称,\n" + + //" isnull( a.Qty, 0 ) AS 发货数量,\n" + + //" '' AS 外部单号,\n" + + //" isnull( b.Qty, 0 ) AS 结算数量,\n" + + //" isnull( b.Price, 0 ) AS 结算单价,\n" + + //" isnull( b.Qty, 0 ) * isnull( b.Price, 0 ) AS 结算金额 ,\n" + + //" C.EstimateTypeDesc AS 物料组 \n" + + //" FROM\n" + + //" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\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" + + //" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + //" WHERE\n" + + //" a.Qty> b.Qty \n" + + //" ) AS temp1\n" + + //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" + + //" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + + //" AND temp1.订货看板编号 = tt.Code \n" + + //" ) UNION2"; + #endregion //var _sql = string.Format(str, contion, condition,version); @@ -855,131 +920,131 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report contionCompare += " WHERE 1=1 "; } - //红旗结算数据中,看板号+物料号没有重复的数据 - var sql10 = "SELECT DISTINCT\n" + - " t1.* \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + - " 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} \n" + - " ) t1\n" + - " LEFT 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" + - "WHERE\n" + - " t2.HQHKanBan IS NULL"; - - - var list_leftjoin_hplatform = DbConnection.Query(string.Format(sql10, contionCompare)); - - - - - //红旗结算数据中,看板号+物料号有重复的数据 - var sql11 = "SELECT DISTINCT\n" + - " t1.* \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + - " 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}\n" + - " ) t1\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" + - "ORDER BY\n" + - " t1.HQHKanBan,\n" + - " t1.MaterialCode"; - var list_innerjoin_hplatform = DbConnection.Query(string.Format(sql11, contionCompare)); - - - string contionCompareBJ = string.Empty; - //选中,是否过滤掉当期结算数据 - if (iscontionversion == "0") - { - contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version); - } - else - { - contionCompareBJ += " WHERE 1=1 "; - } + ////红旗结算数据中,看板号+物料号没有重复的数据 + //var sql10 = "SELECT DISTINCT\n" + + // " t1.* \n" + + // "FROM\n" + + // " (\n" + + // " SELECT\n" + + // " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + + // " 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} \n" + + // " ) t1\n" + + // " LEFT 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" + + // "WHERE\n" + + // " t2.HQHKanBan IS NULL"; + + + //var list_leftjoin_hplatform = DbConnection.Query(string.Format(sql10, contionCompare)); + + + + + ////红旗结算数据中,看板号+物料号有重复的数据 + //var sql11 = "SELECT DISTINCT\n" + + //" t1.* \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + + //" 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}\n" + + //" ) t1\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" + + //"ORDER BY\n" + + //" t1.HQHKanBan,\n" + + //" t1.MaterialCode"; + //var list_innerjoin_hplatform = DbConnection.Query(string.Format(sql11, contionCompare)); + + + //string contionCompareBJ = string.Empty; + ////选中,是否过滤掉当期结算数据 + //if (iscontionversion == "0") + //{ + // contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version); + //} + //else + //{ + // contionCompareBJ += " WHERE 1=1 "; + //} - var sql12 = "SELECT\n" + - " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + - " 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 sql12 = "SELECT\n" + + // " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + + // " 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(string.Format(sql12, contionCompareBJ)); + //var list_hplaform_bj = DbConnection.Query(string.Format(sql12, contionCompareBJ)); - //结算数据比较 - List _lscopy = new List(); + ////结算数据比较 + //List _lscopy = new List(); - foreach (var itm in list_leftjoin_hplatform) - { - var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode); - if (first != null) - { - first.KanbanNumber += "," + itm.KanbanNumber; - first.AcceptanceDate += "," + itm.AcceptanceDate; - first.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber; - } - else - { - _lscopy.Add(itm); - } - } - foreach (var itm in list_innerjoin_hplatform) - { - _lscopy.Add(itm); - } - foreach (var itm in list_hplaform_bj) - { - _lscopy.Add(itm); - } + //foreach (var itm in list_leftjoin_hplatform) + //{ + // var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode); + // if (first != null) + // { + // first.KanbanNumber += "," + itm.KanbanNumber; + // first.AcceptanceDate += "," + itm.AcceptanceDate; + // first.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber; + // } + // else + // { + // _lscopy.Add(itm); + // } + //} + //foreach (var itm in list_innerjoin_hplatform) + //{ + // _lscopy.Add(itm); + //} + //foreach (var itm in list_hplaform_bj) + //{ + // _lscopy.Add(itm); + //} //发运数据比较 @@ -1030,12 +1095,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report itm1.交货时间 = itm.WmsDate; } - var itmcopy = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码); - if (itmcopy != null) - { - itm1.看板编号 = itmcopy.KanbanNumber; - itm1.验收单日期 = itmcopy.AcceptanceDate; - } + //var itmcopy = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码); + //if (itmcopy != null) + //{ + // itm1.看板编号 = itmcopy.KanbanNumber; + // itm1.验收单日期 = itmcopy.AcceptanceDate; + //} } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs index a9540a15..f5c5f196 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs @@ -75,7 +75,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public string CustomerPartCode { set; get; } [ExporterHeader(DisplayName = "物料组")] public string MaterialGroup { set; get; } - [ExporterHeader(DisplayName = "结算数量")] + [ExporterHeader(DisplayName = "结算数量",IsIgnore =true)] public decimal SettleQty { set; get; } [ExporterHeader(DisplayName = "发货数量")] public decimal WMSDeliveryQty { set; get; } @@ -147,11 +147,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //选中,是否过滤掉当期结算数据 if (iscontionversion == "0") { - contion += string.Format(" WHERE Version <'{0}' ", version); + contion += string.Format(" WHERE Version <'{0}' and State=2 ", version); } else { - contion += " WHERE 1=1 "; + contion += " WHERE 1=1 and State=2 "; } string str = string.Empty; @@ -176,78 +176,221 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report strDate += string.Format(" and WMSActualGoodsDate<='{0}' ", endtime); } + string sql = "SELECT\n" + " * \n" + "FROM\n" + " (\n" + " SELECT\n" + - " TEMP1.*,\n" + - " TEMP2.Price,\n" + - " ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + + " * \n" + " FROM\n" + " (\n" + " SELECT\n" + - " '' WmsBillNum,\n" + - " NULL BeginDate,\n" + - " a.Kanban,\n" + - " C.MaterialCode SapCode,\n" + - " C.MaterialDesc,\n" + - " C.CustomerPartCode,\n" + - " C.EstimateTypeDesc MaterialGroup,\n" + - " ISNULL( B.Qty, 0 ) SettleQty,\n" + - " ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + - " isnull( tt.qty, 0 ) BackQty,\n" + - " ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + + " TEMP1.*,\n" + + " TEMP2.Price,\n" + + " ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + " FROM\n" + - " ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n" + - " LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + - " AND A.MaterialCode = B.MaterialCode\n" + - " LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + - " LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + - " AND c.MaterialCode = tt.MaterialCode \n" + - " WHERE\n" + - " B.Kanban IS NULL \n" + - " AND B.MaterialCode IS NULL \n" + - " ) TEMP1\n" + - " LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + - " ) UNION1 UNION ALL\n" + - "SELECT\n" + - " * \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " TEMP1.*,\n" + - " TEMP2.Price,\n" + - " ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + - " FROM\n" + - " (\n" + - " SELECT\n" + - " '' WmsBillNum,\n" + - " NULL BeginDate,\n" + - " a.Kanban,\n" + - " C.MaterialCode SapCode,\n" + - " C.MaterialDesc,\n" + - " C.CustomerPartCode,\n" + - " C.EstimateTypeDesc MaterialGroup,\n" + - " ISNULL( B.Qty, 0 ) SettleQty,\n" + - " ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + - " isnull( tt.qty, 0 ) BackQty,\n" + - " ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + - " FROM\n" + - " ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n" + - " INNER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + - " AND A.MaterialCode = B.MaterialCode\n" + - " LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + - " LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + - " AND c.MaterialCode = tt.MaterialCode \n" + - " WHERE\n" + - " a.WMSDeliveryQty> B.Qty AND (a.WMSDeliveryQty-tt.Qty)!=B.Qty \n" + - " ) TEMP1\n" + - " LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + - " ) UNION2"; + " (\n" + + " SELECT\n" + + " '' WmsBillNum,\n" + + " NULL BeginDate,\n" + + " a.Kanban,\n" + + " C.MaterialCode SapCode,\n" + + " C.MaterialDesc,\n" + + " C.CustomerPartCode,\n" + + " C.EstimateTypeDesc MaterialGroup,\n" + + " ISNULL( B.Qty, 0 ) SettleQty,\n" + + " ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + + " isnull( tt.qty, 0 ) BackQty,\n" + + " ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + + " FROM\n" + + " ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" + + " LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, Extend1 AS MaterialCode FROM Set_WmsKanbanOutPutDetial {0} GROUP BY Kanban, Extend1 ) B ON A.Kanban = B.Kanban \n" + + " AND A.MaterialCode = B.MaterialCode\n" + + " LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + + " LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + + " AND c.MaterialCode = tt.MaterialCode \n" + + " WHERE\n" + + " B.Kanban IS NULL \n" + + " AND B.MaterialCode IS NULL \n" + + " ) TEMP1\n" + + " LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + + " ) UNION1\n" + + " LEFT JOIN temp_vwkanban UNION2 ON UNION1.Kanban= UNION2.[看板号] \n" + + " AND UNION1.CustomerPartCode= UNION2.[客户零件号] \n" + + " WHERE\n" + + " UNION2.[看板号] IS NULL \n" + + " AND UNION2.[客户零件号] IS NULL \n" + + " ) aaa \n" + + "WHERE\n" + + " aaa.CustomerPartCode NOT IN ( '30G839904A041', '80D867172KJ7' )"; + + + + #region 原定规则,又改了! + //string sql = "SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" TEMP1.*,\n" + + //" TEMP2.Price,\n" + + //" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' WmsBillNum,\n" + + //" NULL BeginDate,\n" + + //" a.Kanban,\n" + + //" C.MaterialCode SapCode,\n" + + //" C.MaterialDesc,\n" + + //" C.CustomerPartCode,\n" + + //" C.EstimateTypeDesc MaterialGroup,\n" + + //" ISNULL( B.Qty, 0 ) SettleQty,\n" + + //" ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + + //" isnull( tt.qty, 0 ) BackQty,\n" + + //" ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + + //" FROM\n" + + //" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n" + + //" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + + //" AND A.MaterialCode = B.MaterialCode\n" + + //" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + + //" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + + //" AND c.MaterialCode = tt.MaterialCode \n" + + //" WHERE\n" + + //" B.Kanban IS NULL \n" + + //" AND B.MaterialCode IS NULL \n" + + //" ) TEMP1\n" + + //" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + + //" ) UNION1 UNION ALL\n" + + //"SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" TEMP1.*,\n" + + //" TEMP2.Price,\n" + + //" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' WmsBillNum,\n" + + //" NULL BeginDate,\n" + + //" a.Kanban,\n" + + //" C.MaterialCode SapCode,\n" + + //" C.MaterialDesc,\n" + + //" C.CustomerPartCode,\n" + + //" C.EstimateTypeDesc MaterialGroup,\n" + + //" ISNULL( B.Qty, 0 ) SettleQty,\n" + + //" ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + + //" isnull( tt.qty, 0 ) BackQty,\n" + + //" ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + + //" FROM\n" + + //" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n" + + //" INNER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + + //" AND A.MaterialCode = B.MaterialCode\n" + + //" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + + //" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + + //" AND c.MaterialCode = tt.MaterialCode \n" + + //" WHERE\n" + + //" a.WMSDeliveryQty> B.Qty AND (a.WMSDeliveryQty-tt.Qty)!=B.Qty \n" + + //" ) TEMP1\n" + + //" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + + //" ) UNION2"; + + //20220424-财务要求:大众看板待设置不出现在未结数据里-更新 + //string sql = "SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" * \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" * \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" TEMP1.*,\n" + + //" TEMP2.Price,\n" + + //" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' WmsBillNum,\n" + + //" NULL BeginDate,\n" + + //" a.Kanban,\n" + + //" C.MaterialCode SapCode,\n" + + //" C.MaterialDesc,\n" + + //" C.CustomerPartCode,\n" + + //" C.EstimateTypeDesc MaterialGroup,\n" + + //" ISNULL( B.Qty, 0 ) SettleQty,\n" + + //" ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + + //" isnull( tt.qty, 0 ) BackQty,\n" + + //" ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + + //" FROM\n" + + //" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" + + //" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + + //" AND A.MaterialCode = B.MaterialCode\n" + + //" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + + //" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + + //" AND c.MaterialCode = tt.MaterialCode \n" + + //" WHERE\n" + + //" B.Kanban IS NULL \n" + + //" AND B.MaterialCode IS NULL \n" + + //" ) TEMP1\n" + + //" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + + //" ) UNION1 UNION ALL\n" + + //" SELECT\n" + + //" * \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" TEMP1.*,\n" + + //" TEMP2.Price,\n" + + //" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' WmsBillNum,\n" + + //" NULL BeginDate,\n" + + //" a.Kanban,\n" + + //" C.MaterialCode SapCode,\n" + + //" C.MaterialDesc,\n" + + //" C.CustomerPartCode,\n" + + //" C.EstimateTypeDesc MaterialGroup,\n" + + //" ISNULL( B.Qty, 0 ) SettleQty,\n" + + //" ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + + //" isnull( tt.qty, 0 ) BackQty,\n" + + //" ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + + //" FROM\n" + + //" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" + + //" INNER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + + //" AND A.MaterialCode = B.MaterialCode\n" + + //" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + + //" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + + //" AND c.MaterialCode = tt.MaterialCode \n" + + //" WHERE\n" + + //" a.WMSDeliveryQty> B.Qty \n" + + //" AND ( a.WMSDeliveryQty- tt.Qty ) != B.Qty \n" + + //" ) TEMP1\n" + + //" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + + //" ) UNION2 \n" + + //" ) UNION12\n" + + //" LEFT JOIN temp_vwkanban UNION3 ON UNION12.Kanban= UNION3.[看板号] \n" + + //" AND UNION12.CustomerPartCode= UNION3.[客户零件号] \n" + + //" WHERE\n" + + //" UNION3.[看板号] IS NULL \n" + + //" AND UNION3.[客户零件号] IS NULL \n" + + //" ) aaa \n" + + //"WHERE\n" + + //" aaa.CustomerPartCode NOT IN ( '30G839904A041', '80D867172KJ7' ) "; //财务香凝要求:交货数量-退货数量=结算数量 这样的不体现在未结中 + #endregion + sql = string.Format(sql,contion,strDate); diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs index 2002acfd..d24826dd 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -693,93 +693,154 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " c.MaterialDesc AS 物料描述,\n" + " c.EstimateTypeDesc AS 物料组,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + - " ISNULL( b.ReceiptQty, 0 ) AS 开票数量,\n" + - " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + + " ISNULL( b.Qty, 0 ) AS 开票数量,\n" + + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.Qty, 0 ) ) AS 收货与交货差异 \n" + " FROM\n" + " (\n" + " SELECT SUM\n" + " ( ReceiptQty ) AS ReceiptQty,\n" + " PurchaseOrderNo,\n" + - " MaterialCode \n" + + " MaterialCode,\n" + + " SapCode \n" + " FROM\n" + " Set_WMSSparePart \n" + " WHERE\n" + " PurchaseOrderNo IS NOT NULL \n" + - " AND PurchaseOrderNo != '' {0} \n" + + " AND PurchaseOrderNo != '' {0}\n" + " GROUP BY\n" + " PurchaseOrderNo,\n" + - " MaterialCode \n" + + " MaterialCode,\n" + + " SapCode \n" + " ) AS a\n" + - " LEFT JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + - " AND a.MaterialCode = b.MaterialCode\n" + - " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + + " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode\n" + + " LEFT JOIN ( SELECT SUM ( Qty ) Qty, OrderBillNum, MaterialCode FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, MaterialCode ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n" + + " AND a.SapCode = b.MaterialCode \n" + " WHERE\n" + - " b.PurchaseOrderNo IS NULL \n" + + " b.OrderBillNum IS NULL \n" + " AND b.MaterialCode IS NULL \n" + " ) AS temp1\n" + " LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" + " AND temp1.SAP编码= temp3.MaterialCode\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - " ) unint1 UNION ALL\n" + - "SELECT\n" + - " * \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " temp1.交货单号,\n" + - " temp1.交货日期,\n" + - " temp1.采购订单号,\n" + - " temp1.SAP编码,\n" + - " temp1.物料代码,\n" + - " temp1.物料描述,\n" + - " temp1.发货数量,\n" + - " temp1.开票数量,\n" + - " temp1.收货与交货差异,\n" + - " ISNULL( temp3.Qty, 0 ) 退货数量,\n" + - " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际发货数量,\n" + - " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) - ISNULL( temp1.开票数量, 0 ) 未结数量,\n" + - " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - " ISNULL( TEMP2.Price, 0 ) * ( ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 实际发货总金额 \n" + - " FROM\n" + - " (\n" + - " SELECT\n" + - " '' AS 交货单号,\n" + - " NULL AS 交货日期,\n" + - " a.PurchaseOrderNo AS 采购订单号,\n" + - " c.MaterialCode AS SAP编码,\n" + - " c.CustomerPartCode AS 物料代码,\n" + - " c.MaterialDesc AS 物料描述,\n" + - " c.EstimateTypeDesc AS 物料组,\n" + - " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + - " ISNULL( b.ReceiptQty, 0 ) AS 开票数量,\n" + - " ( ISNULL( b.ReceiptQty, 0 ) - ISNULL( a.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + - " FROM\n" + - " (\n" + - " SELECT SUM\n" + - " ( ReceiptQty ) AS ReceiptQty,\n" + - " PurchaseOrderNo,\n" + - " MaterialCode \n" + - " FROM\n" + - " Set_WMSSparePart \n" + - " WHERE\n" + - " PurchaseOrderNo IS NOT NULL \n" + - " AND PurchaseOrderNo != '' {0} \n" + - " GROUP BY\n" + - " PurchaseOrderNo,\n" + - " MaterialCode \n" + - " ) a\n" + - " INNER JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + - " AND a.MaterialCode = b.MaterialCode\n" + - " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + - " WHERE\n" + - " a.ReceiptQty> b.ReceiptQty \n" + - " ) AS temp1\n" + - " LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" + - " AND temp1.SAP编码= temp3.MaterialCode\n" + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - " ) unint2"; + " ) unint1"; + + //string sqlString = "SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" temp1.交货单号,\n" + + //" temp1.交货日期,\n" + + //" temp1.采购订单号,\n" + + //" temp1.SAP编码,\n" + + //" temp1.物料代码,\n" + + //" temp1.物料描述,\n" + + //" temp1.发货数量,\n" + + //" temp1.开票数量,\n" + + //" temp1.收货与交货差异,\n" + + //" ISNULL( temp3.Qty, 0 ) 退货数量,\n" + + //" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际发货数量,\n" + + //" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) - ISNULL( temp1.开票数量, 0 ) 未结数量,\n" + + //" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + + //" ISNULL( TEMP2.Price, 0 ) * ( ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 实际发货总金额 \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' AS 交货单号,\n" + + //" NULL AS 交货日期,\n" + + //" a.PurchaseOrderNo AS 采购订单号,\n" + + //" c.MaterialCode AS SAP编码,\n" + + //" c.CustomerPartCode AS 物料代码,\n" + + //" c.MaterialDesc AS 物料描述,\n" + + //" c.EstimateTypeDesc AS 物料组,\n" + + //" ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + + //" ISNULL( b.ReceiptQty, 0 ) AS 开票数量,\n" + + //" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + + //" FROM\n" + + //" (\n" + + //" SELECT SUM\n" + + //" ( ReceiptQty ) AS ReceiptQty,\n" + + //" PurchaseOrderNo,\n" + + //" MaterialCode \n" + + //" FROM\n" + + //" Set_WMSSparePart \n" + + //" WHERE\n" + + //" PurchaseOrderNo IS NOT NULL \n" + + //" AND PurchaseOrderNo != '' {0} \n" + + //" GROUP BY\n" + + //" PurchaseOrderNo,\n" + + //" MaterialCode \n" + + //" ) AS a\n" + + //" LEFT JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + + //" AND a.MaterialCode = b.MaterialCode\n" + + //" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + + //" WHERE\n" + + //" b.PurchaseOrderNo IS NULL \n" + + //" AND b.MaterialCode IS NULL \n" + + //" ) AS temp1\n" + + //" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" + + //" AND temp1.SAP编码= temp3.MaterialCode\n" + + //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + //" ) unint1 UNION ALL\n" + + //"SELECT\n" + + //" * \n" + + //"FROM\n" + + //" (\n" + + //" SELECT\n" + + //" temp1.交货单号,\n" + + //" temp1.交货日期,\n" + + //" temp1.采购订单号,\n" + + //" temp1.SAP编码,\n" + + //" temp1.物料代码,\n" + + //" temp1.物料描述,\n" + + //" temp1.发货数量,\n" + + //" temp1.开票数量,\n" + + //" temp1.收货与交货差异,\n" + + //" ISNULL( temp3.Qty, 0 ) 退货数量,\n" + + //" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际发货数量,\n" + + //" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) - ISNULL( temp1.开票数量, 0 ) 未结数量,\n" + + //" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + + //" ISNULL( TEMP2.Price, 0 ) * ( ISNULL( temp1.发货数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 实际发货总金额 \n" + + //" FROM\n" + + //" (\n" + + //" SELECT\n" + + //" '' AS 交货单号,\n" + + //" NULL AS 交货日期,\n" + + //" a.PurchaseOrderNo AS 采购订单号,\n" + + //" c.MaterialCode AS SAP编码,\n" + + //" c.CustomerPartCode AS 物料代码,\n" + + //" c.MaterialDesc AS 物料描述,\n" + + //" c.EstimateTypeDesc AS 物料组,\n" + + //" ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + + //" ISNULL( b.ReceiptQty, 0 ) AS 开票数量,\n" + + //" ( ISNULL( b.ReceiptQty, 0 ) - ISNULL( a.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + + //" FROM\n" + + //" (\n" + + //" SELECT SUM\n" + + //" ( ReceiptQty ) AS ReceiptQty,\n" + + //" PurchaseOrderNo,\n" + + //" MaterialCode \n" + + //" FROM\n" + + //" Set_WMSSparePart \n" + + //" WHERE\n" + + //" PurchaseOrderNo IS NOT NULL \n" + + //" AND PurchaseOrderNo != '' {0} \n" + + //" GROUP BY\n" + + //" PurchaseOrderNo,\n" + + //" MaterialCode \n" + + //" ) a\n" + + //" INNER JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + + //" AND a.MaterialCode = b.MaterialCode\n" + + //" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + + //" WHERE\n" + + //" a.ReceiptQty> b.ReceiptQty \n" + + //" ) AS temp1\n" + + //" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" + + //" AND temp1.SAP编码= temp3.MaterialCode\n" + + //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + //" ) unint2"; + - string _sql = string.Format(sqlString, conditionDate); @@ -1101,7 +1162,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report [ExporterHeader(DisplayName = "发货数量")] public decimal 发货数量 { set; get; } - [ExporterHeader(DisplayName = "开票数量")] + [ExporterHeader(DisplayName = "开票数量", IsIgnore = true)] public decimal 开票数量 { set; get; } @@ -1112,7 +1173,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report [ExporterHeader(DisplayName = "实际发货数量")] public string 实际发货数量 { set; get; } - [ExporterHeader(DisplayName = "未结数量")] + [ExporterHeader(DisplayName = "未结数量", IsIgnore = true)] public decimal 未结数量 { set; get; } [ExporterHeader(DisplayName = "定价")] diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs index 6d04fb66..b832a1a0 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs @@ -77,21 +77,34 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetSalesStockSum(string version) { - string str = - "SELECT A\n" + - " .*,\n" + - " B.PartDesc,\n" + - " B.PartGroup \n" + - "FROM\n" + - " TM_PG_TIME_STOCK_DETAIL\n" + - " A LEFT JOIN (\n" + - " SELECT DISTINCT\n" + - " [ PartCode ],\n" + - " ( ISNULL ( [ PartDesc1 ], '' ) + ISNULL ( [ PartDesc2 ], '' ) ) PartDesc,\n" + - " PartGroup \n" + - " FROM\n" + - " [ VIEW_PG_SIMPLE_PART ] \n" + - " ) B ON A.PartCode = B.PartCode where a.version='{0}'"; + // string str = + // "SELECT A\n" + + //" .*,\n" + + //" B.PartDesc,\n" + + //" B.PartGroup \n" + + //"FROM\n" + + //" TM_PG_TIME_STOCK_DETAIL\n" + + //" A LEFT JOIN (\n" + + //" SELECT DISTINCT\n" + + //" [ PartCode ],\n" + + //" ( ISNULL ( [ PartDesc1 ], '' ) + ISNULL ( [ PartDesc2 ], '' ) ) PartDesc,\n" + + //" PartGroup \n" + + //" FROM\n" + + //" [ VIEW_PG_SIMPLE_PART ] \n" + + //" ) B ON A.PartCode = B.PartCode where a.version='{0}'"; + string str = " SELECT A.*, \n" + +" B.PartDesc, \n" + +" B.PartGroup \n" + +" FROM \n" + +" TM_PG_TIME_STOCK_DETAIL \n" + +" A LEFT JOIN ( \n" + +" SELECT DISTINCT \n" + +" [PartCode], \n" + +" ( ISNULL ( [PartDesc1], '' ) + ISNULL ( [PartDesc2], '' ) ) PartDesc, \n" + +" PartGroup \n" + +" FROM \n" + +" [VIEW_PG_SIMPLE_PART] \n" + +" ) B ON A.PartCode = B.PartCode where a.version='{0}'"; str = string.Format(str, version); var _list = DbConnection.Query(str); return _list.ToList(); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs index 5eaa591e..f6bd4d53 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs @@ -107,10 +107,10 @@ namespace SettleAccount.Job.Services.Report ExcelExporter _exporter = new ExcelExporter();//导出Excel var result = _exporter.Append(_ls.ToList(), "有发货无结算差异对比") - .SeparateBySheet() - .Append(_ls_orgiinal_kanban.ToList(), "原始看板未结对比数据") - .SeparateBySheet() - .Append(_ls_wmskanban.ToList(), "有发货有结算(发货数量大于结算)") + //.SeparateBySheet() + //.Append(_ls_orgiinal_kanban.ToList(), "原始看板未结对比数据") + //.SeparateBySheet() + //.Append(_ls_wmskanban.ToList(), "有发货有结算(发货数量大于结算)") .ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); _fileContainer.SaveAsync(_filename, result.Result, true); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs index b465b3a4..9780ee34 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs @@ -303,18 +303,16 @@ namespace SettleAccount.Job.Services.Report public List GetSparePartSum(Guid id, List exportName, List p_list) { var fileName = exportName.FirstOrDefault(); - var purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value; + //var purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value; var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; - var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; - var matialCode = p_list.Where(p => p.Name == "MatialCode").FirstOrDefault().Value; - var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; - var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; - //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; - + var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; + var matialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; + var beginTime = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value; + var endTime = p_list.Where(p => p.Name == "End").FirstOrDefault().Value; - //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 - var _ls = _sparepartdapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + //var _ls = _sparepartdapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + var _ls = _sparepartdapper.GetReverseWithCodeSettleSparePartReportList("", version, sapCode, matialCode, beginTime, endTime); if (!string.IsNullOrEmpty(sapCode)) { var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); @@ -324,15 +322,6 @@ namespace SettleAccount.Job.Services.Report } } - if (!string.IsNullOrEmpty(purchaseOrderNo)) - { - var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _ls = _ls.Where(p => _groupList.Contains(p.采购订单号)).ToList(); - } - } - var kanbanList = _ls.GroupBy(p => new { p.SAP编码, p.物料描述, p.物料代码 }) .Select(p => new UnSettledSum {