Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java =================================================================== diff -u -r33368 -r33378 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 33368) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 33378) @@ -2402,9 +2402,34 @@ }else{ tousseGroupIdsSql = ""; } - //获取回收科室分组过滤 - String recyDepartmentGroupIdsSql = getRecyDepartmentGroupDepartCodesWhereSql(recyDepartmentGroupDepartCodes, "ou.orgUnitCoding", ";"); - String extraSql = taskGroupsSql + tousseGroupIdsSql; + String recyDepartmentGroupIdsSql = ""; + if(StringUtils.isNotBlank(recyDepartmentGroupDepartCodes)){ + if(recyDepartmentGroupDepartCodes.contains("all") || recyDepartmentGroupDepartCodes.contains("全部")){ + List departmentGroups = objectDao.findAllObjects(DepartmentGroup.class.getSimpleName()); + if(CollectionUtils.isNotEmpty(departmentGroups)){ + Set departCodes = new HashSet(); + for (DepartmentGroup departmentGroup : departmentGroups) { + String depart = departmentGroup.getDepartCodes(); + if(StringUtils.isNotBlank(depart)){ + if(depart.contains(";")){ + String[] departArr = depart.split(";"); + for (int i = 0; i < departArr.length; i++) { + departCodes.add(departArr[i]); + } + }else{ + departCodes.add(depart); + } + } + } + if(departCodes.size() > 0){ + recyDepartmentGroupIdsSql = " and " + SqlUtils.getStringFieldInLargeCollectionsPredicate("ou.orgUnitCoding", departCodes, " 1=1 "); + } + } + }else{ + recyDepartmentGroupIdsSql = SqlUtils.getWhereSqlByfilterFieldAndStringValueAndSeparator("ou.orgUnitCoding", recyDepartmentGroupDepartCodes, ";"); + } + } + String extraSql = taskGroupsSql + tousseGroupIdsSql + recyDepartmentGroupIdsSql; JSONObject resultObj = new JSONObject(); JSONArray tableArr = new JSONArray(); try { @@ -2426,20 +2451,23 @@ tableInfo.put("tableName", tableName); tableInfo.put("tableLayout", tableLayout); if("showTousseColumns".equals(tableLayout)){ - JSONObject departGroupsConfig = table.optJSONObject("departGroupsConfig");//科室分组配置 - boolean showDepartGroupColumn = departGroupsConfig.optBoolean("showDepartGroupColumn", true);//是否显示科室分组的表格列 - Set departGroupIds = null;//要查询的科室分组id - Map departGroupNameToShowName = null;//科室分组名对应的显示名,用于把数据库的科室分组名替换成配置的科室分组名 + JSONObject departGroupsConfig = table.optJSONObject("recyclingDepartGroupsConfig");//回收科室分组配置 + boolean showDepartGroupColumn = departGroupsConfig.optBoolean("showRecyclingDepartGroupColumn", true);//是否显示回收科室分组的表格列 + Set departGroupIds = null;//要查询的回收科室分组id + Map departGroupNameToShowName = null;//回收科室分组名对应的显示名,用于把数据库的回收科室分组名替换成配置的回收科室分组名 + String departGroupName = "";//暂不支持多个回收科室分组 if(showDepartGroupColumn){ //收集需要查询的科室分组id和科室分组名称对应的显示名 - JSONArray departGroups = departGroupsConfig.optJSONArray("departGroups");//科室分组配置节点数据 + JSONArray departGroups = departGroupsConfig.optJSONArray("recyclingDepartGroups");//回收科室分组配置节点数据 departGroupIds = new HashSet(); departGroupNameToShowName = new HashMap(); for (Object obj : departGroups) { JSONObject departGroup = (JSONObject)obj; Long id = departGroup.optLong("id"); departGroupIds.add(id); - departGroupNameToShowName.put(departGroup.optString("departGroupName"), departGroup.optString("showDepartGroupName")); + departGroupName = departGroup.optString("recyclingDepartGroupName"); + departGroupNameToShowName.put(departGroupName, departGroup.optString("showRecyclingDepartGroupName")); + break; } } JSONArray tousseColumnsConfig = table.optJSONArray("tousseColumnsConfig");//表格的器械包列的设置 @@ -2469,9 +2497,9 @@ if(includeOtherTousses){//包含其他器械,则不需要过滤包定义id includeTousseIds.clear(); } - sql = getRecyclingDetailSqlForhandleResultSetByRecyclingDetailPrintConfig(fromTime, toTime, handlerDepartCoding, orOrgUnitNameSQL, departGroupIds, includeTousseIds, extraSql, recyDepartmentGroupIdsSql); + sql = getRecyclingDetailSqlForhandleResultSetByRecyclingDetailPrintConfig(fromTime, toTime, handlerDepartCoding, orOrgUnitNameSQL, departGroupIds, includeTousseIds, extraSql); try { - Map>> orgUnitGroupNameMap = new HashMap>>();//科室分组对应更详细的map + Map>> orgUnitGroupNameMap = new HashMap>>();//回收科室分组对应更详细的map Map sumAmountMap = new HashMap();//各列的汇总map Map ancestorIDToTousseMap = new HashMap();//祖先包定义id对应的器械包,用于后面直接通过id获取到包名字 rs = objectDao.executeSql(sql); @@ -2482,9 +2510,9 @@ Integer amount = rs.getInt("amount"); String orgUnitGroupName = null; if(showDepartGroupColumn){ - orgUnitGroupName = rs.getString("orgUnitGroupName"); + orgUnitGroupName = departGroupName; }else{ - orgUnitGroupName = "空列";//如果表格不显示科室分组列,则用空列代替 + orgUnitGroupName = "空列";//如果表格不显示回收科室分组列,则用空列代替 } Map> departMap = null;//科室对应更详细数据的map if(orgUnitGroupNameMap.containsKey(orgUnitGroupName)){ @@ -2531,7 +2559,7 @@ Map>> newOrgUnitGroupNameMap = new HashMap>>();//最终的表格数据map for(Entry>> orgUnitGroupNameEntry : orgUnitGroupNameMap.entrySet()){ Map> newDepartMap = new HashMap>(); - //替换成配置的科室分组显示名 + //替换成配置的回收科室分组显示名 if(departGroupNameToShowName != null && departGroupNameToShowName.containsKey(orgUnitGroupNameEntry.getKey())){ newOrgUnitGroupNameMap.put(departGroupNameToShowName.get(orgUnitGroupNameEntry.getKey()), newDepartMap); }else{ @@ -2593,32 +2621,36 @@ DatabaseUtil.closeResultSetAndStatement(rs); } }else if("noTousseColumns".equals(tableLayout) || "tousseNameAndAmountInSeperateColumns".equals(tableLayout)){ - boolean showDepartGroupColumn = table.optBoolean("showDepartGroupColumn", true);//是否显示科室分组的表格列 - Set departGroupIds2 = null;//要查询的科室分组ids - Map departGroupNameToShowName = null;//科室分组名对应的显示名,用于把数据库的科室分组名替换成配置的科室分组名 + boolean showDepartGroupColumn = table.optBoolean("showRecyclingDepartGroupColumn", true);//是否显示回收科室分组的表格列 + Set departGroupIds2 = null;//要查询的回收科室分组ids + Map departGroupNameToShowName = null;//回收科室分组名对应的显示名,用于把数据库的回收科室分组名替换成配置的回收科室分组名 + String departGroupName = "";//暂不支持多个回收科室分组 if(showDepartGroupColumn){ departGroupNameToShowName = new HashMap(); - JSONArray departGroups2 = table.optJSONArray("departGroups"); + JSONArray departGroups2 = table.optJSONArray("recyclingDepartGroups"); departGroupIds2 = new HashSet(); for (Object departGroupsObj : departGroups2) { JSONObject departGroup = (JSONObject)departGroupsObj; departGroupIds2.add(departGroup.optLong("id")); - departGroupNameToShowName.put(departGroup.optString("departGroupName"), departGroup.optString("showDepartGroupName")); + departGroupName = departGroup.optString("recyclingDepartGroupName"); + departGroupNameToShowName.put(departGroupName, departGroup.optString("showRecyclingDepartGroupName")); + break; } } - sql = getRecyclingDetailSqlForhandleResultSetByRecyclingDetailPrintConfig(fromTime, toTime, handlerDepartCoding, orOrgUnitNameSQL, departGroupIds2, null, extraSql, recyDepartmentGroupIdsSql); + sql = getRecyclingDetailSqlForhandleResultSetByRecyclingDetailPrintConfig(fromTime, toTime, handlerDepartCoding, orOrgUnitNameSQL, departGroupIds2, null, extraSql); try { rs = objectDao.executeSql(sql); - Map>> orgUnitGroupNameMap = new HashMap>>();//科室分组对应更详细信息的map + Map>> orgUnitGroupNameMap = new HashMap>>();//回收科室分组对应更详细信息的map while(rs.next()){ String depart = rs.getString("depart"); String tousseName = rs.getString("tousseName"); Integer amount = rs.getInt("amount"); String orgUnitGroupName = null; if(showDepartGroupColumn){ orgUnitGroupName = rs.getString("orgUnitGroupName"); + orgUnitGroupName = departGroupName; }else{ - orgUnitGroupName = "空列";//如果表格不显示科室分组列,则用空列代替 + orgUnitGroupName = "空列";//如果表格不显示回收科室分组列,则用空列代替 } if(departGroupNameToShowName != null && departGroupNameToShowName.containsKey(orgUnitGroupName)){ orgUnitGroupName = departGroupNameToShowName.get(orgUnitGroupName); @@ -2665,22 +2697,33 @@ } } /** - * 获取回收科室分组过滤 - * @param recyDepartmentGroupDepartCodes 回收科室分组编码 - * @return "" 或者 " and ****" + * 获取装配界面的打印回收清单格式的查询语句 + * @param fromTime 开始时间 + * @param toTime 结束时间 + * @param handlerDepartCoding 所属科室 + * @param orOrgUnitNameSQL 不查询的科室的sql + * @param departGroupIds 科室分组ids + * @param includeTousseIds 只查询的包定义ids + * @param extraSql 额外的查询条件 + * @return 装配界面的打印回收清单格式的查询语句 */ - private String getRecyDepartmentGroupDepartCodesWhereSql(String recyDepartmentGroupDepartCodes, String filterField, String separator){ - String recyDepartmentGroupIdsSql = ""; - if(StringUtils.isNotBlank(recyDepartmentGroupDepartCodes)){ - if(recyDepartmentGroupDepartCodes.contains("all") || recyDepartmentGroupDepartCodes.contains("全部")){ - List departmentGroups = objectDao.findAllObjects(DepartmentGroup.class.getSimpleName()); + private String getRecyclingDetailSqlForhandleResultSetByRecyclingDetailPrintConfig(String fromTime, String toTime, String handlerDepartCoding, String orOrgUnitNameSQL, Set departGroupIds, Set includeTousseIds, String extraSql){ + String includeTousseIdsSql = CollectionUtils.isEmpty(includeTousseIds)?"": " and " + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("td.ancestorID", includeTousseIds); + String joinRecyclingRecordSql = ""; + String joinInvoicePlanSql = ""; + String departGroupIdsSql = ""; + if(StringUtils.isNotBlank(extraSql) && extraSql.contains("orgUnitCoding") || CollectionUtils.isNotEmpty(departGroupIds)){ + joinRecyclingRecordSql = "join OrgUnit ou on ou.orgUnitCoding=po.departCode "; + joinInvoicePlanSql = "join OrgUnit ou on ou.orgUnitCoding=po.departCoding "; + if(CollectionUtils.isNotEmpty(departGroupIds)){ + List departmentGroups = objectDao.findByHql("select po from " + DepartmentGroup.class.getSimpleName() + " po where " + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("po.id", departGroupIds)); if(CollectionUtils.isNotEmpty(departmentGroups)){ Set departCodes = new HashSet(); for (DepartmentGroup departmentGroup : departmentGroups) { String depart = departmentGroup.getDepartCodes(); if(StringUtils.isNotBlank(depart)){ - if(depart.contains(separator)){ - String[] departArr = depart.split(separator); + if(depart.contains(";")){ + String[] departArr = depart.split(";"); for (int i = 0; i < departArr.length; i++) { departCodes.add(departArr[i]); } @@ -2689,70 +2732,26 @@ } } } - if(departCodes.size() > 0){ - recyDepartmentGroupIdsSql = " and " + SqlUtils.getStringFieldInLargeCollectionsPredicate(filterField, departCodes, " 1=1 "); - } + departGroupIdsSql = " and " + SqlUtils.getStringFieldInLargeCollectionsPredicate("ou.orgUnitCoding", departCodes, " 1=1 "); } - }else{ - recyDepartmentGroupIdsSql = SqlUtils.getWhereSqlByfilterFieldAndStringValueAndSeparator(filterField, recyDepartmentGroupDepartCodes, separator); } } - return recyDepartmentGroupIdsSql; - } - /** - * 获取装配界面的打印回收清单格式的查询语句 - * @param fromTime 开始时间 - * @param toTime 结束时间 - * @param handlerDepartCoding 所属科室 - * @param orOrgUnitNameSQL 不查询的科室的sql - * @param departGroupIds 科室分组ids - * @param includeTousseIds 只查询的包定义ids - * @param extraSql 额外的查询条件 - * @return 装配界面的打印回收清单格式的查询语句 - */ - private String getRecyclingDetailSqlForhandleResultSetByRecyclingDetailPrintConfig(String fromTime, String toTime, String handlerDepartCoding, String orOrgUnitNameSQL, Set departGroupIds, Set includeTousseIds, String extraSql, String recyDepartmentGroupIdsSql){ - String includeTousseIdsSql = CollectionUtils.isEmpty(includeTousseIds)?"": " and " + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("td.ancestorID", includeTousseIds); - String joinRecyclingRecordSql = null; - String joinInvoicePlanSql = null; - String selectUnitGroupNameSql = null; - if(CollectionUtils.isEmpty(departGroupIds)){ - joinRecyclingRecordSql = ""; - joinInvoicePlanSql = ""; - selectUnitGroupNameSql = ""; - if(StringUtils.isNotBlank(recyDepartmentGroupIdsSql)){ - joinRecyclingRecordSql = "join OrgUnit ou on ou.orgUnitCoding=po.departCode "; - joinInvoicePlanSql = "join OrgUnit ou on ou.orgUnitCoding=po.departCoding "; - } - }else{ - joinRecyclingRecordSql = "join OrgUnit ou on ou.orgUnitCoding=po.departCode " - + "join Org_OrgGroup oog on oog.orgUnitId=ou.id " - + "join OrgUnitGroup oug on oug.id=oog.orgGroupId "; - joinInvoicePlanSql = "join OrgUnit ou on ou.orgUnitCoding=po.departCoding " - + "join Org_OrgGroup oog on oog.orgUnitId=ou.id " - + "join OrgUnitGroup oug on oug.id=oog.orgGroupId "; - selectUnitGroupNameSql = "min(oug.name) orgUnitGroupName,"; - } - if(CollectionUtils.isNotEmpty(departGroupIds) && StringUtils.isNotBlank(recyDepartmentGroupIdsSql)){ - extraSql += " and (" + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("oug.id", departGroupIds) + " or 1=1 " + recyDepartmentGroupIdsSql + ") "; - }else if(StringUtils.isNotBlank(recyDepartmentGroupIdsSql)){ - extraSql += recyDepartmentGroupIdsSql; - }else{ - extraSql += " and " + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("oug.id", departGroupIds); - } String sql = String - .format("select "+ selectUnitGroupNameSql +" min(po.depart) depart,po.departCode,td.ancestorID,min(bo.tousseName) tousseName,sum(bo.amount) amount,td.id from %s po " + .format("select min(po.depart) depart,po.departCode,td.ancestorID,min(bo.tousseName) tousseName,sum(bo.amount) amount,td.id from %s po " + "join %s bo on po.id = bo.recyclingRecord_id join %s td on td.id = bo.tousseDefinitionId " + joinRecyclingRecordSql + "where po.recyclingTime between %s and %s and po.orgUnitCoding = '%s' %s " + + departGroupIdsSql + includeTousseIdsSql + extraSql + "group by po.departCode,td.ancestorID,td.id " + "union all " // 装配管理打印回收清单要增加敷料包的统计(DGZYY-162) - + "select "+ selectUnitGroupNameSql +" min(po.depart) depart,po.departCoding,td.ancestorID,min(bo.tousseName) tousseName,sum(bo.amount) amount,td.id from %s po " + + "select min(po.depart) depart,po.departCoding,td.ancestorID,min(bo.tousseName) tousseName,sum(bo.amount) amount,td.id from %s po " + "join %s bo on po.id = bo.recyclingApplication_ID join %s td on td.id = bo.tousseDefinitionId " + joinInvoicePlanSql + "where po.submitTime between %s and %s and po.handleDepartCoding = '%s' %s and td.tousseType = '%s' " + + departGroupIdsSql + includeTousseIdsSql + extraSql + "group by po.departCoding, td.ancestorID,td.id",