Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java =================================================================== diff -u -r32100 -r32141 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 32100) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 32141) @@ -8969,41 +8969,39 @@ //发货单的id下必须有包实例,如果没有包实例与发货单关联,发货单打开之后,会因为没有包实例而签收不了 //如果是发的一次性物品,则没有包实例关联也需要显示 String where3 = " and i.id in (select ii.invoice_id from "+InvoiceItem.class.getSimpleName() - + " ii where ii.diposable = '是' union select invoice_id from "+TousseInstance.class.getSimpleName()+" ti where ti.status='已发货')"; + + " ii where ii.diposable = '"+ Constants.STR_YES +"' union select (case when invoice2_id is not null then invoice2_id else invoice_id end) from "+TousseInstance.class.getSimpleName()+" ti where ti.status='"+ TousseInstance.STATUS_SHIPPED +"')"; sql = String.format("%s %s %s %s", sql,where1,where2,where3); - ResultSet rs = objectDao.executeSql(sql); - if(rs != null){ - try { + ResultSet rs = null; + try { + rs = objectDao.executeSql(sql); + while(rs.next()){ + long id = rs.getLong(1); + final String departCoding = rs.getString(2); + String depart = rs.getString(3); + String type = rs.getString(4); - while(rs.next()){ - long id = rs.getLong(1); - final String departCoding = rs.getString(2); - String depart = rs.getString(3); - String type = rs.getString(4); - - InvoiceStaticsVo vo = CollectionUtils.find(retList, - new Predicate() { - @Override - public boolean evaluate(InvoiceStaticsVo vo) { - return StringUtils.equals(vo.getDepartCode(), - departCoding); - } - }); - if (vo == null) { - vo = new InvoiceStaticsVo(); - retList.add(vo); - vo.setDepart(depart); - vo.setDepartCode(departCoding); + InvoiceStaticsVo vo = CollectionUtils.find(retList, + new Predicate() { + @Override + public boolean evaluate(InvoiceStaticsVo vo) { + return StringUtils.equals(vo.getDepartCode(), + departCoding); } - vo.incrementAmount(type); - vo.addInvoiceId(id); + }); + if (vo == null) { + vo = new InvoiceStaticsVo(); + retList.add(vo); + vo.setDepart(depart); + vo.setDepartCode(departCoding); } - } catch (SQLException e) { - return null; - }finally { - DatabaseUtil.closeResultSetAndStatement(rs); + vo.incrementAmount(type); + vo.addInvoiceId(id); } + } catch (SQLException e) { + return null; + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); } return retList; } @@ -9014,20 +9012,21 @@ String disposableGoodsSql = "select ii.tousseName,ii.amount,ii.invoice_id,i.sendTime from " + InvoiceItem.class.getSimpleName() + " ii inner join " + Invoice.class.getSimpleName() + - " i on ii.invoice_id = i.id where ii.diposable='是'"; + " i on ii.invoice_id = i.id where ii.diposable='"+ Constants.STR_YES +"'"; String tousseSql = "select ti.tousseName,COUNT(*) amount,ti.invoice_id,i.sendTime from " + - TousseInstance.class.getSimpleName() + " ti inner join " + Invoice.class.getSimpleName() + " i on i.id = ti.invoice_id "; + TousseInstance.class.getSimpleName() + " ti , " + Invoice.class.getSimpleName() + " i where ((ti.invoice2_id is not null and i.id = ti.invoice2_id) or (ti.invoice2_id is null and i.id = ti.invoice_id)) "; String idsCondition = "1=1"; - if(invoiceIds != null && !invoiceIds.isEmpty()){ + if(CollectionUtils.isNotEmpty(invoiceIds)){ idsCondition = SqlUtils.getNonStringFieldInLargeCollectionsPredicate("i.id",invoiceIds); - tousseSql = String.format("%s where %s and ti.status='已发货' group by ti.tousseName,ti.invoice_id,i.sendTime", tousseSql,idsCondition); + tousseSql = String.format("%s and %s and ti.status='"+ TousseInstance.STATUS_SHIPPED +"' group by ti.tousseName,ti.invoice_id,i.sendTime", tousseSql,idsCondition); disposableGoodsSql = String.format("%s and %s ", disposableGoodsSql,idsCondition); String sql = String.format("%s union all %s", tousseSql,disposableGoodsSql); - ResultSet rs = objectDao.executeSql(sql); + ResultSet rs = null; try{ + rs = objectDao.executeSql(sql); while(rs.next()){ String tousseName = rs.getString("tousseName"); int amount = rs.getInt("amount");