Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r17837 -r17841 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 17837) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 17841) @@ -10283,9 +10283,9 @@ departCoding,startDateSql,endDateSql,tousseTypeSql); if (includeForeignTousse) { sql += " union all "; - sql += String.format("select 'invoice' as type,fta.tousseName,count(*),'外来器械包' from invoice i,TousseInstance ti,ForeignTousseApplication fta " - +" where i.id = ti.invoice_id and ti.foreignTousseApp_id=fta.id " - +" and i.orgUnitCoding = '%s' and i.sendTime between %s and %s group by fta.tousseName", + sql += String.format("select 'invoice' type,fta.tousseName,sum(ii.amount) amount,'外来器械包' tousseType from invoice i join InvoiceItem ii on ii.invoice_id=i.id " + + "join ForeignTousseApplication fta on fta.id=i.invoicePlan_ID " + +" where i.orgUnitCoding = '%s' and i.sendTime between %s and %s group by fta.tousseName", departCoding,startDateSql,endDateSql); } @@ -10303,83 +10303,86 @@ departCoding,signedTimeString,startDateSql,endDateSql); } - Map> typeOfChildVO = new HashMap>(); - Map nameOfChildVO = new HashMap(); + Map> typeOfChild = new HashMap>(); GoodsOption option = goodsOptionManager.getGoodsOption(GoodsOption.MODEL_TOUSSEWORKLOAD, departCoding); - //若用户自定义了需要查询的器械包,则根据自定义查询,否则查全部的器械包 - if(option != null && StringUtils.isNotBlank(option.getValue())){ - String[] goodsNameArray = option.getValue().split(";"); - nameOfChildVO = new HashMap(); - for(String goodsName: goodsNameArray){ - TousseWorkLoadChildVO childVO = new TousseWorkLoadChildVO(); - childVO.setTousseName(goodsName); - nameOfChildVO.put(goodsName, childVO); - } - - ResultSet result = objectDao.executeSql(sql); - try { + + ResultSet result = objectDao.executeSql(sql); + try { + //若用户自定义了需要查询的器械包,则根据自定义查询,否则查全部的器械包 + if(option != null && StringUtils.isNotBlank(option.getValue())){ + String[] goodsNameArray = option.getValue().split(";"); + HashMap optionTousseName = new HashMap(); + for(String goodsName: goodsNameArray){ + optionTousseName.put(goodsName, goodsName); + } + while(result.next()){ String type = result.getString(1); String tousseName = result.getString(2); Integer amount = result.getInt(3); String tousseType = result.getString(4); - TousseWorkLoadChildVO childVO = nameOfChildVO.get(tousseName); - if(childVO != null){ - setVoAmount(type, amount, childVO); - HashSet childVOSet = typeOfChildVO.get(tousseType); - if (childVOSet == null) { - childVOSet = new HashSet(); - typeOfChildVO.put(tousseType, childVOSet); + HashMap nameOfChild = typeOfChild.get(tousseType); + if (nameOfChild == null) { + nameOfChild = new HashMap(); + typeOfChild.put(tousseType, nameOfChild); + } + + String flag = optionTousseName.get(tousseName); + if(flag != null){ + TousseWorkLoadChildVO child = nameOfChild.get(tousseName); + if(child == null){ + child = new TousseWorkLoadChildVO(); + child.setTousseName(tousseName); + nameOfChild.put(tousseName, child); } - childVOSet.add(childVO); + setVoAmount(type, amount, child); } } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(result); - } - }else{ - ResultSet result = objectDao.executeSql(sql); - try { + } else { while(result.next()){ String type = result.getString(1); String tousseName = result.getString(2); Integer amount = result.getInt(3); String tousseType = result.getString(4); - TousseWorkLoadChildVO childVO = nameOfChildVO.get(tousseName); - if(childVO == null){ - childVO = new TousseWorkLoadChildVO(); - childVO.setTousseName(tousseName); - nameOfChildVO.put(tousseName, childVO); + HashMap nameOfChild = typeOfChild.get(tousseType); + if (nameOfChild == null) { + nameOfChild = new HashMap(); + typeOfChild.put(tousseType, nameOfChild); } - setVoAmount(type, amount, childVO); - HashSet childVOSet = typeOfChildVO.get(tousseType); - if (childVOSet == null) { - childVOSet = new HashSet(); - typeOfChildVO.put(tousseType, childVOSet); + + TousseWorkLoadChildVO child = nameOfChild.get(tousseName); + if(child == null){ + child = new TousseWorkLoadChildVO(); + child.setTousseName(tousseName); + nameOfChild.put(tousseName, child); } - childVOSet.add(childVO); + setVoAmount(type, amount, child); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(result); } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(result); } - List voList = new ArrayList(); - for (Entry> entry : typeOfChildVO.entrySet()) { + List list = new ArrayList(); + Set>> entrySet1 = typeOfChild.entrySet(); + for (Entry> entry : entrySet1) { TousseWorkLoadVO vo = new TousseWorkLoadVO(); vo.setTousseType(entry.getKey()); - vo.setChildrens(new ArrayList(entry.getValue())); - voList.add(vo); + Set> entrySet2 = entry.getValue().entrySet(); + List childList = new LinkedList(); + for (Entry e : entrySet2) { + childList.add(e.getValue()); + } + vo.setChildrens(childList); + list.add(vo); } logger.debug("器械包工作量统计报表后台查询时间:" + (System.currentTimeMillis() - ll) + "毫秒"); - return voList; + return list; } /**