Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r32776 -r32778 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 32776) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 32778) @@ -5722,10 +5722,6 @@ } String diposableGoodsSql = " "; - String diposableGoodsTousseTypeSql = ""; - if(TYPE_AUTO_DEDUCTION.equals(typeSearch)){ - diposableGoodsTousseTypeSql = String.format(" and d.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); - } String invoiceJoinInvoicePlanSql = null; String excludeSciProjectSql = null; String excludeDiposableGoodsItemSql = null; @@ -5738,21 +5734,50 @@ excludeSciProjectSql = ""; excludeDiposableGoodsItemSql = ""; } - if(StringUtils.isBlank(typeSearch) || typeSearch.contains("一次性物品") || typeSearch.contains("高值耗材") || typeSearch.contains(TYPE_AUTO_DEDUCTION)){ - diposableGoodsSql = " union all (select "+ noMaterialAmountSql +" i.depart,i.settleaccountsdepart "+ dgbsOfSupplierNameSql+noQueryIntegralSql +",d.name as name,sum(d.amount) as amount," + if(StringUtils.isBlank(typeSearch) || typeSearch.contains("一次性物品")){ + diposableGoodsSql += " union all (select "+ noMaterialAmountSql +" i.depart,i.settleaccountsdepart "+ dgbsOfSupplierNameSql+noQueryIntegralSql +",d.name as name,sum(d.amount) as amount," +"sum(d.fluctuationPrice*d.amount) as settlementprice,sum(d.fluctuationPrice*d.amount) as settlementDiscountPrice,'一次性物品' as type" + ",d.batch as batchNumber,dgbs.expDate,0 as tousseDefinitionId from invoice i join DiposableGoodsItem d on d.invoice_id=i.id join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on d.disposableGoodsBatchStockID=dgbs.id " + invoiceJoinInvoicePlanSql + " where 1=1 and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " +" and "+diposableGoodsItemPredicate - +diposableGoodsTousseTypeSql + monthFilterSql + excludeSciProjectSql + departFilterSql + iDepartCodingSql + nameFilterSql - + expensiveDisposablegoodsSql + " group by i.depart,i.settleaccountsdepart,d.name,d.batch,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + }else{ + if(typeSearch.contains("高值耗材")){ + diposableGoodsSql += " union all (select "+ noMaterialAmountSql +" i.depart,i.settleaccountsdepart "+ dgbsOfSupplierNameSql+noQueryIntegralSql +",d.name as name,sum(d.amount) as amount," + +"sum(d.fluctuationPrice*d.amount) as settlementprice,sum(d.fluctuationPrice*d.amount) as settlementDiscountPrice,'一次性物品' as type" + + ",d.batch as batchNumber,dgbs.expDate,0 as tousseDefinitionId from invoice i join DiposableGoodsItem d on d.invoice_id=i.id join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on d.disposableGoodsBatchStockID=dgbs.id " + + invoiceJoinInvoicePlanSql + + " where 1=1 and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " + +" and "+diposableGoodsItemPredicate + + monthFilterSql + + excludeSciProjectSql + + departFilterSql + + iDepartCodingSql + + nameFilterSql + + " and d.expensiveDisposablegoodsId is not null " + + " group by i.depart,i.settleaccountsdepart,d.name,d.batch,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + } + if(typeSearch.contains(TYPE_AUTO_DEDUCTION)){ + diposableGoodsSql += " union all (select "+ noMaterialAmountSql +" i.depart,i.settleaccountsdepart "+ dgbsOfSupplierNameSql+noQueryIntegralSql +",d.name as name,sum(d.amount) as amount," + +"sum(d.fluctuationPrice*d.amount) as settlementprice,sum(d.fluctuationPrice*d.amount) as settlementDiscountPrice,'一次性物品' as type" + + ",d.batch as batchNumber,dgbs.expDate,0 as tousseDefinitionId from invoice i join DiposableGoodsItem d on d.invoice_id=i.id join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on d.disposableGoodsBatchStockID=dgbs.id " + + invoiceJoinInvoicePlanSql + + " where 1=1 and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " + +" and "+diposableGoodsItemPredicate + + String.format(" and d.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION) + + monthFilterSql + + excludeSciProjectSql + + departFilterSql + + iDepartCodingSql + + nameFilterSql + + " group by i.depart,i.settleaccountsdepart,d.name,d.batch,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + } } String packingDisposableGoodsSql = " "; { @@ -5906,11 +5931,11 @@ } } if(StringUtils.isNotBlank(typeSearch) && typeSearch.contains(TYPE_CHARGE)){ - String chargeSql = String.format(" select "+ noMaterialAmountSql +"ci.orgUnitName depart, ci.orgUnitName settleAccountsDepart"+ noQueryIntegralSql +",chargeItem name,1 amount,price settlementprice,0 settlementDiscountPrice,'收费项目' type ,'' batchNumber,NULL as expDate ,null as tousseDefinitionId " + String chargeSql = String.format(" union all select "+ noMaterialAmountSql +"ci.orgUnitName depart, ci.orgUnitName settleAccountsDepart"+ noQueryIntegralSql +",chargeItem name,1 amount,price settlementprice,0 settlementDiscountPrice,'收费项目' type ,'' batchNumber,NULL as expDate ,null as tousseDefinitionId " + " from ChargeRecordItem ci inner join ChargeRecord cr on cr.id=ci.chargeRecord_id where 1=1 %s %s %s %s group by ci.orgUnitName,chargeItem,price,chargeTime " , chargeDepartSql,chargeDateSql,chargeItemSql, ciOrgUnitCodeSql); - sql = chargeSql; + sql += chargeSql; }else if(StringUtils.isBlank(typeSearch) || typeSearch.contains(TYPE_ALL)){ sql += String.format(" union all select "+ noMaterialAmountSql +"ci.orgUnitName depart,ci.orgUnitName settleAccountsDepart"+ noQueryIntegralSql +",chargeItem name,1 amount,price settlementprice,0 settlementDiscountPrice,'收费项目' type ,'' batchNumber,NULL as expDate ,null as tousseDefinitionId " + " from ChargeRecordItem ci inner join ChargeRecord cr on cr.id=ci.chargeRecord_id where 1=1 %s %s %s %s group by ci.orgUnitName,chargeItem,price,chargeTime "