Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r25283 -r25286 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 25283) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 25286) @@ -10540,6 +10540,16 @@ + " and wr.endDate %s and wr.washMaterialAmount <> 0 %s group by ci.itemType,ci.orgUnitName,ci.isSencondWashForForeignTousse ", params.betweenSql, SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom)); + + // 统计清洗项的itemType为材料的物品,单独入清洗篮筐的器械,没有关联的器械包 + sql += " union all "; + sql += String + .format("select ci.itemType type,ci.orgUnitName,ci.isSencondWashForForeignTousse ,sum(ci.amount) amount " + + dataIndex.getWashMaterialAmountSqlFromItemTypeIsMaterialWithoutTousseDefinition() + + " and wr.endDate %s and wr.washMaterialAmount <> 0 %s group by ci.itemType,ci.orgUnitName,ci.isSencondWashForForeignTousse ", + params.betweenSql, + SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom)); + // 统计清洗项的itemType不为材料的物品,包括整包清洗的器械包 sql += " union all "; @@ -10567,14 +10577,9 @@ Map amountMap = getWashWorkloadAmountMap(sql); // 质量监测不合格数量 - String unQualitySql = " select sum(qmd.amount)as amount from QualityMonitoringInstance qi ,FormInstance fi,FormDefinition fd," - + " QualityMonitoringDefinition qd,QualityMonitoringGoods qmd " - + " where qi.id = fi.id and fi.formDefinition_id = fd.id and fd.id = qd.id " - + " and qi.id=qmd.qualityMonitoringInstance_id " - + " and fd.formName like '%器械清洗不合格%' and fd.formType = '质量监测'" - + " and qi.datetime between "+dateQueryAdapter.dateConverAdapter2(statDate,"yyyy-mm-dd") - + " and "+dateQueryAdapter.dateConverAdapter2(endDate,"yyyy-mm-dd") - + SqlUtils.get_InSql_Extra("fi.orgUnitCoding", querySupplyRoom); + String unQualitySql = "select sum(qmd.amount) as amount " + + dataIndex.getUnQualifiedMonitorAmountSql("清洗消毒", "", params); + Integer unQualityAmount = getAmountBySql(unQualitySql); CrossTableBean ctBean = getCrossTableBean("普通器械",titleColumnNumMap,statDate,amountMap.get("普通器械"),null); @@ -13575,6 +13580,7 @@ */ private void materialTypeWorkloadReportList(String statDate,String endDate,String querySupplyRoom,List list){ + String UNDEFINED_TYPE= "未设置"; String betweenSql = String.format(" between %s and %s ", dateQueryAdapter.dateConverAdapter2(statDate, "yyyy-mm-dd"), dateQueryAdapter.dateConverAdapter2(endDate, "yyyy-mm-dd")); @@ -13585,23 +13591,23 @@ // 统计整包清洗的器械包、外来器械包、消毒物品、自定义器械包的材料件数 - String sql = "select t1.type,sum(t1.amount) from ( select m.type as type,(min(i.amount)*sum(ms.count)) as amount from "; - sql += "washanddisinfectrecord r,ClassifyBasket_WashRecord cw,ClassifyBasket b,ClassifiedItem i,"; - sql += "TousseDefinition t,materialinstance ms,materialdefinition m "; - sql += "where r.id = cw.washanddisinfectrecord_id and cw.classifybasket_id = b.id and "; - sql += "b.id = i.classifybasket_id and i.toussedefinition_id = t.id and t.id = ms.tousse_id and ms.materialdefinition_id = m.id "; - sql += "and i.itemType <> '材料' "; - sql += "and r.enddate " + params.betweenSql ; - sql += SqlUtils.get_InSql_Extra("r.orgUnitCoding", params.querySupplyRoom) + " group by i.id,m.type "; + String sql = "select t1.type,sum(t1.amount) from ( select md.type as type,sum(ci.amount * mi.count) as amount from "; + sql += "washanddisinfectrecord wr,ClassifyBasket_WashRecord cw,ClassifyBasket cb,ClassifiedItem ci,"; + sql += "TousseDefinition td,materialinstance mi,materialdefinition md "; + sql += "where wr.id = cw.washanddisinfectrecord_id and cw.classifybasket_id = cb.id "; + sql += "and cb.id = ci.classifybasket_id and ci.toussedefinition_id = td.id and td.id = mi.tousse_id and mi.materialdefinition_id = md.id "; + sql += "and ci.itemType <> '材料' and wr.washMaterialAmount <> 0 "; + sql += "and wr.enddate " + params.betweenSql ; + sql += SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom) + " group by md.type"; sql += " union all "; // 统计拆包清洗的材料件数(主要包括拆包清洗的器械包以及外来器械) - sql += "select m.type as type,sum(i.amount) as amount from "; - sql += "washanddisinfectrecord r ,ClassifyBasket_WashRecord cw ,ClassifyBasket b, ClassifiedItem i,materialdefinition "; - sql += "m where r.id = cw.washanddisinfectrecord_id and cw.classifybasket_id = b.id and b.id = i.classifybasket_id "; - sql += "and i.materialdefinition_id = m.id and i.itemType = '材料' and r.enddate " + params.betweenSql; - sql += SqlUtils.get_InSql_Extra("r.orgUnitCoding", params.querySupplyRoom) + " group by m.type"; + sql += "select md.type as type,sum(ci.amount) as amount from "; + sql += "washanddisinfectrecord wr ,ClassifyBasket_WashRecord cw ,ClassifyBasket cb, ClassifiedItem ci,MaterialDefinition md "; + sql += "where wr.id = cw.washanddisinfectrecord_id and cw.classifybasket_id = cb.id and cb.id = ci.classifybasket_id "; + sql += "and ci.materialdefinition_id = md.id and ci.itemType = '材料' and wr.washMaterialAmount <> 0 and wr.enddate " + params.betweenSql; + sql += SqlUtils.get_InSql_Extra("wr.orgUnitCoding", params.querySupplyRoom) + " group by md.type"; // 统计单独登记清洗的材料数量 sql += " union all "; @@ -13619,15 +13625,10 @@ if (StringUtils.isNotBlank(querySupplyRoom)){ likeSql = "and fd.departcodes like '%" + querySupplyRoom + "%'"; } - String sql2 = "select qmd.material,sum(qmd.amount) as amount from QualityMonitoringInstance qi ,FormInstance fi,FormDefinition fd," - + " QualityMonitoringDefinition qd,QualityMonitoringGoods qmd " - + " where qi.id = fi.id and fi.formDefinition_id = fd.id and fd.id = qd.id " - + " and qi.id=qmd.qualityMonitoringInstance_id " + likeSql; - sql2 += " and qd.responsibilitypart = '清洗消毒' and fd.formType = '质量监测'"; - sql2 += " and qi.datetime between "+dateQueryAdapter.dateConverAdapter2(statDate,"yyyy-mm-dd"); - sql2 += " and "+dateQueryAdapter.dateConverAdapter2(endDate,"yyyy-mm-dd"); - sql2 += SqlUtils.get_InSql_Extra("fi.orgUnitCoding", querySupplyRoom); - sql2 += " group by qmd.material "; + + String sql2 = "select qmd.material,sum(qmd.amount) as amount " + + dataIndex.getUnQualifiedMonitorAmountSql("清洗消毒", likeSql, + params) + " group by qmd.material "; ResultSet rs2 = objectDao.executeSql(sql2); Map monitoringMap = new HashMap(); @@ -13638,14 +13639,20 @@ if(StringUtils.isNotBlank(materialName)){ JSONObject obj = CssdUtils.getGoodsNameAndSp(materialName); MaterialDefinition md = materialDefinitionManager.getMaterialDefinitionByName(obj.optString("materialName"), obj.optString("specification")); + + String type = UNDEFINED_TYPE; if(md != null){ - String type = md.getType(); - Integer oldAmount = monitoringMap.get(type); - if(oldAmount == null){ - oldAmount = 0; - } - monitoringMap.put(type, oldAmount + washUnqualifiedAmount); + type = md.getType(); } + else{ + logger.debug("材料定义未找到,materialName = " + materialName + ", amount = " + washUnqualifiedAmount); } + + Integer oldAmount = monitoringMap.get(type); + if(oldAmount == null){ + oldAmount = 0; + } + monitoringMap.put(type, oldAmount + washUnqualifiedAmount); + } } } catch (SQLException e) { @@ -13657,7 +13664,7 @@ List hos = httpOptionManager.getHttpOptionListById(HttpOption.SYSTEMSETTING_MATERIALTYPE); Map materialTypeSecquenceMap = new HashMap(); // 最大的顺序号,用来设置‘未设置’类型的列号 - Integer maxSecquence = 2; + Integer maxSecquence = 1; if(CollectionUtils.isNotEmpty(hos)){ for(HttpOption ho : hos){ String typeName = ho.getOptionText(); @@ -13670,6 +13677,8 @@ } } } + materialTypeSecquenceMap.put(UNDEFINED_TYPE, maxSecquence); + Integer totalAmount = 0; Integer totalUnqualifiedAmount = 0; ResultSet rs = objectDao.executeSql(sql); @@ -13682,18 +13691,19 @@ data.setAmount(amount); data.setColumnNum(1); data.setDayOfMonth(statDate); - Integer washUnqualifiedAmount = monitoringMap.get(materialType); - if(washUnqualifiedAmount == null){ - washUnqualifiedAmount = 0; - } + if(StringUtils.isBlank(materialType)){ - materialType = "未配置"; + materialType = UNDEFINED_TYPE; data.setColumnNum(materialTypeSecquenceMap.size() + 1); }else{ Integer sec = materialTypeSecquenceMap.get(materialType); data.setColumnNum(sec); } + Integer washUnqualifiedAmount = monitoringMap.get(materialType); + if(washUnqualifiedAmount == null){ + washUnqualifiedAmount = 0; + } data.setMaterialType(materialType); totalUnqualifiedAmount += washUnqualifiedAmount; data.setWashUnqualifiedAmount(washUnqualifiedAmount);