Index: ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyDetailDSInvoiceItemView.js =================================================================== diff -u -r15047 -r15589 --- ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyDetailDSInvoiceItemView.js (.../departmentMonthlyDetailDSInvoiceItemView.js) (revision 15047) +++ ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyDetailDSInvoiceItemView.js (.../departmentMonthlyDetailDSInvoiceItemView.js) (revision 15589) @@ -76,7 +76,7 @@ var tousseTypeStore = new Ext.data.SimpleStore( { fields : ['value'], - data : [ ['全部'],['全部器械包'],['器械包'],['敷料包'],['消毒物品'],['外来器械包'],['自定义器械包'],['外部代理灭菌包'],['一次性物品'],['器械材料'],['高值耗材'] ] + data : [ ['全部'],['全部器械包'],['器械包'],['敷料包'],['消毒物品'],['外来器械包'],['自定义器械包'],['外部代理灭菌包'],['一次性物品'],['器械材料'],['高值耗材'],['自动扣减物品'] ] }); var goodsTypeStore = new Ext.data.SimpleStore( { Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r15505 -r15589 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 15505) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 15589) @@ -5661,6 +5661,7 @@ @Override public List getMonthReportData(String startDate,String endDate,String department,String tousseType,String disposableGoodsType,Boolean showCustonTousseAmount){ // String handleDeptCode = AcegiHelper.getLoginUser().getOrgUnitCodingFromSupplyRoomConfig(); + final String TYPE_AUTO_DEDUCTION = "自动扣减物品"; SupplyRoomConfig firstSupplyRoomConfig = supplyRoomConfigManager.getFirstSupplyRoomConfig(); boolean isSupplyRoomUser = supplyRoomConfigManager.isSupplyRoomUser(); if(!isSupplyRoomUser){ @@ -5702,14 +5703,19 @@ String tousseTypeInvoiceSql = ""; String tousseTypeReturnSql = ""; if(StringUtils.isNotBlank(tousseType)){ - tousseTypeInvoiceSql = String.format(" and %s ", SqlUtils.getStringFieldInCollectionsPredicate("ii.tousseType", allTousseType)); + if(TYPE_AUTO_DEDUCTION.equals(tousseType)){ + tousseTypeInvoiceSql = String.format(" and ii.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); + }else{ + tousseTypeInvoiceSql = String.format(" and %s ", SqlUtils.getStringFieldInCollectionsPredicate("ii.tousseType", allTousseType)); + } + 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 %s) ", SqlUtils.getStringFieldInCollectionsPredicate("tousseType", allTousseType)); } } - + String invoicePriceSql = "select '' as coding,min(i.settleAccountsDepart) " + "as depart,sum(ii.settlementPrice) as price,ii.diposable from " + Invoice.class.getSimpleName() + " i," + InvoiceItem.class.getSimpleName() + " ii where i.id = ii.invoice_id and "+invoiceItemDisposableGoodsTypePredicate+" and " + getHandleDeptCodeSql("i.orgUnitCoding") + " and (i.status ='收货签收' or " @@ -5734,34 +5740,35 @@ }finally { DatabaseUtil.closeResultSetAndStatement(rs); } - - //退货统计(器械包或一次性物品) - 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 "+getHandleDeptCodeSql("r.handleDepartCode")+" 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(!TYPE_AUTO_DEDUCTION.equals(tousseType)){ + //退货统计(器械包或一次性物品) + 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 "+getHandleDeptCodeSql("r.handleDepartCode")+" 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); + } } + }catch(Exception e){ + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs5); } - }catch(Exception e){ - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs5); } } @@ -5892,11 +5899,16 @@ } } - if(StringUtils.isBlank(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ + if(StringUtils.isBlank(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType) || TYPE_AUTO_DEDUCTION.equals(tousseType)){ + String tousseTypeSql = ""; + if(TYPE_AUTO_DEDUCTION.equals(tousseType)){ + tousseTypeSql = String.format(" and ii.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); + } // 一次性发货数量统计 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 " + getHandleDeptCodeSql("i.orgUnitCoding") + " " + +tousseTypeSql +" and "+disposableGoodsInvoiceAmountPredicate + " and (i.status ='收货签收' or i.status = '已发货') " + invoiceWheresql; ResultSet disposableGoodsInvoiceAmountResultSet = objectDao.executeSql(disposableGoodsInvoiceAmountSql); @@ -5917,7 +5929,7 @@ } - if(isSupplyRoomUser && (StringUtils.isBlank(tousseType) || "器械材料".equals(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType))){ + if(isSupplyRoomUser && (StringUtils.isBlank(tousseType) || "器械材料".equals(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType) || TYPE_AUTO_DEDUCTION.equals(tousseType))){ if("器械材料".equals(tousseType)){ receiveRecordItemPredicate = String.format(" (i.type!='一次性物品') "); }else if(TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ @@ -5929,9 +5941,14 @@ receiveRecordItemPredicate = String.format(" (i.type!='一次性物品' or i.disposableGoodsId in(%s)) ", disposableGoodsIdSql); } } + String tousseTypeSql = ""; + if(TYPE_AUTO_DEDUCTION.equals(tousseType)){ + tousseTypeSql = String.format(" and r.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); + } //供应室领用(器械材料与一次性物品) String receiveSql = "select i.type,(i.amount*i.price),i.amount,r.departcoding " + "from ReceiveRecord r,ReceiveRecordItem i where r.id = i.receiverecord_id " + +tousseTypeSql + "and "+receiveRecordItemPredicate+" and " + getHandleDeptCodeSql("r.departCoding") + " and r.time " + betweenSql; SupplyRoomConfig config = supplyRoomConfigManager.getFirstSupplyRoomConfig(); @@ -6037,7 +6054,7 @@ } //器械包(含消毒物品、敷料包等)发货数量统计 - if(StringUtils.isBlank(tousseType) || (!"器械材料".equals(tousseType) && !TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType))){ + if(StringUtils.isBlank(tousseType) || (!"器械材料".equals(tousseType) && !TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType) && !TYPE_AUTO_DEDUCTION.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 " + getHandleDeptCodeSql("i.orgUnitCoding") + " " @@ -6196,6 +6213,7 @@ String startTime,String endTime, String departSearch,String departCoding,String typeSearch, String goodsNameSearch, String batch,String searchType,boolean disinfection,String disposableGoodsType,String goodsType, Boolean showCustonTousseAmount) { + final String TYPE_AUTO_DEDUCTION = "自动扣减物品"; boolean isSupplyRoomUser = supplyRoomConfigManager.isSupplyRoomUser(); if(!supplyRoomConfigManager.isSupplyRoomUser()){ departSearch = AcegiHelper.getCurrentOrgUnitName(); @@ -6500,22 +6518,27 @@ caseSql = " CASE ii.tousseType WHEN '消毒物品' THEN (ii.tousseName || '_' || ii.invoicePlanID) WHEN '自定义器械包' THEN (ii.tousseName || '_' || ii.invoicePlanID) ELSE ii.tousseName END "; } - String tousseSql = "select i.settleAccountsDepart," + caseSql + " as name,sum(ii.amount) as amount,sum(ii.settlementPrice) as settlementprice,ii.tousseType as type" + String tousseSql = " union all (select i.settleAccountsDepart," + caseSql + " as name,sum(ii.amount) as amount,sum(ii.settlementPrice) as settlementprice,ii.tousseType as type" + ",'' as batchNumber,null as expDate from invoice i,InvoiceItem ii " + " where i.id = ii.invoice_id " + " and ii.diposable = '否' and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " + monthFilterSql + departFilterSql + typeFilterSql + goodsNameFilterSql - + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,ii.tousseType," + caseSql; + + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,ii.tousseType," + caseSql+")"; String diposableGoodsSql = " "; - if(StringUtils.isBlank(typeSearch) || "一次性物品".equals(typeSearch) || "高值耗材".equals(typeSearch)){ - diposableGoodsSql = " union all (select i.settleaccountsdepart,d.name as name,sum(d.amount) as amount,sum(d.fluctuationPrice*d.amount) as settlementprice,'一次性物品' as type" + String diposableGoodsTousseTypeSql = ""; + if(TYPE_AUTO_DEDUCTION.equals(typeSearch)){ + diposableGoodsTousseTypeSql = String.format(" and d.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); + } + if(StringUtils.isBlank(typeSearch) || "一次性物品".equals(typeSearch) || "高值耗材".equals(typeSearch) || TYPE_AUTO_DEDUCTION.equals(typeSearch)){ + diposableGoodsSql = " (select i.settleaccountsdepart,d.name as name,sum(d.amount) as amount,sum(d.fluctuationPrice*d.amount) as settlementprice,'一次性物品' as type" + ",d.batch as batchNumber,dgbs.expDate from invoice i,DiposableGoodsItem d," + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs " + " where i.id = d.invoice_id and d.disposableGoodsBatchStockID=dgbs.id and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " +" and "+diposableGoodsItemPredicate + +diposableGoodsTousseTypeSql + monthFilterSql + departFilterSql + nameFilterSql @@ -6583,10 +6606,15 @@ + "and i.additionalAmount > 0 and "+getHandleDeptCodeSql("i.handleDepartCode")+" " + damageFilterSql + " group by i.departCoding,i.depart,i.materialName ) "; + String supplyRoomTousseTypeSql = ""; + if(TYPE_AUTO_DEDUCTION.equals(typeSearch)){ + supplyRoomTousseTypeSql = String.format(" and rr.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); + } String supplyRoomDiposableGoodsSql = " union all (select rr.depart as settleaccountsdepart,rri.goodsName,sum(rri.amount),sum(rri.price*rri.amount) as settlementprice,rri.type as type,dbs.batchNumber as batchNumber,dbs.expDate " +" from ReceiveRecord rr,ReceiveRecordItem rri left join " + DisposableGoodsBatchStock.class.getSimpleName() + " dbs " +" on rri.diposableGoodBatchStock_id = dbs.id left join DisposableGoods d on d.id = rri.disposableGoodsId where rr.id = rri.receiveRecord_id and "+getHandleDeptCodeSql("rr.departCoding")+" " +supplyRoomDiposableGoodsFilterSql + +supplyRoomTousseTypeSql +" and "+receiveRecordItemPredicate + " group by rr.depart,rri.goodsName,rri.amount,rri.type,dbs.batchNumber,dbs.expDate) "; // 调拨出库 @@ -6605,11 +6633,20 @@ + " group by oge.orgUnitName, ged.goodsName,dgb.batchNumber,dgb.expDate) "; - String sql = tousseSql + diposableGoodsSql + packingDisposableGoodsSql + materialInvoiceSql + returnGoodsSql + materialReturnSql + supplyRoomDiposableGoodsSql + appropriateOutDiposableGoodsSql - +stocktakeOutDiposableGoodsSql; + String sql = diposableGoodsSql + supplyRoomDiposableGoodsSql ; + if(!TYPE_AUTO_DEDUCTION.equals(typeSearch)){ + sql += tousseSql; + sql += materialInvoiceSql; + sql += returnGoodsSql; + sql += materialReturnSql; + sql += appropriateOutDiposableGoodsSql; + sql += stocktakeOutDiposableGoodsSql; + sql += packingDisposableGoodsSql; +// sql += materialInvoiceSql; +// sql += materialInvoiceSql; + } - if ("器械包".equals(typeSearch) || "器械材料".equals(typeSearch) || "全部".equals(typeSearch) || typeSearch == null || "全部器械包".equals(typeSearch) || "高值耗材".equals(typeSearch)) { sql += lostMaterial; sql += damageMaterial; Index: ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyView.js =================================================================== diff -u -r15054 -r15589 --- ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyView.js (.../departmentMonthlyView.js) (revision 15054) +++ ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyView.js (.../departmentMonthlyView.js) (revision 15589) @@ -8,7 +8,7 @@ //物品类型store var tousseTypeStore = new Ext.data.SimpleStore( { fields : ['value'], - data : [ ['全部'],['全部器械包'],['器械包'],['敷料包'],['消毒物品'],['外来器械包'],['自定义器械包'],['外部代理灭菌包'],['一次性物品'],['器械材料'] ] + data : [ ['全部'],['全部器械包'],['器械包'],['敷料包'],['消毒物品'],['外来器械包'],['自定义器械包'],['外部代理灭菌包'],['一次性物品'],['器械材料'],['自动扣减物品'] ] }); var diposableGooodsStore = new Ext.data.JsonStore({