Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/MonthReportHelper.java =================================================================== diff -u -r36225 -r36557 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/MonthReportHelper.java (.../MonthReportHelper.java) (revision 36225) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/MonthReportHelper.java (.../MonthReportHelper.java) (revision 36557) @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Map.Entry; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -72,9 +73,23 @@ departments = departToBrancheOfHospitalMap.keySet(); } Map nameToBrevityCodeMap = new HashMap(); + // 只是为了在按一次性物品类型分组统计的核算月报模板中,控制jasper中columnName列的顺序 + String b = ""; + String c = ""; + String dgType = ""; + String groupBydgType = ""; + String noQueryDgType = ""; + boolean isAccountingMonthlyReportGroupByDisposableGoodsType = false; if("dgshlyyMode".equals(patternOfReport)){ String querySql = "select name,brevityCode from "+ OrgUnit.class.getSimpleName() +" where 1=1 " + SqlUtils.getIsNotNullSql(dbConnection, "brevityCode") + " order by status asc "; nameToBrevityCodeMap = objectDao.getKeyAndValueAreBothStringMap(querySql); + }else if("accountingMonthlyReportGroupByDisposableGoodsType".equals(patternOfReport)){ + isAccountingMonthlyReportGroupByDisposableGoodsType = true; + b = "b"; + c = "c"; + dgType = ",dg.type dgType "; + groupBydgType = ",dg.type "; + noQueryDgType = " null dgType "; } //启用排除属于科研项目的一次性物品申请单的发货数据 boolean excludeSciProjectInfo = CssdUtils.getSystemSetConfigByNameBool("enableExcludeInvoiceItemOfDisposableGoodsApplicationBelongToSciProject", false); @@ -84,37 +99,37 @@ if(columnConfigOfAccountingInfoMap.containsKey("器械包数量")){ insideAmountShowName = columnConfigOfAccountingInfoMap.get("器械包数量"); }else{ - insideAmountShowName = "器械包数量"; + insideAmountShowName = c+"器械包数量"; } String disposableAmountShowName = null;//一次性物品数量显示名 if(columnConfigOfAccountingInfoMap.containsKey("一次性物品数量")){ disposableAmountShowName = columnConfigOfAccountingInfoMap.get("一次性物品数量"); }else{ - disposableAmountShowName = "一次性物品数量"; + disposableAmountShowName = b+"一次性物品数量"; } String errorDamageAmountShowName = null;//丢失报损材料数量显示名 if(columnConfigOfAccountingInfoMap.containsKey("丢失报损材料数量")){ errorDamageAmountShowName = columnConfigOfAccountingInfoMap.get("丢失报损材料数量"); }else{ - errorDamageAmountShowName = "丢失报损材料数量"; + errorDamageAmountShowName = c+"丢失报损材料数量"; } String insidePriceShowName = null;//器械包总价显示名 if(columnConfigOfAccountingInfoMap.containsKey("器械包总价")){ insidePriceShowName = columnConfigOfAccountingInfoMap.get("器械包总价"); }else{ - insidePriceShowName = "器械包总价"; + insidePriceShowName = c+"器械包总价"; } String errorDamagePriceShowName = null;//丢失报损材料显示名 if(columnConfigOfAccountingInfoMap.containsKey("丢失报损材料总价")){ errorDamagePriceShowName = columnConfigOfAccountingInfoMap.get("丢失报损材料总价"); }else{ - errorDamagePriceShowName = "丢失报损材料总价"; + errorDamagePriceShowName = c+"丢失报损材料总价"; } String disposablePriceShowName = null;//一次性物品总价显示名 if(columnConfigOfAccountingInfoMap.containsKey("一次性物品总价")){ disposablePriceShowName = columnConfigOfAccountingInfoMap.get("一次性物品总价"); }else{ - disposablePriceShowName = "一次性物品总价"; + disposablePriceShowName = b+"一次性物品总价"; } String dgWhetherToChargeSQL = ""; String invoiceItemLeftJoinDisposableGoodsSQL = ""; @@ -131,6 +146,12 @@ receiveRecordItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=i.disposableGoodsId "; godownEntryDiposableGoodsItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=ged.disposableGoodsID "; diposableGoodsItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=dgi.disposableGoodsID "; + }else if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + invoiceItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=ii.disposableGoodsId "; + returnGoodsItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=i.disposableGoodsID "; + receiveRecordItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=i.disposableGoodsId "; + godownEntryDiposableGoodsItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=ged.disposableGoodsID "; + diposableGoodsItemLeftJoinDisposableGoodsSQL = " left join DisposableGoods dg on dg.id=dgi.disposableGoodsID "; } String iDepartSql = null; String rDepartSql = null; @@ -255,6 +276,7 @@ queryProjNameSql = ""; containDiposableGoodsItemSql = ""; } + StringBuffer sbf = new StringBuffer(); if(StringUtils.isBlank(tousseType) || !"器械材料".equals(tousseType)){ //物品类型sql String tousseTypeInvoiceSql = ""; @@ -280,6 +302,7 @@ + queryProjNameSql + ",sum(ii.settlementPrice) as price,ii.diposable,sum(ii.settlementDiscountPrice) as settlementDiscountPrice,ii.tousseType " + dgWhetherToChargeSQL + + dgType + " from " + Invoice.class.getSimpleName() + " i join " + InvoiceItem.class.getSimpleName() + " ii on i.id = ii.invoice_id " + invoiceJoinInvoicePlanSql @@ -288,12 +311,14 @@ + dataIndex.getHandleDeptCodeSql("i.orgUnitCoding", isSupplyRoomUserOrIsExpensiveGoodsSupplyRoomUser, orgUnitCoding) + " and (i.status ='收货签收' or " + "i.status = '已发货') " + iDepartCodingWhereSql + invoiceWheresql + tousseTypeInvoiceSql + excludeSciProjectSql + " group by "+ iDepartSql +" i.settleAccountsDepartCoding,i.settleAccountsDepart,ii.diposable,ii.tousseType"+queryProjNameSql - + dgWhetherToChargeSQL; + + dgWhetherToChargeSQL + + groupBydgType; //如果为高值耗材处理科室用户,并且启用高值耗材功能,且所选物品类型为全部或高值耗材时,则将高值耗材退货数据也抵冲掉 if(enableExpensiveGoods && (StringUtils.isBlank(tousseType) || StringUtils.equals(ExpensiveGoods.TYPE_NAME, tousseType))){ invoicePriceSql += " union all (select "+ iDepartSql +"i.settleAccountsDepartCoding coding,i.settleAccountsDepart settleAccountsDepart,-1 * sum(egi.price) price,'否' as diposable,-1 * sum(egi.price) settlementDiscountPrice,'高值耗材' as tousseType " + noQueryWhetherToChargeSQL + + noQueryDgType + " from ExpensiveGoodsGodownEntry egge join ExpensiveGoodsGodownEntryItem eggei on egge.id=eggei.expensiveGoodsGodownEntry_id " + " join ExpensiveGoodsInstance egi on egi.id=eggei.expensiveGoodsInstanceId join Invoice i on egi.invoiceId=i.id " + " where "+ dataIndex.getHandleDeptCodeSql("i.orgUnitCoding", isSupplyRoomUserOrIsExpensiveGoodsSupplyRoomUser, orgUnitCoding) @@ -304,6 +329,8 @@ ResultSet rs = objectDao.executeSql(invoicePriceSql); try { + Map codeAndTypeMap = new HashMap(); + while(rs.next()){ String code = rs.getString("coding"); String dept = null; @@ -320,19 +347,34 @@ String columnName = ""; String costColumn = ""; if("是".equals(diposable)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + sbf.setLength(0); + String key = sbf.append(code).append(",a").append(rs.getString("dgType")).toString(); + if(codeAndTypeMap.containsKey(key)){ + MonthReportBean mrb = codeAndTypeMap.get(key); + mrb.setMoney(MathTools.add(mrb.getMoney(), price).doubleValue()); + }else{ + MonthReportBean mrb = new MonthReportBean(); + mrb.setRowNum(code); + mrb.setDepartment(settleAccountsDepart); + mrb.setMoney(price); + codeAndTypeMap.put(key, mrb); + } + continue; + } String whetherToCharge = null; if(queryWhetherToCharge){ whetherToCharge = rs.getString("whetherToCharge"); } columnName = getChargeDisposableColumnName(queryWhetherToCharge, whetherToCharge, disposablePriceShowName); - costColumn = "一次性物品记支"; + costColumn = c+"一次性物品记支"; discountPrice = price;//一次性物品发货项中目前还没有记录折扣价 }else{ if(ExpensiveGoods.TYPE_NAME.equals(tType)){ - columnName = "高值耗材总价"; + columnName = c+"高值耗材总价"; }else{ columnName = insidePriceShowName; - costColumn = "器械包记支"; + costColumn = c+"器械包记支"; } } @@ -352,6 +394,28 @@ newMonthReport(code, dept,settleAccountsDepart,"1", "科室记支",costColumn,discountPrice, list, hospitalDistrict, enableMultipleBranchesOfHospital); } } + if(codeAndTypeMap.size() > 0){ + Map departSum = new HashMap(); + for (Entry entry : codeAndTypeMap.entrySet()) { + String key = entry.getKey(); + MonthReportBean item = entry.getValue(); + String code = item.getRowNum(); + Double price = item.getMoney(); + newMonthReport(code, null,item.getDepartment(),"2", "价格统计", key.substring(key.indexOf(",") + 1),price, list, null, null); + if(departSum.containsKey(code)){ + MonthReportBean mrb = departSum.get(code); + mrb.setMoney(MathTools.add(mrb.getMoney(), price).doubleValue()); + }else{ + departSum.put(code, item); + } + } + if(departSum.size() > 0){ + for (Entry entry : departSum.entrySet()) { + MonthReportBean item = entry.getValue(); + newMonthReportForGuiGang(item.getRowNum(), item.getDepartment(),"2", "价格统计","b一次性物品合计",item.getMoney(), list); + } + } + } } catch (SQLException e) { e.printStackTrace(); }finally { @@ -376,6 +440,7 @@ + queryColumnSql + queryProjNameSql + dgWhetherToChargeSQL + + dgType + " from ReturnGoodsRecord r join ReturnGoodsItem i on r.id = i.returnGoodsRecord_ID " + leftJoinSqlForReturnSql + returnGoodsItemLeftJoinDisposableGoodsSQL @@ -390,6 +455,7 @@ } ResultSet rs5 = objectDao.executeSql(returnSql); try { + Map codeAndTypeMap = new HashMap(); while(rs5.next()){ String type = rs5.getString("type"); Double price = rs5.getDouble("settlementPrice"); @@ -429,6 +495,10 @@ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); } if("一次性物品".equals(type)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + setCodeAndTypeMapData(codeAndTypeMap, code, settleAccountsDepart, rs5.getString("dgType"), amount, price); + continue; + } String whetherToCharge = null; if(queryWhetherToCharge){ whetherToCharge = rs5.getString("whetherToCharge"); @@ -457,6 +527,7 @@ } } } + addDisposableGoodsData(codeAndTypeMap, list); }catch(Exception e){ e.printStackTrace(); }finally { @@ -487,7 +558,7 @@ } Double price = materialInvoicePriceResultSet.getDouble("price"); - String columnName = "发货材料总价"; + String columnName = c+"发货材料总价"; String hospitalDistrict = null; if(enableMultipleBranchesOfHospital){ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); @@ -527,7 +598,7 @@ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); } if(tousseAmount > 0){ - newMonthReport(code, dept,settleAccountsDepart,"3","数量统计", "发货材料数量",tousseAmount,list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code, dept,settleAccountsDepart,"3","数量统计", c+"发货材料数量",tousseAmount,list,hospitalDistrict, enableMultipleBranchesOfHospital); } } } catch (SQLException e) { @@ -662,10 +733,10 @@ if(enableMultipleBranchesOfHospital){ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); } - newMonthReport(code, dept,settleAccountsDepart, "2", "价格统计", "发货材料总价", price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code, dept,settleAccountsDepart, "2", "价格统计", c+"发货材料总价", price, list,hospitalDistrict, enableMultipleBranchesOfHospital); if(!hideAmountColumn){ int amount = materialReturnResultSet.getInt("amount"); - newMonthReport(code, dept,settleAccountsDepart, "3", "数量统计", "发货材料数量", amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code, dept,settleAccountsDepart, "3", "数量统计", c+"发货材料数量", amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); } if(enableDiscountPrice){ newMonthReport(code, dept,settleAccountsDepart,"1", "科室记支","材料记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); @@ -688,6 +759,7 @@ + queryProjNameSql + ",ii.amount " + dgWhetherToChargeSQL + + dgType + " from Invoice i inner join InvoiceItem ii on i.id = ii.invoice_id " + invoiceJoinInvoicePlanSql + invoiceItemLeftJoinDisposableGoodsSQL @@ -697,8 +769,10 @@ +" and "+disposableGoodsInvoiceAmountPredicate + excludeSciProjectSql + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql + iDepartCodingWhereSql; - ResultSet disposableGoodsInvoiceAmountResultSet = objectDao.executeSql(disposableGoodsInvoiceAmountSql); + ResultSet disposableGoodsInvoiceAmountResultSet = null; try { + disposableGoodsInvoiceAmountResultSet = objectDao.executeSql(disposableGoodsInvoiceAmountSql); + Map codeAndTypeMap = new HashMap(); while(disposableGoodsInvoiceAmountResultSet.next()){ String code = disposableGoodsInvoiceAmountResultSet.getString("coding"); String dept = null; @@ -710,6 +784,21 @@ } int diposableAmount = disposableGoodsInvoiceAmountResultSet.getInt("amount"); if(diposableAmount > 0){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + sbf.setLength(0); + String key = sbf.append(code).append(",a").append(disposableGoodsInvoiceAmountResultSet.getString("dgType")).toString(); + if(codeAndTypeMap.containsKey(key)){ + MonthReportBean mrb = codeAndTypeMap.get(key); + mrb.setAmount(MathTools.add(mrb.getAmount(), diposableAmount).intValue()); + }else{ + MonthReportBean mrb = new MonthReportBean(); + mrb.setRowNum(code); + mrb.setDepartment(settleAccountsDepart); + mrb.setAmount(diposableAmount); + codeAndTypeMap.put(key, mrb); + } + continue; + } String hospitalDistrict = null; String projName = null; if(showTotalMoneyOfSciProjectDisposableGoodsInvoiceInAccountingMonthlyReport){ @@ -730,6 +819,28 @@ ,diposableAmount,list,hospitalDistrict, enableMultipleBranchesOfHospital); } } + if(codeAndTypeMap.size() > 0){ + Map departSum = new HashMap(); + for (Entry entry : codeAndTypeMap.entrySet()) { + String key = entry.getKey(); + MonthReportBean item = entry.getValue(); + String code = item.getRowNum(); + int amount = item.getAmount(); + newMonthReport(code, null,item.getDepartment(),"3", "数量统计", key.substring(key.indexOf(",") + 1),amount, list, null, null); + if(departSum.containsKey(code)){ + MonthReportBean mrb = departSum.get(code); + mrb.setAmount(MathTools.add(mrb.getAmount(), amount).intValue()); + }else{ + departSum.put(code, item); + } + } + if(departSum.size() > 0){ + for (Entry entry : departSum.entrySet()) { + MonthReportBean item = entry.getValue(); + newMonthReportForGuiGang(item.getRowNum(), item.getDepartment(),"3", "数量统计","b一次性物品合计",item.getAmount(), list); + } + } + } } catch (SQLException e) { e.printStackTrace(); }finally { @@ -757,14 +868,16 @@ //供应室领用(器械材料与一次性物品) String receiveSql = "select "+ rDepartSql +" i.type,(i.amount*i.price) price,i.amount,r.departcoding " + dgWhetherToChargeSQL - + "from ReceiveRecord r join ReceiveRecordItem i on r.id = i.receiverecord_id " + + dgType + + " from ReceiveRecord r join ReceiveRecordItem i on r.id = i.receiverecord_id " + receiveRecordItemLeftJoinDisposableGoodsSQL + "where 1=1 " +tousseTypeSql + "and "+receiveRecordItemPredicate + receiveDepartWhereSql + " and r.time " + betweenSql + rDepartCodingWhereSql; SupplyRoomConfig config = supplyRoomConfigManager.getFirstSupplyRoomConfig(); ResultSet rs4 = objectDao.executeSql(receiveSql); try { + Map codeAndTypeMap = new HashMap(); while(rs4.next()){ String type = rs4.getString("type"); Double price = rs4.getDouble("price"); @@ -781,6 +894,10 @@ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(config.getOrgUnitName()) == null?null:departToBrancheOfHospitalMap.get(config.getOrgUnitName()).getName(); } if("一次性物品".equals(type)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + setCodeAndTypeMapData(codeAndTypeMap, code, config.getOrgUnitName(), rs4.getString("dgType"), amount, price); + continue; + } String whetherToCharge = null; if(queryWhetherToCharge){ whetherToCharge = rs4.getString("whetherToCharge"); @@ -793,15 +910,16 @@ newMonthReport(code,dept, config.getOrgUnitName(), "3", "数量统计",getChargeDisposableColumnName(queryWhetherToCharge, whetherToCharge, disposableAmountShowName) , amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); } }else{ - newMonthReport(code, dept, config.getOrgUnitName(), "2", "价格统计", "发货材料总价", price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code, dept, config.getOrgUnitName(), "2", "价格统计", c+"发货材料总价", price, list,hospitalDistrict, enableMultipleBranchesOfHospital); if(enableDiscountPrice){ - newMonthReport(code, dept, config.getOrgUnitName(),"1", "科室记支","材料记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code, dept, config.getOrgUnitName(),"1", "科室记支",c+"材料记支",price, list,hospitalDistrict, enableMultipleBranchesOfHospital); } if(!hideAmountColumn){ - newMonthReport(code, dept, config.getOrgUnitName(), "3", "数量统计", "发货材料数量", amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code, dept, config.getOrgUnitName(), "3", "数量统计", c+"发货材料数量", amount, list,hospitalDistrict, enableMultipleBranchesOfHospital); } } } + addDisposableGoodsData(codeAndTypeMap, list); }catch(Exception e){ e.printStackTrace(); }finally { @@ -813,6 +931,7 @@ //供应室领用(器械材料与一次性物品) String receiveSql = "select '一次性物品',(ged.amount*ged.price),ged.amount,oge.targetOrgUnitCode,oge.targetOrgUnitName " + dgWhetherToChargeSQL + + dgType + "from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID " + godownEntryDiposableGoodsItemLeftJoinDisposableGoodsSQL + " where oge.type ='退库单' and oge.subType='调拨出库' " @@ -826,9 +945,14 @@ } ResultSet rs4 = objectDao.executeSql(receiveSql); try { + Map codeAndTypeMap = new HashMap(); while(rs4.next()){ String type = rs4.getString(1); if("一次性物品".equals(type)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + setCodeAndTypeMapData(codeAndTypeMap, rs4.getString("targetOrgUnitCode"), rs4.getString("targetOrgUnitName"), rs4.getString("dgType"), rs4.getInt("amount"), rs4.getDouble("price")); + continue; + } Double price = rs4.getDouble(2); String code = rs4.getString(4); String orgUnitName = rs4.getString(5); @@ -856,6 +980,7 @@ } } } + addDisposableGoodsData(codeAndTypeMap, list); }catch(Exception e){ e.printStackTrace(); }finally { @@ -867,6 +992,7 @@ //供应室领用(器械材料与一次性物品) String receiveSql = "select '一次性物品',(ged.amount*ged.price),ged.amount,oge.orgUnitCode,oge.orgUnitName " + dgWhetherToChargeSQL + + dgType + "from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID " + godownEntryDiposableGoodsItemLeftJoinDisposableGoodsSQL + " where oge.type ='退库单' and oge.subType='盘亏出库' " @@ -880,9 +1006,14 @@ } ResultSet rs4 = objectDao.executeSql(receiveSql); try { + Map codeAndTypeMap = new HashMap(); while(rs4.next()){ String type = rs4.getString(1); if("一次性物品".equals(type)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + setCodeAndTypeMapData(codeAndTypeMap, rs4.getString("orgUnitCode"), rs4.getString("orgUnitName"), rs4.getString("dgType"), rs4.getInt("amount"), rs4.getDouble("price")); + continue; + } Double price = rs4.getDouble(2); int amount = rs4.getInt("amount"); String code = rs4.getString(4); @@ -910,6 +1041,7 @@ } } } + addDisposableGoodsData(codeAndTypeMap, list); }catch(Exception e){ e.printStackTrace(); }finally { @@ -922,6 +1054,7 @@ 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 " + dgWhetherToChargeSQL + + dgType + "from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId " + diposableGoodsItemLeftJoinDisposableGoodsSQL + " where " @@ -930,9 +1063,14 @@ + " and pr.packTime " + betweenSql + prDepartCodingWhereSql + containDiposableGoodsItemSql; ResultSet rs = objectDao.executeSql(sql); try { + Map codeAndTypeMap = new HashMap(); while(rs.next()){ String type = rs.getString("type"); if("一次性物品".equals(type)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + setCodeAndTypeMapData(codeAndTypeMap, rs.getString("orgUnitCoding"), rs.getString("orgUnitName"), rs.getString("dgType"), rs.getInt("amount"), rs.getDouble("price")); + continue; + } Double price = rs.getDouble("price"); int amount = rs.getInt("amount"); String code = rs.getString("orgUnitCoding"); @@ -950,6 +1088,7 @@ } } } + addDisposableGoodsData(codeAndTypeMap, list); }catch(Exception e){ e.printStackTrace(); }finally { @@ -960,6 +1099,7 @@ 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 " + dgWhetherToChargeSQL + + dgType + "from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId " + diposableGoodsItemLeftJoinDisposableGoodsSQL + " where " @@ -969,9 +1109,14 @@ ResultSet rs = objectDao.executeSql(sql); try { + Map codeAndTypeMap = new HashMap(); while(rs.next()){ String type = rs.getString("type"); if("一次性物品".equals(type)){ + if(isAccountingMonthlyReportGroupByDisposableGoodsType){ + setCodeAndTypeMapData(codeAndTypeMap, rs.getString("orgUnitCoding"), rs.getString("orgUnitName"), rs.getString("dgType"), rs.getInt("amount"), rs.getDouble("price")); + continue; + } Double price = rs.getDouble("price"); int amount = rs.getInt("amount"); String code = rs.getString("orgUnitCoding"); @@ -999,6 +1144,7 @@ } } } + addDisposableGoodsData(codeAndTypeMap, list); }catch(Exception e){ e.printStackTrace(); }finally { @@ -1090,11 +1236,11 @@ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(settleAccountsDepart) == null?null:departToBrancheOfHospitalMap.get(settleAccountsDepart).getName(); } if(ExpensiveGoods.TYPE_NAME.equals(tousseTypeName)){ - newMonthReport(code,dept,settleAccountsDepart,"3","数量统计", "高值耗材数量",tousseAmount,list,integral,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code,dept,settleAccountsDepart,"3","数量统计", c+"高值耗材数量",tousseAmount,list,integral,hospitalDistrict, enableMultipleBranchesOfHospital); }else{ newMonthReport(code,dept,settleAccountsDepart,"3","数量统计", insideAmountShowName,tousseAmount,list,integral,hospitalDistrict, enableMultipleBranchesOfHospital); if(monthReportMaterialAmountOfTousse){ - newMonthReport(code,dept,settleAccountsDepart, "4", "包内材料统计", "包内材料数量", totalMaterialAmount, list,0.0,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(code,dept,settleAccountsDepart, "4", "包内材料统计", c+"包内材料数量", totalMaterialAmount, list,0.0,hospitalDistrict, enableMultipleBranchesOfHospital); } } } @@ -1132,7 +1278,7 @@ if(enableMultipleBranchesOfHospital){ hospitalDistrict = departToBrancheOfHospitalMap == null || departToBrancheOfHospitalMap.isEmpty() || departToBrancheOfHospitalMap.get(orgUnitName) == null?null:departToBrancheOfHospitalMap.get(orgUnitName).getName(); } - newMonthReport(orgUnitCode, dept,orgUnitName, "2", "价格统计", "收费项目总价", price, list,hospitalDistrict, enableMultipleBranchesOfHospital); + newMonthReport(orgUnitCode, dept,orgUnitName, "2", "价格统计", c+"收费项目总价", price, list,hospitalDistrict, enableMultipleBranchesOfHospital); } }catch(Exception e){ e.printStackTrace(); @@ -1446,4 +1592,111 @@ } parametMap.put("titleInfoArr", getTitleInfoArr(enableMultipleBranchesOfHospital, hasWhetherToCharge, columnTitles, titleInfoMap)); } + /** + * 贵港专用的创建MonthReport,用于合计时减去一次性物品合计 + * @param code 部门编码 + * @param dept 部门名称 + * @param columnNum 列所属的title位置 + * @param columnTitle 列标题 + * @param columnName 列名 + * @param money 价格 + * @param list list + */ + private void newMonthReportForGuiGang(String code, String dept, + String columnNum, String columnTitle, String columnName, + Integer amount,List list) { + MonthReportBean bean = new MonthReportBean(); + bean.setSumOfDisposableGoodsAmount(amount); + bean.setRowNum(code); + bean.setDepartment(dept); + bean.setColumnNum(columnNum); + bean.setColumnTitle(columnTitle); + bean.setColumnName(columnName); + bean.setAmount(amount); + list.add(bean); + } + /** + * 贵港专用的创建MonthReport,用于合计时减去一次性物品合计 + * @param code 部门编码 + * @param dept 部门名称 + * @param columnNum 列所属的title位置 + * @param columnTitle 列标题 + * @param columnName 列名 + * @param money 价格 + * @param list list + */ + private void newMonthReportForGuiGang(String code, String dept, + String columnNum, String columnTitle, String columnName, + Double money,List list) { + MonthReportBean bean = new MonthReportBean(); + bean.setSumOfDisposableGoods(money); + bean.setRowNum(code); + bean.setDepartment(dept); + bean.setColumnNum(columnNum); + bean.setColumnTitle(columnTitle); + bean.setColumnName(columnName); + bean.setMoney(money); + list.add(bean); + } + /** + * 添加一次性物品数据(包括各类型数量、价格和所有一次性物品的总数量和总价格) + * @param codeAndTypeMap <科室编码 + "," + a +一次物品类型, MonthReportBean> + * @param list List + */ + private void addDisposableGoodsData(Map codeAndTypeMap, List list){ + if(codeAndTypeMap.size() > 0){ + Map departSum = new HashMap();//一次性物品合计数据 + //添加一次性物品各类型数据 + for (Entry entry : codeAndTypeMap.entrySet()) { + String key = entry.getKey();//科室编码 + , + a +一次物品类型(a。b。c用于报表列排序) + MonthReportBean item = entry.getValue(); + String code = item.getRowNum(); + String dept = item.getDepartment(); + Double price = item.getMoney(); + Integer amount = item.getAmount(); + String columnName = key.substring(key.indexOf(",") + 1);//a +一次物品类型 + newMonthReport(code, null,dept, "2", "价格统计", columnName, price, list, null, null); + newMonthReport(code, null,dept,"3", "数量统计", columnName, amount, list, null, null); + if(departSum.containsKey(code)){//计算合计 + MonthReportBean mrb = departSum.get(code); + mrb.setAmount(MathTools.add(mrb.getAmount(), amount).intValue()); + mrb.setMoney(MathTools.add(mrb.getMoney(), price).doubleValue()); + }else{ + departSum.put(code, item); + } + } + //添加一次性物品合计 + if(departSum.size() > 0){ + for (Entry entry : departSum.entrySet()) { + MonthReportBean item = entry.getValue(); + newMonthReportForGuiGang(item.getRowNum(), item.getDepartment(), "2", "价格统计", "b一次性物品合计", item.getMoney(), list); + newMonthReportForGuiGang(item.getRowNum(), item.getDepartment(),"3", "数量统计","b一次性物品合计",item.getAmount(), list); + } + } + } + } + /** + * 设置一次性物品数据 + * @param codeAndTypeMap <部门编码+","+一次性物品类型,MonthReportBean> + * @param departCode 部门编码 + * @param departName 部门名称 + * @param disposableGoodsType 一次性物品类型 + * @param amount 数量 + * @param price 价格 + */ + private void setCodeAndTypeMapData(Map codeAndTypeMap, String departCode, String departName, String disposableGoodsType, Integer amount, Double price){ + String key = new StringBuffer(20).append(departCode).append(",a").append(disposableGoodsType).toString(); + if(codeAndTypeMap.containsKey(key)){ + MonthReportBean mrb = codeAndTypeMap.get(key); + mrb.setAmount(MathTools.add(mrb.getAmount(), amount).intValue()); + mrb.setMoney(MathTools.add(mrb.getMoney(), price).doubleValue()); + }else{ + MonthReportBean mrb = new MonthReportBean(); + mrb.setRowNum(departCode); + mrb.setMoney(price); + mrb.setDepartment(departName); + mrb.setAmount(amount); + codeAndTypeMap.put(key, mrb); + } + } } Index: ssts-web/src/main/webapp/jasperRtp/monthReportGroupByDisposableGoodsType.jrxml =================================================================== diff -u -r36554 -r36557 --- ssts-web/src/main/webapp/jasperRtp/monthReportGroupByDisposableGoodsType.jrxml (.../monthReportGroupByDisposableGoodsType.jrxml) (revision 36554) +++ ssts-web/src/main/webapp/jasperRtp/monthReportGroupByDisposableGoodsType.jrxml (.../monthReportGroupByDisposableGoodsType.jrxml) (revision 36557) @@ -186,7 +186,7 @@ - + Index: ssts-web/src/main/webapp/jasperRtp/monthReportGroupByDisposableGoodsType.jasper =================================================================== diff -u -r36554 -r36557 Binary files differ Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java =================================================================== diff -u -r36554 -r36557 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 36554) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 36557) @@ -1150,7 +1150,7 @@ boolean queryWhetherToCharge = CssdUtils.getSystemSetConfigByNameBool("enableWheterToChargeFieldOfDisposableGoods", false); if(!enableMultipleBranchesOfHospital && "accountingMonthlyReportGroupBySterilizationMode".equals(patternOfReport)){//按灭菌方式拆分器械包列,bjcyl个性化报表 dataSource = jasperReportManager.getMonthReportDataGroupBySterilizationMode(startDate, endDate, department, tousseType, disposableGoodsType, showCustonTousseAmount); - }else if(!enableMultipleBranchesOfHospital && "accountingMonthlyReportGroupByDisposableGoodsType".equals(patternOfReport)){//一次性物品拆分,添加一次性物品数量合计、价格合计 + }else if(false && !enableMultipleBranchesOfHospital && "accountingMonthlyReportGroupByDisposableGoodsType".equals(patternOfReport)){//一次性物品拆分,添加一次性物品数量合计、价格合计 dataSource = jasperReportManager.getMonthReportDataGroupByDisposableGoodsType(startDate, endDate, department, tousseType, disposableGoodsType, showCustonTousseAmount); }else{//普通模式(显示数量和数量) dataSource = jasperReportManager