Index: ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart.jrxml =================================================================== diff -u --- ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart.jrxml (revision 0) +++ ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart.jrxml (revision 26921) @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="103"> + <textField> + <reportElement uuid="44490171-536f-433c-ba9c-7d6e64a00900" x="1" y="0" width="614" height="35"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="14" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$P{title}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="dfe1c42e-f8b2-4924-9b8e-eb8a229e9de6" positionType="FixRelativeToBottom" x="1" y="35" width="144" height="34"/> + <textElement verticalAlignment="Middle"> + <font size="12" isBold="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{employmentDepart}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="feea48f4-e268-49d4-94d1-b4af5816d9ba" positionType="FixRelativeToBottom" x="432" y="35" width="183" height="34"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font size="12" isBold="false"/> + </textElement> + <text><![CDATA[页数:共 页 第 页]]></text> + </staticText> + <staticText> + <reportElement uuid="81cca96c-e1ce-4713-86de-05fc14c4899d" style="table_TH" x="81" y="69" width="200" height="34" backcolor="#FFFFFF"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="true"/> + </textElement> + <text><![CDATA[物品名称]]></text> + </staticText> + <staticText> + <reportElement uuid="3ddf7178-e704-4c96-bc9f-106e3b6d50cc" style="table_TH" x="383" y="69" width="70" height="34" backcolor="#FFFFFF"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="true"/> + </textElement> + <text><![CDATA[数量]]></text> + </staticText> + <staticText> + <reportElement uuid="207fe40d-3a67-4738-ac6d-59b1a52f3096" style="table_TH" x="453" y="69" width="80" height="34" backcolor="#FFFFFF"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="true"/> + </textElement> + <text><![CDATA[单价]]></text> + </staticText> + <staticText> + <reportElement uuid="27328556-20ed-4384-959d-d0be3328fdec" style="table_TH" x="533" y="69" width="80" height="34" backcolor="#FFFFFF"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="true"/> + </textElement> + <text><![CDATA[金额]]></text> + </staticText> + <staticText> + <reportElement uuid="81cca96c-e1ce-4713-86de-05fc14c4899d" style="table_TH" x="1" y="69" width="80" height="34" backcolor="#FFFFFF"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="true"/> + </textElement> + <text><![CDATA[类别]]></text> + </staticText> + <staticText> + <reportElement uuid="81cca96c-e1ce-4713-86de-05fc14c4899d" style="table_TH" x="281" y="69" width="102" height="34" backcolor="#FFFFFF"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="true"/> + </textElement> + <text><![CDATA[规格]]></text> + </staticText> + <textField> + <reportElement uuid="8eb525ff-94be-428c-a67e-3173141c1ad6" positionType="FixRelativeToBottom" x="145" y="35" width="287" height="34"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12" isBold="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{statisticsTime}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/DepartmentMonthDetailItem.java =================================================================== diff -u -r25907 -r26921 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/DepartmentMonthDetailItem.java (.../DepartmentMonthDetailItem.java) (revision 25907) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/DepartmentMonthDetailItem.java (.../DepartmentMonthDetailItem.java) (revision 26921) @@ -39,6 +39,10 @@ private int typeOrder = ORDER_TOUSSE; /** + * 规格 + */ + private String specification; + /** * 供应商 主要显示一次性物品和外来器械的供应商 */ private String supplierName; @@ -153,5 +157,13 @@ public void setSupplierName(String supplierName) { this.supplierName = supplierName; } + + public String getSpecification() { + return specification; + } + + public void setSpecification(String specification) { + this.specification = specification; + } } Index: ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart_child.jrxml =================================================================== diff -u --- ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart_child.jrxml (revision 0) +++ ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart_child.jrxml (revision 26921) @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/container/service/ContainerManagerImpl.java =================================================================== diff -u -r26913 -r26921 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/container/service/ContainerManagerImpl.java (.../ContainerManagerImpl.java) (revision 26913) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/container/service/ContainerManagerImpl.java (.../ContainerManagerImpl.java) (revision 26921) @@ -659,7 +659,7 @@ ResultSet rs = null; Collection result = new HashSet(); try { - String equalSql = ""; + String equalSql = null; if(isExclude == null || isExclude){ equalSql = "<>"; }else{ Index: ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyDetailDSInvoiceItemView.js =================================================================== diff -u -r26649 -r26921 --- ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyDetailDSInvoiceItemView.js (.../departmentMonthlyDetailDSInvoiceItemView.js) (revision 26649) +++ ssts-web/src/main/webapp/disinfectsystem/reportforms/departmentMonthlyDetailDSInvoiceItemView.js (.../departmentMonthlyDetailDSInvoiceItemView.js) (revision 26921) @@ -1,6 +1,7 @@ var entityName = "科室月报明细"; var grid; - +var dataForPatternOfReport = []; +var reportTypeJson = null; var myMask; Ext.onReady(function() { Ext.QuickTips.init(); @@ -19,6 +20,36 @@ } }); diposableGooodsStore.load(); + reportTypeJson = sstsConfig.typesOfDetailedAccountingMonthlyReport; + if(reportTypeJson != null && reportTypeJson.length > 1){ + for (var i = 0; i < reportTypeJson.length; i++) { + var item = reportTypeJson[i]; + var optionText = item.optionText; + var reportName = item.reportName; + var reportType = null; + if(reportName == '标准的明细核算月报'){ + reportType = 'standard'; + }else if(reportName == '单个科室的明细核算月报'){ + reportType = 'singleDepart'; + }else{ + continue; + } + dataForPatternOfReport.push([reportType,optionText]); + } + } + var patternOfReport = new Ext.data.SimpleStore({ + fields : ['id', 'name'], + data : dataForPatternOfReport + }); + function getHiddenValueByReportName(reportName){ + var patternOfReport = null; + if(reportName == '单个科室的明细核算月报'){ + patternOfReport = 'singleDepart'; + }else{ + patternOfReport = 'standard'; + } + return patternOfReport; + } function reloadReport(){ var startTime= $Id('startTime').value; var endTime= $Id('endTime').value; @@ -48,39 +79,49 @@ msg: '正在加载,请稍候!', removeMask: true }); + var patternOfReport = null; + if(reportTypeJson == null || reportTypeJson.length == 0){//默认标准的明细核算月报 + patternOfReport = 'standard'; + }else if(reportTypeJson.length == 1){//配置了一个报表格式 + var reportName = reportTypeJson[0].reportName; + if(reportName == '标准的明细核算月报'){ + patternOfReport = 'standard'; + }else if(reportName == '单个科室的明细核算月报'){ + patternOfReport = 'singleDepart'; + } + }else{//配置了多个报表格式 + patternOfReport = Ext.getCmp("patternOfReport").value; + } + if(patternOfReport == "" && reportTypeJson != null && reportTypeJson.length > 1){ + showResult('请选择报表格式。'); + return false; + } var showCustonTousseAmount = false; if(sstsConfig.hasOwnProperty('isMonthReportShowCustonTousseAmount') && sstsConfig.isMonthReportShowCustonTousseAmount){ showCustonTousseAmount = true; } - myMask.show(); var jasperreportFileName = "DepartmentMonthDetail.jasper"; //获取配置是否查询显示供应商,默认false:不查询隐藏供应商 var showSupplierNameInDetailedAccountingMonthlyReport = false; if(sstsConfig.hasOwnProperty('showSupplierNameInDetailedAccountingMonthlyReport') && sstsConfig.showSupplierNameInDetailedAccountingMonthlyReport){ showSupplierNameInDetailedAccountingMonthlyReport = true; } var enableDiscountPrice = sstsConfig.enableDiscountPrice; - if(enableDiscountPrice && showSupplierNameInDetailedAccountingMonthlyReport){//价格供应商都显示 + if("singleDepart" == patternOfReport){//单个科室的明细核算月报 + if(departSearch == '' || departCoding == ''){ + showResult('单个科室的明细核算月报必须选择科室'); + Ext.getCmp('departSearch').focus(); + return false; + } + jasperreportFileName = "DepartmentMonthDetailOfSingleDepart.jasper"; + }else if(enableDiscountPrice && showSupplierNameInDetailedAccountingMonthlyReport){//价格供应商都显示 jasperreportFileName = "DepartmentMonthDetailSupplierNameAndDiscountPrice.jasper"; }else if(enableDiscountPrice){//显示价格 jasperreportFileName = "DepartmentMonthDetailDiscountPrice.jasper"; }else if(showSupplierNameInDetailedAccountingMonthlyReport){//查询显示供应商 jasperreportFileName = "DepartmentMonthDetailSupplierName.jasper"; } - /*window.open(WWWROOT + "/jasperreports/jasperreportsAction!createReportFromJavaBeanSource.do?" - + "reportName=departmentMonthDetail&jasperreportName=" + jasperreportFileName - + "&departSearch=" + departSearch - + "&startTime=" + startTime - + "&endTime=" + endTime - + "&goodsSearch=" + goodsSearch - + "&tousseType=" + tousseType - + "&goodsType=" + goodsType - + "&searchType=" + searchType - + "&batch=" + batch - + "&departCoding=" + departCoding - + "&disposableGoodsType=" + disposableGoodsType - + "&showCustonTousseAmount=" + showCustonTousseAmount, - 'thisIframe', '_self');*/ + myMask.show(); var url = WWWROOT + "/jasperreports/jasperreportsAction!createReportFromJavaBeanSource.do?" + "reportName=departmentMonthDetail&jasperreportName=" + jasperreportFileName + "&departSearch=" + departSearch @@ -92,7 +133,8 @@ + "&batch=" + batch + "&departCoding=" + departCoding + "&disposableGoodsType=" + disposableGoodsType - + "&showCustonTousseAmount=" + showCustonTousseAmount; + + "&showCustonTousseAmount=" + showCustonTousseAmount + + "&patternOfReport=" + patternOfReport; document.getElementById("goodsNameSearch").value = goodsSearch; document.getElementById("reportHiddenForm").action = url; document.getElementById("reportHiddenForm").submit(); @@ -431,6 +473,26 @@ triggerAction : 'all', anchor : '95%' }] + },{ + columnWidth : 0.2, + layout : 'form', + labelWidth : 100, + id : 'patternOfReportLable', + items : [{ + xtype : 'combo', + fieldLabel : "报表格式", + displayField : 'name', + valueField : 'id', + store : patternOfReport, + forceSelection : false, + listWidth:150, + editable : false, + mode : 'local', + triggerAction : 'all', + name : "patternOfReport", + id : "patternOfReport", + anchor : '95%' + }] }] }], buttons:[{ @@ -484,4 +546,9 @@ } reloadReport(); + if(dataForPatternOfReport.length < 1){ + Ext.getCmp("patternOfReportLable").setVisible(false); + }else if(dataForPatternOfReport.length > 1){ + Ext.getCmp('patternOfReport').setValue(getHiddenValueByReportName(reportTypeJson[0].reportName)); + } }); \ No newline at end of file Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r26906 -r26921 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 26906) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 26921) @@ -4641,57 +4641,20 @@ } String betweenSql = ""; if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { - betweenSql = " between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); - monthFilterSql = " and i.sendtime between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); - expensiveGoodsMonthFilterSql = " and egge.time between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); - returnGoodsTimeFilterSql = " and rr.returntime between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); + betweenSql = new StringBuffer(150).append(" between ") + .append(dateQueryAdapter.dateConverAdapter2( startTime, "yyyy-mm-dd HH24:MI:SS")) + .append(" and ") + .append(dateQueryAdapter.dateConverAdapter2( endTime, "yyyy-mm-dd HH24:MI:SS")).toString(); + monthFilterSql = " and i.sendtime" + betweenSql; + expensiveGoodsMonthFilterSql = " and egge.time" + betweenSql; + returnGoodsTimeFilterSql = " and rr.returntime" + betweenSql; returnGoodsFilterSql = returnGoodsTimeFilterSql; packingDisposableGoodsTimeSql = " and pr.packTime "+betweenSql; - lostMaterialFilterSql = " and r.additionalTime between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); - damageFilterSql = " and i.additionalTime between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); + lostMaterialFilterSql = " and r.additionalTime" + betweenSql; + damageFilterSql = " and i.additionalTime" + betweenSql; - supplyRoomDiposableGoodsFilterSql = " and rr.time between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); - outEntryFilterSql = " and oge.time between " - + dateQueryAdapter.dateConverAdapter2( startTime - , "yyyy-mm-dd HH24:MI:SS") - + " and " - + dateQueryAdapter.dateConverAdapter2( endTime - , "yyyy-mm-dd HH24:MI:SS"); + supplyRoomDiposableGoodsFilterSql = " and rr.time" + betweenSql; + outEntryFilterSql = " and oge.time" + betweenSql; } else { monthFilterSql = " and 1=2 "; returnGoodsFilterSql = " and 1=2 "; @@ -4869,6 +4832,39 @@ String expensiveGoodsNameFilterSql = " "; String chargeItemSql = "";//收费项目名称过滤 if (StringUtils.isNotBlank(goodsNameSearch)) { + if("精确查询".equals(searchType)){ + goodsNameFilterSql = " and ii.toussename = '" + goodsNameSearch + + "'"; + expensiveGoodsNameFilterSql = " and case when egm.model is null then eg.name else eg.name + '[' + egm.model + ']' end = '%" + goodsNameSearch + + "%'"; + returnGoodsFilterSql += " and ri.toussename = '" + + goodsNameSearch + "'"; + materialNameFilterSql = " and ii.materialName = '" + + goodsNameSearch + "' "; + lostMaterialFilterSql += " and r.materialName = '" + + goodsNameSearch + "'"; + damageFilterSql += " and i.materialName = '" + + goodsNameSearch + "'"; + supplyRoomDiposableGoodsFilterSql += " and rri.goodsName = '"+goodsNameSearch+"'"; + outEntryFilterSql += " and ged.goodsName = '"+goodsNameSearch+"'"; + chargeItemSql = " and chargeItem = '"+goodsNameSearch+"' "; + }else{ + goodsNameFilterSql = " and ii.toussename like '%" + goodsNameSearch + + "%'"; + expensiveGoodsNameFilterSql = " and case when egm.model is null then eg.name else eg.name + '[' + egm.model + ']' end like '%" + goodsNameSearch + + "%'"; + returnGoodsFilterSql += " and ri.toussename like '%" + + goodsNameSearch + "%'"; + materialNameFilterSql = " and ii.materialName like '%" + + goodsNameSearch + "%' "; + lostMaterialFilterSql += " and r.materialName like '%" + + goodsNameSearch + "%'"; + damageFilterSql += " and i.materialName like '%" + + goodsNameSearch + "%'"; + supplyRoomDiposableGoodsFilterSql += " and rri.goodsName like '%"+goodsNameSearch+"%' "; + outEntryFilterSql += " and ged.goodsName like '%"+goodsNameSearch+"%' "; + chargeItemSql = " and chargeItem like '%"+goodsNameSearch+"%' "; + } //消毒物品需用like查询 if(disinfection){ goodsNameFilterSql = " and ii.toussename like '%" + goodsNameSearch @@ -4882,40 +4878,6 @@ supplyRoomDiposableGoodsFilterSql += " and 1=2"; outEntryFilterSql += " and 1=2"; - }else{ - if("精确查询".equals(searchType)){ - goodsNameFilterSql = " and ii.toussename = '" + goodsNameSearch - + "'"; - expensiveGoodsNameFilterSql = " and case when egm.model is null then eg.name else eg.name + '[' + egm.model + ']' end = '%" + goodsNameSearch - + "%'"; - returnGoodsFilterSql += " and ri.toussename = '" - + goodsNameSearch + "'"; - materialNameFilterSql = " and ii.materialName = '" - + goodsNameSearch + "' "; - lostMaterialFilterSql += " and r.materialName = '" - + goodsNameSearch + "'"; - damageFilterSql += " and i.materialName = '" - + goodsNameSearch + "'"; - supplyRoomDiposableGoodsFilterSql += " and rri.goodsName = '"+goodsNameSearch+"'"; - outEntryFilterSql += " and ged.goodsName = '"+goodsNameSearch+"'"; - chargeItemSql = " and chargeItem = '"+goodsNameSearch+"' "; - }else{ - goodsNameFilterSql = " and ii.toussename like '%" + goodsNameSearch - + "%'"; - expensiveGoodsNameFilterSql = " and case when egm.model is null then eg.name else eg.name + '[' + egm.model + ']' end like '%" + goodsNameSearch - + "%'"; - returnGoodsFilterSql += " and ri.toussename like '%" - + goodsNameSearch + "%'"; - materialNameFilterSql = " and ii.materialName like '%" - + goodsNameSearch + "%' "; - lostMaterialFilterSql += " and r.materialName like '%" - + goodsNameSearch + "%'"; - damageFilterSql += " and i.materialName like '%" - + goodsNameSearch + "%'"; - supplyRoomDiposableGoodsFilterSql += " and rri.goodsName like '%"+goodsNameSearch+"%' "; - outEntryFilterSql += " and ged.goodsName like '%"+goodsNameSearch+"%' "; - chargeItemSql = " and chargeItem like '%"+goodsNameSearch+"%' "; - } } } String nameFilterSql = ""; @@ -5170,6 +5132,8 @@ ResultSet rs = objectDao.executeSql(sql); if (rs != null) { try { + Set toussedefinitionIdSet = new HashSet();//需要查询材料实例数量的包定义id + Map itemAndTDid = new HashMap();//,用于给DepartmentMonthDetailItem计算price和totalAmount while (rs.next()) { String settleaccountsdepart = rs.getString("settleaccountsdepart"); List itemList = detailMap.get(settleaccountsdepart); @@ -5189,17 +5153,25 @@ int disinfectGoodsStatisticAmount = 0; int totalAmount = amount; DepartmentMonthDetailItem mdi = new DepartmentMonthDetailItem(); + boolean flag = true; if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(type) || (TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(type) && !showCustonTousseAmount)) { - String toussedefinitionId = rs.getString("tousseDefinitionId"); + Long toussedefinitionId = rs.getLong("tousseDefinitionId"); if (DatabaseUtil.isPoIdValid(toussedefinitionId)) { - disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount(Long.valueOf(toussedefinitionId)); + toussedefinitionIdSet.add(toussedefinitionId);//记下id,一次性查询对应的材料实例数量 + mdi.setAmount(totalAmount); + itemAndTDid.put(mdi, toussedefinitionId); + flag = false;//先不计算价格和总数量,批量查询时再计算 } } - if (disinfectGoodsStatisticAmount > 0){ - totalAmount = (amount * disinfectGoodsStatisticAmount); + if(flag){ + Double price = 0D; + if(totalAmount != 0){ + price = MathTools.divide(settlementPrice, totalAmount, 4); + } + mdi.setPrice(price); + mdi.setAmount(totalAmount); } - // goodsName = CssdUtils.filterUnderScoreName(goodsName); Double price = 0D; @@ -5213,8 +5185,6 @@ mdi.setSupplierName(supplierName); } } - mdi.setPrice(price); - mdi.setAmount(totalAmount); mdi.setGoodsName(goodsName); mdi.setType(type); mdi.setSettlementPrice(settlementPrice); @@ -5236,6 +5206,8 @@ } itemList.add(mdi); } + //统一计算要查询包定义对应的材料实例数量的DepartmentMonthDetailItem的price和totalAmount + calcPriceAndAmout(toussedefinitionIdSet, itemAndTDid); } catch (SQLException e) { logger.error("获取明细核算月报数据时出错", e); }finally { @@ -5300,7 +5272,737 @@ } return datas; } + @Override + public List getDepartmentMonthDetailList( + String startTime, String endTime, String depart, + String departCoding, String type, String goodsName, String batch, + String searchType, boolean disinfection, + String disposableGoodsType, String goodsType, + Boolean showCustonTousseAmount, String patternOfReport) { + if("singleDepart".equals(patternOfReport)){//单个科室的明细核算月报 + return getDepartmentMonthDetailListOfSingleDepart(startTime, endTime, depart, departCoding, type, goodsName, batch, searchType, disinfection, disposableGoodsType, goodsType, showCustonTousseAmount); + } + return getDepartmentMonthDetailList(startTime, endTime, depart, departCoding, type, goodsName, batch, searchType, disinfection, disposableGoodsType, goodsType, showCustonTousseAmount); + } + //------------------------单个科室的明细核算月报 start--------------- + /** + * 统一计算要查询包定义对应的材料实例数量的DepartmentMonthDetailItem的price和totalAmount + * @param toussedefinitionIdSet 需要查询材料实例数量的包定义id + * @param itemAndTDid ,用于给DepartmentMonthDetailItem计算price和totalAmount + */ + private void calcPriceAndAmout(Set toussedefinitionIdSet, Map itemAndTDid){ + if(toussedefinitionIdSet.size() > 0){ + Map tdIdAndAmountMap = getDisinfectGoodsStatisticAmount(toussedefinitionIdSet); + for (Entry entry : itemAndTDid.entrySet()) { + Long tdId = entry.getValue(); + DepartmentMonthDetailItem item = entry.getKey(); + Integer totalAmount = 0; + if(tdIdAndAmountMap.containsKey(tdId)){ + Integer amount = tdIdAndAmountMap.get(tdId); + if(amount.intValue() != 1 && amount > 0){ + totalAmount = item.getAmount() * amount; + item.setAmount(totalAmount); + } + } + Double price = 0D; + if(totalAmount != 0){ + price = MathTools.divide(item.getSettlementPrice(), totalAmount, 4); + } + item.setPrice(price); + } + } + } + @Override + public List getDepartmentMonthDetailListOfSingleDepart( + String startTime, String endTime, String departSearch, + String departCoding, String typeSearch, String goodsNameSearch, String batch, + String searchType, boolean disinfection, + String disposableGoodsType, String goodsType, + Boolean showCustonTousseAmount) { + //数据库拼接符号 + String concatSymbolInDb = "+"; + if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + concatSymbolInDb = "||"; + } + SupplyRoomConfig config = supplyRoomConfigManager.getSystemParamsObj(); + final String TYPE_AUTO_DEDUCTION = "自动扣减物品"; + final String TYPE_ALL = "全部"; + final String TYPE_CHARGE = "收费项目"; + //是否启用高值耗材(新) + boolean enableExpensiveGoods = CssdUtils.getSystemSetConfigByNameBool("enableExpensiveGoods"); + //是否启用高值耗材(一次性物品的高值耗材) + boolean enableExpensiveDisposableGoods = CssdUtils.getSystemSetConfigByNameBool("enableExpensiveDisposableGoods"); + + //判断当前登录用户是否为匿名用户.如果为匿名用户则只查询一级供应室的数据,否则根据实际情况的条件查询 + String loginUserFullName = AcegiHelper.getLoginUserFullName(); + if(StringUtils.equals(loginUserFullName, Constants.ANONYMOUS_USERNAME)){ + departCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + }else{ + //是否供应室用户 + boolean isSupplyRoomUser = supplyRoomConfigManager.isSupplyRoomUser(); + //是否高值耗材供应科室用户 + boolean isExpensiveGoodsSupplyRoomUser = supplyRoomConfigManager.isExpensiveGoodsSupplyRoomUser(); + if(!isSupplyRoomUser && !isExpensiveGoodsSupplyRoomUser){ + departSearch = AcegiHelper.getCurrentOrgUnitName(); + departCoding = AcegiHelper.getCurrentOrgUnitCode(); + } + } + List datas = new ArrayList(); + List allTousseType = getTousseTypes(typeSearch); + // 查看是否配置显示供应商 + Boolean showSupplierNameInDetailedAccountingMonthlyReport = CssdUtils.getSystemSetConfigByNameBool("showSupplierNameInDetailedAccountingMonthlyReport", false); + String tousseDefinitionOfSupplierNameSql = "";//用器械包定义里的供应商拼接的sql语句,主要用于查询供应商和按供应商分组 + String addTousseDefinitionAtWhere = "";//拼接sql,用于添加查询TousseDefinition表 + String addJoinTousseDefinitionSql = "";//用于连接InvoiceItem和TousseDefinition + String dgbsOfSupplierNameSql = "";//用于查询DisposableGoodsBatchStock或DisposableGoodsBatch的供应商名称,主要用于查询供应商和按供应商分组 + String noQuerySupplierName = "";//不需要查询器械包名称的sql,用于连接union all连接表时保持列数不变 + if(showSupplierNameInDetailedAccountingMonthlyReport){ + tousseDefinitionOfSupplierNameSql = " ,td.supplierName "; + addTousseDefinitionAtWhere = ",TousseDefinition td "; + addJoinTousseDefinitionSql = " and td.id = ii.tousseDefinitionId "; + dgbsOfSupplierNameSql = " ,dgbs.supplierName "; + noQuerySupplierName = ",''"; + } + startTime += ":00"; + endTime += ":59"; + String monthFilterSql = " "; + String expensiveGoodsMonthFilterSql = " "; + String returnGoodsFilterSql = " "; + String returnGoodsTimeFilterSql = " "; + String packingDisposableGoodsTimeSql = " "; + String returnGoodsDepartFilterSql = " "; + String materialNameFilterSql = " "; + String materialTypeFilterSql = " "; + String lostMaterialFilterSql = " "; + String damageFilterSql = " "; + String supplyRoomDiposableGoodsFilterSql = " "; + String outEntryFilterSql = " "; + + String invoiceItemDisposableGoodsTypePredicate = " (1=1) "; + String diposableGoodsItemPredicate = " (1=1) "; + String packingDisposableGoodsTypeSql = " (1=1) "; + String disposableGoodsInvoiceAmountPredicate = " (ii.diposable='是') "; + String returnGoodsItemPredicate = " (1=1) "; + String receiveRecordItemPredicate = " (1=1) "; + String disposableGoodsIdSql = ""; + String outEntryPredicate = " 1=1 "; + + 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); + diposableGoodsItemPredicate = String.format(" (d.disposableGoodsID in(%s)) ", disposableGoodsIdSql); + packingDisposableGoodsTypeSql = String.format(" (dgi.disposableGoodsID in(%s)) ", disposableGoodsIdSql); + disposableGoodsInvoiceAmountPredicate = String.format(" (ii.diposable='是' and ii.disposableGoodsId in(%s)) ", disposableGoodsIdSql); + returnGoodsItemPredicate = String.format(" (ri.disposableGoodsId in(%s)) ", disposableGoodsIdSql); + receiveRecordItemPredicate = String.format(" (rri.type!='一次性物品' or rri.disposableGoodsId in(%s)) ", disposableGoodsIdSql); + outEntryPredicate = String.format(" (ged.disposableGoodsID in(%s)) ", disposableGoodsIdSql); + } + String betweenSql = ""; + if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { + betweenSql = new StringBuffer(150).append(" between ") + .append(dateQueryAdapter.dateConverAdapter2( startTime, "yyyy-mm-dd HH24:MI:SS")) + .append(" and ") + .append(dateQueryAdapter.dateConverAdapter2( endTime, "yyyy-mm-dd HH24:MI:SS")).toString(); + monthFilterSql = " and i.sendtime" + betweenSql; + expensiveGoodsMonthFilterSql = " and egge.time" + betweenSql; + returnGoodsTimeFilterSql = " and rr.returntime" + betweenSql; + returnGoodsFilterSql = returnGoodsTimeFilterSql; + packingDisposableGoodsTimeSql = " and pr.packTime"+betweenSql; + lostMaterialFilterSql = " and r.additionalTime" + betweenSql; + damageFilterSql = " and i.additionalTime" + betweenSql; + + supplyRoomDiposableGoodsFilterSql = " and rr.time" + betweenSql; + outEntryFilterSql = " and oge.time" + betweenSql; + } else { + monthFilterSql = " and 1=2 "; + returnGoodsFilterSql = " and 1=2 "; + packingDisposableGoodsTimeSql = " and 1=2 "; + lostMaterialFilterSql = " and 1=2 "; + damageFilterSql = " and 1=2 "; + } + String departFilterSql = ""; + String packingDisposableGoodsDepartSql = ""; + String chargeDepartSql = ""; + if (StringUtils.isNotBlank(departSearch)) { + departFilterSql = " and i.settleaccountsdepart = '" + departSearch + + "'"; + returnGoodsFilterSql += " and rr.depart = '" + departSearch + + "'"; + returnGoodsDepartFilterSql = " and rr.depart = '" + departSearch + + "'"; + packingDisposableGoodsDepartSql = " and pr.orgUnitName = '" + departSearch + "'"; + lostMaterialFilterSql += " and r.depart = '" + + departSearch + "'"; + damageFilterSql += " and i.depart = '" + + departSearch + "'"; + + supplyRoomDiposableGoodsFilterSql += " and rr.departCoding = '"+departCoding+"'"; + outEntryFilterSql += " and oge.orgUnitCode = '"+departCoding+"'"; + + } + String typeFilterSql = " "; + materialTypeFilterSql = " "; + String expensiveDisposablegoodsSql = ""; + if (StringUtils.isNotBlank(typeSearch)) { + + if ("全部器械包".equals(typeSearch)) { + typeFilterSql = " and ii.diposable = '否' and ii.tousseType <> '" + ExpensiveGoods.TYPE_NAME + "'"; + returnGoodsFilterSql += " and rr.type = '器械包'"; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + }else if("器械包".equals(typeSearch)) { + typeFilterSql = " and ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_INSIDE + + "'"; + returnGoodsFilterSql += " and rr.type = '器械包'"; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + }else if("敷料包".equals(typeSearch)){ + typeFilterSql = " and ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_DRESSING + + "'"; + returnGoodsFilterSql += " and rr.type = '器械包'"; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + } else if ("消毒物品".equals(typeSearch)) { + typeFilterSql = " and ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_DISINFECTION + + "'"; + returnGoodsFilterSql += " and rr.type = '器械包'"; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + } else if ("外来器械包".equals(typeSearch)) { + typeFilterSql = " and (ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_FOREIGN + + "' or ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_SPLIT + "') "; + returnGoodsFilterSql += " and rr.type = '器械包'"; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + } else if ("自定义器械包".equals(typeSearch)) { + typeFilterSql = " and ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_CUSTOM + "'"; + returnGoodsFilterSql += " and rr.type = '器械包'"; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + } else if ("外部代理灭菌包".equals(typeSearch)) { + typeFilterSql = " and ii.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_FOREIGNPROXY + "'"; + returnGoodsFilterSql += " and rr.type = '器械包'"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + returnGoodsItemPredicate = String.format(" ri.tousseDefinition_id in (select id from TousseDefinition where %s) ", SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", allTousseType)); + } else if ("一次性物品".equals(typeSearch)) { + typeFilterSql = " and ii.tousseType = '一次性物品'"; + returnGoodsFilterSql += " and rr.type = '一次性物品'"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + supplyRoomDiposableGoodsFilterSql += " and rri.type = '一次性物品' "; + } else if ("器械材料".equals(typeSearch)) { + typeFilterSql = " and 1=2"; + returnGoodsFilterSql += " and 1=2"; + lostMaterialFilterSql += " and 1=1 "; + damageFilterSql += " and 1=1 "; + supplyRoomDiposableGoodsFilterSql += " and rri.materialDefinition_id in (select id from MaterialDefinition) "; + outEntryFilterSql += " and 1=2"; + } else if ("高值耗材".equals(typeSearch)) { + if(enableExpensiveGoods){ + //新的高值耗材 + typeFilterSql = " and ii.diposable = '否' and ii.tousseType = '" + ExpensiveGoods.TYPE_NAME + "'"; + returnGoodsFilterSql += " and 1=2"; + materialTypeFilterSql = " and 1=2 "; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + outEntryFilterSql += " and 1=2"; + //新的高值耗材还没有供应室领用功能 + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + }else{ + //goodsType是高值耗材类型,值有全部、一次性物品、器械 + if(StringUtils.isNotBlank(goodsType)){ + if("一次性物品".equals(goodsType)){ + returnGoodsFilterSql += " and ri.expensiveDisposablegoodsId is not null and ri.expensiveDisposablegoodsId <> 0"; + materialTypeFilterSql = " and 1=2 "; + supplyRoomDiposableGoodsFilterSql += " and d.goodsType = '"+DisposableGoods.TYPE_EXPENSIVEDIPOSABLEGOODS+"'"; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + expensiveDisposablegoodsSql = " and d.expensiveDisposablegoodsId is not null "; + outEntryFilterSql += " and dg.goodsType = '" + DisposableGoods.TYPE_EXPENSIVEDIPOSABLEGOODS + "' "; + }else{ + returnGoodsFilterSql += " and 1=2 "; + materialTypeFilterSql = " and d.goodsType = '"+MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS+"'"; + supplyRoomDiposableGoodsFilterSql += " and rri.materialDefinition_id in (select id from MaterialDefinition where goodsType = '" + + MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS + "') "; + lostMaterialFilterSql += " and m.goodsType = '"+MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS+"' "; + damageFilterSql += " and m.goodsType = '"+MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS+"' "; + expensiveDisposablegoodsSql = " and 1=2 "; + outEntryFilterSql += " and 1=2 "; + } + }else{ + returnGoodsFilterSql += " and ri.expensiveDisposablegoodsId is not null and ri.expensiveDisposablegoodsId <> 0"; + materialTypeFilterSql = " and d.goodsType = '"+MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS+"'"; + supplyRoomDiposableGoodsFilterSql += " and rri.materialDefinition_id in (select id from MaterialDefinition where goodsType = '" + + MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS + "') "; + lostMaterialFilterSql += " and m.goodsType = '"+MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS+"' "; + damageFilterSql += " and m.goodsType = '"+MaterialDefinition.TYPE_EXPENSIVEMATERIALGOODS+"' "; + expensiveDisposablegoodsSql = " and d.expensiveDisposablegoodsId is not null "; + outEntryFilterSql += " and dg.goodsType = '" + DisposableGoods.TYPE_EXPENSIVEDIPOSABLEGOODS + "' "; + } + typeFilterSql = " and 1=2 "; + } + }else if (TYPE_AUTO_DEDUCTION.equals(typeSearch)) { + typeFilterSql = " and 1=2 "; + }else if(TYPE_ALL.equals(typeSearch)){ + if(!enableExpensiveGoods){ + //没有启用高值耗材,就不查询新的高值耗材的数据 + typeFilterSql = " and ii.tousseType <> '" + ExpensiveGoods.TYPE_NAME + "'"; + } + } + }else{ + if(!enableExpensiveGoods){ + //没有启用高值耗材,就不查询新的高值耗材的数据 + typeFilterSql = " and ii.tousseType <> '" + ExpensiveGoods.TYPE_NAME + "'"; + } + } + String goodsNameFilterSql = " "; + String expensiveGoodsNameFilterSql = " "; + String chargeItemSql = "";//收费项目名称过滤 + if (StringUtils.isNotBlank(goodsNameSearch)) { + if("精确查询".equals(searchType)){ + goodsNameFilterSql = " and ii.toussename = '" + goodsNameSearch + + "'"; + expensiveGoodsNameFilterSql = " and case when egm.model is null then eg.name else eg.name + '[' + egm.model + ']' end = '%" + goodsNameSearch + + "%'"; + returnGoodsFilterSql += " and ri.toussename = '" + + goodsNameSearch + "'"; + materialNameFilterSql = " and ii.materialName = '" + + goodsNameSearch + "' "; + lostMaterialFilterSql += " and r.materialName = '" + + goodsNameSearch + "'"; + damageFilterSql += " and i.materialName = '" + + goodsNameSearch + "'"; + supplyRoomDiposableGoodsFilterSql += " and rri.goodsName = '"+goodsNameSearch+"'"; + outEntryFilterSql += " and ged.goodsName = '"+goodsNameSearch+"'"; + chargeItemSql = " and chargeItem = '"+goodsNameSearch+"' "; + }else{ + goodsNameFilterSql = " and ii.toussename like '%" + goodsNameSearch + + "%'"; + expensiveGoodsNameFilterSql = " and case when egm.model is null then eg.name else eg.name + '[' + egm.model + ']' end like '%" + goodsNameSearch + + "%'"; + returnGoodsFilterSql += " and ri.toussename like '%" + + goodsNameSearch + "%'"; + materialNameFilterSql = " and ii.materialName like '%" + + goodsNameSearch + "%' "; + lostMaterialFilterSql += " and r.materialName like '%" + + goodsNameSearch + "%'"; + damageFilterSql += " and i.materialName like '%" + + goodsNameSearch + "%'"; + supplyRoomDiposableGoodsFilterSql += " and rri.goodsName like '%"+goodsNameSearch+"%' "; + outEntryFilterSql += " and ged.goodsName like '%"+goodsNameSearch+"%' "; + chargeItemSql = " and chargeItem like '%"+goodsNameSearch+"%' "; + } + //消毒物品需用like查询 + if(disinfection){ + goodsNameFilterSql = " and ii.toussename like '%" + goodsNameSearch + + "%'"; + returnGoodsFilterSql += " and ri.toussename like '%" + + goodsNameSearch + "%'"; + lostMaterialFilterSql += " and r.materialName like '%" + + goodsNameSearch + "%'"; + damageFilterSql += " and i.materialName like '%" + + goodsNameSearch + "%'"; + + supplyRoomDiposableGoodsFilterSql += " and 1=2"; + outEntryFilterSql += " and 1=2"; + } + } + String nameFilterSql = ""; + String packingDisposableGoodsNameSql = ""; + if (StringUtils.isNotBlank(goodsNameSearch)) { + nameFilterSql = " and d.name = '" + goodsNameSearch + "'"; + packingDisposableGoodsNameSql = " and dgi.name = '" + goodsNameSearch + "'"; + + } + String supplyRoomDiposableGoodsFilterSqlOFDgbs = ""; + if (StringUtils.isNotBlank(batch)) { + nameFilterSql += " and d.batch = '" + batch + "'"; + goodsNameFilterSql += " and 1=2 "; + returnGoodsFilterSql += " and ri.batchNumber = '"+batch+"' "; + packingDisposableGoodsNameSql += " and dgi.batch = '"+batch+"' "; + lostMaterialFilterSql += " and 1=2 "; + damageFilterSql += " and 1=2 "; + supplyRoomDiposableGoodsFilterSqlOFDgbs = supplyRoomDiposableGoodsFilterSql + " and dgbs.batchNumber = '"+batch+"'"; + supplyRoomDiposableGoodsFilterSql += " and dbs.batchNumber = '"+batch+"'"; + outEntryFilterSql += " and dgbs.batchNumber = '"+batch+"'"; + } + + 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 "+ tousseDefinitionOfSupplierNameSql +",ii.tousseName as name,sum(ii.amount) as amount," + +"sum(ii.settlementPrice) as settlementprice,sum(ii.settlementDiscountPrice) as settlementDiscountPrice,ii.tousseType as type" + + ",'' as batchNumber,null as expDate,ii.tousseDefinitionId as tousseDefinitionId from invoice i,InvoiceItem ii " + + addTousseDefinitionAtWhere + + " where i.id = ii.invoice_id " + + addJoinTousseDefinitionSql + + " and ii.diposable = '否' and ii.expensiveGoodsInstanceId is null and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " + + monthFilterSql + + departFilterSql + + typeFilterSql + + goodsNameFilterSql + + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,ii.tousseType,ii.tousseName,ii.tousseDefinitionId " + tousseDefinitionOfSupplierNameSql + ")"; + //新的高值耗材(发货) + String selectExpensiveGoodsSql = ""; + //如果有启用高值耗材则查询 + if(enableExpensiveGoods){ + selectExpensiveGoodsSql = " union all (select i.settleAccountsDepart"+noQuerySupplierName+",case when egm.model is null then eg.name else eg.name "+ concatSymbolInDb +" '[' "+ concatSymbolInDb +" egm.model "+ concatSymbolInDb +" ']' end as name,sum(ii.amount) as amount," + +"sum(ii.settlementPrice) as settlementprice,sum(ii.settlementDiscountPrice) as settlementDiscountPrice,ii.tousseType as type" + + ",'' as batchNumber,ei.expDate as expDate,0 as tousseDefinitionId from " + Invoice.class.getSimpleName() + " i join " + + InvoiceItem.class.getSimpleName()+" ii on i.id = ii.invoice_id join " + ExpensiveGoodsInstance.class.getSimpleName() + + " ei on ei.id = ii.expensiveGoodsInstanceId" + + " join ExpensiveGoods eg on ei.expensiveGoods_id=eg.id " + + " left join ExpensiveGoodsModel egm on ei.expensiveGoodsModelId=egm.id" + + " where ii.diposable = '否' and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " + + monthFilterSql + + departFilterSql + + typeFilterSql + + goodsNameFilterSql + + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,ii.tousseType,case when egm.model is null then eg.name else eg.name "+ concatSymbolInDb +" '[' "+ concatSymbolInDb +" egm.model "+ concatSymbolInDb +" ']' end,ii.expensiveGoodsInstanceId,ei.expDate)"; + //新的高值耗材(一键退库-即退货),如果所选物品类型为全部或高值耗材时, + selectExpensiveGoodsSql += " union all (select i.settleAccountsDepart "+ noQuerySupplierName+",case when egm.model is null then eg.name else eg.name "+ concatSymbolInDb +" '[' "+ concatSymbolInDb +" egm.model "+ concatSymbolInDb +" ']' end as name,-1 * count(egi.id) as amount,-1 * sum(egi.price) settlementprice,-1 * sum(egi.price) settlementprice,'高值耗材' as type,null as batchNumber,egi.expDate,null as tousseDefinitionId " + + " 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 " + +" join ExpensiveGoods eg on egi.expensiveGoods_id=eg.id " + +" left join ExpensiveGoodsModel egm on egi.expensiveGoodsModelId=egm.id " + +" where 1=1 and egge.type='退库单' and i.orgUnitCoding='" + departCoding + "' " + + expensiveGoodsMonthFilterSql + + (StringUtils.isBlank(typeSearch) || StringUtils.equals(ExpensiveGoods.TYPE_NAME, typeSearch) ? " " : " and 1=2 ") + + departFilterSql + + expensiveGoodsNameFilterSql + + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,case when egm.model is null then eg.name else eg.name "+ concatSymbolInDb +" '[' "+ concatSymbolInDb +" egm.model "+ concatSymbolInDb +" ']' end,egi.expDate)"; + } + + String diposableGoodsSql = " "; + 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) && !enableExpensiveGoods || TYPE_AUTO_DEDUCTION.equals(typeSearch)){ + diposableGoodsSql = " union all (select i.settleaccountsdepart "+ dgbsOfSupplierNameSql +",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,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 + + expensiveDisposablegoodsSql + + " group by i.settleaccountsdepart,d.name,d.batch,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + } + String packingDisposableGoodsSql = " "; + { + if(StringUtils.isBlank(typeSearch) || "一次性物品".equals(typeSearch)){ + packingDisposableGoodsSql = " union all (select pr.orgUnitName "+ dgbsOfSupplierNameSql +",dgi.name as name,sum(dgi.amount) as amount," + +"sum(dgi.fluctuationPrice*dgi.amount) as settlementprice,sum(dgi.fluctuationPrice*dgi.amount) as settlementDiscountPrice,'一次性物品' as type" + + ",dgi.batch as batchNumber,dgbs.expDate,0 as tousseDefinitionId from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId " + + " inner join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on dgi.disposableGoodsBatchStockID=dgbs.id" + + " where "+getHandleDeptCodeSql("pr.orgUnitCoding")+" " + +" and "+packingDisposableGoodsTypeSql + + packingDisposableGoodsTimeSql + + packingDisposableGoodsDepartSql + + packingDisposableGoodsNameSql + + " group by pr.orgUnitName,dgi.name,dgi.batch,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + } + } + + String materialInvoiceSql = " "; + String materialReturnSql = " "; + String lostMaterial = " "; + String damageMaterial = " "; + //当批次号为空时、且物品类型为空或器械材料或高值耗材时,才查询材料的发货、退货、丢失报损补充等数据 + if(StringUtils.isBlank(batch)){ + if ((StringUtils.isBlank(typeSearch) || "器械材料".equals(typeSearch) || "高值耗材".equals(typeSearch))) { + // 材料发货 + materialInvoiceSql = " union all (select i.settleAccountsDepart "+ noQuerySupplierName +",case when td.name is null then ii.materialName else ii.materialName "+ concatSymbolInDb +"'('"+ concatSymbolInDb +" td.name "+ concatSymbolInDb +"')' end,sum(ii.amount),sum(ii.settlementPrice)," + +"sum(ii.settlementPrice) as settlementDiscountPrice,'材料' as type,'' as batchNumber,null as expDate,td.id as tousseDefinitionId " + + " from MaterialInvoiceItem ii" + + " left join TousseDefinition td on td.id= ii.tousseDefinitionId " + + " inner join MaterialInvoice i on i.id = ii.materialInvoice_id " + + " inner join materialDefinition d on ii.materialDefinitionId = d.id where " + + getHandleDeptCodeSql("i.orgUnitCoding")+" " + + monthFilterSql + + departFilterSql + + materialNameFilterSql + + materialTypeFilterSql + + " group by i.settleaccountsdepart,case when td.name is null then ii.materialName else ii.materialName "+ concatSymbolInDb +" '(' "+ concatSymbolInDb +" td.name "+ concatSymbolInDb +"')' end,td.id) "; + } + // 材料退货 + materialReturnSql = " union all (select rr.depart as settleaccountsdepart "+ noQuerySupplierName+",ii.materialName,-sum(ii.amount),-sum(ii.settlementPrice)," + +"-sum(ii.settlementPrice) as settlementDiscountPrice,'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " + + " from ReturnMaterialRecord rr,materialDefinition d," + + "ReturnMaterialItem ii where rr.id = ii.returnMaterialRecord_ID " + + " and ii.materialDefinitionId = d.id and "+getHandleDeptCodeSql("rr.handleDepartCode")+" " + + returnGoodsTimeFilterSql + + returnGoodsDepartFilterSql + + materialNameFilterSql + + materialTypeFilterSql + + " group by rr.depart,ii.materialName) "; + + lostMaterial = " union all (select r.depart "+noQuerySupplierName+",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 " + + " from MaterialErrorDamageDetail r left join materialDefinition m on r.materialDefinitionId = m.id where 1=1 and r.errorType = '缺失' and r.type = '"+MaterialErrorDamageDetail.TYPE_ERROR+"' and r.materialName != '器械包标识牌' and r.additionalAmount > 0 and "+getHandleDeptCodeSql("r.handleDepartCode")+" " + + lostMaterialFilterSql + "group by r.depart,r.materialName ) "; + String banQuery = " and 1 = 0 "; + String damagedTousseAtCost = config.getDamagedTousseAtCost(); + if(Constants.STR_YES.equals(damagedTousseAtCost)){ + banQuery = ""; + } + damageMaterial = " union all (select i.depart"+noQuerySupplierName+",i.materialName,sum(i.additionalAmount),sum(i.materialCost*i.additionalAmount)," + +"sum(i.materialCost*i.additionalAmount) as settlementDiscountPrice,'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " + + "from MaterialErrorDamageDetail i left join materialDefinition m on i.materialDefinitionId = m.id where 1=1 " + + banQuery + + " and i.type = '" + MaterialErrorDamageDetail.TYPE_DAMAGE + "' and i.additionalAmount > 0 and "+getHandleDeptCodeSql("i.handleDepartCode")+" " + damageFilterSql + + " group by i.departCode,i.depart,i.materialName ) "; + } + //退货(一次性物品、器械包) + String returnGoodsSql = " union all (select rr.depart as settleaccountsdepart"+dgbsOfSupplierNameSql+",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,"+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,"+returnGoodsTousseDefinitionId+ dgbsOfSupplierNameSql +") "; + + 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"+ dgbsOfSupplierNameSql +" as settleaccountsdepart,rri.goodsName,sum(rri.amount)," + +"sum(rri.price*rri.amount) as settlementprice,sum(rri.price*rri.amount) as settlementDiscountPrice,rri.type as type,dgbs.batchNumber as batchNumber,dgbs.expDate,0 as tousseDefinitionId " + +" from ReceiveRecord rr,ReceiveRecordItem rri left join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs " + +" on rri.diposableGoodBatchStock_id = dgbs.id left join DisposableGoods d on d.id = rri.disposableGoodsId where rr.id = rri.receiveRecord_id and "+getHandleDeptCodeSql("rr.departCoding")+" " + +supplyRoomDiposableGoodsFilterSqlOFDgbs + +supplyRoomTousseTypeSql + +" and "+receiveRecordItemPredicate + + supplyRoomDiposableGoodsFilterSql + + " group by rr.depart,rri.goodsName,rri.amount,rri.type,dgbs.batchNumber,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + // 调拨出库 + String appropriateOutDiposableGoodsSql = " union all (select oge.targetOrgUnitName as settleaccountsdepart"+dgbsOfSupplierNameSql+",ged.goodsName,sum(ged.amount)," + +"sum(ged.price*ged.amount) as settlementprice,sum(ged.price*ged.amount) as settlementDiscountPrice,'一次性物品' as type,dgbs.batchNumber as batchNumber,dgbs.expDate,0 as tousseDefinitionId " + +" from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID inner join DisposableGoodsBatch dgbs on ged.disposableGoodsBatchID=dgbs.id inner join DisposableGoods dg on dgbs.diposablegoods_id = dg.id " + +" where oge.type ='退库单' and oge.subType='调拨出库' and "+getHandleDeptCodeSql("oge.orgUnitCode")+" " + +outEntryFilterSql + +" and "+outEntryPredicate + + " group by oge.targetOrgUnitName, ged.goodsName,dgbs.batchNumber,dgbs.expDate "+ dgbsOfSupplierNameSql +") "; + // 盘亏出库 + String stocktakeOutDiposableGoodsSql = " union all (select oge.orgUnitName"+dgbsOfSupplierNameSql+" as settleaccountsdepart,ged.goodsName,sum(ged.amount)," + +"sum(ged.price*ged.amount) as settlementprice,sum(ged.price*ged.amount) as settlementDiscountPrice,'一次性物品' as type,dgbs.batchNumber as batchNumber,dgbs.expDate,0 as tousseDefinitionId " + +" from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID inner join DisposableGoodsBatch dgbs on ged.disposableGoodsBatchID=dgbs.id inner join DisposableGoods dg on dgbs.diposablegoods_id = dg.id " + +" where oge.type ='退库单' and oge.subType='盘亏出库' and "+getHandleDeptCodeSql("oge.orgUnitCode")+" " + +outEntryFilterSql + +" and "+outEntryPredicate + + " group by oge.orgUnitName, ged.goodsName,dgbs.batchNumber,dgbs.expDate"+dgbsOfSupplierNameSql+") "; + + + String sql = tousseSql + selectExpensiveGoodsSql + diposableGoodsSql + supplyRoomDiposableGoodsSql ; + + if(!TYPE_AUTO_DEDUCTION.equals(typeSearch)){ + sql += materialInvoiceSql; + sql += returnGoodsSql; + sql += materialReturnSql; + sql += appropriateOutDiposableGoodsSql; + sql += stocktakeOutDiposableGoodsSql; + sql += packingDisposableGoodsSql; + } + + if ("器械包".equals(typeSearch) || "器械材料".equals(typeSearch) || "全部".equals(typeSearch) || typeSearch == null || "全部器械包".equals(typeSearch) || "高值耗材".equals(typeSearch)) { + sql += lostMaterial; + sql += damageMaterial; + } + String chargeDateSql = "";//收费项目时间过滤 + if(TYPE_CHARGE.equals(typeSearch) || TYPE_ALL.equals(typeSearch) || StringUtils.isBlank(typeSearch)){ + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + chargeDateSql = String.format(" and chargeTime %s ", betweenSql); + } + if(StringUtils.isNotBlank(departSearch)){ + chargeDepartSql = String.format(" and ci.orgUnitCode = '%s' ", departCoding); + } + } + if(TYPE_CHARGE.equals(typeSearch)){ + String chargeSql = String.format(" select ci.orgUnitName settleAccountsDepart,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 group by ci.orgUnitName,chargeItem,price,chargeTime " + , chargeDepartSql,chargeDateSql,chargeItemSql); + sql = chargeSql; + }else if(TYPE_ALL.equals(typeSearch) || StringUtils.isBlank(typeSearch)){ + sql += String.format(" union all select ci.orgUnitName settleAccountsDepart,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 group by ci.orgUnitName,chargeItem,price,chargeTime " + , chargeDepartSql,chargeDateSql,chargeItemSql); + } + String database = dbConnection.getDatabase(); + if (dbConnection.isSqlServer()) { + String orderSql = " order by settleaccountsdepart,type"; + sql += orderSql; + } + + logger.debug("执行sql:" + sql); + + Map> detailMap = new HashMap>(); + Map manufacturerMap = getDiposableGoodsManufacturer(); + + Map disposableGoodsExternalCodeMap = disposableGoodsExternalCodeMap(); + Map expensiveExternalCode = expensiveExternalCode(); + Map materialExternalCodeMap = getMaterialExternalCode(); + Map tousseExternalCodeMap = getTousseExternalCode(); + ResultSet rs = objectDao.executeSql(sql); + if (rs != null) { + try { + Set toussedefinitionIdSet = new HashSet();//需要查询材料实例数量的包定义id + Map itemAndTDid = new HashMap();//,用于给DepartmentMonthDetailItem计算price和totalAmount + while (rs.next()) { + String settleaccountsdepart = rs.getString("settleaccountsdepart"); + List itemList = detailMap.get(settleaccountsdepart); + if (itemList == null) { + itemList = new ArrayList(); + detailMap.put(settleaccountsdepart, itemList); + } + String goodsName = rs.getString("name"); + String type = rs.getString("type"); + double settlementPrice = rs.getDouble("settlementprice"); + double settlementDiscountPrice = rs.getDouble("settlementDiscountPrice"); + int amount = rs.getInt("amount"); + int disinfectGoodsStatisticAmount = 0; + int totalAmount = amount; + DepartmentMonthDetailItem mdi = new DepartmentMonthDetailItem(); + + mdi.setType(type); + mdi.setSettlementPrice(settlementPrice); + mdi.setSettlementDiscountPrice(settlementDiscountPrice); + if(DisposableGoods.TYPE_NAME.equals(type)){ + int beginIndex = goodsName.indexOf("["); + int endIndex = goodsName.lastIndexOf("]"); + if(beginIndex != -1 && endIndex != -1){ + String specification = goodsName.substring(beginIndex + 1, endIndex); + goodsName = goodsName.substring(0, beginIndex); + mdi.setSpecification(specification); + } + } + mdi.setGoodsName(goodsName); + itemList.add(mdi); + boolean flag = true;//是否需要现在计算价格和数量 + if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(type) + || (TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(type) && !showCustonTousseAmount)) { + Long toussedefinitionId = rs.getLong("tousseDefinitionId"); + if (DatabaseUtil.isPoIdValid(toussedefinitionId)) { + toussedefinitionIdSet.add(toussedefinitionId);//记下id,一次性查询对应的材料实例数量 + mdi.setAmount(totalAmount); + itemAndTDid.put(mdi, toussedefinitionId); + flag = false;//先不计算价格和总数量,批量查询时再计算 + } + } + if(flag){ + Double price = 0D; + if(totalAmount != 0){ + price = MathTools.divide(settlementPrice, totalAmount, 4); + } + mdi.setPrice(price); + mdi.setAmount(totalAmount); + } + } + //统一计算要查询包定义对应的材料实例数量的DepartmentMonthDetailItem的price和totalAmount + calcPriceAndAmout(toussedefinitionIdSet, itemAndTDid); + } catch (SQLException e) { + logger.error("获取明细核算月报数据时出错", e); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + } + Iterator itr = detailMap.keySet().iterator(); + while(itr.hasNext()){ + String depart = itr.next(); + List list = detailMap.get(depart); + //消毒物品相同名称的合并 + Map tmpMap = new HashMap(); + List removeItems = new ArrayList(); + double totalPrice = 0.0d; + double totalPriceDiscount = 0.0d; + for (DepartmentMonthDetailItem dmi : list) { + String tousseName = dmi.getGoodsName(); + String type = dmi.getType(); + if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(type) + || TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(type)) { + DepartmentMonthDetailItem item = tmpMap.get(tousseName); + if(item == null){ + item = new DepartmentMonthDetailItem(); + item.setAmount(0); + item.setPrice(0d); + item.setSettlementPrice(0d); + item.setSettlementDiscountPrice(0d); + item.setExternalCode(tousseExternalCodeMap.get(tousseName)); + tmpMap.put(tousseName, item); + } + + item.setAmount(item.getAmount()+dmi.getAmount()); + item.setBatchNumber(dmi.getBatchNumber()); + item.setDiposable(dmi.getDiposable()); + item.setExpDate(dmi.getExpDate()); + item.setGoodsName(tousseName); + item.setManufacturer(dmi.getManufacturer()); + 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(); + totalPriceDiscount += dmi.getSettlementDiscountPrice(); + } + list.removeAll(removeItems); + Iterator itr2 = tmpMap.keySet().iterator(); + while(itr2.hasNext()){ + String key = itr2.next(); + DepartmentMonthDetailItem dmi = tmpMap.get(key); + list.add(dmi); + } + DepartmentMonthDetail detail = new DepartmentMonthDetail(); + detail.setDepart(depart); + detail.setTotalPrice(totalPrice); + detail.setTotalPriceDiscount(totalPriceDiscount); + detail.setItems(list); + sortDetailItems(detail); + datas.add(detail); + } + return datas; + } + //------------------------单个科室的明细核算月报 end----------------- /** * 获取消毒物品材料数量,没有申请单的可能是自定义装配生成的 * @param disinfectGoodsName @@ -5330,7 +6032,36 @@ } return statisticsAmount; } - + /** + * 获取消毒物品材料数量,没有申请单的可能是自定义装配生成的 + * @param toussedefinitionIdSet 包定义id + * @return 自定义器械包或者是拆包的消毒物品,返回材料数量,其他情况都返回0 + */ + private Map getDisinfectGoodsStatisticAmount(Set toussedefinitionIdSet) { + Map tdIdAndAmountMap = new HashMap(); + if(toussedefinitionIdSet.size() == 0){ + return tdIdAndAmountMap; + } + String sql = "select sum(i.count) count,t.id from Toussedefinition t,MaterialInstance i " + + "where t.id = i.tousse_id and " + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("t.id", toussedefinitionIdSet) + + " and ((t.isApplyEntireTousse='" + Constants.STR_NO +"' and t.tousseType='" + + TousseDefinition.PACKAGE_TYPE_DISINFECTION+"') or t.tousseType='"+TousseDefinition.PACKAGE_TYPE_CUSTOM+"') group by t.id"; + ResultSet rs = objectDao.executeSql(sql); + if(rs != null){ + try { + if(rs.next()){ + Long id = rs.getLong("id"); + Integer count = rs.getInt("count"); + tdIdAndAmountMap.put(id, count); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + } + return tdIdAndAmountMap; + } // 对科室中的物品明细按类型和名称排序,先按类型排序,然后按名称,器械包排在一起,一次性物品排在一起 // 按type是否为“一次性物品”分组,因为有部分InvoiceItem的tousseType属性为空 private void sortDetailItems(DepartmentMonthDetail detail) { Index: ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart_child.jasper =================================================================== diff -u Binary files differ Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java =================================================================== diff -u -r26898 -r26921 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 26898) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 26921) @@ -784,9 +784,10 @@ pos1); } } + String patternOfReport = StrutsParamUtils.getPraramValue("patternOfReport", null); return jasperReportManager.getDepartmentMonthDetailList( startTime,endTime, departSearch, departCoding,tousseType, goodsSearch, batch,searchType,disinfection, - disposableGoodsType,goodsType,showCustonTousseAmount); + disposableGoodsType,goodsType,showCustonTousseAmount, patternOfReport); } else if (reportName.equals("tousseReturnDisinfection")) {// 器械包返消 String startDate = StrutsParamUtils.getPraramValue("startDate", null); String endDate = StrutsParamUtils.getPraramValue("endDate", null); @@ -1995,7 +1996,23 @@ } else if (reportName.equals("departmentMonthDetail")) { String startTime = StrutsParamUtils.getPraramValue("startTime",null); String endTime = StrutsParamUtils.getPraramValue("endTime",null); - map.put("title", "明细核算月报(" + startTime +" & " + endTime +")"); + String patternOfReport = StrutsParamUtils.getPraramValue("patternOfReport",null); + SupplyRoomConfig config = supplyRoomConfigManager.getSystemParamsObj(); + String title = null; + if("singleDepart".equals(patternOfReport)){ + if(config != null && StringUtils.isNotBlank(config.getUnitName())){ + title = config.getUnitName() + "消毒供应中心出库清单"; + }else{ + title = "消毒供应中心出库清单"; + } + String depart = StrutsParamUtils.getPraramValue("departSearch",null); + map.put("employmentDepart", "领用科室:" + depart); + map.put("tabulator", "制表人:" + AcegiHelper.getLoginUser().getUserFullName()); + map.put("statisticsTime", "统计时间:" + startTime.substring(0, 10) + "~" + endTime.substring(0, 10)); + }else{ + title = "明细核算月报(" + startTime +" & " + endTime +")"; + } + map.put("title", title); return map; } else if (reportName.equals("yearWorkloadReport")) { String year = StrutsParamUtils.getPraramValue("year", ""); Index: ssts-web/src/main/webapp/jasperRtp/DepartmentMonthDetailOfSingleDepart.jasper =================================================================== diff -u Binary files differ Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManager.java =================================================================== diff -u -r26906 -r26921 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManager.java (.../JasperReportManager.java) (revision 26906) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManager.java (.../JasperReportManager.java) (revision 26921) @@ -255,8 +255,46 @@ public List getDepartmentMonthDetailList( String startTime,String endTime, String depart,String departCoding,String type, String goodsName, String batch,String searchType,boolean disinfection,String disposableGoodsType,String goodsType,Boolean showCustonTousseAmount); - /** + * 查询明细核算月报数据方法重载 根据报表格式调用相应的方法 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param depart 科室名称 + * @param departCoding 科室编码 + * @param type 类型 + * @param goodsName 物品名称 + * @param batch 批次号 + * @param searchType + * @param disinfection + * @param disposableGoodsType + * @param goodsType + * @param showCustonTousseAmount + * @param patternOfReport 报表格式 + * @return + */ + public List getDepartmentMonthDetailList( + String startTime,String endTime, String depart,String departCoding,String type, String goodsName, + String batch,String searchType,boolean disinfection,String disposableGoodsType,String goodsType,Boolean showCustonTousseAmount, String patternOfReport); + /** + * 查询单个科室的明细核算月报数据 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param depart 科室名称 + * @param departCoding 科室编码 + * @param type 类型 + * @param goodsName 物品名称 + * @param batch 批次号 + * @param searchType + * @param disinfection + * @param disposableGoodsType + * @param goodsType + * @param showCustonTousseAmount + * @return + */ + public List getDepartmentMonthDetailListOfSingleDepart( + String startTime,String endTime, String depart,String departCoding,String type, String goodsName, + String batch,String searchType,boolean disinfection,String disposableGoodsType,String goodsType,Boolean showCustonTousseAmount); + /** * 查询器械返消统计报表(按科室与包定义汇总) * @param startDate 查询开始时间 格式'2018-02-02' * @param endDate 查询结束时间 格式'2018-02-02'