Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManager.java =================================================================== diff -u -r13248 -r13316 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManager.java (.../JasperReportManager.java) (revision 13248) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManager.java (.../JasperReportManager.java) (revision 13316) @@ -53,7 +53,7 @@ */ public interface JasperReportManager { - public List getMonthReportData(String startDate,String endDate,String department,String disposableGoodsType); + public List getMonthReportData(String startDate,String endDate,String department,String tousseType,String disposableGoodsType); public List getWorkLoad(String startTime, String endTime, String querySupplyRoom); Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java =================================================================== diff -u -r13248 -r13316 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 13248) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 13316) @@ -394,8 +394,10 @@ String startDate = StrutsParamUtils.getPraramValue("startTime",null); String endDate = StrutsParamUtils.getPraramValue("endTime",null); String department = StrutsParamUtils.getPraramValue("depart", null); + //增加物品类型 + String tousseType = StrutsParamUtils.getPraramValue("tousseType", ""); String disposableGoodsType = StrutsParamUtils.getPraramValue("disposableGoodsType", ""); - return jasperReportManager.getMonthReportData(startDate, endDate, department,disposableGoodsType); + return jasperReportManager.getMonthReportData(startDate, endDate, department,tousseType,disposableGoodsType); } else if (reportName.equals("departmentMonthDetail")) {// 明细核算月报 String startTime = StrutsParamUtils.getPraramValue("startTime", Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r13299 -r13316 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 13299) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 13316) @@ -3683,7 +3683,7 @@ } @Override - public List getMonthReportData(String startDate,String endDate,String department,String disposableGoodsType){ + public List getMonthReportData(String startDate,String endDate,String department,String tousseType,String disposableGoodsType){ String handleDeptCode = AcegiHelper.getLoginUser().getOrgUnitCodingFromSupplyRoomConfig(); List list = new ArrayList(); String invoiceWheresql = "" ; @@ -3712,260 +3712,295 @@ returnGoodsItemPredicate = String.format(" (r.type!='一次性物品' or i.disposableGoodsId in(%s)) ", disposableGoodsIdSql); receiveRecordItemPredicate = String.format(" (i.type!='一次性物品' or i.disposableGoodsId in(%s)) ", disposableGoodsIdSql); } - String invoicePriceSql = "select '' as coding,min(i.settleAccountsDepart) " + if(StringUtils.isBlank(tousseType) || !"器械材料".equals(tousseType)){ + //物品类型sql + String tousseTypeInvoiceSql = ""; + String tousseTypeReturnSql = ""; + if(StringUtils.isNotBlank(tousseType)){ + tousseTypeInvoiceSql = String.format(" and ii.tousseType='%s' ", tousseType); + if(TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ + tousseTypeReturnSql = " and i.disposableGoodsId in (select id from DisposableGoods) "; + }else{ + tousseTypeReturnSql = String.format(" and i.tousseDefinition_id in (select id from TousseDefinition where tousseType in ('%s')) ", tousseType); + } + } + + String invoicePriceSql = "select '' as coding,min(i.settleAccountsDepart) " + "as depart,sum(ii.settlementPrice) as price,ii.diposable from Invoice i," + "InvoiceItem ii where i.id = ii.invoice_id and "+invoiceItemDisposableGoodsTypePredicate+" and i.orgUnitCoding = '" + handleDeptCode + "' and (i.status ='收货签收' or " - + "i.status = '已发货') " + invoiceWheresql + " group by i.settleAccountsDepart,ii.diposable"; - ResultSet rs = objectDao.executeSql(invoicePriceSql); - try { - while(rs.next()){ - String code = rs.getString(1); - String dept = rs.getString(2); - Double price = rs.getDouble(3); - String diposable = rs.getString(4); - String columnName = ""; - if("是".equals(diposable)){ - columnName = "一次性物品总价"; - }else{ - columnName = "器械包总价"; + + "i.status = '已发货') " + invoiceWheresql + tousseTypeInvoiceSql + " group by i.settleAccountsDepart,ii.diposable"; + ResultSet rs = objectDao.executeSql(invoicePriceSql); + try { + while(rs.next()){ + String code = rs.getString(1); + String dept = rs.getString(2); + Double price = rs.getDouble(3); + String diposable = rs.getString(4); + String columnName = ""; + if("是".equals(diposable)){ + columnName = "一次性物品总价"; + }else{ + columnName = "器械包总价"; + } + newMonthReport(code, dept,"1", "价格统计",columnName,price, list); } - newMonthReport(code, dept,"1", "价格统计",columnName,price, list); + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs); - } - // 材料发货价格 - String materialInvoicePriceSql = "select '' as coding,min(i.settleAccountsDepart) " - + "as depart,sum(ii.settlementPrice) as price from MaterialInvoice i," - + "MaterialInvoiceItem ii where i.id = ii.materialInvoice_id and i.orgUnitCoding = '" + handleDeptCode + "' " + invoiceWheresql + " group by i.settleAccountsDepart"; - ResultSet materialInvoicePriceResultSet = objectDao.executeSql(materialInvoicePriceSql); - try { - while(materialInvoicePriceResultSet.next()){ - String code = materialInvoicePriceResultSet.getString(1); - String dept = materialInvoicePriceResultSet.getString(2); - Double price = materialInvoicePriceResultSet.getDouble(3); - String columnName = "材料总价"; - - newMonthReport(code, dept,"1", "价格统计",columnName,price, list); + + //退货统计(器械包或一次性物品) + String returnSql = "select r.type,(-i.settlementPrice),-i.amount,'',r.depart " + + "from ReturnGoodsRecord r,ReturnGoodsItem i where r.id = i.returnGoodsRecord_ID" + + " and "+returnGoodsItemPredicate+ tousseTypeReturnSql + " and r.handleDepartCode = '"+handleDeptCode+"' and r.returnTime " + betweenSql; + if(StringUtils.isNotBlank(department)){ + returnSql += " and r.depart = '" + department + "'"; } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(materialInvoicePriceResultSet); - } - String invoiceAmountSql = "select '' as coding,i.settleAccountsDepart " - + "as depart,ii.amount,ii.tousseType,ii.tousseName,ii.invoicePlanID from Invoice i,InvoiceItem ii where i.id = ii.invoice_id " - + " and i.orgUnitCoding = '" + handleDeptCode + "' " - + " and (ii.amount is not null and ii.amount>0 and ii.tousseType!='一次性物品') "// 限制为只查包含器械包数量的 - + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql; - - ResultSet rs2 = objectDao.executeSql(invoiceAmountSql); - try { - while(rs2.next()){ - String code = rs2.getString(1); - String dept = rs2.getString(2); - Double tousseAmount = rs2.getDouble(3); - String tousseType = rs2.getString(4); - String tousseName = rs2.getString(5); - Long invoicePlanId = rs2.getLong(6); - // 如果是消毒物品,用统计数量替换包数量 - if ("消毒物品".equals(tousseType)) { - if (StringUtils.isNotBlank(tousseName) - && DatabaseUtil.isPoIdValid(invoicePlanId)) { - int disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount( - tousseName, invoicePlanId.toString()); - if (disinfectGoodsStatisticAmount > 0) { - tousseAmount = (tousseAmount * disinfectGoodsStatisticAmount); - } + ResultSet rs5 = objectDao.executeSql(returnSql); + try { + while(rs5.next()){ + String type = rs5.getString(1); + Double price = rs5.getDouble(2); + Double amount = rs5.getDouble(3); + String code = rs5.getString(4); + String dept = rs5.getString(5); + if("一次性物品".equals(type)){ + newMonthReport(code, dept, "1", "价格统计", "一次性物品总价", price, list); + newMonthReport(code, dept, "2", "数量统计", "一次性物品数量", amount, list); + }else{ + newMonthReport(code, dept, "1", "价格统计", "器械包总价", price, list); + newMonthReport(code, dept, "2", "数量统计", "器械包数量", amount, list); } } - if(tousseAmount > 0){ - newMonthReport(code, dept,"2","数量统计", "器械包数量",tousseAmount,list); - } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs5); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs2); } - // 材料发货数量 - String materialInvoiceAmountSql = "select '' as coding,i.settleAccountsDepart " - + "as depart,mi.amount from MaterialInvoice i inner join MaterialInvoiceItem mi on i.id=mi.materialInvoice_id " - + "where i.orgUnitCoding = '" + handleDeptCode + "' " - + " and (mi.amount is not null and mi.amount>0) " - + " " + invoiceWheresql; - ResultSet materialInvoiceAmountResultSet = objectDao.executeSql(materialInvoiceAmountSql); - try { - while(materialInvoiceAmountResultSet.next()){ - String code = materialInvoiceAmountResultSet.getString(1); - String dept = materialInvoiceAmountResultSet.getString(2); - Double tousseAmount = materialInvoiceAmountResultSet.getDouble(3); - if(tousseAmount > 0){ - newMonthReport(code, dept,"2","数量统计", "材料数量",tousseAmount,list); + if(StringUtils.isBlank(tousseType) || "器械材料".equals(tousseType)){ + // 材料发货价格 + String materialInvoicePriceSql = "select '' as coding,min(i.settleAccountsDepart) " + + "as depart,sum(ii.settlementPrice) as price from MaterialInvoice i," + + "MaterialInvoiceItem ii where i.id = ii.materialInvoice_id and i.orgUnitCoding = '" + handleDeptCode + "' " + invoiceWheresql + " group by i.settleAccountsDepart"; + ResultSet materialInvoicePriceResultSet = objectDao.executeSql(materialInvoicePriceSql); + try { + while(materialInvoicePriceResultSet.next()){ + String code = materialInvoicePriceResultSet.getString(1); + String dept = materialInvoicePriceResultSet.getString(2); + Double price = materialInvoicePriceResultSet.getDouble(3); + String columnName = "材料总价"; + + newMonthReport(code, dept,"1", "价格统计",columnName,price, list); } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(materialInvoicePriceResultSet); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(materialInvoiceAmountResultSet); - } - // 一次性发货统计 - String disposableGoodsInvoiceAmountSql = "select '' as coding,i.settleAccountsDepart " - + "as depart,ii.amount from Invoice i inner join InvoiceItem ii on i.id = ii.invoice_id " - + "where i.orgUnitCoding = '" + handleDeptCode + "' " - +" and "+disposableGoodsInvoiceAmountPredicate - + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql; - ResultSet disposableGoodsInvoiceAmountResultSet = objectDao.executeSql(disposableGoodsInvoiceAmountSql); - try { - while(disposableGoodsInvoiceAmountResultSet.next()){ - String code = disposableGoodsInvoiceAmountResultSet.getString(1); - String dept = disposableGoodsInvoiceAmountResultSet.getString(2); - Double diposableAmount = disposableGoodsInvoiceAmountResultSet.getDouble(3); - if(diposableAmount > 0){ - newMonthReport(code, dept,"2","数量统计", "一次性物品数量",diposableAmount,list); + + // 材料发货数量 + String materialInvoiceAmountSql = "select '' as coding,i.settleAccountsDepart " + + "as depart,mi.amount from MaterialInvoice i inner join MaterialInvoiceItem mi on i.id=mi.materialInvoice_id " + + "where i.orgUnitCoding = '" + handleDeptCode + "' " + + " and (mi.amount is not null and mi.amount>0) " + + " " + invoiceWheresql; + + ResultSet materialInvoiceAmountResultSet = objectDao.executeSql(materialInvoiceAmountSql); + try { + while(materialInvoiceAmountResultSet.next()){ + String code = materialInvoiceAmountResultSet.getString(1); + String dept = materialInvoiceAmountResultSet.getString(2); + Double tousseAmount = materialInvoiceAmountResultSet.getDouble(3); + if(tousseAmount > 0){ + newMonthReport(code, dept,"2","数量统计", "材料数量",tousseAmount,list); + } } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(materialInvoiceAmountResultSet); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(disposableGoodsInvoiceAmountResultSet); - } - String recyclingErrorSql = "select r.departCode,r.depart,r.materialName,sum(r.materialCost*r.amount),sum(r.amount) " - + " from RecyclingError r where r.packingTask_ID is null and r.errorType = '缺失' " - + " and r.handleDepartCode = '" + handleDeptCode + "' and r.missTime " + betweenSql; - - if(StringUtils.isNotBlank(department)){ - recyclingErrorSql += " and r.depart = '"+department+"' "; - } - recyclingErrorSql += " group by r.departCode,r.depart,r.materialName"; - ResultSet rs3 = objectDao.executeSql(recyclingErrorSql); - try { - if(rs3 != null){ - while(rs3.next()){ - String code = rs3.getString(1); - String dept = rs3.getString(2); - String materialName = rs3.getString(3); - Double money = rs3.getDouble(4); - Double amount = rs3.getDouble(5); - - newMonthReport(code, dept,"2", "数量统计","材料数量",amount, list); - newMonthReport(code, dept,"1", "价格统计","材料总价",money, list); + + //材料报损统计 + String damageSql = "select r.departCoding,r.depart,i.materialName,sum(i.materialCost*i.additionalAmount),sum(i.additionalAmount) " + + " from RecyclingDamageRecord r,RecyclingDamageItem i where r.id = i.RecyclingDamageRecord_ID " + + " and r.additionalDeptCode = '" + handleDeptCode + "' and r.status != '未补充' and i.additionalTime is not null and i.additionalTime " + + betweenSql; + + if(StringUtils.isNotBlank(department)){ + damageSql += " and r.depart = '"+department+"' "; + } + damageSql += " group by r.departCoding,r.depart,i.materialName"; + ResultSet rs33 = objectDao.executeSql(damageSql); + try { + if(rs33 != null){ + while(rs33.next()){ + String code = rs33.getString(1); + String dept = rs33.getString(2); + String materialName = rs33.getString(3); + Double money = rs33.getDouble(4); + Double amount = rs33.getDouble(5); + + newMonthReport(code, dept, "2", "数量统计", "材料数量", amount, list); + newMonthReport(code, dept, "1", "价格统计", "材料总价", money, list); + } } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs33); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs3); - } - - String damageSql = "select r.departCoding,r.depart,i.materialName,sum(i.materialCost*i.additionalAmount),sum(i.additionalAmount) " - + " from RecyclingDamageRecord r,RecyclingDamageItem i where r.id = i.RecyclingDamageRecord_ID " - + " and r.additionalDeptCode = '" + handleDeptCode + "' and r.status != '未补充' and i.additionalTime is not null and i.additionalTime " - + betweenSql; - - if(StringUtils.isNotBlank(department)){ - damageSql += " and r.depart = '"+department+"' "; - } - damageSql += " group by r.departCoding,r.depart,i.materialName"; - ResultSet rs33 = objectDao.executeSql(damageSql); - try { - if(rs33 != null){ - while(rs33.next()){ - String code = rs33.getString(1); - String dept = rs33.getString(2); - String materialName = rs33.getString(3); - Double money = rs33.getDouble(4); - Double amount = rs33.getDouble(5); + + //材料丢失统计 + String recyclingErrorSql = "select r.departCode,r.depart,r.materialName,sum(r.materialCost*r.amount),sum(r.amount) " + + " from RecyclingError r where r.packingTask_ID is null and r.errorType = '缺失' " + + " and r.handleDepartCode = '" + handleDeptCode + "' and r.missTime " + betweenSql; + + if(StringUtils.isNotBlank(department)){ + recyclingErrorSql += " and r.depart = '"+department+"' "; + } + recyclingErrorSql += " group by r.departCode,r.depart,r.materialName"; + ResultSet rs3 = objectDao.executeSql(recyclingErrorSql); + try { + if(rs3 != null){ + while(rs3.next()){ + String code = rs3.getString(1); + String dept = rs3.getString(2); + String materialName = rs3.getString(3); + Double money = rs3.getDouble(4); + Double amount = rs3.getDouble(5); + + newMonthReport(code, dept,"2", "数量统计","材料数量",amount, list); + newMonthReport(code, dept,"1", "价格统计","材料总价",money, list); + } + } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs3); + } + + // 材料退货 + String materialReturnSql = "select '',r.depart , (-i.settlementPrice),-i.amount " + + "from ReturnMaterialRecord r,ReturnMaterialItem i where r.id = i.returnMaterialRecord_ID" + + " and r.handleDepartCode = '"+handleDeptCode+"' and r.returnTime " + betweenSql; + if(StringUtils.isNotBlank(department)){ + materialReturnSql += " and r.depart = '" + department + "'"; + } + ResultSet materialReturnResultSet = objectDao.executeSql(materialReturnSql); + try { + while(materialReturnResultSet.next()){ + String code = materialReturnResultSet.getString(1); + String dept = materialReturnResultSet.getString(2); + Double price = materialReturnResultSet.getDouble(3); + Double amount = materialReturnResultSet.getDouble(4); + newMonthReport(code, dept, "1", "价格统计", "材料价格", price, list); newMonthReport(code, dept, "2", "数量统计", "材料数量", amount, list); - newMonthReport(code, dept, "1", "价格统计", "材料总价", money, list); } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(materialReturnResultSet); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs33); } - String receiveSql = "select i.type,(i.amount*i.price),i.amount,r.departcoding " - + "from ReceiveRecord r,ReceiveRecordItem i where r.id = i.receiverecord_id " - + "and "+receiveRecordItemPredicate+" and r.departCoding = '" + handleDeptCode + "' and r.time " + betweenSql; - - SupplyRoomConfig config = supplyRoomConfigManager.getFirstSupplyRoomConfig(); - ResultSet rs4 = objectDao.executeSql(receiveSql); - try { - while(rs4.next()){ - String type = rs4.getString(1); - Double price = rs4.getDouble(2); - Double amount = rs4.getDouble(3); - String code = rs4.getString(4); - if("一次性物品".equals(type)){ - newMonthReport(code, config.getOrgUnitName(), "1", "价格统计", "一次性物品总价", price, list); - newMonthReport(code, config.getOrgUnitName(), "2", "数量统计", "一次性物品数量", amount, list); - }else{ - newMonthReport(code, config.getOrgUnitName(), "1", "价格统计", "材料总价", price, list); - newMonthReport(code, config.getOrgUnitName(), "2", "数量统计", "材料数量", amount, list); + if(StringUtils.isBlank(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ + // 一次性发货数量统计 + String disposableGoodsInvoiceAmountSql = "select '' as coding,i.settleAccountsDepart " + + "as depart,ii.amount from Invoice i inner join InvoiceItem ii on i.id = ii.invoice_id " + + "where i.orgUnitCoding = '" + handleDeptCode + "' " + +" and "+disposableGoodsInvoiceAmountPredicate + + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql; + ResultSet disposableGoodsInvoiceAmountResultSet = objectDao.executeSql(disposableGoodsInvoiceAmountSql); + try { + while(disposableGoodsInvoiceAmountResultSet.next()){ + String code = disposableGoodsInvoiceAmountResultSet.getString(1); + String dept = disposableGoodsInvoiceAmountResultSet.getString(2); + Double diposableAmount = disposableGoodsInvoiceAmountResultSet.getDouble(3); + if(diposableAmount > 0){ + newMonthReport(code, dept,"2","数量统计", "一次性物品数量",diposableAmount,list); + } } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(disposableGoodsInvoiceAmountResultSet); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs4); + } - String returnSql = "select r.type,(-i.settlementPrice),-i.amount,'',r.depart " - + "from ReturnGoodsRecord r,ReturnGoodsItem i where r.id = i.returnGoodsRecord_ID" - + " and "+returnGoodsItemPredicate+" and r.handleDepartCode = '"+handleDeptCode+"' and r.returnTime " + betweenSql; - if(StringUtils.isNotBlank(department)){ - returnSql += " and r.depart = '" + department + "'"; - } - ResultSet rs5 = objectDao.executeSql(returnSql); - try { - while(rs5.next()){ - String type = rs5.getString(1); - Double price = rs5.getDouble(2); - Double amount = rs5.getDouble(3); - String code = rs5.getString(4); - String dept = rs5.getString(5); - if("一次性物品".equals(type)){ - newMonthReport(code, dept, "1", "价格统计", "一次性物品总价", price, list); - newMonthReport(code, dept, "2", "数量统计", "一次性物品数量", amount, list); - }else{ - newMonthReport(code, dept, "1", "价格统计", "器械包总价", price, list); - newMonthReport(code, dept, "2", "数量统计", "器械包数量", amount, list); + if(StringUtils.isBlank(tousseType) || "器械材料".equals(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ + //供应室领用(器械材料与一次性物品) + String receiveSql = "select i.type,(i.amount*i.price),i.amount,r.departcoding " + + "from ReceiveRecord r,ReceiveRecordItem i where r.id = i.receiverecord_id " + + "and "+receiveRecordItemPredicate+" and r.departCoding = '" + handleDeptCode + "' and r.time " + betweenSql; + + SupplyRoomConfig config = supplyRoomConfigManager.getFirstSupplyRoomConfig(); + ResultSet rs4 = objectDao.executeSql(receiveSql); + try { + while(rs4.next()){ + String type = rs4.getString(1); + Double price = rs4.getDouble(2); + Double amount = rs4.getDouble(3); + String code = rs4.getString(4); + if("一次性物品".equals(type)){ + newMonthReport(code, config.getOrgUnitName(), "1", "价格统计", "一次性物品总价", price, list); + newMonthReport(code, config.getOrgUnitName(), "2", "数量统计", "一次性物品数量", amount, list); + }else{ + newMonthReport(code, config.getOrgUnitName(), "1", "价格统计", "材料总价", price, list); + newMonthReport(code, config.getOrgUnitName(), "2", "数量统计", "材料数量", amount, list); + } } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs4); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs5); } - // 材料退货 - String materialReturnSql = "select '',r.depart , (-i.settlementPrice),-i.amount " - + "from ReturnMaterialRecord r,ReturnMaterialItem i where r.id = i.returnMaterialRecord_ID" - + " and r.handleDepartCode = '"+handleDeptCode+"' and r.returnTime " + betweenSql; - if(StringUtils.isNotBlank(department)){ - returnSql += " and r.depart = '" + department + "'"; - } - ResultSet materialReturnResultSet = objectDao.executeSql(materialReturnSql); - try { - while(materialReturnResultSet.next()){ - String code = materialReturnResultSet.getString(1); - String dept = materialReturnResultSet.getString(2); - Double price = materialReturnResultSet.getDouble(3); - Double amount = materialReturnResultSet.getDouble(4); - - newMonthReport(code, dept, "1", "价格统计", "材料价格", price, list); - newMonthReport(code, dept, "2", "数量统计", "材料数量", amount, list); + + //器械包(含消毒物品、敷料包等)发货数量统计 + if(StringUtils.isBlank(tousseType) || (!"器械材料".equals(tousseType) && !TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType))){ + String invoiceAmountSql = "select '' as coding,i.settleAccountsDepart " + + "as depart,ii.amount,ii.tousseType,ii.tousseName,ii.invoicePlanID from Invoice i,InvoiceItem ii where i.id = ii.invoice_id " + + " and i.orgUnitCoding = '" + handleDeptCode + "' " + + " and (ii.amount is not null and ii.amount>0 and ii.tousseType!='一次性物品') "// 限制为只查包含器械包(含消毒物品、敷料包等)数量的 + + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql; + + ResultSet rs2 = objectDao.executeSql(invoiceAmountSql); + try { + while(rs2.next()){ + String code = rs2.getString(1); + String dept = rs2.getString(2); + Double tousseAmount = rs2.getDouble(3); + String tousseTypeName = rs2.getString(4); + String tousseName = rs2.getString(5); + Long invoicePlanId = rs2.getLong(6); + // 如果是消毒物品,用统计数量替换包数量 + if ("消毒物品".equals(tousseTypeName)) { + if (StringUtils.isNotBlank(tousseName) + && DatabaseUtil.isPoIdValid(invoicePlanId)) { + int disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount( + tousseName, invoicePlanId.toString()); + if (disinfectGoodsStatisticAmount > 0) { + tousseAmount = (tousseAmount * disinfectGoodsStatisticAmount); + } + } + } + if(tousseAmount > 0){ + newMonthReport(code, dept,"2","数量统计", "器械包数量",tousseAmount,list); + } + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs2); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(materialReturnResultSet); } + return list; } Index: ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyView.js =================================================================== diff -u -r13121 -r13316 --- ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyView.js (.../departmentMonthlyView.js) (revision 13121) +++ ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyView.js (.../departmentMonthlyView.js) (revision 13316) @@ -5,6 +5,12 @@ Ext.onReady(function() { Ext.QuickTips.init(); + //物品类型store + var tousseTypeStore = new Ext.data.SimpleStore( { + fields : ['value'], + data : [ ['全部'],['全部器械包'],['器械包'],['消毒物品'],['外来器械包'],['自定义器械包'],['外部代理灭菌包'],['一次性物品'],['器械材料'] ] + }); + var diposableGooodsStore = new Ext.data.JsonStore({ fields : [ 'typeName','typeValue' ], url : WWWROOT + '/disinfectSystem/diposableGoodsAction!getDisposableGoodsTypeForFilter.do', @@ -25,17 +31,25 @@ var endTime = $Id('endTime').value; var departSearch = $Id('departSearch').value; var disposableGoodsType = Ext.getCmp("disposableGoodsType").value; + if(disposableGoodsType == "全部"){ + disposableGoodsType = ""; + } if(startTime == null || startTime == "" || endTime == null || endTime == ""){ showResult('请选择查询时间。'); return false; } + //物品类型 + var tousseType = $Id('tousseType').value; + if(tousseType == "全部"){ + tousseType = ""; + } myMask = new Ext.LoadMask(Ext.getBody(), { msg: '正在加载,请稍候!', removeMask: true }); myMask.show(); - window.open(WWWROOT+"/jasperreports/jasperreportsAction!createReportFromJavaBeanSource.do?jasperreportName=monthReport.jasper&depart="+departSearch+"&startTime="+startTime+"&endTime="+endTime+"&disposableGoodsType="+disposableGoodsType+"&reportName=monthReport",'thisIframe','_self'); + window.open(WWWROOT+"/jasperreports/jasperreportsAction!createReportFromJavaBeanSource.do?jasperreportName=monthReport.jasper&depart="+departSearch+"&startTime="+startTime+"&endTime="+endTime+"&tousseType="+tousseType+"&disposableGoodsType="+disposableGoodsType+"&reportName=monthReport",'thisIframe','_self'); } var columns = [ @@ -122,7 +136,7 @@ height : 70, labelWidth : 70, items : [{ - columnWidth : .3, + columnWidth : .15, layout : 'form', labelWidth : 60, items : [{ @@ -151,7 +165,7 @@ } }] },{ - columnWidth : .3, + columnWidth : .15, layout : 'form', labelWidth : 60, items : [{ @@ -180,7 +194,7 @@ } }] },{ - columnWidth : .4, + columnWidth : .15, layout : 'form', labelWidth : 50, items : [{ @@ -202,8 +216,40 @@ allowBlank : true }] },{ - columnWidth : 0.3, + columnWidth : .15, layout : 'form', + labelWidth : 60, + items : [{ + xtype : 'combo', + fieldLabel : '物品类型', + id : 'tousseType', + name : 'tousseType', + valueField : 'value', + displayField : 'value', + store : tousseTypeStore, + forceSelection : true, + value:'全部', + editable : false, + mode : 'local', + triggerAction : 'all', + anchor : '95%', + listeners : { + select : function(store,records){ + if(Ext.getCmp('disposableGoodsType')){ + if(Ext.getCmp('tousseType').getValue() == '全部' + || Ext.getCmp('tousseType').getValue() == '一次性物品'){ + Ext.getCmp('disposableGoodsType').setDisabled(false); + }else{ + Ext.getCmp('disposableGoodsType').setValue('全部'); + Ext.getCmp('disposableGoodsType').setDisabled(true); + } + } + } + } + }] + },{ + columnWidth : 0.15, + layout : 'form', labelWidth : 100, items : [{ xtype : 'combo',