Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r33216 -r33235 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 33216) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 33235) @@ -15746,6 +15746,19 @@ }finally { DatabaseUtil.closeResultSetAndStatement(rs); } + sql = "select distinct fdi.name from FormDefinition fd join FormDefinitionItem fdi on fdi.formDefinition_id=fd.id where fdi.type='数字'"; + ResultSet rs1 = null; + Set numNames = new HashSet(); + try { + rs1 = objectDao.executeSql(sql); + while (rs1.next()) { + numNames.add(rs1.getString("name")); + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs1); + } // 质量检测加数量汇总 if ("质量监测".equals(monitoringType)) { Integer totalAmount = 0; @@ -15761,7 +15774,7 @@ questionName = list.get(0).getQuestionName(); } if (totalAmount > 0 || list.size() > 0) { - List> listMap = getBeanMap(list); + List> listMap = getBeanMap(list,numNames); if( listMap != null && listMap.size() > 1){ Map beanStatisticsMap = listMap.get(0); Map beanStatisticsMap2 = listMap.get(1); @@ -15861,7 +15874,7 @@ questionName = list.get(0).getQuestionName(); } // 对每个bean 做统计 - List> listMap = getBeanMapByResult(list); + List> listMap = getBeanMapByResult(list,numNames); if( listMap != null && listMap.size() > 0){ Map beanStatisticsMap = listMap.get(0); if(beanStatisticsMap != null){ @@ -15891,16 +15904,6 @@ } if(totalAmount != null && totalAmount > 0){ addQualifiedAmountInfo(isQualifiedAmount, list, orderNumber, option, questionName); - MonitoringItemBean bean = new MonitoringItemBean(); - bean.setGoodsName("汇总"); - bean.setDateTime("汇总"); - bean.setOrderNumber(orderNumber); - bean.setOption(option); - bean.setQuestionName(questionName); - bean.setAmount(totalAmount); - bean.setAnswer(totalAmount+""); - bean.setPositionMsg(""); - list.add(bean); } } } @@ -17533,7 +17536,7 @@ return sql; } - private List> getBeanMap(List beanList){ + private List> getBeanMap(List beanList,Set numNames){ if(beanList == null) return null; List> listMap = new ArrayList>(); @@ -17550,20 +17553,44 @@ String key = orderNumber + "_" + option + "_" + questionName; // 统计项有值才添加 if(StringUtils.isNotBlank(answer)){ - if( !map.containsKey(key) ){ - map.put(key, 1); + if(numNames.contains(questionName)){ + if(StringUtils.isNotBlank(answer) && StringUtils.isNumeric(answer)){ + Integer amount = Integer.valueOf(answer); + if( !map.containsKey(key) ){ + map.put(key, amount); + }else{ + int value = map.get(key) + amount; + map.put(key, value); + } + } }else{ - int value = map.get(key) + 1; - map.put(key, value); + if( !map.containsKey(key) ){ + map.put(key, 1); + }else{ + int value = map.get(key) + 1; + map.put(key, value); + } } // 有数量才添加 Integer amount = mt.getAmount(); if(amount != null && amount > 0){ - if( !map2.containsKey(key) ){ - map2.put(key, amount); + if(numNames.contains(questionName)){ + if(StringUtils.isNotBlank(answer) && StringUtils.isNumeric(answer)){ + Integer answerNum = Integer.valueOf(answer); + if(!map2.containsKey(key) ){ + map2.put(key, answerNum); + }else{ + int value = map2.get(key) + answerNum; + map2.put(key, value); + } + } }else{ - int value = map2.get(key) + amount; - map2.put(key, value); + if( !map2.containsKey(key) ){ + map2.put(key, amount); + }else{ + int value = map2.get(key) + amount; + map2.put(key, value); + } } } }else if(key.equals("1_-_-")){ @@ -17589,7 +17616,7 @@ * @param beanList * @return */ - private List> getBeanMapByResult(List beanList){ + private List> getBeanMapByResult(List beanList, Set numNames){ if(beanList == null) return null; List> listMap = new ArrayList>(); @@ -17608,6 +17635,17 @@ int value = map.get(key) + 1; map.put(key, value); } + //指定的元素也添加(比如数字) + }else if(numNames.contains(option)){ + if(StringUtils.isNotBlank(answer) && StringUtils.isNumeric(answer)){ + Integer amount = Integer.valueOf(answer); + if( !map.containsKey(key) ){ + map.put(key, amount); + }else{ + int value = map.get(key) + amount; + map.put(key, value); + } + } } } listMap.add(map);