Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r17365 -r17368 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 17365) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 17368) @@ -5792,10 +5792,14 @@ * 核算月报查询 */ @Override - public List getMonthReportData(String startDate,String endDate,String department,String tousseType,String disposableGoodsType,Boolean showCustonTousseAmount){ + public List getMonthReportData(String startDate,String endDate, + String department,String tousseType,String disposableGoodsType,Boolean showCustonTousseAmount){ // String handleDeptCode = AcegiHelper.getLoginUser().getOrgUnitCodingFromSupplyRoomConfig(); boolean enableDiscountPrice = CssdUtils.getSystemSetConfigByNameBool("enableDiscountPrice"); + //是否启用包内材料统计列 + boolean monthReportMaterialAmountOfTousse = CssdUtils.getSystemSetConfigByNameBool("monthReportMaterialAmountOfTousse"); + final String TYPE_AUTO_DEDUCTION = "自动扣减物品"; SupplyRoomConfig firstSupplyRoomConfig = supplyRoomConfigManager.getFirstSupplyRoomConfig(); boolean isSupplyRoomUser = supplyRoomConfigManager.isSupplyRoomUser(); @@ -5825,6 +5829,8 @@ String packingDisposableGoodsTypePredicate = "1=1"; List allTousseType = getTousseTypes(tousseType); String disposableGoodsIdSql = ""; + //包定义id跟材料数量的临时表 + String tousseDefinitionIdMaterialAmountSql = " (select sum(mi.count) materialAmount,td.id,td.tousseType from MaterialInstance mi join TousseDefinition td on mi.tousse_id = td.id group by td.id,td.tousseType) "; if(StringUtils.isNotBlank(disposableGoodsType)){ disposableGoodsIdSql = String.format(" select id from DisposableGoods where type='%s' ", disposableGoodsType); invoiceItemDisposableGoodsTypePredicate = String.format(" (ii.diposable='否' or ii.disposableGoodsId in(%s)) ", disposableGoodsIdSql); @@ -5884,9 +5890,10 @@ } if(!TYPE_AUTO_DEDUCTION.equals(tousseType)){ //退货统计(器械包或一次性物品) - String returnSql = "select r.type,(-i.settlementPrice),-i.amount,r.departCoding,r.depart " - + "from ReturnGoodsRecord r,ReturnGoodsItem i where r.id = i.returnGoodsRecord_ID" - + " and "+returnGoodsItemPredicate+ tousseTypeReturnSql + " and "+getHandleDeptCodeSql("r.handleDepartCode")+" and r.returnTime " + betweenSql; + String returnSql = "select r.type,(-i.settlementPrice),-i.amount,r.departCoding,r.depart,tdm.tousseType,tdm.materialAmount as materialAmount " + + "from ReturnGoodsRecord r join ReturnGoodsItem i on r.id = i.returnGoodsRecord_ID " + + " left join " + tousseDefinitionIdMaterialAmountSql + " tdm on tdm.id = i.tousseDefinition_id " + + " where "+returnGoodsItemPredicate+ tousseTypeReturnSql + " and "+getHandleDeptCodeSql("r.handleDepartCode")+" and r.returnTime " + betweenSql; if(StringUtils.isNotBlank(department)){ returnSql += " and r.depart = '" + department + "'"; } @@ -5898,6 +5905,21 @@ Double amount = rs5.getDouble(3); String code = rs5.getString(4); String dept = rs5.getString(5); + String returnTousseType = rs5.getString("tousseType"); + int materialAmount = rs5.getInt("materialAmount"); + Double totalMaterialAmount = amount * materialAmount; + + // 如果是消毒物品,用统计数量替换包数量 + if ("消毒物品".equals(returnTousseType)) { + if (materialAmount > 0) { + amount = totalMaterialAmount; + } + }else if(TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(returnTousseType)&& !showCustonTousseAmount){ + if (materialAmount > 0) { + amount = totalMaterialAmount; + } + } + if("一次性物品".equals(type)){ newMonthReport(code, dept, "2", "价格统计", "一次性物品总价", price, list); if(enableDiscountPrice){ @@ -5910,6 +5932,9 @@ newMonthReport(code, dept,"1", "科室记支","器械包记支",price, list); } newMonthReport(code, dept, "3", "数量统计", "器械包数量", amount, list); + if(monthReportMaterialAmountOfTousse){ + newMonthReport(code, dept, "4", "包内材料统计", "包内材料数量", totalMaterialAmount, list); + } } } }catch(Exception e){ @@ -5931,7 +5956,7 @@ String code = materialInvoicePriceResultSet.getString(1); String dept = materialInvoicePriceResultSet.getString(2); Double price = materialInvoicePriceResultSet.getDouble(3); - String columnName = "材料总价"; + String columnName = "发货材料总价"; newMonthReport(code, dept,"2", "价格统计",columnName,price, list); if(enableDiscountPrice){ @@ -5958,7 +5983,7 @@ String dept = materialInvoiceAmountResultSet.getString(2); Double tousseAmount = materialInvoiceAmountResultSet.getDouble(3); if(tousseAmount > 0){ - newMonthReport(code, dept,"3","数量统计", "材料数量",tousseAmount,list); + newMonthReport(code, dept,"3","数量统计", "发货材料数量",tousseAmount,list); } } } catch (SQLException e) { @@ -5986,8 +6011,8 @@ Double money = rs33.getDouble(4); Double amount = rs33.getDouble(5); - newMonthReport(code, dept, "3", "数量统计", "材料数量", amount, list); - newMonthReport(code, dept, "2", "价格统计", "材料总价", money, list); + newMonthReport(code, dept, "3", "数量统计", "丢失报损材料数量", amount, list); + newMonthReport(code, dept, "2", "价格统计", "丢失报损材料总价", money, list); if(enableDiscountPrice){ newMonthReport(code, dept,"1", "科室记支","材料记支",money, list); } @@ -6018,8 +6043,8 @@ Double money = rs3.getDouble(4); Double amount = rs3.getDouble(5); - newMonthReport(code, dept,"3", "数量统计","材料数量",amount, list); - newMonthReport(code, dept,"2", "价格统计","材料总价",money, list); + newMonthReport(code, dept,"3", "数量统计","丢失报损材料数量",amount, list); + newMonthReport(code, dept,"2", "价格统计","丢失报损材料总价",money, list); if(enableDiscountPrice){ newMonthReport(code, dept,"1", "科室记支","材料记支",money, list); } @@ -6046,8 +6071,8 @@ Double price = materialReturnResultSet.getDouble(3); Double amount = materialReturnResultSet.getDouble(4); - newMonthReport(code, dept, "2", "价格统计", "材料总价", price, list); - newMonthReport(code, dept, "3", "数量统计", "材料数量", amount, list); + newMonthReport(code, dept, "2", "价格统计", "发货材料总价", price, list); + newMonthReport(code, dept, "3", "数量统计", "发货材料数量", amount, list); if(enableDiscountPrice){ newMonthReport(code, dept,"1", "科室记支","材料记支",price, list); } @@ -6126,11 +6151,11 @@ } newMonthReport(code, config.getOrgUnitName(), "3", "数量统计", "一次性物品数量", amount, list); }else{ - newMonthReport(code, config.getOrgUnitName(), "2", "价格统计", "材料总价", price, list); + newMonthReport(code, config.getOrgUnitName(), "2", "价格统计", "发货材料总价", price, list); if(enableDiscountPrice){ newMonthReport(code, config.getOrgUnitName(),"1", "科室记支","材料记支",price, list); } - newMonthReport(code, config.getOrgUnitName(), "3", "数量统计", "材料数量", amount, list); + newMonthReport(code, config.getOrgUnitName(), "3", "数量统计", "发货材料数量", amount, list); } } }catch(Exception e){ @@ -6231,8 +6256,9 @@ //器械包(含消毒物品、敷料包等)发货数量统计 if(StringUtils.isBlank(tousseType) || (!"器械材料".equals(tousseType) && !TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType) && !TYPE_AUTO_DEDUCTION.equals(tousseType))){ String invoiceAmountSql = "select i.settleAccountsDepartCoding as coding,i.settleAccountsDepart " - + "as depart,ii.amount,ii.tousseType,ii.tousseName,ii.invoicePlanID,ii.tousseDefinitionId from Invoice i,InvoiceItem ii where i.id = ii.invoice_id " - + " and " + getHandleDeptCodeSql("i.orgUnitCoding") + " " + + "as depart,ii.amount,ii.tousseType,ii.tousseName,ii.invoicePlanID,tdm.materialAmount from Invoice i join InvoiceItem ii on i.id = ii.invoice_id " + + " left join " + tousseDefinitionIdMaterialAmountSql + " tdm on tdm.id = ii.tousseDefinitionId " + + " where " + getHandleDeptCodeSql("i.orgUnitCoding") + " " + " and (ii.amount is not null and ii.amount>0) "// 限制为只查包含器械包(含消毒物品、敷料包等)数量的 + " and " + SqlUtils.getStringFieldInCollectionsPredicate("ii.tousseType", allTousseType) + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql; @@ -6246,21 +6272,23 @@ String tousseTypeName = rs2.getString(4); String tousseName = rs2.getString(5); Long invoicePlanId = rs2.getLong(6); - Long tousseDefinitionId = rs2.getLong(7); + int materialAmount = rs2.getInt("materialAmount"); + Double totalMaterialAmount = tousseAmount * materialAmount; // 如果是消毒物品,用统计数量替换包数量 if ("消毒物品".equals(tousseTypeName)) { - int disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount(tousseDefinitionId); - if (disinfectGoodsStatisticAmount > 0) { - tousseAmount = (tousseAmount * disinfectGoodsStatisticAmount); + if (materialAmount > 0) { + tousseAmount = totalMaterialAmount; } }else if(TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(tousseTypeName)&& !showCustonTousseAmount){ - int disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount(tousseDefinitionId); - if (disinfectGoodsStatisticAmount > 0) { - tousseAmount = (tousseAmount * disinfectGoodsStatisticAmount); + if (materialAmount > 0) { + tousseAmount = totalMaterialAmount; } } if(tousseAmount > 0){ newMonthReport(code, dept,"3","数量统计", "器械包数量",tousseAmount,list); + if(monthReportMaterialAmountOfTousse){ + newMonthReport(code, dept, "4", "包内材料统计", "包内材料数量", totalMaterialAmount, list); + } } } } catch (SQLException e) { @@ -6692,6 +6720,7 @@ } String returnGoodsTousseType = " CASE rr.type WHEN '一次性物品' THEN (rr.type) WHEN '器械包' THEN (td.toussetype) ELSE rr.type END "; + String returnGoodsTousseDefinitionId = " CASE rr.type WHEN '器械包' THEN ri.tousseDefinition_id ELSE 0 END "; String tousseSql = " (select i.settleAccountsDepart,ii.tousseName as name,sum(ii.amount) as amount," +"sum(ii.settlementPrice) as settlementprice,sum(ii.settlementDiscountPrice) as settlementDiscountPrice,ii.tousseType as type" @@ -6769,14 +6798,14 @@ String returnGoodsSql = " union all (select rr.depart as settleaccountsdepart,ri.toussename as name," + "-sum(ri.amount) as amount,-sum(ri.settlementPrice) as settlementprice,-sum(ri.settlementPrice) as settlementDiscountPrice," +returnGoodsTousseType+" as type" - + ",ri.batchNumber as batchNumber,dgbs.expDate,0 as tousseDefinitionId from " + ReturnGoodsRecord.class.getSimpleName() + " rr inner join " + + ",ri.batchNumber as batchNumber,dgbs.expDate,"+returnGoodsTousseDefinitionId+" as tousseDefinitionId from " + ReturnGoodsRecord.class.getSimpleName() + " rr inner join " + ReturnGoodsItem.class.getSimpleName()+ " ri on rr.id = ri.returngoodsrecord_id " + " left join " + TousseDefinition.class.getSimpleName() + " td on td.id = ri.tousseDefinition_id" + " left join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on ri.disposableGoodsBatchStockID=dgbs.id" + " where " + getHandleDeptCodeSql("rr.handleDepartCode")+" " + returnGoodsFilterSql +" and "+returnGoodsItemPredicate - + " group by rr.depart,ri.toussename,"+returnGoodsTousseType+",ri.batchNumber,dgbs.expDate) "; + + " group by rr.depart,ri.toussename,"+returnGoodsTousseType+",ri.batchNumber,dgbs.expDate,"+returnGoodsTousseDefinitionId+") "; String lostMaterial = " union all (select r.depart,r.materialName,sum(r.additionalAmount),sum(r.additionalAmount * r.materialCost)," +"sum(r.additionalAmount * r.materialCost) as settlementDiscountPrice,'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " @@ -6928,6 +6957,9 @@ String type = dmi.getType(); if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(type) || TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(type)) { + if(tousseName.equals("面罩")){ + System.out.println(tousseName); + } DepartmentMonthDetailItem item = tmpMap.get(tousseName); if(item == null){ item = new DepartmentMonthDetailItem(); @@ -6944,11 +6976,12 @@ item.setExpDate(dmi.getExpDate()); item.setGoodsName(tousseName); item.setManufacturer(dmi.getManufacturer()); - item.setPrice(dmi.getPrice()); item.setSettlementPrice(item.getSettlementPrice() + dmi.getSettlementPrice()); item.setSettlementDiscountPrice(MathTools.add(item.getSettlementDiscountPrice(), dmi.getSettlementDiscountPrice()).doubleValue()); item.setType(type); item.setExternalCode(item.getExternalCode()); + double price = item.getAmount() == 0?dmi.getPrice(): item.getSettlementPrice() / item.getAmount(); + item.setPrice(price); removeItems.add(dmi); } totalPrice += dmi.getSettlementPrice(); Index: ssts-web/src/main/webapp/disinfectsystem/config/dysyy/config.js =================================================================== diff -u -r17362 -r17368 --- ssts-web/src/main/webapp/disinfectsystem/config/dysyy/config.js (.../config.js) (revision 17362) +++ ssts-web/src/main/webapp/disinfectsystem/config/dysyy/config.js (.../config.js) (revision 17368) @@ -85,5 +85,7 @@ //核算月报只有一列的时候,是否使用另外的一个模板。新模板的名称monthReportOneColumn.jasper applyMonthReportOneColumnTemplate:true, //外来器械拆分小包名称带总拆包数量 - nameIncludeSplitTotalAmountForSplitForeignTousse : true + nameIncludeSplitTotalAmountForSplitForeignTousse : true, + //核算月报是否统计包内材料,如果为true,则在核算月报新添加一列,包内材料统计,包内材料数量的统计项 + monthReportMaterialAmountOfTousse:true } \ No newline at end of file