Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java =================================================================== diff -u -r40302 -r40450 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 40302) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 40450) @@ -842,6 +842,21 @@ title = "供应室护理质量指标统计表"; } JSONArray dataIndexsArray = dataConfigObj.optJSONArray("dataIndexsArray"); + //移除一些在日期范围和查询具体天数种不查询的指标 + if(dataIndexsArray != null && ("日期范围".equals(queryScope) || "天".equals(queryScope))){ + Iterator obj = dataIndexsArray.iterator(); + while(obj.hasNext()){ + JSONObject dataIndexObj = obj.next(); + String dataIndexSource = dataIndexObj.optString("dataIndexSource"); + if("设备设施定期维护检测完成率(清洗)".equals(dataIndexSource) || "设备设施定期维护检测完成率(灭菌)".equals(dataIndexSource) + || "设备设施定期维护完成率".equals(dataIndexSource) || "设备设施定期检测完成率".equals(dataIndexSource) + || "继续教育率".equals(dataIndexSource) + || "从业人员离职率".equals(dataIndexSource) + || "从业人员离岗率".equals(dataIndexSource)){ + obj.remove(); + } + } + } Set ownGroups = null; Set sterilizationmodes = null; Map descriptionOfDataIndexMap = new HashMap(); Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/SupplyRoomQualityQuota.java =================================================================== diff -u -r36887 -r40450 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/SupplyRoomQualityQuota.java (.../SupplyRoomQualityQuota.java) (revision 36887) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/SupplyRoomQualityQuota.java (.../SupplyRoomQualityQuota.java) (revision 40450) @@ -61,6 +61,7 @@ public static String DATAINDEXSOURCE_STERILIZER_USEAMOUNT_QUALIFIEDRATIO = "灭菌炉次合格率"; public static String DATAINDEXSOURCE_STERILIZER_LOAD_QUALIFIEDRATIO = "灭菌装载合格率"; public static String DATAINDEXSOURCE_OCCUPATIONAL_EXPOSURE_INCIDENCE = "职业暴露发生率"; + public static String DATAINDEXSOURCE_FOREIGNTOUSSE_WASHRETURN_QUALIFIEDRATIO = "外来器械包清洗消毒返还合格率"; /** * 灭菌情况确认人srSituationComfirmer不为空的灭菌记录条数 */ @@ -92,6 +93,28 @@ */ public static String DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_RATIO = "设备设施定期维护检测完成率(灭菌)"; /** + * 设备设施定期维护完成率 + */ + public static String DATAINDEXSOURCE_MAINTENANCECOMPLETION_RATIO = "设备设施定期维护完成率"; + /** + * 设备设施定期检测完成率 + */ + public static String DATAINDEXSOURCE_MONITORCOMPLETION_RATIO = "设备设施定期检测完成率"; + /** + * 继续教育率 + */ + public static String DATAINDEXSOURCE_CONTINUING_EDUCATION_RATIO = "继续教育率"; + + /** + * 从业人员离职率 + */ + public static String DATAINDEXSOURCE_RESIGNATIONS_RATIO = "从业人员离职率"; + + /** + * 从业人员离岗率 + */ + public static String DATAINDEXSOURCE_OFFTHEJOB_RATIO = "从业人员离岗率"; + /** * 交叉报表的列名称(月份和天) */ private String columnName; Index: forgon-tools/src/main/java/com/forgon/tools/date/DateTools.java =================================================================== diff -u -r38737 -r40450 --- forgon-tools/src/main/java/com/forgon/tools/date/DateTools.java (.../DateTools.java) (revision 38737) +++ forgon-tools/src/main/java/com/forgon/tools/date/DateTools.java (.../DateTools.java) (revision 40450) @@ -5,11 +5,10 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; import java.time.format.DateTimeFormatter; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Locale; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1140,5 +1139,71 @@ } catch (ParseException e) {} return date; } - + + /** + * 查询年的天数、月的天数、上下半年的天数 + * @param year 年 + * @param month 月(可选) + * @param searchThisYearAndLastYear 是否同时查询去年 + * @return 包含天数信息的Map + */ + public static Map getDays(int year, Integer month, boolean searchThisYearAndLastYear) { + Map daysMap = new HashMap<>(); + + // 处理年份天数查询 + daysMap.put(String.valueOf(year), processYearDays(year)); + // 如果需要查询去年 + if (searchThisYearAndLastYear) { + daysMap.put(String.valueOf(year - 1), processYearDays(year - 1)); + } + // 如果指定了月份 + else if (month != null) { + daysMap.put(String.format("%02d", month), processMonthDays(year, month)); + } + // 默认查询全年各月及上下半年天数 + else { + processFullYearDays(year, daysMap); + } + return daysMap; + } + + /** + * 处理指定年份的天数 + */ + private static int processYearDays(int year) { + return Year.of(year).length(); + } + + /** + * 处理指定月份的天数 + */ + private static int processMonthDays(int year, int month) { + YearMonth yearMonth = YearMonth.of(year, month); + return yearMonth.lengthOfMonth(); + } + + /** + * 处理全年各月及上下半年天数 + */ + private static void processFullYearDays(int year, Map daysMap) { + int firstHalfDays = 0; + int secondHalfDays = 0; + + for (int month = 1; month <= 12; month++) { + YearMonth yearMonth = YearMonth.of(year, month); + int daysInMonth = yearMonth.lengthOfMonth(); + + String monthKey = String.format("%02d", month); + daysMap.put(monthKey, daysInMonth); + + if (month <= 6) { + firstHalfDays += daysInMonth; + } else { + secondHalfDays += daysInMonth; + } + } + + daysMap.put("firstHalfOfYearDays", firstHalfDays); + daysMap.put("secondHalfOfYearDays", secondHalfDays); + } } Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/SupplyRoomQualityQuotaHelper.java =================================================================== diff -u -r38737 -r40450 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/SupplyRoomQualityQuotaHelper.java (.../SupplyRoomQualityQuotaHelper.java) (revision 38737) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/SupplyRoomQualityQuotaHelper.java (.../SupplyRoomQualityQuotaHelper.java) (revision 40450) @@ -14,7 +14,7 @@ import java.util.Map; import java.util.Set; import java.util.Map.Entry; - +import com.forgon.tools.date.DateTools; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -122,7 +122,7 @@ value = MapUtils.getString(result, key, "0"); } if(onlyCalcRatio){ - value = MapUtils.getString(result, key + SupplyRoomQualityQuota.RATIO, ""); + value = MapUtils.getString(result, key + SupplyRoomQualityQuota.RATIO, "0%"); SupplyRoomQualityQuota vo = new SupplyRoomQualityQuota(quotaName , rowSerialNumber, firstDayToLastDay.get(i - 1), i, value, dataIndexsAsRows); list.add(vo); }else{ @@ -136,7 +136,7 @@ */ String value = MapUtils.getString(result, SupplyRoomQualityQuota.TOTAL, "0"); if(onlyCalcRatio){ - String ratio = MapUtils.getString(result, (SupplyRoomQualityQuota.TOTAL + SupplyRoomQualityQuota.RATIO), ""); + String ratio = MapUtils.getString(result, (SupplyRoomQualityQuota.TOTAL + SupplyRoomQualityQuota.RATIO), "0%"); SupplyRoomQualityQuota ratioVo = new SupplyRoomQualityQuota(quotaName, rowSerialNumber, SupplyRoomQualityQuota.TOTAL , size + 1, ratio, dataIndexsAsRows); list.add(ratioVo); }else{ @@ -497,7 +497,7 @@ if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_COUNT)){ sterilizerMaintenanceMap = new HashMap(); } - getMaintenance_completion_count(departmentCode, SupplyRoomQualityQuota.DAY, betweenSql, null, null, deviceMaintenanceMap, rinserMaintenanceMap, sterilizerMaintenanceMap, null,null); + getMaintenance_completion_count(departmentCode, SupplyRoomQualityQuota.DAY, betweenSql, null, null, deviceMaintenanceMap, rinserMaintenanceMap, sterilizerMaintenanceMap, null,null , DeviceMaintenance.MAINTENANCE_TYPE_MAINTENANCE); } /** @@ -519,7 +519,14 @@ } getRatio(occupational_exposure_incidence, totalNumberOfPeopleMap, null); }*/ - + Map dataindexsource_foreigntousse_washreturn_qualifiedratioMap = null; + if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_FOREIGNTOUSSE_WASHRETURN_QUALIFIEDRATIO)){ + Map totalMap = new HashMap<>(); + dataindexsource_foreigntousse_washreturn_qualifiedratioMap = new HashMap<>(); + getDataindexsource_foreigntousse_wash_return_qualifiedratio(departmentCode, month, SupplyRoomQualityQuota.DAY, startTime, endTime, null + ,dataindexsource_foreigntousse_washreturn_qualifiedratioMap, totalMap); + getRatio(dataindexsource_foreigntousse_washreturn_qualifiedratioMap, totalMap, null); + } int i = 0;//序号 for (int j = 0; j < dataConfigArr.size(); j++) { JSONObject dataConfig = (JSONObject)dataConfigArr.get(j); @@ -621,6 +628,8 @@ getSupplyRoomQualityQuota(list, item_invoice_qualified, dataIndexNameForDisplay, i++, firstDayToLastDay, false, dataIndexsAsRows); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_ITEM_INVOICE_QUALIFIEDRATIO.equals(dataIndexSource)){ getSupplyRoomQualityQuota(list, item_invoice_qualified, dataIndexNameForDisplay, i++, firstDayToLastDay, true, dataIndexsAsRows); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_FOREIGNTOUSSE_WASHRETURN_QUALIFIEDRATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, dataindexsource_foreigntousse_washreturn_qualifiedratioMap, dataIndexNameForDisplay, i++, firstDayToLastDay, true, dataIndexsAsRows); } } return list; @@ -968,41 +977,186 @@ Map deviceMaintenanceMap = null;//设备维护完成次数 Map rinserMaintenanceMap = null;//设备维护完成次数(清洗机) 设备设施定期维护检测完成率(清洗) Map sterilizerMaintenanceMap = null;//设备维护完成次数(灭菌炉) 设备设施定期维护检测完成率(灭菌) + Map daysMap = null; if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_COUNT) || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_COUNT) || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_COUNT) || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_RATIO) - || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_RATIO)){ - if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_COUNT)){ - deviceMaintenanceMap = new HashMap(); - } - if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_COUNT) - || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_RATIO)){ - rinserMaintenanceMap = new HashMap(); - } - if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_COUNT) - || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_RATIO)){ - sterilizerMaintenanceMap = new HashMap(); - } + || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_RATIO) + || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCECOMPLETION_RATIO)){ + deviceMaintenanceMap = new HashMap(); + Map maintenanceCycleMap = new HashMap<>(); + Map rinserMaintenanceCycleMap = new HashMap<>(); Set rinserNames = null; Set sterilizerNames = null; - getMaintenance_completion_count(departmentCode, format, betweenSql, queryScope, year, deviceMaintenanceMap, rinserMaintenanceMap, sterilizerMaintenanceMap,rinserNames,sterilizerNames); + + daysMap = DateTools.getDays(Integer.parseInt(year), null, StringUtils.isNotBlank(lastYearTime)); + + rinserMaintenanceMap = new HashMap<>(); + rinserNames = new HashSet<>(); + ResultSet rs = null; + try { + rs = objectDao.executeSql("select name,maintenanceCycle from " + Rinser.class.getSimpleName()+" where useStatus='在用' and maintenanceCycle>0 and name not like '%手%' "); + while (rs.next()) { + String name = rs.getString("name"); + rinserNames.add(name); + int maintenanceCycle = rs.getInt("maintenanceCycle"); + rinserMaintenanceCycleMap.put(name, maintenanceCycle); + maintenanceCycleMap.put(name, maintenanceCycle); + } + } catch (Exception e) { + logger.error(e); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + Map sterilizerMaintenanceCycleMap = new HashMap<>(); + sterilizerMaintenanceMap = new HashMap<>(); + sterilizerNames = new HashSet<>(); + ResultSet rs2 = null; + try { + rs2 = objectDao.executeSql("select name,maintenanceCycle from " + Sterilizer.class.getSimpleName()+" where useStatus='在用' and maintenanceCycle>0 "); + while (rs2.next()) { + String name = rs2.getString("name"); + sterilizerNames.add(name); + int maintenanceCycle = rs2.getInt("maintenanceCycle"); + sterilizerMaintenanceCycleMap.put(name, maintenanceCycle); + maintenanceCycleMap.put(name, maintenanceCycle); + } + } catch (Exception e) { + logger.error(e); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs2); + } + getMaintenance_completion_count(departmentCode, format, betweenSql, queryScope, year, deviceMaintenanceMap, rinserMaintenanceMap, sterilizerMaintenanceMap,rinserNames,sterilizerNames, DeviceMaintenance.MAINTENANCE_TYPE_MAINTENANCE); if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_RATIO)){ - if(rinserNames == null){ - rinserNames = objectDao.getStringSet("select distinct name from " + Rinser.class.getSimpleName()+" where useStatus='在用' and name not like '%手%'", "无"); + Map totalNumberOfRinserMap = new HashMap(); + if(MapUtils.isNotEmpty(rinserMaintenanceCycleMap)){ + if(StringUtils.isNotBlank(lastYearTime)){ + String lastYearStr = String.valueOf(Integer.parseInt(year) - 1); + Integer dayValue = daysMap.get(lastYearStr); + Integer totalAmout = 0; + for (Integer maintenanceCycle : rinserMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfRinserMap.put("去年", totalAmout); + dayValue = daysMap.get(year); + totalAmout = 0; + for (Integer maintenanceCycle : rinserMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfRinserMap.put("今年", totalAmout); + }else{ + for (int i = 1; i <= 12; i++) { + String key = ""; + if (i > 9) { + key = "" + i; + } else { + key = "0" + i; + } + Integer dayValue = daysMap.get(key); + Integer totalAmout = 0; + for (Integer maintenanceCycle : rinserMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + + totalNumberOfRinserMap.put(key, totalAmout); + } + Integer dayValue = daysMap.get(year); + Integer totalAmout = 0; + for (Integer maintenanceCycle : rinserMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfRinserMap.put(SupplyRoomQualityQuota.TOTAL, totalAmout); + } } - int rinserCount = rinserNames == null?MathTools.ZERO_INTEGER:rinserNames.size(); - Map totalNumberOfRinserMap = getFixedValueMap(rinserCount); getRatio(rinserMaintenanceMap, totalNumberOfRinserMap, null,true); } if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_RATIO)){ - if(sterilizerNames == null){ - sterilizerNames = objectDao.getStringSet("select distinct name from " + Sterilizer.class.getSimpleName() + " where useStatus='在用'", "无"); + Map totalNumberOfSterilizerMap = new HashMap<>(); + if(MapUtils.isNotEmpty(sterilizerMaintenanceCycleMap)) { + if (StringUtils.isNotBlank(lastYearTime)) { + String lastYearStr = String.valueOf(Integer.parseInt(year) - 1); + Integer dayValue = daysMap.get(lastYearStr); + Integer totalAmout = 0; + for (Integer maintenanceCycle : sterilizerMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put("去年", totalAmout); + dayValue = daysMap.get(year); + totalAmout = 0; + for (Integer maintenanceCycle : sterilizerMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put("今年", totalAmout); + } else { + for (int i = 1; i <= 12; i++) { + String key = ""; + if (i > 9) { + key = "" + i; + } else { + key = "0" + i; + } + Integer dayValue = daysMap.get(key); + Integer totalAmout = 0; + for (Integer maintenanceCycle : sterilizerMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + + totalNumberOfSterilizerMap.put(key, totalAmout); + } + Integer dayValue = daysMap.get(year); + Integer totalAmout = 0; + for (Integer maintenanceCycle : sterilizerMaintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put(SupplyRoomQualityQuota.TOTAL, totalAmout); + } } - int sterilizerCount = sterilizerNames == null?MathTools.ZERO_INTEGER:sterilizerNames.size(); - Map totalNumberOfSterilizerMap = getFixedValueMap(sterilizerCount); getRatio(sterilizerMaintenanceMap, totalNumberOfSterilizerMap, null,true); } + if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCECOMPLETION_RATIO)){ + Map totalNumberOfSterilizerMap = new HashMap<>(); + if(MapUtils.isNotEmpty(maintenanceCycleMap)) { + if (StringUtils.isNotBlank(lastYearTime)) { + String lastYearStr = String.valueOf(Integer.parseInt(year) - 1); + Integer dayValue = daysMap.get(lastYearStr); + Integer totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put("去年", totalAmout); + dayValue = daysMap.get(year); + totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put("今年", totalAmout); + } else { + for (int i = 1; i <= 12; i++) { + String key = ""; + if (i > 9) { + key = "" + i; + } else { + key = "0" + i; + } + Integer dayValue = daysMap.get(key); + Integer totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + + totalNumberOfSterilizerMap.put(key, totalAmout); + } + Integer dayValue = daysMap.get(year); + Integer totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put(SupplyRoomQualityQuota.TOTAL, totalAmout); + } + } + getRatio(deviceMaintenanceMap, totalNumberOfSterilizerMap, null,true); + } } /** @@ -1033,7 +1187,123 @@ } getRatio(occupational_exposure_incidence, totalNumberOfPeopleMap, null,true); } - + //外来器械包清洗消毒返还合格率 + Map dataindexsource_foreigntousse_washreturn_qualifiedratioMap = null; + if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_FOREIGNTOUSSE_WASHRETURN_QUALIFIEDRATIO)){ + Map totalMap = new HashMap<>(); + dataindexsource_foreigntousse_washreturn_qualifiedratioMap = new HashMap<>(); + getDataindexsource_foreigntousse_wash_return_qualifiedratio(departmentCode, year, queryScope, startTime, endTime, null + ,dataindexsource_foreigntousse_washreturn_qualifiedratioMap, totalMap); + getRatio(dataindexsource_foreigntousse_washreturn_qualifiedratioMap, totalMap, null,true); + } + //设备设施定期检测 + Map deviceMonitorMap = null;//设备设施定期检测完成次数 + Map rinserMonitorMap = null;//设备设施定期检测完成次数(清洗机) + Map sterilizerMonitorMap = null;//设备设施定期检测完成次数(灭菌炉) + if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_MONITORCOMPLETION_RATIO)){ + deviceMonitorMap = new HashMap(); + Map maintenanceCycleMap = new HashMap<>(); + Map rinserMaintenanceCycleMap = new HashMap<>(); + Set rinserNames = new HashSet<>(); + Set sterilizerNames = null; + if(daysMap == null){ + daysMap = DateTools.getDays(Integer.parseInt(year), null, StringUtils.isNotBlank(lastYearTime)); + } + + rinserMonitorMap = new HashMap<>(); + ResultSet rs = null; + try { + rs = objectDao.executeSql("select name,maintenanceCycle from " + Rinser.class.getSimpleName()+" where useStatus='在用' and maintenanceCycle>0 and name not like '%手%' "); + while (rs.next()) { + String name = rs.getString("name"); + rinserNames.add(name); + int maintenanceCycle = rs.getInt("maintenanceCycle"); + rinserMaintenanceCycleMap.put(name, maintenanceCycle); + maintenanceCycleMap.put(name, maintenanceCycle); + } + } catch (Exception e) { + logger.error(e); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + Map sterilizerMaintenanceCycleMap = new HashMap<>(); + sterilizerMonitorMap = new HashMap<>(); + sterilizerNames = new HashSet<>(); + ResultSet rs2 = null; + try { + rs2 = objectDao.executeSql("select name,maintenanceCycle from " + Sterilizer.class.getSimpleName()+" where useStatus='在用' and maintenanceCycle>0 "); + while (rs2.next()) { + String name = rs2.getString("name"); + sterilizerNames.add(name); + int maintenanceCycle = rs2.getInt("maintenanceCycle"); + sterilizerMaintenanceCycleMap.put(name, maintenanceCycle); + maintenanceCycleMap.put(name, maintenanceCycle); + } + } catch (Exception e) { + logger.error(e); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs2); + } + getMaintenance_completion_count(departmentCode, format, betweenSql, queryScope, year, deviceMonitorMap, rinserMonitorMap, sterilizerMonitorMap,rinserNames,sterilizerNames, DeviceMaintenance.MAINTENANCE_TYPE_PERIODIC_TESTING); + + Map totalNumberOfSterilizerMap = new HashMap<>(); + if(MapUtils.isNotEmpty(maintenanceCycleMap)) { + if (StringUtils.isNotBlank(lastYearTime)) { + String lastYearStr = String.valueOf(Integer.parseInt(year) - 1); + Integer dayValue = daysMap.get(lastYearStr); + Integer totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put("去年", totalAmout); + dayValue = daysMap.get(year); + totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put("今年", totalAmout); + } else { + for (int i = 1; i <= 12; i++) { + String key = ""; + if (i > 9) { + key = "" + i; + } else { + key = "0" + i; + } + Integer dayValue = daysMap.get(key); + Integer totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + + totalNumberOfSterilizerMap.put(key, totalAmout); + } + Integer dayValue = daysMap.get(year); + Integer totalAmout = 0; + for (Integer maintenanceCycle : maintenanceCycleMap.values()) { + totalAmout += dayValue / maintenanceCycle; + } + totalNumberOfSterilizerMap.put(SupplyRoomQualityQuota.TOTAL, totalAmout); + } + } + getRatio(deviceMonitorMap, totalNumberOfSterilizerMap, null,true); + } + Map offthejobMap = null;//从业人员离岗率 + Map resignationsMap = null;//从业人员离职率 + Map continuing_educationMap = null;//继续教育率 + if(dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_OFFTHEJOB_RATIO) + || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_RESIGNATIONS_RATIO) + || dataIndexSources.contains(SupplyRoomQualityQuota.DATAINDEXSOURCE_CONTINUING_EDUCATION_RATIO)){ + Map totalMap = new HashMap<>(); + offthejobMap = new HashMap<>(); + resignationsMap = new HashMap<>(); + continuing_educationMap = new HashMap<>(); + getOrgUnitUserAmountMonthlyData(departmentCode, year, queryScope, startTime, endTime, null + ,offthejobMap ,resignationsMap,continuing_educationMap, totalMap); + getRatio(offthejobMap, totalMap, null,true); + getRatio(resignationsMap, totalMap, null,true); + getRatio(continuing_educationMap, totalMap, null,true); + } int i = 0;//序号 for (int k = 0; k < dataConfigArr.size(); k++) { JSONObject dataConfig = (JSONObject)dataConfigArr.get(k); @@ -1112,11 +1382,11 @@ getSupplyRoomQualityQuota(list, replaceKey(total_by_sterilizationmodeMap.get(sterilizationmode), queryScope, year), dataIndexNameForDisplay + " (" + sterilizationmode + ")", i++, false, dataIndexsAsRows,queryScope); } }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_COUNT.equals(dataIndexSource)){ - getSupplyRoomQualityQuota(list, deviceMaintenanceMap, dataIndexNameForDisplay, i++, false, dataIndexsAsRows,queryScope); + getSupplyRoomQualityQuota(list, deviceMonitorMap, dataIndexNameForDisplay, i++, false, dataIndexsAsRows,queryScope); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_COUNT.equals(dataIndexSource)){ - getSupplyRoomQualityQuota(list, rinserMaintenanceMap, dataIndexNameForDisplay, i++, false, dataIndexsAsRows,queryScope); + getSupplyRoomQualityQuota(list, rinserMonitorMap, dataIndexNameForDisplay, i++, false, dataIndexsAsRows,queryScope); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_COUNT.equals(dataIndexSource)){ - getSupplyRoomQualityQuota(list, sterilizerMaintenanceMap, dataIndexNameForDisplay, i++, false, dataIndexsAsRows,queryScope); + getSupplyRoomQualityQuota(list, sterilizerMonitorMap, dataIndexNameForDisplay, i++, false, dataIndexsAsRows,queryScope); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_STERILIZER_USEAMOUNT_QUALIFIEDRATIO.equals(dataIndexSource)){ getSupplyRoomQualityQuota(list, sterilizerUseQualified, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_DISPOSABLEGOODS_WASH_QUALIFIED.equals(dataIndexSource)){ @@ -1132,9 +1402,21 @@ }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_ITEM_INVOICE_QUALIFIEDRATIO.equals(dataIndexSource)){ getSupplyRoomQualityQuota(list, item_invoice_qualified, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_RINSER_RATIO.equals(dataIndexSource)){ - getSupplyRoomQualityQuota(list, rinserMaintenanceMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + getSupplyRoomQualityQuota(list, rinserMonitorMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCE_COMPLETION_STERILIZER_RATIO.equals(dataIndexSource)){ - getSupplyRoomQualityQuota(list, sterilizerMaintenanceMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + getSupplyRoomQualityQuota(list, sterilizerMonitorMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_FOREIGNTOUSSE_WASHRETURN_QUALIFIEDRATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, dataindexsource_foreigntousse_washreturn_qualifiedratioMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MAINTENANCECOMPLETION_RATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, deviceMaintenanceMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_MONITORCOMPLETION_RATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, deviceMonitorMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_OFFTHEJOB_RATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, offthejobMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_RESIGNATIONS_RATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, resignationsMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); + }else if(SupplyRoomQualityQuota.DATAINDEXSOURCE_CONTINUING_EDUCATION_RATIO.equals(dataIndexSource)){ + getSupplyRoomQualityQuota(list, continuing_educationMap, dataIndexNameForDisplay, i++, true, dataIndexsAsRows,queryScope); } } return list; @@ -1816,18 +2098,18 @@ */ private void getMaintenance_completion_count(String orgUnitCoding, String format, String betweenSql, String queryScope, String thisYear , Map deviceMaintenanceMap, Map rinserMaintenanceMap, Map sterilizerMaintenanceMap - ,Set rinserNames, Set sterilizerNames){ - ResultSet rs = null; + ,Set rinserNames, Set sterilizerNames , String type){ boolean isDeviceMaintenanceCus = false; if(rinserMaintenanceMap != null || sterilizerMaintenanceMap != null){ isDeviceMaintenanceCus = CssdUtils.getSystemSetConfigByNameBool("isDeviceMaintenanceCus", false); - if(rinserMaintenanceMap != null){ - rinserNames = objectDao.getStringSet("select distinct name from " + Rinser.class.getSimpleName()+" where useStatus='在用' and name not like '%手%'", "无"); + if(rinserMaintenanceMap != null && CollectionUtils.isEmpty(rinserNames)){ + rinserNames = objectDao.getStringSet("select distinct name from " + Rinser.class.getSimpleName()+" where useStatus='在用' and maintenanceCycle>0 and name not like '%手%'", "无"); } - if(sterilizerMaintenanceMap != null){ - sterilizerNames = objectDao.getStringSet("select distinct name from " + Sterilizer.class.getSimpleName() + " where useStatus='在用'", "无"); + if(sterilizerMaintenanceMap != null && CollectionUtils.isEmpty(sterilizerNames)){ + sterilizerNames = objectDao.getStringSet("select distinct name from " + Sterilizer.class.getSimpleName() + " where useStatus='在用' and maintenanceCycle>0 ", "无"); } } + ResultSet rs = null; try { String monthlyStr = null; if("mm".equals(format) || "yyyy".equals(format)){ @@ -1856,6 +2138,11 @@ sql.append(orgUnitCoding); sql.append("' "); } + if(DeviceMaintenance.MAINTENANCE_TYPE_MAINTENANCE.equals(type)){ + sql.append(" and d.maintenanceType='"+ DeviceMaintenance.MAINTENANCE_TYPE_MAINTENANCE +"' "); + }else if(DeviceMaintenance.MAINTENANCE_TYPE_PERIODIC_TESTING.equals(type)){ + sql.append(" and d.maintenanceType='"+ DeviceMaintenance.MAINTENANCE_TYPE_PERIODIC_TESTING +"' "); + } sql.append(" and d.maintenanceTime "); sql.append(betweenSql); sql.append(" group by "); @@ -2104,7 +2391,9 @@ } newQuota.setValue(ratio); }else{ - newQuota.setValue(MathTools.add(Integer.valueOf(newQuota.getValue()), Integer.valueOf(quota.getValue())).intValue() + ""); + int newQuotaValue = StringUtils.isBlank(newQuota.getValue())?0:Integer.parseInt(newQuota.getValue()); + int quotaValue = StringUtils.isBlank(quota.getValue())?0:Integer.parseInt(quota.getValue()); + newQuota.setValue(MathTools.add(newQuotaValue, Integer.valueOf(quotaValue)).intValue() + ""); } }else{ newQuota = new SupplyRoomQualityQuota(); @@ -2227,4 +2516,172 @@ } return map; } + private void getDataindexsource_foreigntousse_wash_return_qualifiedratio(String departmentCode, String date, String queryScope, String startTime, + String endTime, List firstDayToLastDay, Map numeratorMap, Map totalMap) { + Integer totalNumerator = 0; + Integer totalAmout = 0; + if (StringTools.isNotBlank(departmentCode) + && (StringTools.isNotBlank(date) + || StringTools.isNotBlank(startTime) && StringTools.isNotBlank(endTime))) { + String applicationTimeSql = null; + if (SupplyRoomQualityQuota.DAY.equals(queryScope)) { + startTime = startTime + " 00:00:00"; + endTime = endTime + " 23:59:59"; + applicationTimeSql = dateQueryAdapter.dateConverAdapter("temp.applicationTime", null); + } else if(SupplyRoomQualityQuota.YEAR.equals(queryScope)){ + applicationTimeSql = dateQueryAdapter.dateConverAdapter3("temp.applicationTime", "yyyy"); + }else { + applicationTimeSql = dateQueryAdapter.dateConverAdapter3("temp.applicationTime", "mm"); + startTime = date + "-01-01 00:00:00"; + endTime = DataIndex.getNextYear(date) + " 00:00:00"; + } + StringBuffer sql = new StringBuffer(); + sql.append("select "); + sql.append(applicationTimeSql); + sql.append(" dateTime,sum(sumAmount) sumAmount,sum(cleanQualifiedAmount) cleanQualifiedAmount from (" + + "select ti.amount sumAmount," + + "case when ti.cleanQualified ='是' then ti.amount else 0 end " + + "cleanQualifiedAmount " + + ",ip.applicationTime " + + "from TousseItem ti " + + "join invoicePlan ip on ip.id=ti.recyclingApplication_ID where " + + + " ip.handleDepartCoding='"+ departmentCode +"' and ti.packageStatus in ('已归还','提前归还') ) temp" + + " where " + + dateQueryAdapter.dateAreaSql("temp.applicationTime", startTime, endTime) + + " group by "); + sql.append(applicationTimeSql); + ResultSet rs = null; + try { + rs = objectDao.executeSql(sql.toString()); + while (rs.next()) { + String month = StringTools.defaultString(rs.getString("dateTime")); + int amount = rs.getInt("cleanQualifiedAmount"); + totalNumerator += amount; + if(SupplyRoomQualityQuota.YEAR.equals(queryScope)){ + if(date.equals(month)){ + month = "今年"; + }else{ + month = "去年"; + } + } + numeratorMap.put(month, amount); + int sumAmount = rs.getInt("sumAmount"); + totalAmout += sumAmount; + totalMap.put(month, sumAmount); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + } + numeratorMap.put(SupplyRoomQualityQuota.TOTAL, totalNumerator); + totalMap.put(SupplyRoomQualityQuota.TOTAL, totalAmout); + if (SupplyRoomQualityQuota.DAY.equals(queryScope)) { + dataIndex.convertEveryDay(numeratorMap, firstDayToLastDay); + dataIndex.convertEveryDay(totalMap, firstDayToLastDay); + } else if(SupplyRoomQualityQuota.MONTH.equals(queryScope)){ + dataIndex.convertMonthly(numeratorMap); + dataIndex.convertMonthly(totalMap); + } + } + + /** + * 获取科室人数月度统计的数据 + * @param departmentCode + * @param date + * @param queryScope + * @param startTime + * @param endTime + * @param firstDayToLastDay + * @param numeratorMapOfOffTheJob 从业人员离岗 + * @param numeratorMapOfResignations 从业人员离职 + * @param numeratorMapOfContinuingEducation 继续教育 + * @param totalMap + */ + private void getOrgUnitUserAmountMonthlyData(String departmentCode, String date, String queryScope, String startTime, + String endTime, List firstDayToLastDay + , Map numeratorMapOfOffTheJob + , Map numeratorMapOfResignations + , Map numeratorMapOfContinuingEducation, Map totalMap) { + Integer totalContinuingEducationAmountNumerator = 0; + Integer totalOffTheJobNumerator = 0; + Integer totalResignationsNumerator = 0; + Integer totalAmout = 0; + if (StringTools.isNotBlank(departmentCode) + && (StringTools.isNotBlank(date) + || StringTools.isNotBlank(startTime) && StringTools.isNotBlank(endTime))) { + String timeSql = null; + if (SupplyRoomQualityQuota.DAY.equals(queryScope)) { + startTime = startTime + " 00:00:00"; + endTime = endTime + " 23:59:59"; + timeSql = dateQueryAdapter.dateConverAdapter("oua.yearMonth", null); + } else if(SupplyRoomQualityQuota.YEAR.equals(queryScope)){ + timeSql = dateQueryAdapter.dateConverAdapter3("oua.yearMonth", "yyyy"); + }else { + timeSql = dateQueryAdapter.dateConverAdapter3("oua.yearMonth", "mm"); + startTime = date + "-01-01 00:00:00"; + endTime = DataIndex.getNextYear(date) + " 00:00:00"; + } + StringBuffer sql = new StringBuffer(); + sql.append("select "); + sql.append(timeSql); + sql.append(" dateTime,sum(oua.amount) amount,sum(oua.continuingEducationAmount) continuingEducationAmount,sum(oua.offTheJobAmount) offTheJobAmount ,sum(oua.resignationsAmount) resignationsAmount from " + + OrgUnitUserAmountMonthly.class.getSimpleName() + + " oua where oua.orgUnitCode='" + + departmentCode + "' and " + + dateQueryAdapter.dateAreaSql("oua.yearMonth", startTime, endTime) + + " group by "); + sql.append(timeSql); + ResultSet rs = null; + try { + rs = objectDao.executeSql(sql.toString()); + while (rs.next()) { + String month = StringTools.defaultString(rs.getString("dateTime")); + int continuingEducationAmount = rs.getInt("continuingEducationAmount"); + totalContinuingEducationAmountNumerator += continuingEducationAmount; + if(SupplyRoomQualityQuota.YEAR.equals(queryScope)){ + if(date.equals(month)){ + month = "今年"; + }else{ + month = "去年"; + } + } + numeratorMapOfContinuingEducation.put(month, continuingEducationAmount); + + int offTheJobAmount = rs.getInt("offTheJobAmount"); + totalOffTheJobNumerator += offTheJobAmount; + numeratorMapOfOffTheJob.put(month, offTheJobAmount); + + int resignationsAmount = rs.getInt("resignationsAmount"); + totalResignationsNumerator += resignationsAmount; + numeratorMapOfResignations.put(month, resignationsAmount); + + int amount = rs.getInt("amount"); + totalAmout += amount; + totalMap.put(month, amount); + } + } catch (Exception e) { + logger.error(e.getMessage()); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + } + numeratorMapOfContinuingEducation.put(SupplyRoomQualityQuota.TOTAL, totalContinuingEducationAmountNumerator); + numeratorMapOfOffTheJob.put(SupplyRoomQualityQuota.TOTAL, totalOffTheJobNumerator); + numeratorMapOfResignations.put(SupplyRoomQualityQuota.TOTAL, totalResignationsNumerator); + totalMap.put(SupplyRoomQualityQuota.TOTAL, totalAmout); + if (SupplyRoomQualityQuota.DAY.equals(queryScope)) { + dataIndex.convertEveryDay(numeratorMapOfContinuingEducation, firstDayToLastDay); + dataIndex.convertEveryDay(numeratorMapOfOffTheJob, firstDayToLastDay); + dataIndex.convertEveryDay(numeratorMapOfResignations, firstDayToLastDay); + dataIndex.convertEveryDay(totalMap, firstDayToLastDay); + } else if(SupplyRoomQualityQuota.MONTH.equals(queryScope)){ + dataIndex.convertMonthly(numeratorMapOfContinuingEducation); + dataIndex.convertMonthly(numeratorMapOfOffTheJob); + dataIndex.convertMonthly(numeratorMapOfResignations); + dataIndex.convertMonthly(totalMap); + } + } }