Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/dataindex/DataIndex.java =================================================================== diff -u -r35357 -r35393 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/dataindex/DataIndex.java (.../DataIndex.java) (revision 35357) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/dataindex/DataIndex.java (.../DataIndex.java) (revision 35393) @@ -356,12 +356,13 @@ groupBySql = ""; } amountSql = String - .format("select sum(%s) amount %s %s %s " + .format("select sum(%s) amount %s %s %s %s " + "from RecyclingRecord rr inner join RecyclingItem ri on ri.recyclingRecord_id = rr.id inner join TousseDefinition td on ri.tousseDefinitionId = td.id join TousseDefinition tdc on tdc.id=td.ancestorID " + " %s where rr.recyclingTime %s %s %s and %s %s %s " + SqlUtils.getIsNotNullSql(dbConnection, "rr.operator") + " %s %s %s %s %s %s ", amountColumnSql, + obj.extraSelectColumns, obj.selectUserName?",rr.operator userName":"", obj.selectTousseType?",td.tousseType":"", obj.selectTousseName?",td.name tousseName":"", @@ -394,7 +395,7 @@ } // 统计清洗项的itemType为材料的物品,包括拆包清洗的器械包以及外来器械包 amountSql += String - .format("select %s %s %s %s %s %s " + .format("select %s %s %s %s %s %s %s " + getWashMaterialAmountSqlFromItemTypeIsMaterial(obj.extraJoinCondition) + " and wr.endDate %s %s %s and %s %s %s and wr.washMaterialAmount <> 0 %s %s %s %s %s " + "%s %s ", @@ -404,6 +405,7 @@ obj.selectTousseType ? selectTousseTypeSql : "", obj.selectTousseName ? selectTousseNameSql : "", obj.extraSelectColumns, + obj.extraSelectColumns1, obj.betweenSql, SqlUtils.get_InSql_Extra("wr.orgUnitCoding", obj.querySupplyRoom), SqlUtils.get_InSql_Extra("ci.orgUnitName", obj.applicationDepart), @@ -422,7 +424,7 @@ // 统计清洗项的itemType为材料的物品,器械是单独添加进清洗篮筐,没有关联的包定义 amountSql += " union all "; amountSql += String - .format("select %s %s %s %s %s %s " + .format("select %s %s %s %s %s %s %s " + getWashMaterialAmountSqlFromItemTypeIsMaterialWithoutTousseDefinition(obj.extraJoinCondition) + " and wr.endDate %s %s %s and %s %s %s and wr.washMaterialAmount <> 0 %s " + "%s %s ", @@ -432,6 +434,7 @@ obj.selectTousseType ? ",'材料' tousseType " : "", obj.selectTousseName ? selectTousseNameSql : "", obj.extraSelectColumns, + obj.extraSelectColumns2, obj.betweenSql, SqlUtils.get_InSql_Extra("wr.orgUnitCoding", obj.querySupplyRoom), SqlUtils.get_InSql_Extra("ci.orgUnitName", obj.applicationDepart), @@ -456,7 +459,7 @@ joinMaterialInstanceSql = " inner join MaterialInstance mi on mi.tousse_id = td.id "; } amountSql += String - .format("select %s %s %s %s %s %s " + .format("select %s %s %s %s %s %s %s " + getWashMaterialAmountSqlFromItemTypeIsNotMaterial(joinMaterialInstanceSql + obj.extraJoinCondition) + " and wr.endDate %s %s %s and %s %s %s and wr.washMaterialAmount <> 0 %s %s %s %s %s " + "%s %s ", @@ -466,6 +469,7 @@ obj.selectTousseType ? selectTousseTypeSql : "", obj.selectTousseName ? ",ci.name tousseName " : "", obj.extraSelectColumns, + obj.extraSelectColumns3, obj.betweenSql, SqlUtils.get_InSql_Extra("wr.orgUnitCoding", obj.querySupplyRoom), SqlUtils.get_InSql_Extra("ci.orgUnitName", obj.applicationDepart), @@ -498,7 +502,7 @@ && !obj.extraQuery.contains("tdc.") && !obj.extraGroupBy.contains("tdc.")) { amountSql += " union all "; - amountSql += String.format("select %s %s %s %s %s %s " + amountSql += String.format("select %s %s %s %s %s %s %s " + getWashMaterialAmountSqlFromTousseTypeIsMaterial(obj.extraJoinCondition) + "and wr.endDate %s %s %s " + "%s %s ", @@ -508,6 +512,7 @@ obj.selectTousseType ? ",'材料' tousseType " : "", obj.selectTousseName ? ",md.name tousseName " : "", obj.extraSelectColumns, + obj.extraSelectColumns4, obj.betweenSql, SqlUtils.get_InSql_Extra("wr.orgUnitCoding", obj.querySupplyRoom), obj.extraQuery, @@ -1415,13 +1420,14 @@ groupBySql = ""; } amountSql = String - .format("select sum(item.amount) amount %s %s " + .format("select sum(item.amount) amount %s %s %s " + "from InvoicePlan ip inner join TousseItem item on item.recyclingApplication_ID=ip.id inner join TousseDefinition td on td.id=item.tousseDefinitionId join TousseDefinition tdc on tdc.id=td.ancestorID " + "where ip.applicationTime %s %s %s and %s %s %s " + "and item.tousseType<>'一次性物品' %s %s %s %s %s " + "group by td.tousseType,td.name ", obj.selectTousseType ? ",td.tousseType" : "", obj.selectTousseName ? ",td.name tousseName " : "", + obj.extraSelectColumns, obj.betweenSql, SqlUtils.get_InSql_Extra("ip.handleDepartCoding", obj.querySupplyRoom), SqlUtils.get_InSql_Extra("ip.depart", obj.applicationDepart), @@ -1548,7 +1554,7 @@ sum = "sum"; } amountSql = String.format( - "select min(ci.tousseAmountForMaterial) amount %s %s %s %s %s " + "select min(ci.tousseAmountForMaterial) amount %s %s %s %s %s %s " + "from WashAndDisinfectRecord wdr,ClassifyBasket_WashRecord cw,ClassifyBasket cb,ClassifiedItem ci,TousseDefinition td,TousseDefinition tdc " + "where cw.WashAndDisinfectRecord_ID = wdr.id and cb.id = cw.ClassifyBasket_ID and ci.classifybasket_id = cb.id and td.id=ci.tousseDefinitionID and tdc.id=td.ancestorID " + "and ci.itemType = '材料' " @@ -1558,6 +1564,7 @@ obj.selectTousseType ? ",min(td.tousseType) tousseType" : "", obj.selectTousseName ? ",min(td.name) tousseName" : "", obj.extraSelectColumns, + obj.extraSelectColumns1, obj.betweenSql, SqlUtils.get_InSql_Extra("wdr.orgUnitCoding", obj.querySupplyRoom), SqlUtils.get_InSql_Extra("ci.orgUnitName", obj.applicationDepart), @@ -1572,7 +1579,7 @@ groupSql); amountSql += " union all "; - amountSql += String.format("select %s(ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end) amount %s %s %s %s %s " + amountSql += String.format("select %s(ci.amount-case when numOfUnwashedStops is null then 0 else numOfUnwashedStops end) amount %s %s %s %s %s %s " + "from WashAndDisinfectRecord wdr,ClassifyBasket_WashRecord cw,ClassifyBasket cb,ClassifiedItem ci,TousseDefinition td,TousseDefinition tdc " + "where cw.WashAndDisinfectRecord_ID = wdr.id and cb.id = cw.ClassifyBasket_ID and ci.classifybasket_id = cb.id and td.id=ci.tousseDefinitionID and tdc.id=td.ancestorID " + "and wdr.endDate %s %s %s and %s %s %s and ci.itemtype != '材料' and wdr.washMaterialAmount <> 0 %s %s %s %s %s %s ", @@ -1582,6 +1589,7 @@ obj.selectTousseType ? ",ci.itemType tousseType" : "", obj.selectTousseName ? ",td.name tousseName" : "", obj.extraSelectColumns, + obj.extraSelectColumns2, obj.betweenSql, SqlUtils.get_InSql_Extra("wdr.orgUnitCoding", obj.querySupplyRoom), SqlUtils.get_InSql_Extra("ci.orgUnitName", obj.applicationDepart), @@ -1796,12 +1804,13 @@ } if(!obj.getIsOnlyQueryComboTousse()){ amountSql = String - .format("select count(*) amount %s %s %s %s " + .format("select count(*) amount %s %s %s %s %s " + "from TousseInstance ti inner join TousseDefinition td on ti.tousseDefinition_id = td.id join TousseDefinition tdc on tdc.id=td.ancestorID " + "where %s and ti.reviewTime %s %s %s and %s %s %s " + SqlUtils.getIsNotNullSql(dbConnection, "ti.reviewer") + " %s %s %s %s %s " + " %s", + obj.extraSelectColumns, obj.queryIntegral?",sum(tdc.integral) integral":"", obj.selectUserName ? ",ti.reviewer userName" : "", obj.selectTousseType ? ",td.tousseType" : "", @@ -1826,12 +1835,13 @@ amountSql += " union all "; } amountSql += String - .format("select count(*) amount %s %s %s %s " + .format("select count(*) amount %s %s %s %s %s " + "from TousseInstance ti inner join TousseDefinition td on ti.tousseDefinition_id = td.id join TousseDefinition tdc on tdc.id=td.ancestorID " + "where "+ obj.getIsQueryComByPackageSize() +" ti.comboTousseInstanceId is null and ti.comboTousseDefinitionId is not null and ti.reviewTime %s %s %s and %s %s %s " + SqlUtils.getIsNotNullSql(dbConnection, "ti.reviewer") + " %s %s %s %s " + " %s ", + obj.extraSelectColumns, obj.queryIntegral?",sum(tdc.integral) integral":"", obj.selectUserName ? ",ti.reviewer userName" : "", obj.selectTousseType ? ",td.tousseType" : "", @@ -2044,6 +2054,54 @@ groupBySql); } break; + case "发货中包含加急的包数量": + if (obj.isGroup){ + groupBySql = String.format("%s %s %s %s", + obj.selectUserName ? ",i.sender" : "", + obj.selectTousseType ? ",td.tousseType" : "", + obj.selectTousseName ? ",td.name" : "", + obj.extraGroupBy + ); + groupBySql = groupBySql.trim(); + if(groupBySql.startsWith(",")){ + groupBySql = groupBySql.substring(1); + } + groupBySql = " group by " + groupBySql; + }else{ + groupBySql = ""; + } + if(!obj.getIsOnlyQueryComboTousse()){ + if (obj.includeTousses) { + amountSql = String + .format("select count(*) amount %s %s %s %s " + + "from Invoice i join TousseInstance ti on ti.invoice_id=i.id " + + "inner join TousseDefinition td on td.id=ti.tousseDefinition_id " + + "join TousseDefinition tdc on tdc.id=td.ancestorID %s " + + "where ti.urgentLevel_id is not null and i.sendTime %s %s %s and %s %s %s " + + " %s %s %s %s %s " + + " %s %s ", + obj.selectUserName ? ",i.sender userName" : "", + obj.selectTousseType ? ",td.tousseType" : "", + obj.selectTousseName ? ",td.name tousseName" : "", + obj.extraSelectColumns, + obj.extraJoinCondition, + obj.betweenSql, + SqlUtils.get_InSql_Extra("i.orgUnitCoding", + obj.querySupplyRoom), + SqlUtils.get_InSql_Extra("i.depart",obj.applicationDepart), + SqlUtils.getStringFieldInLargeCollectionsPredicate("i.depart", obj.recyDepartGroup, " 1=1 "), + obj.sterilizationModeSqlWithAliasOfTousseDefinitionIsTd, + obj.packageTypeSqlWithAliasOfTousseDefinitionIsTd, + obj.isDisableIDCardSqlWithAliasOfTousseDefinitionIsTd, + obj.taskGroupSqlWithAliasOfTousseDefinitionIsTd, + obj.tousseGroupSqlWithAliasOfTousseDefinitionIsTd, + obj.tousseTypeAndPackageSizeSql, + obj.extraWhereSql, + obj.extraQuery, + groupBySql); + } + } + break; case "年度报表中的发货数量(按包)": // 包含器械包 if (obj.includeTousses){ @@ -2155,12 +2213,13 @@ case "签收数量": if(!obj.getIsOnlyQueryComboTousse()){ amountSql = String - .format("select count(*) amount, td.tousseType, td.name tousseName " + .format("select count(*) amount %s, td.tousseType, td.name tousseName " + "from TousseInstance ti inner join TousseDefinition td on ti.tousseDefinition_id=td.id join TousseDefinition tdc on tdc.id=td.ancestorID %s " + "where %s and ti.signedDate %s %s %s and %s %s %s " + SqlUtils.getIsNotNullSql(dbConnection, "ti.signedUser") + " %s %s %s %s %s %s " + "group by td.tousseType,td.name", + obj.extraSelectColumns, obj.extraJoinCondition, obj.haveCombo?"ti.comboTousseInstanceId is null and ti.comboTousseDefinitionId is null":"1=1", obj.betweenSql, @@ -2182,12 +2241,13 @@ amountSql += " union all "; } amountSql += String - .format("select count(*) amount, td.tousseType, td.name tousseName " + .format("select count(*) amount %s, td.tousseType, td.name tousseName " + "from TousseInstance ti inner join TousseDefinition td on ti.tousseDefinition_id=td.id join TousseDefinition tdc on tdc.id=td.ancestorID %s " + "where "+ obj.getIsQueryComByPackageSize() +" ti.comboTousseInstanceId is null and ti.comboTousseDefinitionId is not null and ti.signedDate %s %s %s and %s %s %s " + SqlUtils.getIsNotNullSql(dbConnection, "ti.signedUser") + " %s %s %s %s %s " + "group by td.tousseType,td.name ", + obj.extraSelectColumns, obj.extraJoinCondition, obj.betweenSql, SqlUtils.get_InSql_Extra("ti.orgUnitCoding", obj.querySupplyRoom),