Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r30908 -r30927 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 30908) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 30927) @@ -2928,6 +2928,8 @@ } //启用排除属于科研项目的一次性物品申请单的发货数据 boolean excludeSciProjectInfo = CssdUtils.getSystemSetConfigByNameBool("enableExcludeInvoiceItemOfDisposableGoodsApplicationBelongToSciProject", false); + //核算月报中单独显示属于科研项目的一次性物品申请单发货的总金额 + boolean showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport = CssdUtils.getSystemSetConfigByNameBool("showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport", false); String insideAmountShowName = null;//器械包数量显示名 if(columnConfigOfAccountingInfoMap.containsKey("器械包数量")){ insideAmountShowName = columnConfigOfAccountingInfoMap.get("器械包数量"); @@ -3061,14 +3063,26 @@ String invoiceJoinInvoicePlanSql = null; String excludeSciProjectSql = null; String excludeDiposableGoodsItemSql = null; - if(excludeSciProjectInfo){//排除属于科研项目的一次性物品申请单的发货数据 + String queryProjNameSql = null; + String containDiposableGoodsItemSql = null; + if(showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ invoiceJoinInvoicePlanSql = " left join "+ InvoicePlan.class.getSimpleName() +" ip on i.invoicePlan_ID=ip.id "; + excludeSciProjectSql = ""; + excludeDiposableGoodsItemSql = ""; + containDiposableGoodsItemSql = " and dgi.invoice_id in (select i.id from "+ Invoice.class.getSimpleName() +" i join "+ InvoicePlan.class.getSimpleName() +" ip on ip.id=i.invoicePlan_ID where (ip.projName is not null) and dgi.invoice_id=i.id) "; + queryProjNameSql = ",ip.projName "; + }else if(excludeSciProjectInfo){//排除属于科研项目的一次性物品申请单的发货数据 + invoiceJoinInvoicePlanSql = " left join "+ InvoicePlan.class.getSimpleName() +" ip on i.invoicePlan_ID=ip.id "; excludeSciProjectSql = " and (ip.projName is null or ip.projName='')"; excludeDiposableGoodsItemSql = " and dgi.invoice_id in (select i.id from "+ Invoice.class.getSimpleName() +" i left join "+ InvoicePlan.class.getSimpleName() +" ip on ip.id=i.invoicePlan_ID where (ip.projName is null or ip.projName='') and dgi.invoice_id=i.id) "; + queryProjNameSql = ""; + containDiposableGoodsItemSql = ""; }else{ invoiceJoinInvoicePlanSql = ""; excludeSciProjectSql = ""; excludeDiposableGoodsItemSql = ""; + queryProjNameSql = ""; + containDiposableGoodsItemSql = ""; } if(StringUtils.isBlank(tousseType) || !"器械材料".equals(tousseType)){ //物品类型sql @@ -3092,11 +3106,12 @@ } String invoicePriceSql = "select "+ iDepartSql+"i.settleAccountsDepartCoding as coding,i.settleAccountsDepart " + + queryProjNameSql + ",sum(ii.settlementPrice) as price,ii.diposable,sum(ii.settlementDiscountPrice) as settlementDiscountPrice,ii.tousseType from " + Invoice.class.getSimpleName() + " i join " + InvoiceItem.class.getSimpleName() + " ii on i.id = ii.invoice_id " + invoiceJoinInvoicePlanSql + "where 1=1 and "+invoiceItemDisposableGoodsTypePredicate+" and " + getHandleDeptCodeSql("i.orgUnitCoding") + " and (i.status ='收货签收' or " - + "i.status = '已发货') " + iDepartCodingWhereSql + invoiceWheresql + tousseTypeInvoiceSql + excludeSciProjectSql + " group by "+ iDepartSql +" i.settleAccountsDepartCoding,i.settleAccountsDepart,ii.diposable,ii.tousseType"; + + "i.status = '已发货') " + iDepartCodingWhereSql + invoiceWheresql + tousseTypeInvoiceSql + excludeSciProjectSql + " group by "+ iDepartSql +" i.settleAccountsDepartCoding,i.settleAccountsDepart,ii.diposable,ii.tousseType"+queryProjNameSql; //如果为高值耗材处理科室用户,并且启用高值耗材功能,且所选物品类型为全部或高值耗材时,则将高值耗材退货数据也抵冲掉 if(enableExpensiveGoods && (StringUtils.isBlank(tousseType) || StringUtils.equals(ExpensiveGoods.TYPE_NAME, tousseType))){ @@ -3137,7 +3152,14 @@ } String hospitalDistrict = null; - if(enableMultipleBranchesOfHospital){ + String projName = null; + if(showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ + projName = rs.getString("projName"); + } + if(StringUtils.isNotBlank(projName) && showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ + dept = "科研物资领用公共部门"; + settleAccountsDepart = "科研物资领用公共部门"; + }else if(enableMultipleBranchesOfHospital){ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); } newMonthReport(code, dept,settleAccountsDepart,"2", "价格统计",columnName,price, list, hospitalDistrict, enableMultipleBranchesOfHospital); @@ -3437,6 +3459,7 @@ } // 一次性发货数量统计 String disposableGoodsInvoiceAmountSql = "select "+ iDepartSql +"i.settleAccountsDepartCoding as coding,i.settleAccountsDepart " + + queryProjNameSql + ",ii.amount from Invoice i inner join InvoiceItem ii on i.id = ii.invoice_id " + invoiceJoinInvoicePlanSql + "where " + getHandleDeptCodeSql("i.orgUnitCoding") + " " @@ -3456,7 +3479,14 @@ int diposableAmount = disposableGoodsInvoiceAmountResultSet.getInt("amount"); if(diposableAmount > 0){ String hospitalDistrict = null; - if(enableMultipleBranchesOfHospital){ + String projName = null; + if(showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ + projName = disposableGoodsInvoiceAmountResultSet.getString("projName"); + } + if(StringUtils.isNotBlank(projName) && showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ + dept = "科研物资领用公共部门"; + settleAccountsDepart = "科研物资领用公共部门"; + }else if(enableMultipleBranchesOfHospital){ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); } newMonthReport(code, dept,settleAccountsDepart,"3","数量统计", disposableAmountShowName,diposableAmount,list,hospitalDistrict, enableMultipleBranchesOfHospital); @@ -3546,18 +3576,18 @@ try { while(rs4.next()){ String type = rs4.getString(1); - Double price = rs4.getDouble(2); - String code = rs4.getString(4); - String orgUnitName = rs4.getString(5); - String depart = null; - if(showApplicationDepart){ - depart = orgUnitName; - } - String hospitalDistrict = null; - if(enableMultipleBranchesOfHospital){ - hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); - } if("一次性物品".equals(type)){ + Double price = rs4.getDouble(2); + String code = rs4.getString(4); + String orgUnitName = rs4.getString(5); + String depart = null; + if(showApplicationDepart){ + depart = orgUnitName; + } + String hospitalDistrict = null; + if(enableMultipleBranchesOfHospital){ + hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); + } newMonthReport(code, depart,orgUnitName, "2", "价格统计", disposablePriceShowName, price, list,hospitalDistrict, enableMultipleBranchesOfHospital); if(enableDiscountPrice){ newMonthReport(code, depart,orgUnitName,"1", "科室记支","一次性物品记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); @@ -3589,19 +3619,19 @@ try { while(rs4.next()){ String type = rs4.getString(1); - Double price = rs4.getDouble(2); - int amount = rs4.getInt("amount"); - String code = rs4.getString(4); - String orgUnitName = rs4.getString(5); - String hospitalDistrict = null; - if(enableMultipleBranchesOfHospital){ - hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); - } - String depart = null; - if(showApplicationDepart){ - depart = orgUnitName; - } if("一次性物品".equals(type)){ + Double price = rs4.getDouble(2); + int amount = rs4.getInt("amount"); + String code = rs4.getString(4); + String orgUnitName = rs4.getString(5); + String hospitalDistrict = null; + if(enableMultipleBranchesOfHospital){ + hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); + } + String depart = null; + if(showApplicationDepart){ + depart = orgUnitName; + } newMonthReport(code, depart,orgUnitName, "2", "价格统计", disposablePriceShowName, price, list,hospitalDistrict, enableMultipleBranchesOfHospital); if(enableDiscountPrice){ newMonthReport(code, depart,orgUnitName,"1", "科室记支","一次性物品记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); @@ -3619,41 +3649,77 @@ } // 一次性物品装配扣减库存 { - if(isSupplyRoomUser && (StringUtils.isBlank(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType))){ - String sql = "select "+ prDepartSql +"'一次性物品' type,(dgi.amount*dgi.fluctuationPrice) price,dgi.amount,pr.orgUnitCoding,pr.orgUnitName " - + "from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId where " - +packingDisposableGoodsTypePredicate+" and " + getHandleDeptCodeSql("pr.orgUnitCoding") + " and pr.packTime " + betweenSql + prDepartCodingWhereSql + excludeDiposableGoodsItemSql; - - ResultSet rs = objectDao.executeSql(sql); - try { - while(rs.next()){ - String type = rs.getString("type"); - Double price = rs.getDouble("price"); - int amount = rs.getInt("amount"); - String code = rs.getString("orgUnitCoding"); - String dept = null; - if(showApplicationDepart){ - dept = rs.getString("depart"); + if(showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ + if(isSupplyRoomUser && (StringUtils.isBlank(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType))){ + String sql = "select "+ prDepartSql +"'一次性物品' type,(dgi.amount*dgi.fluctuationPrice) price,dgi.amount,pr.orgUnitCoding,pr.orgUnitName " + + "from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId where " + +packingDisposableGoodsTypePredicate+" and " + getHandleDeptCodeSql("pr.orgUnitCoding") + " and pr.packTime " + betweenSql + prDepartCodingWhereSql + containDiposableGoodsItemSql; + ResultSet rs = objectDao.executeSql(sql); + try { + while(rs.next()){ + String type = rs.getString("type"); + if("一次性物品".equals(type)){ + Double price = rs.getDouble("price"); + int amount = rs.getInt("amount"); + String code = rs.getString("orgUnitCoding"); + String dept = null; + if(showApplicationDepart){ + dept = rs.getString("depart"); + } + String orgUnitName = rs.getString("orgUnitName"); + String hospitalDistrict = null; + newMonthReport(code, "科研物资领用公共部门","科研物资领用公共部门", "2", "价格统计", disposablePriceShowName, price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + if(enableDiscountPrice){ + newMonthReport(code, "科研物资领用公共部门","科研物资领用公共部门","1", "科室记支","一次性物品记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + } + if(!hideAmountColumn){ + newMonthReport(code, "科研物资领用公共部门","科研物资领用公共部门", "3", "数量统计", disposableAmountShowName, amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); + } + } } - String orgUnitName = rs.getString("orgUnitName"); - String hospitalDistrict = null; - if(enableMultipleBranchesOfHospital){ - hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null ?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); - } - if("一次性物品".equals(type)){ - newMonthReport(code, dept,orgUnitName, "2", "价格统计", disposablePriceShowName, price, list,hospitalDistrict, enableMultipleBranchesOfHospital); - if(enableDiscountPrice){ - newMonthReport(code, dept,orgUnitName,"1", "科室记支","一次性物品记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + } + }else{ + if(isSupplyRoomUser && (StringUtils.isBlank(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType))){ + String sql = "select "+ prDepartSql +"'一次性物品' type,(dgi.amount*dgi.fluctuationPrice) price,dgi.amount,pr.orgUnitCoding,pr.orgUnitName " + + "from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId where " + +packingDisposableGoodsTypePredicate+" and " + getHandleDeptCodeSql("pr.orgUnitCoding") + " and pr.packTime " + betweenSql + prDepartCodingWhereSql + excludeDiposableGoodsItemSql; + + ResultSet rs = objectDao.executeSql(sql); + try { + while(rs.next()){ + String type = rs.getString("type"); + if("一次性物品".equals(type)){ + Double price = rs.getDouble("price"); + int amount = rs.getInt("amount"); + String code = rs.getString("orgUnitCoding"); + String dept = null; + if(showApplicationDepart){ + dept = rs.getString("depart"); + } + String orgUnitName = rs.getString("orgUnitName"); + String hospitalDistrict = null; + if(enableMultipleBranchesOfHospital){ + hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null ?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); + } + newMonthReport(code, dept,orgUnitName, "2", "价格统计", disposablePriceShowName, price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + if(enableDiscountPrice){ + newMonthReport(code, dept,orgUnitName,"1", "科室记支","一次性物品记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + } + if(!hideAmountColumn){ + newMonthReport(code, dept,orgUnitName, "3", "数量统计", disposableAmountShowName, amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); + } } - if(!hideAmountColumn){ - newMonthReport(code, dept,orgUnitName, "3", "数量统计", disposableAmountShowName, amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); - } } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs); } } }