Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/PackingUnqualifieReportHelper.java =================================================================== diff -u --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/PackingUnqualifieReportHelper.java (revision 0) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/PackingUnqualifieReportHelper.java (revision 35801) @@ -0,0 +1,362 @@ +package com.forgon.disinfectsystem.jasperreports.util; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Component; + +import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.jasperreports.javabeansource.PackingFractionDefectiveBean; +import com.forgon.disinfectsystem.reportforms.vo.ReportQueryParams; +import com.forgon.tools.MapTools; +import com.forgon.tools.MathTools; +import com.forgon.tools.date.DateTools; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.util.SqlUtils; + +/** + * 包装区工作量不合格率报表 + * + */ +@Component +public class PackingUnqualifieReportHelper extends ReportHelper{ + /** + * 获取包装区工作量不合格率 + * @param month 查询的月份 格式如 2017-01 + * @param deptCode 查询的科室编码 如 9541 + * @param isHideDisinfection 查询结果是否隐藏消毒物品 + * @param queryDateType 查询时间类型 year or month or day + * @return 包装区工作量及不合格率的bean + */ + public List getPackingFDSource(String startTime, String endTime,String querySupplyRoom,boolean isHideDisinfection, String taskGroup, String queryDateType) { + //构建一些查询需要的信息 + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdfyyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ReportQueryParams params = new ReportQueryParams(objectDao); + params.querySupplyRoom = querySupplyRoom; + //不同查询时间类型的一些处理 + Calendar calendar = Calendar.getInstance(); + Date endDate = calendar.getTime(); + //数据查询的时间类型 queryDateType为年份是值为month 否则day + String dateType; + //查询的开始时间 + String startDateStr; + //查询的结束时间 + String endDateStr; + //开始日期 + Date startDate = null; + //日期差量 查询天为Calendar.MONTH 否则 Calendar.DAY_OF_MONTH + Integer addDateType; + //装配数量map<时间,<列头,数量>> + Map> packingAmountMap = new HashMap>(); + // 装配总数map + Map totalAmountMap = new HashMap(); + //不合格数据map <时间,<表单名称,数量>> + Map> unQualityAmountMap = new HashMap>(); + + if("year".equals(queryDateType)){ + dateType = "month"; + startDateStr = startTime + "-01-01 00:00:00"; + try { + startDate = sdfyyyyMMddHHmmss.parse(startDateStr); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(startDate); + calendar.add(Calendar.YEAR, 1); + endDateStr = sdfyyyyMMdd.format(calendar.getTime()) + " 00:00:00"; + }else if("day".equals(queryDateType)){ + dateType = "day"; + startDateStr = startTime + " 00:00:00"; + endDateStr = endTime + " 23:59:59"; + }else{//按月份查询查询的是天 + dateType = "day"; + startDateStr = startTime + "-01 00:00:00"; + if(StringUtils.isBlank(endTime)){ + try { + startDate = sdfyyyyMMddHHmmss.parse(startDateStr); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(startDate); + calendar.add(Calendar.MONTH, 1); + endDateStr = sdfyyyyMMdd.format(calendar.getTime()) + " 00:00:00"; + }else{ + String[] dateArr = endTime.split("-"); + endDateStr = DateTools.getLastDayOfMonthByDate(dateArr[0], dateArr[1]) + " 23:59:59"; + } + } + if("month".equals(dateType)){ + addDateType = Calendar.MONTH; + params.monthlyStr = dateQueryAdapter.dateToVarchar2("qi.datetime"); + }else{ + addDateType = Calendar.DAY_OF_MONTH; + params.monthlyStr = dateQueryAdapter.dateToVarchar1("qi.datetime"); + } + try { + if(startDate == null){//按月份查询的 如果没传结束月份 前面已经获取过 + startDate = sdfyyyyMMddHHmmss.parse(startDateStr); + } + calendar.setTime(startDate); + endDate = sdfyyyyMMddHHmmss.parse(endDateStr); + } catch (ParseException e) { + e.printStackTrace(); + } + params.betweenSql = String.format(" between %s and %s ", + dateQueryAdapter.dateAdapter(startDate), + dateQueryAdapter.dateAdapter(endDate)); + + + //设置列名和列顺序 + Map sourceSortMap = new HashMap(); + sourceSortMap.put("器械包", 1); + sourceSortMap.put("外来器械包", 2); + sourceSortMap.put("敷料包", 3); + boolean showDisinfectionByPackage = false; + if(isHideDisinfection == false){ + showDisinfectionByPackage = CssdUtils.getSystemSetConfigByNameBool("showDisinfectionByPackage", false); + sourceSortMap.put("消毒物品", 4); + } + sourceSortMap.put("灭菌物品", 5); + sourceSortMap.put("自定义器械包", 6); + sourceSortMap.put("外部代理灭菌", 7); + sourceSortMap.put("自制物品", 8); + sourceSortMap.put("聚合包", 9); + sourceSortMap.put("配包总数", 10); + sourceSortMap.put("超大包", 11); + sourceSortMap.put("大包", 12); + sourceSortMap.put("中包", 13); + sourceSortMap.put("小包", 14); + + setWorkAmountByPackageFilterDisinfectionData(packingAmountMap, totalAmountMap, params, taskGroup, dateType, isHideDisinfection, showDisinfectionByPackage); + setUnQualityAmountMapOfPackingFDSource(unQualityAmountMap, dateType, isHideDisinfection, startDate, endDate, querySupplyRoom); + + //最终返回的表数据 + List returnList = new ArrayList(); + SimpleDateFormat sdf = null; + if("month".equals(dateType)){ + sdf = new SimpleDateFormat("yyyy-MM"); + }else{ + sdf = sdfyyyyMMdd; + } + while(endDate.after(startDate)){ + String thisStartDate = sdf.format(startDate); + // 各类型包数量 + Map tousseTypeMap = null; + if(packingAmountMap.containsKey(thisStartDate)){ + tousseTypeMap = packingAmountMap.get(thisStartDate); + for(Entry entry : tousseTypeMap.entrySet()){ + String title = entry.getKey(); + PackingFractionDefectiveBean bean = new PackingFractionDefectiveBean(); + bean.setDate(thisStartDate); + bean.setResult(entry.getValue()); + bean.setTitle(title); + bean.setTitleSort(sourceSortMap.get(title)); + returnList.add(bean); + } + } + PackingFractionDefectiveBean bean = new PackingFractionDefectiveBean(); + bean.setDate(thisStartDate); + bean.setResult(totalAmountMap.get(thisStartDate)); + String title = "配包总数"; + bean.setTitle(title); + bean.setTitleSort(sourceSortMap.get(title)); + + Integer unQualityTotalAmount = 0; + if(unQualityAmountMap.containsKey(thisStartDate)){ + Map formNameAmountMap = unQualityAmountMap.get(thisStartDate); + for(Entry entry: formNameAmountMap.entrySet()){ + String formName = entry.getKey(); + PackingFractionDefectiveBean unQualitybean = new PackingFractionDefectiveBean(); + Integer amount = entry.getValue(); + unQualityTotalAmount+=amount; + unQualitybean.setDate(thisStartDate); + unQualitybean.setResult(amount); + unQualitybean.setTitle(formName); + unQualitybean.setTitleSort(10); + returnList.add(unQualitybean); + } + } + + bean.setTotalAmount(totalAmountMap.get(thisStartDate)); + bean.setUnqualifiedAmount(unQualityTotalAmount); + returnList.add(bean); + calendar.setTime(startDate); + calendar.add(addDateType, 1); + startDate = calendar.getTime(); + } + return returnList; + } + private void setWorkAmountByPackageFilterDisinfectionData(Map> packingAmountMap, Map totalAmountMap, ReportQueryParams params, String taskGroup, String dateType, boolean isHideDisinfection, boolean showDisinfectionByPackage){ + params.selectTousseType = true; + params.tousseTypeAndPackageSizeSql = " and td.tousseType <> '消毒物品' "; + //任务组的过滤 + params.taskGroupSqlWithAliasOfTousseDefinitionIsTd = SqlUtils.get_InSql_Extra("tdc.taskGroup", taskGroup); + //按包的大小进行分组 + params.extraSelectColumns = " ,td.packageSize packageSize "; + String queryDateSQL = ""; + if("month".equals(dateType)){ + queryDateSQL = dateQueryAdapter.dateToVarchar2("ti.operationTime"); + }else{ + queryDateSQL = dateQueryAdapter.dateToVarchar1("ti.operationTime"); + } + params.extraGroupBy = " ,td.packageSize," + queryDateSQL; + params.monthlyStr = queryDateSQL; + params.isGroup = true; + ResultSet rs = null; + boolean showComTousse = false; + try { + // 取配包数量,不包括消毒物品 + String workAmountByPackageSql = dataIndex.getWorkAmountByPackageSQL("配包数量", params); + rs = objectDao.executeSql(workAmountByPackageSql); + while(rs.next()){ + String dateStr = rs.getString("monthstr"); + Map tousseTypeMap = null; + if(packingAmountMap.containsKey(dateStr)){ + tousseTypeMap = packingAmountMap.get(dateStr); + }else{ + tousseTypeMap = new HashMap(); + packingAmountMap.put(dateStr, tousseTypeMap); + } + + String tousseType = rs.getString("tousseType"); + if(!showComTousse && TousseDefinition.PACKAGE_TYPE_COMBO.equals(tousseType)){ + showComTousse = true; + } + // 将外来器械拆分小包的类型转为外来器械包类型进行统计 + if (TousseDefinition.PACKAGE_TYPE_SPLIT.equals(tousseType)){ + tousseType = TousseDefinition.PACKAGE_TYPE_FOREIGN; + } + + Integer amount = rs.getInt("amount"); + totalAmountMap.put(dateStr, MathTools.add(amount, totalAmountMap.get(dateStr)).intValue()); + if(tousseTypeMap.containsKey(tousseType)){ + int count = tousseTypeMap.get(tousseType); + tousseTypeMap.put(tousseType,count+amount); + }else{ + tousseTypeMap.put(tousseType,amount); + } + String packageSize = rs.getString("packageSize"); + if(StringUtils.isBlank(packageSize)){ + packageSize = "未定义包大小"; + } + if(tousseTypeMap.containsKey(packageSize)){ + int count = tousseTypeMap.get(packageSize); + tousseTypeMap.put(packageSize,count+amount); + }else{ + tousseTypeMap.put(packageSize, amount); + } + } + } catch (SQLException e) { + e.printStackTrace(); + } finally{ + DatabaseUtil.closeResultSetAndStatement(rs); + } + // 毒物品的配包数量,按材料或者按包计算(根据config.js的配置) + if (isHideDisinfection == false) { + params.tousseTypeAndPackageSizeSql = " and td.tousseType = '消毒物品' "; + params.tousseTypes = TousseDefinition.PACKAGE_TYPE_DISINFECTION; + String workAmountByPackageOfDisinfectionSql = null; + if(showDisinfectionByPackage){ + workAmountByPackageOfDisinfectionSql = dataIndex.getWorkAmountByPackageSQL("配包数量", params); + }else{ + int dataSoureOfMaterialsCountOfToussesInReports = CssdUtils.getSystemSetConfigByNameInt("dataSoureOfMaterialsCountOfToussesInReports", 3); + params.extraSelectColumns = ",td.packageSize packageSize ," + queryDateSQL + " monthstr"; + workAmountByPackageOfDisinfectionSql = dataIndex.getWorkAmountByMaterialSQL("配包数量", params,dataSoureOfMaterialsCountOfToussesInReports); + } + ResultSet disinfectionRs = null; + try { + disinfectionRs = objectDao.executeSql(workAmountByPackageOfDisinfectionSql); + while (disinfectionRs.next()) { + String dateStr = disinfectionRs.getString("monthstr"); + String tousseType = disinfectionRs.getString("tousseType"); + String packageSize = disinfectionRs.getString("packageSize"); + Integer amount = disinfectionRs.getInt("amount"); + totalAmountMap.put(dateStr, MathTools.add(amount, totalAmountMap.get(dateStr)).intValue()); + Map tousseTypeMap = null; + if(packingAmountMap.containsKey(dateStr)){ + tousseTypeMap = packingAmountMap.get(dateStr); + }else{ + tousseTypeMap = new HashMap(); + packingAmountMap.put(dateStr, tousseTypeMap); + } + if (tousseTypeMap.containsKey(tousseType)) { + int count = tousseTypeMap.get(tousseType); + tousseTypeMap.put(tousseType, count + amount); + } else { + tousseTypeMap.put(tousseType, amount); + } + if(StringUtils.isBlank(packageSize)){ + packageSize = "未定义包大小"; + } + if(tousseTypeMap.containsKey(packageSize)){ + int count = tousseTypeMap.get(packageSize); + tousseTypeMap.put(packageSize,count+amount); + }else{ + tousseTypeMap.put(packageSize, amount); + } + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(disinfectionRs); + } + } + } + /** + * 设置不合格数据 + * @param unQualityAmountMap 不合格数据 + * @param dateType 数据查询的时间类型 queryDateType为年份是值为month 否则day + * @param isHideDisinfection 是否消毒物品不合格 + * @param startDate 开始日期 + * @param endDate 结束日期 + */ + private void setUnQualityAmountMapOfPackingFDSource(Map> unQualityAmountMap, String dateType, boolean isHideDisinfection + , Date startDate, Date endDate, String querySupplyRoom){ + String queryDateSQL = null; + if("month".equals(dateType)){ + queryDateSQL = dateQueryAdapter.dateToVarchar2("qi.datetime"); + }else{ + queryDateSQL = dateQueryAdapter.dateToVarchar1("qi.datetime"); + } + String isHideDisinfectionSql = ""; + if(isHideDisinfection){ + isHideDisinfectionSql = " and fd.formName<>'消毒物品不合格' "; + } + String unQualitySql = "select fd.formName,sum(qmd.amount) amount,"+ queryDateSQL +" monthstr from QualityMonitoringInstance qi," + + "FormInstance fi,FormDefinition fd,QualityMonitoringDefinition qmdf,QualityMonitoringGoods qmd " + + "where qi.id = fi.id and fi.formDefinition_id = fd.id and fd.id = qmdf.id " + + " and qi.id=qmd.qualityMonitoringInstance_id and qmdf.responsibilitypart = '装配管理' " + + "and fd.departcodes like '%"+querySupplyRoom+"%' " + + SqlUtils.getHandleDepartCodingOfQualityMonitoringDefinitionSql(querySupplyRoom) + + isHideDisinfectionSql + +" and fd.formType = '质量监测' and " + + " qi.datetime between " + + dateQueryAdapter.dateAdapter(startDate) + + " and " + + dateQueryAdapter.dateAdapter(endDate) + + " group by fd.formName,"+queryDateSQL; + ResultSet unQualityRs = null; + try { + unQualityRs = objectDao.executeSql(unQualitySql); + while(unQualityRs.next()){ + MapTools.setStringStringIntegerMap(unQualityAmountMap, unQualityRs.getString("monthstr"), unQualityRs.getString("formName"), unQualityRs.getInt("amount")); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(unQualityRs); + } + } +} Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r35798 -r35801 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 35798) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 35801) @@ -186,6 +186,7 @@ import com.forgon.disinfectsystem.jasperreports.util.MonthReportGroupByDisposableGoodsTypeHelper; import com.forgon.disinfectsystem.jasperreports.util.MonthReportGroupBySterilizationModeHelper; import com.forgon.disinfectsystem.jasperreports.util.MonthReportHelper; +import com.forgon.disinfectsystem.jasperreports.util.PackingUnqualifieReportHelper; import com.forgon.disinfectsystem.jasperreports.util.RealTimeBulletinBoardWorkloadHelper; import com.forgon.disinfectsystem.jasperreports.util.ReportSqlUtil; import com.forgon.disinfectsystem.jasperreports.util.StatisticalWorkloadHelper; @@ -351,6 +352,8 @@ private SupplyRoomQualityQuotaHelper supplyRoomQualityQuotaHelper; @Autowired private DepartSatisfyReportHelper departSatisfyReportHelper; + @Autowired + private PackingUnqualifieReportHelper packingUnqualifieReportHelper; public void setPackingManager(PackingManager packingManager) { this.packingManager = packingManager; } @@ -760,325 +763,10 @@ } @Override public List getPackingFDSource(String startTime, String endTime,String querySupplyRoom,boolean isHideDisinfection, String taskGroup, String queryDateType) { - //构建一些查询需要的信息 - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat sdfyyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - ReportQueryParams params = new ReportQueryParams(objectDao); - params.querySupplyRoom = querySupplyRoom; - //不同查询时间类型的一些处理 - Calendar calendar = Calendar.getInstance(); - Date endDate = calendar.getTime(); - //数据查询的时间类型 queryDateType为年份是值为month 否则day - String dateType; - //查询的开始时间 - String startDateStr; - //查询的结束时间 - String endDateStr; - //开始日期 - Date startDate = null; - //日期差量 查询天为Calendar.MONTH 否则 Calendar.DAY_OF_MONTH - Integer addDateType; - //装配数量map<时间,<列头,数量>> - Map> packingAmountMap = new HashMap>(); - // 装配总数map - Map totalAmountMap = new HashMap(); - //不合格数据map <时间,<表单名称,数量>> - Map> unQualityAmountMap = new HashMap>(); - - if("year".equals(queryDateType)){ - dateType = "month"; - startDateStr = startTime + "-01-01 00:00:00"; - try { - startDate = sdfyyyyMMddHHmmss.parse(startDateStr); - } catch (ParseException e) { - e.printStackTrace(); - } - calendar.setTime(startDate); - calendar.add(Calendar.YEAR, 1); - endDateStr = sdfyyyyMMdd.format(calendar.getTime()) + " 00:00:00"; - }else if("day".equals(queryDateType)){ - dateType = "day"; - startDateStr = startTime + " 00:00:00"; - endDateStr = endTime + " 23:59:59"; - }else{//按月份查询查询的是天 - dateType = "day"; - startDateStr = startTime + "-01 00:00:00"; - if(StringUtils.isBlank(endTime)){ - try { - startDate = sdfyyyyMMddHHmmss.parse(startDateStr); - } catch (ParseException e) { - e.printStackTrace(); - } - calendar.setTime(startDate); - calendar.add(Calendar.MONTH, 1); - endDateStr = sdfyyyyMMdd.format(calendar.getTime()) + " 00:00:00"; - }else{ - String[] dateArr = endTime.split("-"); - endDateStr = DateTools.getLastDayOfMonthByDate(dateArr[0], dateArr[1]) + " 23:59:59"; - } - } - if("month".equals(dateType)){ - addDateType = Calendar.MONTH; - params.monthlyStr = dateQueryAdapter.dateToVarchar2("qi.datetime"); - }else{ - addDateType = Calendar.DAY_OF_MONTH; - params.monthlyStr = dateQueryAdapter.dateToVarchar1("qi.datetime"); - } - try { - if(startDate == null){//按月份查询的 如果没传结束月份 前面已经获取过 - startDate = sdfyyyyMMddHHmmss.parse(startDateStr); - } - calendar.setTime(startDate); - endDate = sdfyyyyMMddHHmmss.parse(endDateStr); - } catch (ParseException e) { - e.printStackTrace(); - } - params.betweenSql = String.format(" between %s and %s ", - dateQueryAdapter.dateAdapter(startDate), - dateQueryAdapter.dateAdapter(endDate)); - - - //设置列名和列顺序 - Map sourceSortMap = new HashMap(); - sourceSortMap.put("器械包", 1); - sourceSortMap.put("外来器械包", 2); - sourceSortMap.put("敷料包", 3); - boolean showDisinfectionByPackage = false; - if(isHideDisinfection == false){ - showDisinfectionByPackage = CssdUtils.getSystemSetConfigByNameBool("showDisinfectionByPackage", false); - sourceSortMap.put("消毒物品", 4); - } - sourceSortMap.put("灭菌物品", 5); - sourceSortMap.put("自定义器械包", 6); - sourceSortMap.put("外部代理灭菌", 7); - sourceSortMap.put("自制物品", 8); - sourceSortMap.put("聚合包", 9); - sourceSortMap.put("配包总数", 10); - sourceSortMap.put("超大包", 11); - sourceSortMap.put("大包", 12); - sourceSortMap.put("中包", 13); - sourceSortMap.put("小包", 14); - - setWorkAmountByPackageFilterDisinfectionData(packingAmountMap, totalAmountMap, params, taskGroup, dateType, isHideDisinfection, showDisinfectionByPackage); - setUnQualityAmountMapOfPackingFDSource(unQualityAmountMap, dateType, isHideDisinfection, startDate, endDate, querySupplyRoom); - - //最终返回的表数据 - List returnList = new ArrayList(); - SimpleDateFormat sdf = null; - if("month".equals(dateType)){ - sdf = new SimpleDateFormat("yyyy-MM"); - }else{ - sdf = sdfyyyyMMdd; - } - while(endDate.after(startDate)){ - String thisStartDate = sdf.format(startDate); - // 各类型包数量 - Map tousseTypeMap = null; - if(packingAmountMap.containsKey(thisStartDate)){ - tousseTypeMap = packingAmountMap.get(thisStartDate); - for(Entry entry : tousseTypeMap.entrySet()){ - String title = entry.getKey(); - PackingFractionDefectiveBean bean = new PackingFractionDefectiveBean(); - bean.setDate(thisStartDate); - bean.setResult(entry.getValue()); - bean.setTitle(title); - bean.setTitleSort(sourceSortMap.get(title)); - returnList.add(bean); - } - } - PackingFractionDefectiveBean bean = new PackingFractionDefectiveBean(); - bean.setDate(thisStartDate); - bean.setResult(totalAmountMap.get(thisStartDate)); - String title = "配包总数"; - bean.setTitle(title); - bean.setTitleSort(sourceSortMap.get(title)); - - Integer unQualityTotalAmount = 0; - if(unQualityAmountMap.containsKey(thisStartDate)){ - Map formNameAmountMap = unQualityAmountMap.get(thisStartDate); - for(Entry entry: formNameAmountMap.entrySet()){ - String formName = entry.getKey(); - PackingFractionDefectiveBean unQualitybean = new PackingFractionDefectiveBean(); - Integer amount = entry.getValue(); - unQualityTotalAmount+=amount; - unQualitybean.setDate(thisStartDate); - unQualitybean.setResult(amount); - unQualitybean.setTitle(formName); - unQualitybean.setTitleSort(10); - returnList.add(unQualitybean); - } - } - - bean.setTotalAmount(totalAmountMap.get(thisStartDate)); - bean.setUnqualifiedAmount(unQualityTotalAmount); - returnList.add(bean); - calendar.setTime(startDate); - calendar.add(addDateType, 1); - startDate = calendar.getTime(); - } - return returnList; + return packingUnqualifieReportHelper.getPackingFDSource(startTime, endTime, querySupplyRoom, isHideDisinfection, taskGroup, queryDateType); } - /** - * 设置不合格数据 - * @param unQualityAmountMap 不合格数据 - * @param dateType 数据查询的时间类型 queryDateType为年份是值为month 否则day - * @param isHideDisinfection 是否消毒物品不合格 - * @param startDate 开始日期 - * @param endDate 结束日期 - */ - private void setUnQualityAmountMapOfPackingFDSource(Map> unQualityAmountMap, String dateType, boolean isHideDisinfection - , Date startDate, Date endDate, String querySupplyRoom){ - String queryDateSQL = null; - if("month".equals(dateType)){ - queryDateSQL = dateQueryAdapter.dateToVarchar2("qi.datetime"); - }else{ - queryDateSQL = dateQueryAdapter.dateToVarchar1("qi.datetime"); - } - String isHideDisinfectionSql = ""; - if(isHideDisinfection){ - isHideDisinfectionSql = " and fd.formName<>'消毒物品不合格' "; - } - String unQualitySql = "select fd.formName,sum(qmd.amount) amount,"+ queryDateSQL +" monthstr from QualityMonitoringInstance qi," - + "FormInstance fi,FormDefinition fd,QualityMonitoringDefinition qmdf,QualityMonitoringGoods qmd " - + "where qi.id = fi.id and fi.formDefinition_id = fd.id and fd.id = qmdf.id " - + " and qi.id=qmd.qualityMonitoringInstance_id and qmdf.responsibilitypart = '装配管理' " - + "and fd.departcodes like '%"+querySupplyRoom+"%' " - + SqlUtils.getHandleDepartCodingOfQualityMonitoringDefinitionSql(querySupplyRoom) - + isHideDisinfectionSql - +" and fd.formType = '质量监测' and " - + " qi.datetime between " - + dateQueryAdapter.dateAdapter(startDate) - + " and " - + dateQueryAdapter.dateAdapter(endDate) - + " group by fd.formName,"+queryDateSQL; - ResultSet unQualityRs = null; - try { - unQualityRs = objectDao.executeSql(unQualitySql); - while(unQualityRs.next()){ - MapTools.setStringStringIntegerMap(unQualityAmountMap, unQualityRs.getString("monthstr"), unQualityRs.getString("formName"), unQualityRs.getInt("amount")); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - DatabaseUtil.closeResultSetAndStatement(unQualityRs); - } - } - private void setWorkAmountByPackageFilterDisinfectionData(Map> packingAmountMap, Map totalAmountMap, ReportQueryParams params, String taskGroup, String dateType, boolean isHideDisinfection, boolean showDisinfectionByPackage){ - params.selectTousseType = true; - params.tousseTypeAndPackageSizeSql = " and td.tousseType <> '消毒物品' "; - //任务组的过滤 - params.taskGroupSqlWithAliasOfTousseDefinitionIsTd = SqlUtils.get_InSql_Extra("tdc.taskGroup", taskGroup); - //按包的大小进行分组 - params.extraSelectColumns = " ,td.packageSize packageSize "; - String queryDateSQL = ""; - if("month".equals(dateType)){ - queryDateSQL = dateQueryAdapter.dateToVarchar2("ti.operationTime"); - }else{ - queryDateSQL = dateQueryAdapter.dateToVarchar1("ti.operationTime"); - } - params.extraGroupBy = " ,td.packageSize," + queryDateSQL; - params.monthlyStr = queryDateSQL; - params.isGroup = true; - ResultSet rs = null; - boolean showComTousse = false; - try { - // 取配包数量,不包括消毒物品 - String workAmountByPackageSql = dataIndex.getWorkAmountByPackageSQL("配包数量", params); - rs = objectDao.executeSql(workAmountByPackageSql); - while(rs.next()){ - String dateStr = rs.getString("monthstr"); - Map tousseTypeMap = null; - if(packingAmountMap.containsKey(dateStr)){ - tousseTypeMap = packingAmountMap.get(dateStr); - }else{ - tousseTypeMap = new HashMap(); - packingAmountMap.put(dateStr, tousseTypeMap); - } - - String tousseType = rs.getString("tousseType"); - if(!showComTousse && TousseDefinition.PACKAGE_TYPE_COMBO.equals(tousseType)){ - showComTousse = true; - } - // 将外来器械拆分小包的类型转为外来器械包类型进行统计 - if (TousseDefinition.PACKAGE_TYPE_SPLIT.equals(tousseType)){ - tousseType = TousseDefinition.PACKAGE_TYPE_FOREIGN; - } - - Integer amount = rs.getInt("amount"); - totalAmountMap.put(dateStr, MathTools.add(amount, totalAmountMap.get(dateStr)).intValue()); - if(tousseTypeMap.containsKey(tousseType)){ - int count = tousseTypeMap.get(tousseType); - tousseTypeMap.put(tousseType,count+amount); - }else{ - tousseTypeMap.put(tousseType,amount); - } - String packageSize = rs.getString("packageSize"); - if(StringUtils.isBlank(packageSize)){ - packageSize = "未定义包大小"; - } - if(tousseTypeMap.containsKey(packageSize)){ - int count = tousseTypeMap.get(packageSize); - tousseTypeMap.put(packageSize,count+amount); - }else{ - tousseTypeMap.put(packageSize, amount); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } finally{ - DatabaseUtil.closeResultSetAndStatement(rs); - } - // 毒物品的配包数量,按材料或者按包计算(根据config.js的配置) - if (isHideDisinfection == false) { - params.tousseTypeAndPackageSizeSql = " and td.tousseType = '消毒物品' "; - params.tousseTypes = TousseDefinition.PACKAGE_TYPE_DISINFECTION; - String workAmountByPackageOfDisinfectionSql = null; - if(showDisinfectionByPackage){ - workAmountByPackageOfDisinfectionSql = dataIndex.getWorkAmountByPackageSQL("配包数量", params); - }else{ - int dataSoureOfMaterialsCountOfToussesInReports = CssdUtils.getSystemSetConfigByNameInt("dataSoureOfMaterialsCountOfToussesInReports", 3); - params.extraSelectColumns = ",td.packageSize packageSize ," + queryDateSQL + " monthstr"; - workAmountByPackageOfDisinfectionSql = dataIndex.getWorkAmountByMaterialSQL("配包数量", params,dataSoureOfMaterialsCountOfToussesInReports); - } - ResultSet disinfectionRs = null; - try { - disinfectionRs = objectDao.executeSql(workAmountByPackageOfDisinfectionSql); - while (disinfectionRs.next()) { - String dateStr = disinfectionRs.getString("monthstr"); - String tousseType = disinfectionRs.getString("tousseType"); - String packageSize = disinfectionRs.getString("packageSize"); - Integer amount = disinfectionRs.getInt("amount"); - totalAmountMap.put(dateStr, MathTools.add(amount, totalAmountMap.get(dateStr)).intValue()); - Map tousseTypeMap = null; - if(packingAmountMap.containsKey(dateStr)){ - tousseTypeMap = packingAmountMap.get(dateStr); - }else{ - tousseTypeMap = new HashMap(); - packingAmountMap.put(dateStr, tousseTypeMap); - } - if (tousseTypeMap.containsKey(tousseType)) { - int count = tousseTypeMap.get(tousseType); - tousseTypeMap.put(tousseType, count + amount); - } else { - tousseTypeMap.put(tousseType, amount); - } - if(StringUtils.isBlank(packageSize)){ - packageSize = "未定义包大小"; - } - if(tousseTypeMap.containsKey(packageSize)){ - int count = tousseTypeMap.get(packageSize); - tousseTypeMap.put(packageSize,count+amount); - }else{ - tousseTypeMap.put(packageSize, amount); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - DatabaseUtil.closeResultSetAndStatement(disinfectionRs); - } - } - } + + @Override public Integer getQualityMonitoringSourceForPacking(String sql, String date, List list,boolean isHideDisinfection) {