Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/InstrumentSetDemandReportHelper.java =================================================================== diff -u -r41526 -r41592 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/InstrumentSetDemandReportHelper.java (.../InstrumentSetDemandReportHelper.java) (revision 41526) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/InstrumentSetDemandReportHelper.java (.../InstrumentSetDemandReportHelper.java) (revision 41592) @@ -196,61 +196,6 @@ StringUtils.defaultString(brancheOfHospitalName, StringUtils.EMPTY), StringUtils.defaultString(tousseName, StringUtils.EMPTY)); } - -/* *//** - * 构建结果列表 - *//* - private List> buildResultList(Map> operationNameMap, - Map amountMap, - Map> ipIdMap, - Map parametMap) { - - List resultList = new ArrayList<>(); - Integer totalTotalAmount = 0; - Integer totalStockAmount = 0; - Integer totalExpectedGapAmount = 0; - for (String key : operationNameMap.keySet()) { - String[] keyParts = key.split("\\|", -1); - - Map resultMap = new HashMap<>(); - resultMap.put("operationTime", keyParts[0]); - resultMap.put("depart", keyParts[1]); - resultMap.put("brancheOfHospitalName", keyParts[2]); - resultMap.put("tousseName", keyParts[3]); - - // 拼接排重后的operationName - Set operationNames = operationNameMap.get(key); - resultMap.put("operationNames", String.join(", ", operationNames)); - - // 汇总的amount - Integer totalAmount = amountMap.getOrDefault(key, 0); - totalTotalAmount += totalAmount; - resultMap.put("totalAmount", totalAmount); - - // ipId数量(排重后) - resultMap.put("ipCount", ipIdMap.get(key).size()); - - // 库存和缺口计算 - Integer stockAmount = getStockAmount(keyParts[1], keyParts[3]); - totalStockAmount += stockAmount; - resultMap.put("stockAmount", stockAmount); - - if (totalAmount != null && stockAmount != null && totalAmount > stockAmount) { - resultMap.put("expectedGapAmount", totalAmount - stockAmount); - resultMap.put("isUrgent", Constants.STR_YES); - totalExpectedGapAmount += totalAmount - stockAmount; - } else { - resultMap.put("expectedGapAmount", 0); - resultMap.put("isUrgent", Constants.STR_NO); - } - - resultList.add(resultMap); - } - parametMap.put("totalTotalAmount", totalTotalAmount); - parametMap.put("totalStockAmount", totalStockAmount); - parametMap.put("totalExpectedGapAmount", totalExpectedGapAmount); - return resultList; - }*/ /** * 构建VO列表 */ @@ -318,16 +263,16 @@ return resultList; } /** - * 获取库存数量(添加参数化查询) + * 获取库存数量 */ private Integer getStockAmount(String departName, String tousseName) { - // 使用参数化查询避免SQL注入 + String sql = "SELECT SUM(amount) FROM GoodsStock WHERE 1=1 AND amount > 0 AND goodsType = '器械包' " + "AND tousseDefinitionId IS NOT NULL " + "AND orgUnitName = '"+ departName +"' AND name = '"+ tousseName +"' "; try { - // 这里需要根据你的objectDao实现参数化查询 + return objectDao.countBySql(sql); } catch (Exception e) { logger.error("查询库存数量失败 - depart: {"+ departName +"}, tousseName: {"+ tousseName +"}, error: {"+ e.getMessage() +"}");