Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/ReportSqlUtil.java =================================================================== diff -u -r38752 -r38757 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/ReportSqlUtil.java (.../ReportSqlUtil.java) (revision 38752) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/ReportSqlUtil.java (.../ReportSqlUtil.java) (revision 38757) @@ -207,27 +207,21 @@ ctTypeIdSql = SqlUtils.getInLongListSql("ct.id", chineseMedicineInstrTypeIdSet); } // 统计清洗项的itemType为材料的物品,包括拆包清洗的器械包以及外来器械包 - String sql = String - .format("select ct.name,sum(ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end) amount " + String sql = "select ct.name,sum(ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end) amount " + queryDaySql + dataIndex.getWashMaterialAmountSqlFromItemTypeIsMaterial(params.extraJoinCondition) - + " and wr.endDate %s and wr.washMaterialAmount <> 0 %s "+ ctTypeIdSql +" group by ci.itemType,ci.orgUnitName,ci.isSencondWashForForeignTousse, td.tousseType " + + " and wr.endDate "+ params.betweenSql +" and wr.washMaterialAmount <> 0 "+ SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom) + ctTypeIdSql +" group by ci.itemType,ci.orgUnitName,ci.isSencondWashForForeignTousse, td.tousseType " + groupByDaySql - + ",ct.name ", - params.betweenSql, - SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom)); + + ",ct.name "; // 统计清洗项的itemType为材料的物品,单独入清洗篮筐的器械,没有关联的器械包 sql += " union all "; - sql += String - .format("select ct.name,sum(ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end) amount " + sql += "select ct.name,sum(ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end) amount " + queryDaySql + dataIndex.getWashMaterialAmountSqlFromItemTypeIsMaterialWithoutTousseDefinition(params.extraJoinCondition) - + " and wr.endDate %s and wr.washMaterialAmount <> 0 %s "+ ctTypeIdSql +" group by ci.itemType,ci.orgUnitName,ci.isSencondWashForForeignTousse, td.tousseType " + + " and wr.endDate "+ params.betweenSql +" and wr.washMaterialAmount <> 0 "+ SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom) + ctTypeIdSql +" group by ci.itemType,ci.orgUnitName,ci.isSencondWashForForeignTousse, td.tousseType " + groupByDaySql - + ",ct.name ", - params.betweenSql, - SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom)); + + ",ct.name "; // 统计清洗项的itemType不为材料的物品,包括整包清洗的器械包 @@ -242,27 +236,21 @@ + " 1=1 " + ctTypeIdSql + "group by mi.tousse_id,ct.name ) b on b.tdId=td.id "; - sql += String - .format("select b.name,sum((ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end)*b.miCount) amount " + sql += "select b.name,sum((ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end)*b.miCount) amount " + queryDaySql + dataIndex.getWashMaterialAmountSqlFromItemTypeIsNotMaterial(joinMaterialInstanceSql) - + " and wr.endDate %s and wr.washMaterialAmount <> 0 %s group by b.name " + + " and wr.endDate "+ params.betweenSql +" and wr.washMaterialAmount <> 0 "+ SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom) +" group by b.name " + groupByDaySql - + ",b.name ", - params.betweenSql, - SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom)); + + ",b.name "; sql += " union all "; - sql += String - .format("select ct.name,sum(wrm.amount) amount " + sql += "select ct.name,sum(wrm.amount) amount " + queryDaySql + "from WashAndDisinfectRecord wr, WashRecord_WashMaterial wm,WashAndDisinfectRecordMaterial wrm,MaterialDefinition md, OrgUnit org " + " ,ChineseMedicineInstrType ct " + "where ct.id=md.chineseMedicineInstrTypeId and wm.WashAndDisinfectRecord_ID = wr.id and wrm.id = wm.WashAndDisinfectMaterial_ID and wrm.materialDefinition_id = md.id and org.orgUnitCoding = wr.orgUnitCoding " - + " and wr.endDate %s %s "+ ctTypeIdSql +" group by ct.name " - + groupByDaySql, - params.betweenSql, SqlUtils.get_InSql_Extra( - "wr.orgUnitCoding", params.querySupplyRoom)); + + " and wr.endDate "+ params.betweenSql + SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom) + ctTypeIdSql +" group by ct.name " + + groupByDaySql; sql = " select sum(rs.amount) amount, rs.name "+ endDaySql + " from (" + sql + ")rs "