Index: ssts-web/src/main/webapp/jasperRtp/disinfectionFractionDefective.jasper =================================================================== diff -u -r12331 -r16451 Binary files differ Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r16449 -r16451 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 16449) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 16451) @@ -2,6 +2,7 @@ import java.io.File; import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -1758,49 +1759,35 @@ sourceMap.put("灭菌总数", amount); sourceMap.put("灭菌炉数", sterilizationAmount); Iterator iterator = sourceMap.keySet().iterator(); - + //质量监测不合格数列 + double fractionDefective = addMonitoringDataToList( + departCoding, returnList, queryDate, startDate,endDate, amount); // 各类型包数量 while (iterator.hasNext()) { String title = iterator.next(); DisinfectionFractionDefectiveBean bean = new DisinfectionFractionDefectiveBean(); bean.setDate(queryDate); - bean.setResult("" + sourceMap.get(title)); + bean.setResult(sourceMap.get(title)); bean.setTitle(title); bean.setTitleSort(sourceSortMap.get(title)); + bean.setPercentage(fractionDefective); returnList.add(bean); } - // 质量监测不合格数列 - String monitoringSql = "select fd.formName,sum(qi.amount) from QualityMonitoringInstance qi ,FormInstance fi," - + "FormDefinition fd,QualityMonitoringDefinition qd" - + " where qi.id = fi.id and fi.formDefinition_id = fd.id and fd.id = qd.id and fi.orgUnitCoding = '"+departCoding+"'" - + " and qd.responsibilitypart = '灭菌管理' and fd.formType = '质量监测' and fd.departcodes like '%"+departCoding+"%' " - + " and qi.datetime between " - + dateQueryAdapter.dateAdapter(startDate) - + " and " - + dateQueryAdapter.dateAdapter(endDate) - + " group by fd.formName"; - Integer unqualifiedAmount = getQualityMonitoringSource( - monitoringSql, queryDate, returnList); - // 不合格率列 - DisinfectionFractionDefectiveBean bean = getFractionDefective( - amount, unqualifiedAmount, queryDate); - returnList.add(bean); } // 月合计汇总行 Map totalRowMap = new HashMap(); Integer monthUnqualifiedAmount = 0; // 月不合格总数 for (DisinfectionFractionDefectiveBean bean : returnList) { String title = bean.getTitle(); - String result = bean.getResult(); - if (!title.equals("不合格率") && totalRowMap.get(title) == null) { - totalRowMap.put(title, Integer.valueOf(result)); - } else if (!title.equals("不合格率") - && totalRowMap.get(title) != null) { + Integer result = bean.getResult(); + if (totalRowMap.get(title) == null) { + totalRowMap.put(title, result); + } else if (totalRowMap.get(title) != null) { totalRowMap.put(title, - (Integer.valueOf(result) + totalRowMap.get(title))); + (result + totalRowMap.get(title))); } if (bean.getTitleSort() == 7) { - monthUnqualifiedAmount += Integer.valueOf(result); + monthUnqualifiedAmount += result; } } Integer monthTotalAmount = totalRowMap.get("灭菌总数"); // 月灭菌总数 @@ -1812,77 +1799,69 @@ Integer result = totalRowMap.get(title); DisinfectionFractionDefectiveBean bean = new DisinfectionFractionDefectiveBean(); bean.setDate("合计"); - bean.setResult("" + result); + bean.setResult(result); bean.setTitle(title); Integer sort = sourceSortMap.get(title); if (sort == null) { sort = 7; } bean.setTitleSort(sort); + Double fractionDefective = 0.00; + if(monthTotalAmount > 0 && monthUnqualifiedAmount > 0){ + fractionDefective = new BigDecimal(monthUnqualifiedAmount).divide(new BigDecimal(monthTotalAmount),4,RoundingMode.HALF_UP).doubleValue(); + } + bean.setPercentage(fractionDefective); returnList.add(bean); } } catch (Exception e) { } - DisinfectionFractionDefectiveBean bean = new DisinfectionFractionDefectiveBean(); - bean.setDate("合计"); - - double fractionDefective = 0.00; - if (monthTotalAmount != null && monthTotalAmount != 0 - && monthUnqualifiedAmount != 0) { - fractionDefective = new BigDecimal(monthUnqualifiedAmount) - .divide(new BigDecimal(monthTotalAmount), 4, - BigDecimal.ROUND_HALF_UP).doubleValue(); - fractionDefective = new BigDecimal(fractionDefective).multiply( - new BigDecimal(100)).doubleValue(); - } - bean.setResult("" + fractionDefective + "%"); - bean.setTitle("不合格率"); - bean.setTitleSort(8); - returnList.add(bean); } return returnList; } - public DisinfectionFractionDefectiveBean getFractionDefective( - Integer totalAmount, Integer unqualifiedAmount, String date) { - DisinfectionFractionDefectiveBean bean = new DisinfectionFractionDefectiveBean(); - bean.setTitleSort(8); - bean.setTitle("不合格率"); - double fractionDefective = 0.00; - if (totalAmount != 0 && unqualifiedAmount != 0) { - fractionDefective = new BigDecimal(unqualifiedAmount).divide( - new BigDecimal(totalAmount), 4, BigDecimal.ROUND_HALF_UP) - .doubleValue(); - fractionDefective = new BigDecimal(fractionDefective).multiply( - new BigDecimal(100)).doubleValue(); - } - bean.setResult("" + fractionDefective + "%"); - bean.setDate(date); - return bean; - } - - public Integer getQualityMonitoringSource(String sql, String date, - List list) { - ResultSet rs = objectDao.executeSql(sql); - Integer totalAmount = 0; + private double addMonitoringDataToList(String departCoding, + List returnList, + String queryDate, String startDate, String endDate, Integer amount) { + String monitoringSql = "select fd.formName,sum(qi.amount) from QualityMonitoringInstance qi ,FormInstance fi," + + "FormDefinition fd,QualityMonitoringDefinition qd" + + " where qi.id = fi.id and fi.formDefinition_id = fd.id and fd.id = qd.id and fi.orgUnitCoding = '"+departCoding+"'" + + " and qd.responsibilitypart = '灭菌管理' and fd.formType = '质量监测' and fd.departcodes like '%"+departCoding+"%' " + + " and qi.datetime between " + + dateQueryAdapter.dateAdapter(startDate) + + " and " + + dateQueryAdapter.dateAdapter(endDate) + + " group by fd.formName"; + + ResultSet rs = objectDao.executeSql(monitoringSql); + Integer unqualifiedAmount = 0; + Map monitoringMap = new HashMap(); try { while (rs.next()) { String name = rs.getString(1); - Integer amount = rs.getInt(2); - totalAmount += amount; - DisinfectionFractionDefectiveBean bean = new DisinfectionFractionDefectiveBean(); - bean.setDate(date); - bean.setResult("" + amount); - bean.setTitle(name); - bean.setTitleSort(7); - list.add(bean); + Integer tmpAmount = rs.getInt(2); + unqualifiedAmount += tmpAmount; + monitoringMap.put(name, tmpAmount); } } catch (Exception e) { e.printStackTrace(); - }finally { + } finally { DatabaseUtil.closeResultSetAndStatement(rs); } - return totalAmount; + + double fractionDefective = 0.00; + if (amount != 0 && unqualifiedAmount != 0) { + fractionDefective = new BigDecimal(unqualifiedAmount).divide(new BigDecimal(amount),4,RoundingMode.HALF_UP).doubleValue(); + } + for (String monitoringName : monitoringMap.keySet()) { + DisinfectionFractionDefectiveBean bean = new DisinfectionFractionDefectiveBean(); + bean.setDate(queryDate); + bean.setResult(monitoringMap.get(monitoringName)); + bean.setTitle(monitoringName); + bean.setPercentage(fractionDefective); + bean.setTitleSort(7); + returnList.add(bean); + } + return fractionDefective; } @Override Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/DisinfectionFractionDefectiveBean.java =================================================================== diff -u -r12331 -r16451 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/DisinfectionFractionDefectiveBean.java (.../DisinfectionFractionDefectiveBean.java) (revision 12331) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/DisinfectionFractionDefectiveBean.java (.../DisinfectionFractionDefectiveBean.java) (revision 16451) @@ -22,7 +22,10 @@ private String title; - private String result; + private Integer result; + + private Double percentage;//不合格率 + public String getDate() { return date; @@ -48,15 +51,23 @@ this.title = title; } - public String getResult() { + public Integer getResult() { return result; } - public void setResult(String result) { + public void setResult(Integer result) { this.result = result; } - public static List getDateOfMonth(String month) { + public Double getPercentage() { + return percentage; + } + + public void setPercentage(Double percentage) { + this.percentage = percentage; + } + + public static List getDateOfMonth(String month) { List list = new ArrayList(); try{ Date date = new SimpleDateFormat("yyyy-MM").parse(month); @@ -89,6 +100,6 @@ } return list; - } - + } + } Index: ssts-web/src/main/webapp/jasperRtp/disinfectionFractionDefective.jrxml =================================================================== diff -u -r12331 -r16451 --- ssts-web/src/main/webapp/jasperRtp/disinfectionFractionDefective.jrxml (.../disinfectionFractionDefective.jrxml) (revision 12331) +++ ssts-web/src/main/webapp/jasperRtp/disinfectionFractionDefective.jrxml (.../disinfectionFractionDefective.jrxml) (revision 16451) @@ -31,13 +31,10 @@ - - - - + @@ -46,6 +43,9 @@ + + + @@ -63,19 +63,19 @@ - + - + - + - + @@ -85,7 +85,7 @@ - + @@ -94,121 +94,127 @@ - + + + + + - + - + - + + + + + + + + + + + + - + - + - + - + - + + + + + - + - + + + + - + - + - - + + - - - - - - - + + - - - - + + + + + + + + - - + + - - - - - - + - - - - - - + - - - - -