Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/CustomReportsOfZsyy.java =================================================================== diff -u -r27610 -r28949 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/CustomReportsOfZsyy.java (.../CustomReportsOfZsyy.java) (revision 27610) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/CustomReportsOfZsyy.java (.../CustomReportsOfZsyy.java) (revision 28949) @@ -192,7 +192,15 @@ } bean3.setTitle("应急处理器械次数 "); bean3.setRowNum(list.size()+1); - list.add(bean3); + list.add(bean3); + String operatingRoomCodes = CssdUtils.getSystemSetConfigByName("operatingRoomCodes"); + String notInDepartSql = ""; + if(StringUtils.isNotBlank(operatingRoomCodes)){ + String[] departArr = operatingRoomCodes.split(","); + for (int i = 0; i < departArr.length; i++) { + notInDepartSql += " and rr.departCode != '" + departArr[i] + "' "; + } + } // 普通器械清洗不合格率 普通器械清洗不合格 WorkQualityCollection bean4 = new WorkQualityCollection(); for (String key : startAndEndDays.keySet()){ @@ -207,7 +215,10 @@ + " join ClassifyBasket_RecyclingRecord cr on rr.id=cr.RecyclingRecord_ID " + " join ClassifyBasket cb on cr.ClassifyBasket_ID=cb.id join ClassifyBasket_WashRecord cw on cb.id=cw.ClassifyBasket_ID " + " join WashAndDisinfectRecord wr on cw.WashAndDisinfectRecord_ID=wr.id " - + " where rr.depart is not null and rr.depart != '手术一区' and rr.depart != '手术二区' and rr.depart != '手术三区' and wr.id is not null " + + " where rr.depart is not null " + //+ "and rr.depart != '手术一区' and rr.depart != '手术二区' and rr.depart != '手术三区' " + + notInDepartSql + + "and wr.id is not null " + " and ritem.tousseDefinitionId in (select cit.tousseDefinitionID from ClassifyBasket clb,ClassifiedItem cit where clb.id=cit.classifybasket_id and cb.id=clb.id) " + " and rr.orgUnitCoding = '"+querySupplyRoom+"'" + " and (rr.recyclingTime between "+dateQueryAdapter.dateAdapter(startDay)+" and " + dateQueryAdapter.dateAdapter(endDay) + ")"; @@ -225,19 +236,42 @@ endDay = innerMap.get(keyOfInnerMap); } sql = getWorkUnQualityAmountContainSql("专科器械清洗不合格",startDay,endDay,querySupplyRoom); - totalSql = "select sum("+ columnSqlForBean5 +") from ClassifyBasket cb " - + " join ClassifyBasket_WashRecord cw on cb.id=cw.ClassifyBasket_ID join WashAndDisinfectRecord wr on cw.WashAndDisinfectRecord_ID=wr.id " - + " join ClassifiedItem cit on cb.id=cit.classifybasket_id " - + joinSqlForBean5 - + " where wr.id is not null " - + " and (cb.recyclingTime between "+dateQueryAdapter.dateAdapter(startDay)+" and " + dateQueryAdapter.dateAdapter(endDay) + ")"; + ReportQueryParams params = new ReportQueryParams(); + String betweenSql = String.format(" between %s and %s ", dateQueryAdapter.dateAdapter(startDay),dateQueryAdapter.dateAdapter(endDay)); + params.betweenSql = betweenSql; + params.querySupplyRoom = querySupplyRoom; + params.isDisableIDCardSqlWithAliasOfTousseDefinitionIsTd = ""; + params.taskGroupSqlWithAliasOfTousseDefinitionIsTd = " and td.tousseGroupName='专科' "; + params.tousseGroupSqlWithAliasOfTousseDefinitionIsTd = ""; + params.tousseTypeAndPackageSizeSql = ""; + //数据库计算字符串长度的函数名 + String sqlLengthFunctionName = DatabaseUtil.getSqlLengthFunctionName(dbConnection); + params.sqlLengthFunctionName = sqlLengthFunctionName; + params.monthlyStr = dateQueryAdapter.dateConverAdapter3("wr.endDate","mm"); + // 处理器械总件数 + totalSql = String.format("select sum(tl.amount) amount from (" + +dataIndex.getWorkAmountByMaterialSQL("清洗数量", params, dataSoureOfMaterialsCountOfToussesInReports) + + ") tl "); setWorkQualityCollectionData(bean5,key,sql,totalSql); } bean5.setTitle("专科器械清洗不合格率"); bean5.setRowNum(list.size()+1); list.add(bean5); // 手术器械清洗不合格率 手术器械清洗不合格 WorkQualityCollection bean6 = new WorkQualityCollection(); + String departSql = ""; + if(StringUtils.isNotBlank(operatingRoomCodes)){ + String[] departArr = operatingRoomCodes.split(","); + departSql += " and ("; + for (int i = 0; i < departArr.length; i++) { + if(i == 0){ + departSql += " rr.departCode='" + departArr[i] + "' "; + }else{ + departSql += " or rr.departCode='" + departArr[i] + "' "; + } + } + departSql += ") "; + } for (String key : startAndEndDays.keySet()){ Map innerMap = startAndEndDays.get(key); for (String keyOfInnerMap : innerMap.keySet()) { @@ -249,7 +283,9 @@ + joinSqlForBean6 + " join ClassifyBasket_RecyclingRecord cr on rr.id=cr.RecyclingRecord_ID join ClassifyBasket cb on cr.ClassifyBasket_ID=cb.id join ClassifyBasket_WashRecord cw on cb.id=cw.ClassifyBasket_ID " + " join WashAndDisinfectRecord wr on cw.WashAndDisinfectRecord_ID=wr.id " - + " where rr.depart is not null and (rr.depart = '手术一区' or rr.depart = '手术二区' or rr.depart = '手术三区') " + + " where rr.depart is not null " + //+ " and (rr.depart = '手术一区' or rr.depart = '手术二区' or rr.depart = '手术三区') " + + departSql + " and wr.id is not null " + " and ritem.tousseDefinitionId in (select cit.tousseDefinitionID from ClassifyBasket clb,ClassifiedItem cit where clb.id=cit.classifybasket_id and cb.id=clb.id) " + " and (rr.recyclingTime between "+dateQueryAdapter.dateAdapter(startDay)+" and " + dateQueryAdapter.dateAdapter(endDay) + ")"; @@ -410,6 +446,13 @@ list.add(bean16); // 无菌物品发放不及时次数 无菌物品发放不及时 WorkQualityCollection bean17 = new WorkQualityCollection(); + notInDepartSql = ""; + if(StringUtils.isNotBlank(operatingRoomCodes)){ + String[] departArr = operatingRoomCodes.split(","); + for (int i = 0; i < departArr.length; i++) { + notInDepartSql += " and org.orgUnitCoding != '" + departArr[i] + "' "; + } + } for (String key : startAndEndDays.keySet()){ Map innerMap = startAndEndDays.get(key); for (String keyOfInnerMap : innerMap.keySet()) { @@ -418,7 +461,8 @@ } sql = getWorkUnQualityAmountEqualSql("无菌物品发放不及时",startDay,endDay,querySupplyRoom); totalSql = "select sum(it.amount) from invoice iv,InvoiceItem it,OrgUnit org where iv.id=it.invoiceID and iv.orgUnitCoding=org.orgUnitCoding " - + " and org.name != '手术一区' and org.name != '手术二区' and org.name != '手术三区' " + //+ " and org.name != '手术一区' and org.name != '手术二区' and org.name != '手术三区' " + + notInDepartSql + " and (iv.sendTime between "+dateQueryAdapter.dateAdapter(startDay)+" and " + dateQueryAdapter.dateAdapter(endDay) + ")"; setWorkQualityCollectionData(bean17,key,sql,totalSql); } @@ -519,6 +563,14 @@ joinTwo = " join (select td.id tid, sum(mi.count) amount from MaterialInstance mi, tousseDefinition td where mi.tousse_id=td.id and td.forDisplay=1 and td.tousseGroupName = '专科' group by td.id) tdc on tdc.tid=cit.tousseDefinitionID "; joinThree = " join (select td.id tid, sum(mi.count) amount from MaterialInstance mi, tousseDefinition td where mi.tousse_id=td.id and td.forDisplay=1 group by td.id) tdc on tdc.tid=ritem.tousseDefinitionId "; } + String operatingRoomCodes = CssdUtils.getSystemSetConfigByName("operatingRoomCodes"); + String notInDepartSql = ""; + if(StringUtils.isNotBlank(operatingRoomCodes)){ + String[] departArr = operatingRoomCodes.split(","); + for (int i = 0; i < departArr.length; i++) { + notInDepartSql += " and rr.departCode != '" + departArr[i] + "' "; + } + } // 普通器械清洗不合格率 // 总数量 按照回收时科室不等于“手术一区、手术二区、手术三区”的器械包材料清洗总件数。并且器械包定义的器械包分组不等于“专科” String totalSqlOne = "select " +dateQueryAdapter.dateConverAdapter3("rr.recyclingTime","mm") @@ -527,7 +579,10 @@ + " join ClassifyBasket_RecyclingRecord cr on rr.id=cr.RecyclingRecord_ID " + " join ClassifyBasket cb on cr.ClassifyBasket_ID=cb.id join ClassifyBasket_WashRecord cw on cb.id=cw.ClassifyBasket_ID " + " join WashAndDisinfectRecord wr on cw.WashAndDisinfectRecord_ID=wr.id " - + " where rr.depart is not null and rr.depart != '手术一区' and rr.depart != '手术二区' and rr.depart != '手术三区' and wr.id is not null " + + " where rr.depart is not null " + //+ " and rr.depart != '手术一区' and rr.depart != '手术二区' and rr.depart != '手术三区' " + + notInDepartSql + + " and wr.id is not null " + " and ritem.tousseDefinitionId in (select cit.tousseDefinitionID from ClassifyBasket clb,ClassifiedItem cit where clb.id=cit.classifybasket_id and cb.id=clb.id) " + " and rr.orgUnitCoding = '"+querySupplyRoom+"'" + " and (rr.recyclingTime between "+dateQueryAdapter.dateAdapter(queryYear)+" and " + dateQueryAdapter.dateAdapter(nextYear) + ")" @@ -544,14 +599,22 @@ addWorkQualityCollectionBean(list,titleName,sql,totalmap); // 专科器械清洗不合格率 // 总数量 按照器械包定义的器械包分组等于“专科” 的器械材料清洗总件数 - String totalSqlTwo = "select " +dateQueryAdapter.dateConverAdapter3("cb.recyclingTime","mm") - + " month,sum("+ columnTwo +") from ClassifyBasket cb " - + " join ClassifyBasket_WashRecord cw on cb.id=cw.ClassifyBasket_ID join WashAndDisinfectRecord wr on cw.WashAndDisinfectRecord_ID=wr.id " - + " join ClassifiedItem cit on cb.id=cit.classifybasket_id " - + joinTwo - + " where wr.id is not null " - + " and (cb.recyclingTime between "+dateQueryAdapter.dateAdapter(queryYear)+" and " + dateQueryAdapter.dateAdapter(nextYear) + ")" - + " group by " + dateQueryAdapter.dateConverAdapter3("cb.recyclingTime","mm"); + ReportQueryParams params = new ReportQueryParams(); + String betweenSql = String.format(" between %s and %s ", dateQueryAdapter.dateAdapter(queryYear),dateQueryAdapter.dateAdapter(nextYear)); + params.betweenSql = betweenSql; + params.querySupplyRoom = querySupplyRoom; + params.isDisableIDCardSqlWithAliasOfTousseDefinitionIsTd = ""; + params.taskGroupSqlWithAliasOfTousseDefinitionIsTd = " and td.tousseGroupName='专科' "; + params.tousseGroupSqlWithAliasOfTousseDefinitionIsTd = ""; + params.tousseTypeAndPackageSizeSql = ""; + //数据库计算字符串长度的函数名 + String sqlLengthFunctionName = DatabaseUtil.getSqlLengthFunctionName(dbConnection); + params.sqlLengthFunctionName = sqlLengthFunctionName; + params.monthlyStr = dateQueryAdapter.dateConverAdapter3("wr.endDate","mm"); + // 处理器械总件数 + String totalSqlTwo = String.format("select monthstr,sum(tl.amount) amount from (" + +dataIndex.getWorkAmountByMaterialSQL("清洗数量", params, dataSoureOfMaterialsCountOfToussesInReports) + + ") tl group by monthstr "); totalmap = getMapBySql(totalSqlTwo); sql = " select " + dateQueryAdapter.dateConverAdapter3("qmi.dateTime","mm") + " monthstr,sum(qmd.amount) amount " + " from QualityMonitoringInstance qmi,FormInstance fi,FormDefinition fd,QualityMonitoringGoods qmd" @@ -564,12 +627,29 @@ addWorkQualityCollectionBean(list,titleName,sql,totalmap); // 手术器械清洗不合格率 // 总数量:按照回收科室等于“手术一区、手术二区、手术三区”的器械材料清洗总件数 + + + String departSql = ""; + if(StringUtils.isNotBlank(operatingRoomCodes)){ + String[] departArr = operatingRoomCodes.split(","); + departSql += " and ("; + for (int i = 0; i < departArr.length; i++) { + if(i == 0){ + departSql += " rr.departCode='" + departArr[i] + "' "; + }else{ + departSql += " or rr.departCode='" + departArr[i] + "' "; + } + } + departSql += ") "; + } String totalSqlThree = "select " +dateQueryAdapter.dateConverAdapter3("rr.recyclingTime","mm") + " month,sum("+ columnOneOrThree +") from RecyclingRecord rr join RecyclingItem ritem on ritem.recyclingRecord_id = rr.id " + joinThree + " join ClassifyBasket_RecyclingRecord cr on rr.id=cr.RecyclingRecord_ID join ClassifyBasket cb on cr.ClassifyBasket_ID=cb.id join ClassifyBasket_WashRecord cw on cb.id=cw.ClassifyBasket_ID " + " join WashAndDisinfectRecord wr on cw.WashAndDisinfectRecord_ID=wr.id " - + " where rr.depart is not null and (rr.depart = '手术一区' or rr.depart = '手术二区' or rr.depart = '手术三区') " + + " where rr.depart is not null " + //+ " and (rr.depart = '手术一区' or rr.depart = '手术二区' or rr.depart = '手术三区') " + + departSql + " and wr.id is not null " + " and ritem.tousseDefinitionId in (select cit.tousseDefinitionID from ClassifyBasket clb,ClassifiedItem cit where clb.id=cit.classifybasket_id and cb.id=clb.id) " + " and (rr.recyclingTime between "+dateQueryAdapter.dateAdapter(queryYear)+" and " + dateQueryAdapter.dateAdapter(nextYear) + ")" @@ -685,9 +765,17 @@ titleName = "包内化学指示卡变色不合格例数"; addWorkQualityCollectionBean(list,titleName,sql,packingAmountMap); // 无菌物品发放不及时次数 + notInDepartSql = ""; + if(StringUtils.isNotBlank(operatingRoomCodes)){ + String[] departArr = operatingRoomCodes.split(","); + for (int i = 0; i < departArr.length; i++) { + notInDepartSql += " and org.orgUnitCoding != '" + departArr[i] + "' "; + } + } String totalSql = "select " +dateQueryAdapter.dateConverAdapter3("iv.sendTime","mm") + " month, sum(it.amount) from invoice iv,InvoiceItem it,OrgUnit org where iv.id=it.invoiceID and iv.orgUnitCoding=org.orgUnitCoding " - + " and org.name != '手术一区' and org.name != '手术二区' and org.name != '手术三区' " + //+ " and org.name != '手术一区' and org.name != '手术二区' and org.name != '手术三区' " + + notInDepartSql + " and (iv.sendTime between "+dateQueryAdapter.dateAdapter(queryYear)+" and " + dateQueryAdapter.dateAdapter(nextYear) + ")" + " group by " + dateQueryAdapter.dateConverAdapter3("iv.sendTime","mm"); totalmap = getMapBySql(totalSql);