Administrator 3 years ago
parent
commit
5936064c9e
  1. 441
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
  2. 269
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs
  3. 199
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  4. 43
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs
  5. 8
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs
  6. 25
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

441
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") if (iscontionversion == "0")
{ {
contion += string.Format(" WHERE Version <'{0}' ", version); contion += string.Format(" WHERE Version <'{0}' and State = 2 ", version);
} }
else else
{ {
contion += " WHERE 1=1 "; contion += " WHERE 1=1 and State = 2 ";
} }
//更改:按照财务要求,将有发货有结算中发货数量大于结算数据的数据整合到未结报表中20220324,sum求和不带交货单号,后算出来 //又更改规则了20220425 要求去比对出库单
string str = "SELECT\n" + string str = "SELECT\n" +
" * \n" + " * \n" +
"FROM\n" + "FROM\n" +
@ -716,7 +716,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" 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( tt.Qty, 0 ) AS 实际发货数量,\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" + " temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ISNULL( TEMP2.Price, 0 ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 实际发货总金额 \n" + " ISNULL( TEMP2.Price, 0 ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 实际发货总金额 \n" +
" FROM\n" + " FROM\n" +
@ -735,69 +735,134 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" 0 AS 结算金额 ,\n" + " 0 AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组 \n" + " C.EstimateTypeDesc AS 物料组 \n" +
" FROM\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" + " (\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" + " SELECT\n" +
" AND a.MaterialCode = b.MaterialCode\n" + " Qty,\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \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" + " WHERE\n" +
" b.HQHKanBan IS NULL \n" + " b.Kanban IS NULL \n" +
" AND b.MaterialCode IS NULL \n" + " AND b.MaterialCode IS NULL \n" +
" ) AS temp1\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 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" +
" ) 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" + " 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); //var _sql = string.Format(str, contion, condition,version);
@ -855,131 +920,131 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
contionCompare += " WHERE 1=1 "; 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" + // " {0} \n" +
" ) t1\n" + // " ) t1\n" +
" LEFT JOIN (\n" + // " LEFT JOIN (\n" +
" SELECT\n" + // " SELECT\n" +
" HQHKanBan,\n" + // " HQHKanBan,\n" +
" MaterialCode \n" + // " MaterialCode \n" +
" FROM\n" + // " FROM\n" +
" Set_HQ_H_Platform a \n" + // " Set_HQ_H_Platform a \n" +
" {0} \n" + // " {0} \n" +
" GROUP BY\n" + // " GROUP BY\n" +
" HQHKanBan,\n" + // " HQHKanBan,\n" +
" MaterialCode \n" + // " MaterialCode \n" +
" HAVING\n" + // " HAVING\n" +
" COUNT ( * ) > 1 \n" + // " COUNT ( * ) > 1 \n" +
" ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" + // " ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" + // " AND t1.MaterialCode = t2.MaterialCode \n" +
"WHERE\n" + // "WHERE\n" +
" t2.HQHKanBan IS NULL"; // " t2.HQHKanBan IS NULL";
var list_leftjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql10, contionCompare)); //var list_leftjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql10, contionCompare));
//红旗结算数据中,看板号+物料号有重复的数据 ////红旗结算数据中,看板号+物料号有重复的数据
var sql11 = "SELECT DISTINCT\n" + //var sql11 = "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" + //" {0}\n" +
" ) t1\n" + //" ) t1\n" +
" INNER JOIN (\n" + //" INNER JOIN (\n" +
" SELECT\n" + //" SELECT\n" +
" HQHKanBan,\n" + //" HQHKanBan,\n" +
" MaterialCode \n" + //" MaterialCode \n" +
" FROM\n" + //" FROM\n" +
" Set_HQ_H_Platform a \n" + //" Set_HQ_H_Platform a \n" +
" {0}\n" + //" {0}\n" +
" GROUP BY\n" + //" GROUP BY\n" +
" HQHKanBan,\n" + //" HQHKanBan,\n" +
" MaterialCode \n" + //" MaterialCode \n" +
" HAVING\n" + //" HAVING\n" +
" COUNT ( * ) > 1 \n" + //" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.HQHKanBan = t2.HQHKanBan \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, contionCompare)); //var list_innerjoin_hplatform = DbConnection.Query<CompareExtend1>(string.Format(sql11, contionCompare));
string contionCompareBJ = string.Empty; //string contionCompareBJ = string.Empty;
//选中,是否过滤掉当期结算数据 ////选中,是否过滤掉当期结算数据
if (iscontionversion == "0") //if (iscontionversion == "0")
{ //{
contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version); // contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version);
} //}
else //else
{ //{
contionCompareBJ += " WHERE 1=1 "; // contionCompareBJ += " WHERE 1=1 ";
} //}
var sql12 = "SELECT\n" + //var sql12 = "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}"; // "{0}";
var list_hplaform_bj = DbConnection.Query<CompareExtend1>(string.Format(sql12, contionCompareBJ)); //var list_hplaform_bj = DbConnection.Query<CompareExtend1>(string.Format(sql12, contionCompareBJ));
//结算数据比较 ////结算数据比较
List<CompareExtend1> _lscopy = new List<CompareExtend1>(); //List<CompareExtend1> _lscopy = new List<CompareExtend1>();
foreach (var itm in list_leftjoin_hplatform) //foreach (var itm in list_leftjoin_hplatform)
{ //{
var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode); // var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode);
if (first != null) // if (first != null)
{ // {
first.KanbanNumber += "," + itm.KanbanNumber; // first.KanbanNumber += "," + itm.KanbanNumber;
first.AcceptanceDate += "," + itm.AcceptanceDate; // first.AcceptanceDate += "," + itm.AcceptanceDate;
first.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber; // first.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber;
} // }
else // else
{ // {
_lscopy.Add(itm); // _lscopy.Add(itm);
} // }
} //}
foreach (var itm in list_innerjoin_hplatform) //foreach (var itm in list_innerjoin_hplatform)
{ //{
_lscopy.Add(itm); // _lscopy.Add(itm);
} //}
foreach (var itm in list_hplaform_bj) //foreach (var itm in list_hplaform_bj)
{ //{
_lscopy.Add(itm); // _lscopy.Add(itm);
} //}
//发运数据比较 //发运数据比较
@ -1030,12 +1095,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
itm1. = itm.WmsDate; itm1. = itm.WmsDate;
} }
var itmcopy = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm1. && p.MaterialCode == itm1.Sap编码); //var itmcopy = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码);
if (itmcopy != null) //if (itmcopy != null)
{ //{
itm1. = itmcopy.KanbanNumber; // itm1.看板编号 = itmcopy.KanbanNumber;
itm1. = itmcopy.AcceptanceDate; // itm1.验收单日期 = itmcopy.AcceptanceDate;
} //}
} }

269
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; } public string CustomerPartCode { set; get; }
[ExporterHeader(DisplayName = "物料组")] [ExporterHeader(DisplayName = "物料组")]
public string MaterialGroup { set; get; } public string MaterialGroup { set; get; }
[ExporterHeader(DisplayName = "结算数量")] [ExporterHeader(DisplayName = "结算数量",IsIgnore =true)]
public decimal SettleQty { set; get; } public decimal SettleQty { set; get; }
[ExporterHeader(DisplayName = "发货数量")] [ExporterHeader(DisplayName = "发货数量")]
public decimal WMSDeliveryQty { set; get; } public decimal WMSDeliveryQty { set; get; }
@ -147,11 +147,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//选中,是否过滤掉当期结算数据 //选中,是否过滤掉当期结算数据
if (iscontionversion == "0") if (iscontionversion == "0")
{ {
contion += string.Format(" WHERE Version <'{0}' ", version); contion += string.Format(" WHERE Version <'{0}' and State=2 ", version);
} }
else else
{ {
contion += " WHERE 1=1 "; contion += " WHERE 1=1 and State=2 ";
} }
string str = string.Empty; string str = string.Empty;
@ -176,78 +176,221 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
strDate += string.Format(" and WMSActualGoodsDate<='{0}' ", endtime); strDate += string.Format(" and WMSActualGoodsDate<='{0}' ", endtime);
} }
string sql = "SELECT\n" + string sql = "SELECT\n" +
" * \n" + " * \n" +
"FROM\n" + "FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" TEMP1.*,\n" + " * \n" +
" TEMP2.Price,\n" +
" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" +
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" '' WmsBillNum,\n" + " TEMP1.*,\n" +
" NULL BeginDate,\n" + " TEMP2.Price,\n" +
" a.Kanban,\n" + " ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \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" + " FROM\n" +
" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n" + " (\n" +
" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" + " SELECT\n" +
" AND A.MaterialCode = B.MaterialCode\n" + " '' WmsBillNum,\n" +
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + " NULL BeginDate,\n" +
" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + " a.Kanban,\n" +
" AND c.MaterialCode = tt.MaterialCode \n" + " C.MaterialCode SapCode,\n" +
" WHERE\n" + " C.MaterialDesc,\n" +
" B.Kanban IS NULL \n" + " C.CustomerPartCode,\n" +
" AND B.MaterialCode IS NULL \n" + " C.EstimateTypeDesc MaterialGroup,\n" +
" ) TEMP1\n" + " ISNULL( B.Qty, 0 ) SettleQty,\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + " ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" +
" ) UNION1 UNION ALL\n" + " isnull( tt.qty, 0 ) BackQty,\n" +
"SELECT\n" + " ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" +
" * \n" + " FROM\n" +
"FROM\n" + " ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" +
" (\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" +
" SELECT\n" + " AND A.MaterialCode = B.MaterialCode\n" +
" TEMP1.*,\n" + " LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" +
" TEMP2.Price,\n" + " LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" +
" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + " AND c.MaterialCode = tt.MaterialCode \n" +
" FROM\n" + " WHERE\n" +
" (\n" + " B.Kanban IS NULL \n" +
" SELECT\n" + " AND B.MaterialCode IS NULL \n" +
" '' WmsBillNum,\n" + " ) TEMP1\n" +
" NULL BeginDate,\n" + " LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" +
" a.Kanban,\n" + " ) UNION1\n" +
" C.MaterialCode SapCode,\n" + " LEFT JOIN temp_vwkanban UNION2 ON UNION1.Kanban= UNION2.[看板号] \n" +
" C.MaterialDesc,\n" + " AND UNION1.CustomerPartCode= UNION2.[客户零件号] \n" +
" C.CustomerPartCode,\n" + " WHERE\n" +
" C.EstimateTypeDesc MaterialGroup,\n" + " UNION2.[看板号] IS NULL \n" +
" ISNULL( B.Qty, 0 ) SettleQty,\n" + " AND UNION2.[客户零件号] IS NULL \n" +
" ISNULL( a.WMSDeliveryQty, 0 ) WMSDeliveryQty,\n" + " ) aaa \n" +
" isnull( tt.qty, 0 ) BackQty,\n" + "WHERE\n" +
" ( ISNULL( a.WMSDeliveryQty, 0 ) - ISNULL( b.Qty, 0 ) - isnull( tt.qty, 0 ) ) AS DiffQty \n" + " aaa.CustomerPartCode NOT IN ( '30G839904A041', '80D867172KJ7' )";
" 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" + #region 原定规则,又改了!
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" + //string sql = "SELECT\n" +
" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" + //" * \n" +
" AND c.MaterialCode = tt.MaterialCode \n" + //"FROM\n" +
" WHERE\n" + //" (\n" +
" a.WMSDeliveryQty> B.Qty AND (a.WMSDeliveryQty-tt.Qty)!=B.Qty \n" + //" SELECT\n" +
" ) TEMP1\n" + //" TEMP1.*,\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" + //" TEMP2.Price,\n" +
" ) UNION2"; //" 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); sql = string.Format(sql,contion,strDate);

199
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs

@ -693,91 +693,152 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" c.MaterialDesc AS 物料描述,\n" + " c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" + " c.EstimateTypeDesc AS 物料组,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 开票数量,\n" + " ISNULL( b.Qty, 0 ) AS 开票数量,\n" +
" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.Qty, 0 ) ) AS 收货与交货差异 \n" +
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" SELECT SUM\n" + " SELECT SUM\n" +
" ( ReceiptQty ) AS ReceiptQty,\n" + " ( ReceiptQty ) AS ReceiptQty,\n" +
" PurchaseOrderNo,\n" + " PurchaseOrderNo,\n" +
" MaterialCode \n" + " MaterialCode,\n" +
" SapCode \n" +
" FROM\n" + " FROM\n" +
" Set_WMSSparePart \n" + " Set_WMSSparePart \n" +
" WHERE\n" + " WHERE\n" +
" PurchaseOrderNo IS NOT NULL \n" + " PurchaseOrderNo IS NOT NULL \n" +
" AND PurchaseOrderNo != '' {0} \n" + " AND PurchaseOrderNo != '' {0}\n" +
" GROUP BY\n" + " GROUP BY\n" +
" PurchaseOrderNo,\n" + " PurchaseOrderNo,\n" +
" MaterialCode \n" + " MaterialCode,\n" +
" SapCode \n" +
" ) AS a\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" + " 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" +
" AND a.MaterialCode = b.MaterialCode\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" +
" 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" + " AND a.SapCode = b.MaterialCode \n" +
" WHERE\n" + " WHERE\n" +
" b.PurchaseOrderNo IS NULL \n" + " b.OrderBillNum IS NULL \n" +
" AND b.MaterialCode IS NULL \n" + " AND b.MaterialCode IS NULL \n" +
" ) AS temp1\n" + " ) AS temp1\n" +
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" + " LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" +
" AND temp1.SAP编码= temp3.MaterialCode\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" + " 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";
@ -1101,7 +1162,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "发货数量")] [ExporterHeader(DisplayName = "发货数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "开票数量")] [ExporterHeader(DisplayName = "开票数量", IsIgnore = true)]
public decimal { set; get; } public decimal { set; get; }
@ -1112,7 +1173,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "实际发货数量")] [ExporterHeader(DisplayName = "实际发货数量")]
public string { set; get; } public string { set; get; }
[ExporterHeader(DisplayName = "未结数量")] [ExporterHeader(DisplayName = "未结数量", IsIgnore = true)]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "定价")] [ExporterHeader(DisplayName = "定价")]

43
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<SalesStockSum> GetSalesStockSum(string version) public virtual List<SalesStockSum> GetSalesStockSum(string version)
{ {
string str = // string str =
"SELECT A\n" + // "SELECT A\n" +
" .*,\n" + //" .*,\n" +
" B.PartDesc,\n" + //" B.PartDesc,\n" +
" B.PartGroup \n" + //" B.PartGroup \n" +
"FROM\n" + //"FROM\n" +
" TM_PG_TIME_STOCK_DETAIL\n" + //" TM_PG_TIME_STOCK_DETAIL\n" +
" A LEFT JOIN (\n" + //" A LEFT JOIN (\n" +
" SELECT DISTINCT\n" + //" SELECT DISTINCT\n" +
" [ PartCode ],\n" + //" [ PartCode ],\n" +
" ( ISNULL ( [ PartDesc1 ], '' ) + ISNULL ( [ PartDesc2 ], '' ) ) PartDesc,\n" + //" ( ISNULL ( [ PartDesc1 ], '' ) + ISNULL ( [ PartDesc2 ], '' ) ) PartDesc,\n" +
" PartGroup \n" + //" PartGroup \n" +
" FROM\n" + //" FROM\n" +
" [ VIEW_PG_SIMPLE_PART ] \n" + //" [ VIEW_PG_SIMPLE_PART ] \n" +
" ) B ON A.PartCode = B.PartCode where a.version='{0}'"; //" ) 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); str = string.Format(str, version);
var _list = DbConnection.Query<SalesStockSum>(str); var _list = DbConnection.Query<SalesStockSum>(str);
return _list.ToList(); return _list.ToList();

8
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs

@ -107,10 +107,10 @@ namespace SettleAccount.Job.Services.Report
ExcelExporter _exporter = new ExcelExporter();//导出Excel ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls.ToList(), "有发货无结算差异对比") var result = _exporter.Append(_ls.ToList(), "有发货无结算差异对比")
.SeparateBySheet() //.SeparateBySheet()
.Append(_ls_orgiinal_kanban.ToList(), "原始看板未结对比数据") //.Append(_ls_orgiinal_kanban.ToList(), "原始看板未结对比数据")
.SeparateBySheet() //.SeparateBySheet()
.Append(_ls_wmskanban.ToList(), "有发货有结算(发货数量大于结算)") //.Append(_ls_wmskanban.ToList(), "有发货有结算(发货数量大于结算)")
.ExportAppendDataAsByteArray(); .ExportAppendDataAsByteArray();
result.ShouldNotBeNull(); result.ShouldNotBeNull();
_fileContainer.SaveAsync(_filename, result.Result, true); _fileContainer.SaveAsync(_filename, result.Result, true);

25
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

@ -303,18 +303,16 @@ namespace SettleAccount.Job.Services.Report
public List<UnSettledSum> GetSparePartSum(Guid id, List<string> exportName, List<CustomCondition> p_list) public List<UnSettledSum> GetSparePartSum(Guid id, List<string> exportName, List<CustomCondition> p_list)
{ {
var fileName = exportName.FirstOrDefault(); 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 version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value;
var sapCode = p_list.Where(p => p.Name == "SAPCode").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 matialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value;
var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; var beginTime = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value;
var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; var endTime = p_list.Where(p => p.Name == "End").FirstOrDefault().Value;
//var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").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)) if (!string.IsNullOrEmpty(sapCode))
{ {
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); 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. }) var kanbanList = _ls.GroupBy(p => new { p.SAP编码, p., p. })
.Select(p => new UnSettledSum .Select(p => new UnSettledSum
{ {

Loading…
Cancel
Save