Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r13130 -r13136 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 13130) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 13136) @@ -7612,24 +7612,25 @@ } String endDate = dateQueryAdapter.dateAdapter(currentRecord.getStockTakeDate()); - + String basesql = "select d.name,d.specification,i.amount,i.cost from GodownEntry r,GodownEntryItem i,DisposableGoodsStock d " + + "where r.id = i.godownEntry_id and i.diposableGoods_id = d.id "; //入库sql - String insql = " where po.godownEntry.type ='"+GodownEntry.TYPE_IN+"' and po.godownEntry.warehouseID = " + String insql = basesql + " and r.type ='"+GodownEntry.TYPE_IN+"' and r.warehouseID = " + currentRecord.getWarehouseId(); if(StringUtils.isBlank(startDate)){ - insql += " and po.godownEntry.time < " + endDate + ""; + insql += " and r.time < " + endDate + ""; }else{ - insql += " and po.godownEntry.time between " + startDate + " and " + endDate + " "; + insql += " and r.time between " + startDate + " and " + endDate + " "; } Map> inMap = getGodownEntryItemBySql(insql); //退库sql - String outsql = " where po.godownEntry.type ='"+GodownEntry.TYPE_OUT+"' and po.godownEntry.warehouseID = " + String outsql = basesql + " and r.type ='"+GodownEntry.TYPE_OUT+"' and r.warehouseID = " + currentRecord.getWarehouseId(); if(StringUtils.isBlank(startDate)){ - outsql += " and po.godownEntry.time < " + endDate + ""; + outsql += " and r.time < " + endDate + ""; }else{ - outsql += " and po.godownEntry.time between " + startDate + " and " + endDate + " "; + outsql += " and r.time between " + startDate + " and " + endDate + " "; } Map> outMap = getGodownEntryItemBySql(outsql); @@ -7727,21 +7728,28 @@ @SuppressWarnings("unchecked") public Map> getGodownEntryItemBySql(String sql){ - List list = objectDao.findBySql(GodownEntryItem.class.getSimpleName(), sql); + ResultSet rs = objectDao.executeSql(sql); Map> map = new HashMap>(); - if(list != null){ - for (GodownEntryItem item : list) { - DisposableGoodsStock stock = item.getDiposableGoods(); - String key = stock.getName(); - if(StringUtils.isNotBlank(stock.getSpecification())){ - key = "[" + stock.getSpecification() + "]"; + try { + while(rs.next()){ + GodownEntryItem item = new GodownEntryItem(); + item.setAmount(rs.getLong(3)); + item.setCost(rs.getDouble(4)); + String key = rs.getString(1); + if(StringUtils.isNotBlank(rs.getString(2))){ + key = "[" + rs.getString(2) + "]"; } List items = map.get(key); if(items == null){ items = new ArrayList(); + map.put(key, items); } items.add(item); } + } catch (SQLException e) { + e.printStackTrace(); + }finally{ + DatabaseUtil.closeResultSetAndStatement(rs); } return map; }