Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/WorkloadAndIncomeStatisticsReportHelper.java =================================================================== diff -u --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/WorkloadAndIncomeStatisticsReportHelper.java (revision 0) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/WorkloadAndIncomeStatisticsReportHelper.java (revision 36253) @@ -0,0 +1,775 @@ +package com.forgon.disinfectsystem.jasperreports.util; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.disinfectsystem.basedatamanager.reportoption.GoodsOptionManager; +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.entity.basedatamanager.reportoption.GoodsOption; +import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.invoicemanager.Invoice; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoiceItem; +import com.forgon.disinfectsystem.entity.materialerrordamage.MaterialErrorDamageDetail; +import com.forgon.disinfectsystem.jasperreports.javabeansource.WorkloadAndIncomeStatisticsBean; +import com.forgon.disinfectsystem.jasperreports.javabeansource.WorkloadAndIncomeStatisticsShowBean; +import com.forgon.exception.SystemException; +import com.forgon.tools.MathTools; +import com.forgon.tools.date.DateTools; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.util.SqlUtils; + +@Component +public class WorkloadAndIncomeStatisticsReportHelper extends ReportHelper{ + @Autowired + private GoodsOptionManager goodsOptionManager; + @Autowired + private SupplyRoomConfigManager supplyRoomConfigManager; + /** + * + * @param requestParameters 请求参数 + * @param parametMap 报表参数 + * @return + */ + public List getWorkloadAndIncomeStatisticsReportData(Map requestParameters, Map parametMap){ + //需要判断是不是第一供应室 第一供应室 才显示领用数据 + String orgUnitCoding = requestParameters.get("orgUnitCoding"); + SupplyRoomConfig config = supplyRoomConfigManager.getFirstSupplyRoomConfig(); + boolean firstSupplyCode = false;//是否第一供应室 供应室会显示领用数据 + if(config != null && config.getOrgUnitCoding().equals(orgUnitCoding)){ + firstSupplyCode = true; + } + String showCustonTousseAmountStr = requestParameters.get("showCustonTousseAmount"); + if(StringUtils.isBlank(showCustonTousseAmountStr)){ + showCustonTousseAmountStr = ""; + } + Boolean showCustonTousseAmount = Boolean.valueOf(showCustonTousseAmountStr); + String[] optionValues = getDepartOptionValues(); + String queryType = requestParameters.get("queryType"); + if("汇总".equals(queryType)){ + return summary(firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues, requestParameters, parametMap); + } else if("环比".equals(queryType)){ + return monthOnMonthComparison(firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues, requestParameters, parametMap); + }else if("同比".equals(queryType)){ + String comparisonType = requestParameters.get("comparisonType"); + String yearMonth = requestParameters.get("yearMonth"); + if("上半年对比".equals(comparisonType)){ + return comparisonInTheFirstHalfOfTheYear(yearMonth, parametMap, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + }else if("季度对比".equals(comparisonType)){ + return quarterlyComparison(yearMonth, parametMap, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + }else if("月度对比".equals(comparisonType)){ + return monthlyComparison(yearMonth, parametMap, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + }else if("年度对比".equals(comparisonType)){ + return yearComparison(yearMonth, parametMap, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + }else{ + throw new SystemException("对比类型参数异常:" + comparisonType); + } + } + return null; + } + /** + * 获取汇总数据 + * @param firstSupplyCode 是否第一供应室 供应室会显示领用数据 + * @param orgUnitCoding 供应室编码 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param optionValues 本院科室 + * @param requestParameters 请求参数 + * @param parametMap 报表参数 + * @return + */ + private List summary(boolean firstSupplyCode, String orgUnitCoding, boolean showCustonTousseAmount, String[] optionValues, Map requestParameters, Map parametMap){ + String startTime = null; + String endTime = null; + Set dateStrSet = new HashSet(); + String betweenSql = null; + String year = requestParameters.get("year"); + startTime = year + "-01-01 00:00:00"; + endTime = Integer.parseInt(year) + 1 + "-01-01 00:00:00"; + betweenSql = " between " + dateQueryAdapter.dateAdapter(startTime) + " and " + dateQueryAdapter.dateAdapter(endTime); + parametMap.put("title", year + "年度消毒供应中心年度工作量及收入统计报表"); + dateStrSet.add(year + "-01"); + dateStrSet.add(year + "-02"); + dateStrSet.add(year + "-03"); + dateStrSet.add(year + "-04"); + dateStrSet.add(year + "-05"); + dateStrSet.add(year + "-06"); + dateStrSet.add(year + "-07"); + dateStrSet.add(year + "-08"); + dateStrSet.add(year + "-09"); + dateStrSet.add(year + "-10"); + dateStrSet.add(year + "-11"); + dateStrSet.add(year + "-12"); + List beans = getBasicData(dateStrSet, betweenSql, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + List showBeans = new ArrayList(); + if(beans.size() > 0){ + DecimalFormat df = new DecimalFormat("0.0000"); + for (WorkloadAndIncomeStatisticsBean bean : beans) { + showBeans.add(bean.getShowBean(df)); + } + } + return showBeans; + } + /** + * 获取环比数据 + * @param firstSupplyCode 是否第一供应室 + * @param orgUnitCoding 供应室编码 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param optionValues 本院科室 + * @param requestParameters 请求参数 + * @param parametMap 报表参数 + * @return + */ + private List monthOnMonthComparison(boolean firstSupplyCode, String orgUnitCoding, boolean showCustonTousseAmount, String[] optionValues, Map requestParameters, Map parametMap){ + String startTime = null; + String endTime = null; + Set dateStrSet = new HashSet(); + String yearMonth = requestParameters.get("yearMonth"); + String[] yearAndMonth = yearMonth.split("-"); + String yyyy = yearAndMonth[0]; + String mm = yearAndMonth[1]; + String lastMonth = DateTools.getNextMonth(yyyy, mm, -2); + String nextMonth = DateTools.getNextMonth(yyyy, mm, 0); + startTime = lastMonth + "-01 00:00:00"; + endTime = nextMonth+ "-01 00:00:00"; + dateStrSet.add(lastMonth); + dateStrSet.add(yearMonth); + parametMap.put("title", yyyy + "年"+ mm +"月份消毒供应中心工作量及收入统计报表"); + String betweenSql = " between " + dateQueryAdapter.dateAdapter(startTime) + " and " + dateQueryAdapter.dateAdapter(endTime); + List beans = getBasicData(dateStrSet, betweenSql, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + List showBeans = new ArrayList(); + if(beans.size() > 0){ + DecimalFormat df = new DecimalFormat("0.0000"); + WorkloadAndIncomeStatisticsBean bean1 = beans.get(0); + WorkloadAndIncomeStatisticsBean bean2 = beans.get(1); + showBeans.add(bean1.getShowBean(df)); + showBeans.add(bean2.getShowBean(df)); + df.applyPattern("0.00"); + WorkloadAndIncomeStatisticsShowBean showBean3 = comparisonBean("环比增减", df, bean1, bean2); + showBeans.add(showBean3); + } + return showBeans; + } + /** + * 获取同比-年度对比数据 + * @param firstSupplyCode 是否第一供应室 供应室会显示领用数据 + * @param orgUnitCoding 供应室编码 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param optionValues 本院科室 + * @param parametMap 报表参数 + * @return + */ + private List yearComparison(String yearMonth , Map parametMap, boolean firstSupplyCode, String orgUnitCoding, boolean showCustonTousseAmount, String[] optionValues){ + String[] yearAndMonth = yearMonth.split("-"); + String year = yearAndMonth[0]; + int lastYear = Integer.parseInt(year) - 1; + parametMap.put("title", year + "年消毒供应中心年度工作量及收入同比对比"); + Set dateStrSet = new HashSet(); + String lastStartDate = lastYear + "-01-01 00:00:00"; + String lastEndDate = year + "-01-01 00:00:00"; + String startDate = year + "-01-01 00:00:00"; + String endDate = lastYear + 2 + "-01-01 00:00:00"; + + dateStrSet.add(lastYear + "-01"); + dateStrSet.add(lastYear + "-02"); + dateStrSet.add(lastYear + "-03"); + dateStrSet.add(lastYear + "-04"); + dateStrSet.add(lastYear + "-05"); + dateStrSet.add(lastYear + "-06"); + dateStrSet.add(lastYear + "-07"); + dateStrSet.add(lastYear + "-08"); + dateStrSet.add(lastYear + "-09"); + dateStrSet.add(lastYear + "-10"); + dateStrSet.add(lastYear + "-11"); + dateStrSet.add(lastYear + "-12"); + List lastBeans = getBasicData(dateStrSet, + " between " + dateQueryAdapter.dateAdapter(lastStartDate) + " and " + dateQueryAdapter.dateAdapter(lastEndDate) + , firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + WorkloadAndIncomeStatisticsBean lastBeanSum = new WorkloadAndIncomeStatisticsBean(); + lastBeanSum.setDateStr(lastYear + ""); + for (WorkloadAndIncomeStatisticsBean lastBean : lastBeans) { + lastBeanSum.setForgonAmount(MathTools.add(lastBeanSum.getForgonAmount(), lastBean.getForgonAmount()).longValue()); + lastBeanSum.setThisCourtAmount(MathTools.add(lastBeanSum.getThisCourtAmount(), lastBean.getThisCourtAmount()).longValue()); + lastBeanSum.setOtherCourtAmount(MathTools.add(lastBeanSum.getOtherCourtAmount(), lastBean.getOtherCourtAmount()).longValue()); + lastBeanSum.setForgonPrice(MathTools.add(lastBeanSum.getForgonPrice(), lastBean.getForgonPrice()).doubleValue()); + lastBeanSum.setThisCourtPrice(MathTools.add(lastBeanSum.getThisCourtPrice(), lastBean.getThisCourtPrice()).doubleValue()); + lastBeanSum.setOtherCourtPrice(MathTools.add(lastBeanSum.getOtherCourtPrice(), lastBean.getOtherCourtPrice()).doubleValue()); + } + dateStrSet.clear(); + dateStrSet.add(year + "-01"); + dateStrSet.add(year + "-02"); + dateStrSet.add(year + "-03"); + dateStrSet.add(year + "-04"); + dateStrSet.add(year + "-05"); + dateStrSet.add(year + "-06"); + dateStrSet.add(year + "-07"); + dateStrSet.add(year + "-08"); + dateStrSet.add(year + "-09"); + dateStrSet.add(year + "-10"); + dateStrSet.add(year + "-11"); + dateStrSet.add(year + "-12"); + List beans = getBasicData(dateStrSet, + " between " + dateQueryAdapter.dateAdapter(startDate) + " and " + dateQueryAdapter.dateAdapter(endDate) + , firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + WorkloadAndIncomeStatisticsBean beanSum = new WorkloadAndIncomeStatisticsBean(); + beanSum.setDateStr(year); + for (WorkloadAndIncomeStatisticsBean bean : beans) { + beanSum.setForgonAmount(MathTools.add(beanSum.getForgonAmount(), bean.getForgonAmount()).longValue()); + beanSum.setThisCourtAmount(MathTools.add(beanSum.getThisCourtAmount(), bean.getThisCourtAmount()).longValue()); + beanSum.setOtherCourtAmount(MathTools.add(beanSum.getOtherCourtAmount(), bean.getOtherCourtAmount()).longValue()); + beanSum.setForgonPrice(MathTools.add(beanSum.getForgonPrice(), bean.getForgonPrice()).doubleValue()); + beanSum.setThisCourtPrice(MathTools.add(beanSum.getThisCourtPrice(), bean.getThisCourtPrice()).doubleValue()); + beanSum.setOtherCourtPrice(MathTools.add(beanSum.getOtherCourtPrice(), bean.getOtherCourtPrice()).doubleValue()); + } + DecimalFormat df = new DecimalFormat("0.0000"); + List showBeans = new ArrayList(); + showBeans.add(lastBeanSum.getShowBean(df)); + showBeans.add(beanSum.getShowBean(df)); + df.applyPattern("0.00"); + WorkloadAndIncomeStatisticsShowBean comparisonBean = comparisonBean("同比增减", df, lastBeanSum, beanSum); + showBeans.add(comparisonBean); + return showBeans; + } + /** + * 获取同比-月度对比数据 + * @param firstSupplyCode 是否第一供应室 供应室会显示领用数据 + * @param orgUnitCoding 供应室编码 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param optionValues 本院科室 + * @param parametMap 报表参数 + * @return + */ + private List monthlyComparison(String yearMonth , Map parametMap, boolean firstSupplyCode, String orgUnitCoding, boolean showCustonTousseAmount, String[] optionValues){ + yearMonth = "2023-07"; + String[] yearAndMonth = yearMonth.split("-"); + String month = yearAndMonth[1]; + String year = yearAndMonth[0]; + int lastYear = Integer.parseInt(year) - 1; + parametMap.put("title", year + "年"+ month +"月消毒供应中心年度工作量及收入同比对比"); + Set dateStrSet = new HashSet(); + String lastStartDate = lastYear + "-" + month + "-01 00:00:00"; + String lastEndDate = null; + String startDate = year + "-" + month + "-01 00:00:00"; + String endDate = null; + if("month".equals("12")){ + lastEndDate = year + "-01-01 00:00:00"; + endDate = (lastYear + 2) + "-01-01 00:00:00"; + }else{ + int nextMonth = Integer.parseInt(month) + 1; + if(nextMonth < 10){ + lastEndDate = lastYear + "-0" + nextMonth + "-01 00:00:00"; + endDate = year + "-0" + nextMonth + "-01 00:00:00"; + }else{ + lastEndDate = lastYear + "-" + nextMonth + "-01 00:00:00"; + endDate = year + "-" + nextMonth + "-01 00:00:00"; + } + } + dateStrSet.add(lastYear + "-" + month); + WorkloadAndIncomeStatisticsBean lastBean = getBasicData(dateStrSet, + " between " + dateQueryAdapter.dateAdapter(lastStartDate) + " and " + dateQueryAdapter.dateAdapter(lastEndDate) + , firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues).get(0); + dateStrSet.clear(); + dateStrSet.add(yearMonth); + WorkloadAndIncomeStatisticsBean bean = getBasicData(dateStrSet, + " between " + dateQueryAdapter.dateAdapter(startDate) + " and " + dateQueryAdapter.dateAdapter(endDate) + , firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues).get(0); + DecimalFormat df = new DecimalFormat("0.0000"); + List showBeans = new ArrayList(); + showBeans.add(lastBean.getShowBean(df)); + showBeans.add(bean.getShowBean(df)); + df.applyPattern("0.00"); + WorkloadAndIncomeStatisticsShowBean comparisonBean = comparisonBean("同比增减", df, lastBean, bean); + showBeans.add(comparisonBean); + return showBeans; + } + /** + * 获取同比-季度对比数据 + * @param firstSupplyCode 是否第一供应室 供应室会显示领用数据 + * @param orgUnitCoding 供应室编码 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param optionValues 本院科室 + * @param parametMap 报表参数 + * @return + */ + private List quarterlyComparison(String yearMonth, Map parametMap, boolean firstSupplyCode, String orgUnitCoding, boolean showCustonTousseAmount, String[] optionValues){ + //yearMonth = "2022-07"; + String[] yearAndMonth = yearMonth.split("-"); + String month = yearAndMonth[1]; + String year = yearAndMonth[0]; + int lastYear = Integer.parseInt(year) - 1; + String quarterlyName = null; + if("01".equals(month) || "02".equals(month) || "03".equals(month)){ + quarterlyName = "一季度"; + }else if("04".equals(month) || "05".equals(month) || "06".equals(month)){ + quarterlyName = "二季度"; + }else if("07".equals(month) || "08".equals(month) || "09".equals(month)){ + quarterlyName = "三季度"; + }else{ + quarterlyName = "四季度"; + } + parametMap.put("title", year + "年"+ quarterlyName +"消毒供应中心年度工作量及收入同比对比"); + Set lastDateStrSet = new HashSet(); + Set dateStrSet = new HashSet(); + String lastStartDate = null; + String lastEndDate = null; + String startDate = null; + String endDate = null; + if("一季度".equals(quarterlyName)){ + lastDateStrSet.add(lastYear + "-01"); + lastDateStrSet.add(lastYear + "-02"); + lastDateStrSet.add(lastYear + "-03"); + lastStartDate = lastYear + "-01-01 00:00:00"; + lastEndDate = lastYear + "-04-01 00:00:00"; + + dateStrSet.add(year + "-01"); + dateStrSet.add(year + "-02"); + dateStrSet.add(year + "-03"); + startDate = year + "-01-01 00:00:00"; + endDate = year + "-04-01 00:00:00"; + }else if("二季度".equals(quarterlyName)){ + lastDateStrSet.add(lastYear + "-04"); + lastDateStrSet.add(lastYear + "-05"); + lastDateStrSet.add(lastYear + "-06"); + lastStartDate = lastYear + "-04-01 00:00:00"; + lastEndDate = lastYear + "-07-01 00:00:00"; + + dateStrSet.add(year + "-04"); + dateStrSet.add(year + "-05"); + dateStrSet.add(year + "-06"); + startDate = year + "-04-01 00:00:00"; + endDate = year + "-07-01 00:00:00"; + }else if("三季度".equals(quarterlyName)){ + lastDateStrSet.add(lastYear + "-07"); + lastDateStrSet.add(lastYear + "-08"); + lastDateStrSet.add(lastYear + "-09"); + lastStartDate = lastYear + "-07-01 00:00:00"; + lastEndDate = lastYear + "-10-01 00:00:00"; + + dateStrSet.add(year + "-07"); + dateStrSet.add(year + "-08"); + dateStrSet.add(year + "-09"); + startDate = year + "-07-01 00:00:00"; + endDate = year + "-10-01 00:00:00"; + }else{ + lastDateStrSet.add(lastYear + "-10"); + lastDateStrSet.add(lastYear + "-11"); + lastDateStrSet.add(lastYear + "-12"); + lastStartDate = lastYear + "-10-01 00:00:00"; + lastEndDate = year + "-01-01 00:00:00"; + + dateStrSet.add(year + "-10"); + dateStrSet.add(year + "-11"); + dateStrSet.add(year + "-12"); + startDate = year + "-10-01 00:00:00"; + endDate = lastYear + 2 + "-01-01 00:00:00"; + } + + List lastBeans = getBasicData(lastDateStrSet, + " between " + dateQueryAdapter.dateAdapter(lastStartDate) + " and " + dateQueryAdapter.dateAdapter(lastEndDate) + , firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + WorkloadAndIncomeStatisticsBean lastBeanSum = new WorkloadAndIncomeStatisticsBean(); + lastBeanSum.setDateStr(lastYear + quarterlyName); + for (WorkloadAndIncomeStatisticsBean lastBean : lastBeans) { + lastBeanSum.setForgonAmount(MathTools.add(lastBeanSum.getForgonAmount(), lastBean.getForgonAmount()).longValue()); + lastBeanSum.setThisCourtAmount(MathTools.add(lastBeanSum.getThisCourtAmount(), lastBean.getThisCourtAmount()).longValue()); + lastBeanSum.setOtherCourtAmount(MathTools.add(lastBeanSum.getOtherCourtAmount(), lastBean.getOtherCourtAmount()).longValue()); + lastBeanSum.setForgonPrice(MathTools.add(lastBeanSum.getForgonPrice(), lastBean.getForgonPrice()).doubleValue()); + lastBeanSum.setThisCourtPrice(MathTools.add(lastBeanSum.getThisCourtPrice(), lastBean.getThisCourtPrice()).doubleValue()); + lastBeanSum.setOtherCourtPrice(MathTools.add(lastBeanSum.getOtherCourtPrice(), lastBean.getOtherCourtPrice()).doubleValue()); + } + List beans = getBasicData(dateStrSet, + " between " + dateQueryAdapter.dateAdapter(startDate) + " and " + dateQueryAdapter.dateAdapter(endDate) + , firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + WorkloadAndIncomeStatisticsBean beanSum = new WorkloadAndIncomeStatisticsBean(); + beanSum.setDateStr(year + quarterlyName); + for (WorkloadAndIncomeStatisticsBean bean : beans) { + beanSum.setForgonAmount(MathTools.add(beanSum.getForgonAmount(), bean.getForgonAmount()).longValue()); + beanSum.setThisCourtAmount(MathTools.add(beanSum.getThisCourtAmount(), bean.getThisCourtAmount()).longValue()); + beanSum.setOtherCourtAmount(MathTools.add(beanSum.getOtherCourtAmount(), bean.getOtherCourtAmount()).longValue()); + beanSum.setForgonPrice(MathTools.add(beanSum.getForgonPrice(), bean.getForgonPrice()).doubleValue()); + beanSum.setThisCourtPrice(MathTools.add(beanSum.getThisCourtPrice(), bean.getThisCourtPrice()).doubleValue()); + beanSum.setOtherCourtPrice(MathTools.add(beanSum.getOtherCourtPrice(), bean.getOtherCourtPrice()).doubleValue()); + } + DecimalFormat df = new DecimalFormat("0.0000"); + List showBeans = new ArrayList(); + showBeans.add(lastBeanSum.getShowBean(df)); + showBeans.add(beanSum.getShowBean(df)); + df.applyPattern("0.00"); + WorkloadAndIncomeStatisticsShowBean comparisonBean = comparisonBean("同比增减", df, lastBeanSum, beanSum); + showBeans.add(comparisonBean); + return showBeans; + } + /** + * 同比-上半年对比 + * @param parametMap 报表返回参数 + * @param yearMonth 年月 + * @param firstSupplyCode 是否第一供应室 供应室会显示领用数据 + * @param orgUnitCoding 供应室编码 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param optionValues 本院科室 + * @return + */ + private List comparisonInTheFirstHalfOfTheYear(String yearMonth, Map parametMap, boolean firstSupplyCode, String orgUnitCoding, boolean showCustonTousseAmount, String[] optionValues){ + String year = yearMonth.split("-")[0]; + parametMap.put("title", year + "年上半年消毒供应中心年度工作量及收入同比对比"); + int lastYear = Integer.parseInt(year) - 1; + String lastStartDate = lastYear + "-01-01 00:00:00"; + String lastEndDate = lastYear + "-07-01 00:00:00"; + String betweenSql = " between " + dateQueryAdapter.dateAdapter(lastStartDate) + " and " + dateQueryAdapter.dateAdapter(lastEndDate); + Set dateStrSet = new HashSet(); + dateStrSet.add(lastYear + "-01"); + dateStrSet.add(lastYear + "-02"); + dateStrSet.add(lastYear + "-03"); + dateStrSet.add(lastYear + "-04"); + dateStrSet.add(lastYear + "-05"); + dateStrSet.add(lastYear + "-06"); + List lastBeans = getBasicData(dateStrSet, betweenSql, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + WorkloadAndIncomeStatisticsBean lastBeanSum = new WorkloadAndIncomeStatisticsBean(); + lastBeanSum.setDateStr(lastYear + "上半年"); + for (WorkloadAndIncomeStatisticsBean lastBean : lastBeans) { + lastBeanSum.setForgonAmount(MathTools.add(lastBeanSum.getForgonAmount(), lastBean.getForgonAmount()).longValue()); + lastBeanSum.setThisCourtAmount(MathTools.add(lastBeanSum.getThisCourtAmount(), lastBean.getThisCourtAmount()).longValue()); + lastBeanSum.setOtherCourtAmount(MathTools.add(lastBeanSum.getOtherCourtAmount(), lastBean.getOtherCourtAmount()).longValue()); + lastBeanSum.setForgonPrice(MathTools.add(lastBeanSum.getForgonPrice(), lastBean.getForgonPrice()).doubleValue()); + lastBeanSum.setThisCourtPrice(MathTools.add(lastBeanSum.getThisCourtPrice(), lastBean.getThisCourtPrice()).doubleValue()); + lastBeanSum.setOtherCourtPrice(MathTools.add(lastBeanSum.getOtherCourtPrice(), lastBean.getOtherCourtPrice()).doubleValue()); + } + String startDate = year + "-01-01 00:00:00"; + String endDate = year + "-07-01 00:00:00"; + betweenSql = " between " + dateQueryAdapter.dateAdapter(startDate) + " and " + dateQueryAdapter.dateAdapter(endDate); + dateStrSet.clear(); + dateStrSet.add(year + "-01"); + dateStrSet.add(year + "-02"); + dateStrSet.add(year + "-03"); + dateStrSet.add(year + "-04"); + dateStrSet.add(year + "-05"); + dateStrSet.add(year + "-06"); + List beans = getBasicData(dateStrSet, betweenSql, firstSupplyCode, orgUnitCoding, showCustonTousseAmount, optionValues); + WorkloadAndIncomeStatisticsBean beanSum = new WorkloadAndIncomeStatisticsBean(); + beanSum.setDateStr(year + "上半年"); + for (WorkloadAndIncomeStatisticsBean bean : beans) { + beanSum.setForgonAmount(MathTools.add(beanSum.getForgonAmount(), bean.getForgonAmount()).longValue()); + beanSum.setThisCourtAmount(MathTools.add(beanSum.getThisCourtAmount(), bean.getThisCourtAmount()).longValue()); + beanSum.setOtherCourtAmount(MathTools.add(beanSum.getOtherCourtAmount(), bean.getOtherCourtAmount()).longValue()); + beanSum.setForgonPrice(MathTools.add(beanSum.getForgonPrice(), bean.getForgonPrice()).doubleValue()); + beanSum.setThisCourtPrice(MathTools.add(beanSum.getThisCourtPrice(), bean.getThisCourtPrice()).doubleValue()); + beanSum.setOtherCourtPrice(MathTools.add(beanSum.getOtherCourtPrice(), bean.getOtherCourtPrice()).doubleValue()); + } + DecimalFormat df = new DecimalFormat("0.0000"); + List showBeans = new ArrayList(); + showBeans.add(lastBeanSum.getShowBean(df)); + showBeans.add(beanSum.getShowBean(df)); + df.applyPattern("0.00"); + WorkloadAndIncomeStatisticsShowBean comparisonBean = comparisonBean("同比增减", df, lastBeanSum, beanSum); + showBeans.add(comparisonBean); + return showBeans; + } + /** + * 对比两个WorkloadAndIncomeStatisticsBean 返回一个用来展示的showBean + * @param dateStr 返回的showBean的dateStr列显示值 + * @param bean1 时间早的bean + * @param bean2 时间晚的bean + * @return + */ + private WorkloadAndIncomeStatisticsShowBean comparisonBean(String dateStr, DecimalFormat df, WorkloadAndIncomeStatisticsBean bean1, WorkloadAndIncomeStatisticsBean bean2){ + WorkloadAndIncomeStatisticsShowBean showBean3 = new WorkloadAndIncomeStatisticsShowBean(); + showBean3.setDateStr(dateStr); + Long subForgonAmount = MathTools.sub(bean2.getForgonAmount(), bean1.getForgonAmount()).longValue(); + if(MathTools.equals(bean1.getForgonAmount(), 0L)){ + showBean3.setForgonAmount("-"); + }else{ + showBean3.setForgonAmount(df.format(100.00 * subForgonAmount / bean1.getForgonAmount()) + "%"); + } + Double subForgonPrice = MathTools.sub(bean2.getForgonPrice(), bean1.getForgonPrice()).doubleValue(); + if(MathTools.equals(bean1.getForgonPrice(), 0.00d)){ + showBean3.setForgonPrice("-"); + }else{ + showBean3.setForgonPrice(df.format(100.00 * subForgonPrice / bean1.getForgonPrice()) + "%"); + } + Long subThisCourtAmount = MathTools.sub(bean2.getThisCourtAmount(), bean1.getThisCourtAmount()).longValue(); + if(MathTools.equals(bean1.getThisCourtAmount(), 0L)){ + showBean3.setThisCourtAmount("-"); + }else{ + showBean3.setThisCourtAmount(df.format(100.00 * subThisCourtAmount / bean1.getThisCourtAmount()) + "%"); + } + Long subOtherCourtAmount = MathTools.sub(bean2.getOtherCourtAmount(), bean1.getOtherCourtAmount()).longValue(); + if(MathTools.equals(bean1.getOtherCourtAmount(), 0L)){ + showBean3.setOtherCourtAmount("-"); + }else{ + showBean3.setOtherCourtAmount(df.format(100.00 * subOtherCourtAmount / bean1.getOtherCourtAmount()) + "%"); + } + Double subThisCourtPrice = MathTools.sub(bean2.getThisCourtPrice(), bean1.getThisCourtPrice()).doubleValue(); + if(MathTools.equals(bean1.getThisCourtPrice(), 0.00d)){ + showBean3.setThisCourtPrice("-"); + }else{ + showBean3.setThisCourtPrice(df.format(100.00 * subThisCourtPrice / bean1.getThisCourtPrice()) + "%"); + } + Double subOtherCourtPrice = MathTools.sub(bean2.getOtherCourtPrice(), bean1.getOtherCourtPrice()).doubleValue(); + if(MathTools.equals(bean1.getOtherCourtPrice(), 0.00d)){ + showBean3.setOtherCourtPrice("-"); + }else{ + showBean3.setOtherCourtPrice(df.format(100.00 * subOtherCourtPrice / bean1.getOtherCourtPrice()) + "%"); + } + return showBean3; + } + /** + * 获取基础数据 + * @param dateStrSet 时间列的值 因为没数据的行也要显示 所以要定要显示什么行 + * @param betweenSql 时间过滤 + * @param firstSupplyCode 是否第一供应室 供应室会显示领用数据 + * @param supplyRoomCode 供应室编码 + * @param showCustonTousseAmount 是否显示自定义器械包包数 + * @param optionValues 本院科室 + * @return + */ + private List getBasicData(Set dateStrSet, String betweenSql, boolean firstSupplyCode, String supplyRoomCode, boolean showCustonTousseAmount, String[] optionValues){ + //查询本院 + String sql = getSql(firstSupplyCode,supplyRoomCode, betweenSql ,showCustonTousseAmount, true, optionValues); + ResultSet rs = null; + Map beanMap = new HashMap(); + for(String date : dateStrSet){ + WorkloadAndIncomeStatisticsBean bean = new WorkloadAndIncomeStatisticsBean(); + bean.setDateStr(date); + beanMap.put(date, bean); + } + try { + System.out.println(sql); + rs = objectDao.executeSql(sql); + while(rs.next()){ + Double price = rs.getDouble("price"); + Long amount = rs.getLong("amount"); + String dateStr = rs.getString("dateStr"); + WorkloadAndIncomeStatisticsBean bean = beanMap.get(dateStr); + bean.setDateStr(dateStr); + bean.setThisCourtAmount(amount - rs.getLong("forgonAmount")); + bean.setThisCourtPrice(price - rs.getDouble("forgonPrice")); + beanMap.put(dateStr, bean); + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + //查询 外院 实际是查询所有,再减本院数据 + String sql2 = getSql(firstSupplyCode,supplyRoomCode, betweenSql ,showCustonTousseAmount, false, null); + ResultSet rs2 = null; + try { + rs2 = objectDao.executeSql(sql2); + while(rs2.next()){ + Double price = rs2.getDouble("price"); + Long amount = rs2.getLong("amount"); + String dateStr = rs2.getString("dateStr"); + WorkloadAndIncomeStatisticsBean bean = beanMap.get(dateStr); + bean.setThisCourtAmount(amount - bean.getThisCourtAmount()); + bean.setThisCourtPrice(price - bean.getThisCourtPrice()); + bean.setForgonAmount(rs2.getLong("forgonAmount")); + bean.setForgonPrice(rs2.getDouble("forgonPrice")); + beanMap.put(dateStr, bean); + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs2); + } + List beans = new ArrayList(beanMap.values()); + Collections.sort(beans, new Comparator() { + @Override + public int compare(WorkloadAndIncomeStatisticsBean o1, + WorkloadAndIncomeStatisticsBean o2) { + return o1.getDateStr().compareTo(o2.getDateStr()); + } + }); + return beans; + } + /** + * 获取设置为内院的科室 + * @return + */ + private String[] getDepartOptionValues(){ + //配置的为内院的科室,其他的位外院的科室 + GoodsOption option = goodsOptionManager.getGoodsOption(GoodsOption.MODEL_ADYTUM_DEPARTMENT, AcegiHelper.getCurrentOrgUnitCode()); + if (option != null && StringUtils.isNotBlank(option.getValue())) { + return option.getValue().split(";"); + } + String[] a = new String[1]; + a[0] = "手术室"; + //a[1] = ""; + return a; + } + /** + * 获取查询语句 + * @param firstSupplyCode 是否第一供应室 + * @param orgUnitCoding 供应室编码 + * @param betweenSql 时间过滤 + * @param showCustonTousseAmount 显示自定义器械包数量 + * @param queryInDepart 是否部门过滤 + * @param optionValues 过滤的部门 + * @return + */ + private String getSql(boolean firstSupplyCode, String orgUnitCoding, String betweenSql, Boolean showCustonTousseAmount, Boolean queryInDepart, String[] optionValues){ + String showCustonTousseAmountSqlForIiTousseType = null; + String showCustonTousseAmountSqlForTdTousseType = null; + if(!showCustonTousseAmount){ + showCustonTousseAmountSqlForIiTousseType = " or ii.tousseType='自定义器械包' "; + showCustonTousseAmountSqlForTdTousseType = " or td.tousseType='自定义器械包' "; + }else{ + showCustonTousseAmountSqlForIiTousseType = ""; + showCustonTousseAmountSqlForTdTousseType = ""; + } + String iDepartInSql = ""; + String rDepartInSql = ""; + String ogeOrgUnitNameInSql = ""; + String prDepartInSql = ""; + String crOrgUnitNameInSql = ""; + if(queryInDepart && optionValues != null){ + iDepartInSql = SqlUtils.get_InSql("i.depart", optionValues); + rDepartInSql = SqlUtils.get_InSql("r.depart", optionValues); + ogeOrgUnitNameInSql = SqlUtils.get_InSql("oge.orgUnitName", optionValues); + prDepartInSql = SqlUtils.get_InSql("pr.depart", optionValues); + crOrgUnitNameInSql = SqlUtils.get_InSql("cr.orgUnitName", optionValues); + } + + String iSendTimeDateSql = null; + String rReturnTimeDateSql = null; + String iAdditionalTimeDateSql = null; + String rTimeDateSql = null; + String ogeTimeDateSql = null; + String prPackTimeDateSql = null; + String crChargeTimeDateSql = null; + if(dbConnection.isOracle()){ + iSendTimeDateSql = " TO_CHAR(i.sendtime, 'YYYY-MM') dateStr, "; + rReturnTimeDateSql = " TO_CHAR(r.returnTime, 'YYYY-MM') dateStr, "; + iAdditionalTimeDateSql = " TO_CHAR(i.additionalTime, 'YYYY-MM') dateStr, "; + rTimeDateSql = " TO_CHAR(r.time, 'YYYY-MM') dateStr, "; + ogeTimeDateSql = " TO_CHAR(oge.time, 'YYYY-MM') dateStr, "; + prPackTimeDateSql = " TO_CHAR(pr.packTime, 'YYYY-MM') dateStr, "; + crChargeTimeDateSql = " TO_CHAR(cr.chargeTime, 'YYYY-MM') dateStr, "; + }else{ + iSendTimeDateSql = " CONVERT(varchar(7), i.sendtime, 120) dateStr, "; + rReturnTimeDateSql = " CONVERT(varchar(7), r.returnTime, 120) dateStr, "; + iAdditionalTimeDateSql = " CONVERT(varchar(7),i.additionalTime, 120) dateStr, "; + rTimeDateSql = " CONVERT(varchar(7),r.time, 120) dateStr, "; + ogeTimeDateSql = " CONVERT(varchar(7),oge.time, 120) dateStr, "; + prPackTimeDateSql = " CONVERT(varchar(7),pr.packTime, 120) dateStr, "; + crChargeTimeDateSql = " CONVERT(varchar(7),cr.chargeTime, 120) dateStr, "; + } + //发货 + String invoicePriceSql = " select "+ iSendTimeDateSql +"ii.settlementPrice as price,"+ + " case when ii.materialAmount>0 and ii.tousseType='消毒物品' and td.isApplyEntireTousse='否' " + + showCustonTousseAmountSqlForIiTousseType + + "then ii.materialAmount*ii.amount else ii.amount end amount,case when ii.tousseType in('外来器械包','外来器械拆分小包') then ii.amount else 0 end forgonAmount" + + ",case when ii.tousseType in('外来器械包','外来器械拆分小包') then ii.settlementPrice else 0 end forgonPrice " + //+ ",sum(ii.settlementDiscountPrice) as settlementDiscountPrice" + + " from " + Invoice.class.getSimpleName() + " i join " + + InvoiceItem.class.getSimpleName() + " ii on i.id = ii.invoice_id " + + "left join " + TousseDefinition.class.getSimpleName() + " td on ii.tousseDefinitionId=td.id " + + "where i.sendtime "+ + betweenSql + + iDepartInSql + +" and i.orgUnitCoding='" + + orgUnitCoding + + "' and (i.status ='收货签收' or i.status = '已发货') "; + //退货统计(器械包或一次性物品) + String returnSql = "select "+ rReturnTimeDateSql +"(-i.settlementPrice) price," + +" case when i.materialAmountAtThatTime>0 and td.tousseType='消毒物品' and td.isApplyEntireTousse='否' " + + showCustonTousseAmountSqlForTdTousseType + + "then -i.materialAmountAtThatTime*i.amount else -i.amount end amount" + + ",case when td.tousseType in('外来器械包','外来器械拆分小包') then -i.amount else 0 end forgonAmount " + + ",case when td.tousseType in('外来器械包','外来器械拆分小包') then -i.settlementPrice else 0 end forgonPrice " + + " from ReturnGoodsRecord r join ReturnGoodsItem i on r.id = i.returnGoodsRecord_ID " + + "left join "+ TousseDefinition.class.getSimpleName() +" td on td.id=i.tousseDefinition_id" + + " where r.handleDepartCode='" + + orgUnitCoding + +"' and r.returnTime " + betweenSql + rDepartInSql; + // 材料发货 + String materialInvoicePriceSql = "select "+ iSendTimeDateSql +" ii.settlementPrice as price,ii.amount amount,0 forgonAmount,0 forgonPrice from MaterialInvoice i," + + "MaterialInvoiceItem ii where i.id = ii.materialInvoice_id and i.orgUnitCoding='" + + orgUnitCoding + +"' and i.sendtime " + + betweenSql+iDepartInSql; + + //材料报损统计 + String damageSql = "select "+ iAdditionalTimeDateSql +"i.materialCost*i.additionalAmount price,i.additionalAmount amount,0 forgonAmount,0 forgonPrice " + + " from MaterialErrorDamageDetail i where " + + "i.handleDepartCode='" + + orgUnitCoding + +"' and i.additionalTime " + betweenSql + + iDepartInSql + + " and i.type = '" + + MaterialErrorDamageDetail.TYPE_DAMAGE + + "' "; + + //材料丢失统计 + String recyclingErrorSql = "select "+ iAdditionalTimeDateSql +"i.materialCost*i.additionalAmount price,i.additionalAmount amount,0 forgonAmount,0 forgonPrice " + + " from MaterialErrorDamageDetail i where i.errorType = '缺失' and i.type = '"+MaterialErrorDamageDetail.TYPE_ERROR+"' and i.materialName != '器械包标识牌' " + + " and i.handleDepartCode='" + + orgUnitCoding + +"' and i.additionalTime " + betweenSql + iDepartInSql; + // 材料退货 + String materialReturnSql = "select "+ rReturnTimeDateSql +"(-i.settlementPrice) settlementPrice,-i.amount amount,0 forgonAmount,0 forgonPrice " + + "from ReturnMaterialRecord r,ReturnMaterialItem i where r.id = i.returnMaterialRecord_ID" + + " and r.handleDepartCode='" + + orgUnitCoding + +"' and r.returnTime " + betweenSql + rDepartInSql; + //供应室领用(器械材料与一次性物品) 供应室为一级供应室才查询 + String receiveSql = "select "+ rTimeDateSql +"(i.amount*i.price) price,i.amount,0 forgonAmount,0 forgonPrice " + + "from ReceiveRecord r join ReceiveRecordItem i on r.id = i.receiverecord_id " + + "where r.time " + betweenSql + rDepartInSql; + if(!firstSupplyCode){ + receiveSql += " and 1=2 "; + } + //调拨出库 盘亏出库 + String godownEntrySql = "select "+ ogeTimeDateSql +"(ged.amount*ged.price) price,ged.amount,0 forgonAmount,0 forgonPrice " + + "from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID " + + " where oge.type ='退库单' and oge.subType in('调拨出库','盘亏出库') and " + + " oge.orgUnitCode='" + + orgUnitCoding + +"' and oge.time " + betweenSql + ogeOrgUnitNameInSql; + // 一次性物品装配扣减库存 + String packingRecordSql = "select "+ prPackTimeDateSql +"(dgi.amount*dgi.fluctuationPrice) price,dgi.amount,0 forgonAmount,0 forgonPrice " + + "from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId where " + + " pr.orgUnitCoding='" + + orgUnitCoding + +"' and pr.packTime " + betweenSql + prDepartInSql; + //收费项目 + String chargeRecordSql = "select "+ crChargeTimeDateSql +" price,0 amount,0 forgonAmount,0 forgonPrice from ChargeRecordItem ci " + + " inner join ChargeRecord cr on cr.id=ci.chargeRecord_id where " + + " cr.orgUnitCode='" + + orgUnitCoding + + "' and cr.chargeTime " + betweenSql + crOrgUnitNameInSql; + String sql = "select dateStr,sum(price) price,sum(amount) amount,sum(forgonAmount) forgonAmount,sum(forgonPrice) forgonPrice from ("+ invoicePriceSql + + " union all " + +returnSql + + " union all " + +materialInvoicePriceSql + + " union all " + +damageSql + + " union all " + +recyclingErrorSql + + " union all " + +materialReturnSql + + " union all " + +receiveSql + + " union all " + +godownEntrySql + + " union all " + +packingRecordSql + + " union all " + +chargeRecordSql + +") t group by dateStr"; + return sql; + } +} Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java =================================================================== diff -u -r36224 -r36253 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 36224) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 36253) @@ -102,6 +102,7 @@ import com.forgon.disinfectsystem.jasperreports.service.WorkQualityCollectionReport; import com.forgon.disinfectsystem.jasperreports.util.InstrumentRepairReportHelper; import com.forgon.disinfectsystem.jasperreports.util.MonthReportHelper; +import com.forgon.disinfectsystem.jasperreports.util.WorkloadAndIncomeStatisticsReportHelper; import com.forgon.disinfectsystem.recyclingrecord.service.RecyclingItemManager; import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseDefinitionManager; import com.forgon.oa.onlineusers.service.OnlineUserManager; @@ -157,6 +158,13 @@ private InvoiceReportManager invoiceReportManager; private InstrumentRepairReportHelper instrumentRepairReportHelper; + + private WorkloadAndIncomeStatisticsReportHelper workloadAndIncomeStatisticsReportHelper; + + public void setWorkloadAndIncomeStatisticsReportHelper( + WorkloadAndIncomeStatisticsReportHelper workloadAndIncomeStatisticsReportHelper) { + this.workloadAndIncomeStatisticsReportHelper = workloadAndIncomeStatisticsReportHelper; + } public void setInstrumentRepairReportHelper( InstrumentRepairReportHelper instrumentRepairReportHelper) { this.instrumentRepairReportHelper = instrumentRepairReportHelper; @@ -1525,6 +1533,8 @@ return jasperReportManager.getStatisticalWorkloadData(startTime, endTime, departCoding, tousseTypes, packageSizes, BooleanUtils.toBoolean(isStrengthen),taskGroup); } + }else if("workloadAndIncomeStatisticsReport".equals(reportName)){ + return workloadAndIncomeStatisticsReportHelper.getWorkloadAndIncomeStatisticsReportData(requestParameters, parametMap); }else if (reportName.equals("disposableGoodsInventory")) {// 一次性物品盘点月报 String month = StrutsParamUtils.getPraramValue("month", null); Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/WorkloadAndIncomeStatisticsShowBean.java =================================================================== diff -u --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/WorkloadAndIncomeStatisticsShowBean.java (revision 0) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/WorkloadAndIncomeStatisticsShowBean.java (revision 36253) @@ -0,0 +1,78 @@ +package com.forgon.disinfectsystem.jasperreports.javabeansource; +/** + * 工作量及收入统计报表bean(用来展示的 因为需要加一些特殊行 与原有字段类型不相符 所以需要一个用来展示的) + * + */ +public class WorkloadAndIncomeStatisticsShowBean { + /** + * 时间列值 + */ + private String dateStr; + /** + * 本院数量 + */ + private String thisCourtAmount = "0"; + /** + * 外院数量 + */ + private String otherCourtAmount = "0"; + /** + * 外来器械数量 + */ + private String forgonAmount = "0"; + /** + * 本院收入 + */ + private String thisCourtPrice = "0.000"; + /** + * 外院收入 + */ + private String otherCourtPrice = "0.000"; + /** + * 外来器械收入 + */ + private String forgonPrice = "0.000"; + public String getDateStr() { + return dateStr; + } + public void setDateStr(String dateStr) { + this.dateStr = dateStr; + } + public String getThisCourtAmount() { + return thisCourtAmount; + } + public void setThisCourtAmount(String thisCourtAmount) { + this.thisCourtAmount = thisCourtAmount; + } + public String getOtherCourtAmount() { + return otherCourtAmount; + } + public void setOtherCourtAmount(String otherCourtAmount) { + this.otherCourtAmount = otherCourtAmount; + } + public String getForgonAmount() { + return forgonAmount; + } + public void setForgonAmount(String forgonAmount) { + this.forgonAmount = forgonAmount; + } + public String getThisCourtPrice() { + return thisCourtPrice; + } + public void setThisCourtPrice(String thisCourtPrice) { + this.thisCourtPrice = thisCourtPrice; + } + public String getOtherCourtPrice() { + return otherCourtPrice; + } + public void setOtherCourtPrice(String otherCourtPrice) { + this.otherCourtPrice = otherCourtPrice; + } + public String getForgonPrice() { + return forgonPrice; + } + public void setForgonPrice(String forgonPrice) { + this.forgonPrice = forgonPrice; + } + +} Index: ssts-web/src/main/webapp/jasperRtp/workloadAndIncomeStatisticsReport.jrxml =================================================================== diff -u --- ssts-web/src/main/webapp/jasperRtp/workloadAndIncomeStatisticsReport.jrxml (revision 0) +++ ssts-web/src/main/webapp/jasperRtp/workloadAndIncomeStatisticsReport.jrxml (revision 36253) @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: ssts-web/src/main/webapp/jasperRtp/workloadAndIncomeStatisticsReport.jasper =================================================================== diff -u Binary files differ Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/WorkloadAndIncomeStatisticsBean.java =================================================================== diff -u --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/WorkloadAndIncomeStatisticsBean.java (revision 0) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/javabeansource/WorkloadAndIncomeStatisticsBean.java (revision 36253) @@ -0,0 +1,89 @@ +package com.forgon.disinfectsystem.jasperreports.javabeansource; + +import java.text.DecimalFormat; + +/** + * 工作量及收入统计报表bean(用来方便计算的 减少类型转换) + * + */ +public class WorkloadAndIncomeStatisticsBean { + /** + * 时间 + */ + private String dateStr; + /** + * 本院数量 + */ + private Long thisCourtAmount = 0L; + /** + * 外院数量 + */ + private Long otherCourtAmount = 0L; + /** + * 外来器械数量 + */ + private Long forgonAmount = 0L; + /** + * 本院收入 + */ + private Double thisCourtPrice = 0.0; + /** + * 外院收入 + */ + private Double otherCourtPrice = 0.0; + /** + * 外来器械收入 + */ + private Double forgonPrice = 0.0; + public String getDateStr() { + return dateStr; + } + public void setDateStr(String dateStr) { + this.dateStr = dateStr; + } + public Long getThisCourtAmount() { + return thisCourtAmount; + } + public void setThisCourtAmount(Long thisCourtAmount) { + this.thisCourtAmount = thisCourtAmount; + } + public Long getOtherCourtAmount() { + return otherCourtAmount; + } + public void setOtherCourtAmount(Long otherCourtAmount) { + this.otherCourtAmount = otherCourtAmount; + } + public Long getForgonAmount() { + return forgonAmount; + } + public void setForgonAmount(Long forgonAmount) { + this.forgonAmount = forgonAmount; + } + public Double getThisCourtPrice() { + return thisCourtPrice; + } + public void setThisCourtPrice(Double thisCourtPrice) { + this.thisCourtPrice = thisCourtPrice; + } + public Double getOtherCourtPrice() { + return otherCourtPrice; + } + public void setOtherCourtPrice(Double otherCourtPrice) { + this.otherCourtPrice = otherCourtPrice; + } + public Double getForgonPrice() { + return forgonPrice; + } + public void setForgonPrice(Double forgonPrice) { + this.forgonPrice = forgonPrice; + } + public WorkloadAndIncomeStatisticsShowBean getShowBean(DecimalFormat df){ + WorkloadAndIncomeStatisticsShowBean showBean = new WorkloadAndIncomeStatisticsShowBean(); + showBean.setDateStr(this.dateStr); + showBean.setForgonAmount(this.forgonAmount.toString()); + showBean.setForgonPrice(df.format(this.forgonPrice)); + showBean.setThisCourtAmount(this.thisCourtAmount.toString()); + showBean.setThisCourtPrice(df.format(this.thisCourtPrice)); + return showBean; + } +} Index: forgon-tools/src/main/java/com/forgon/tools/date/DateTools.java =================================================================== diff -u -r35869 -r36253 --- forgon-tools/src/main/java/com/forgon/tools/date/DateTools.java (.../DateTools.java) (revision 35869) +++ forgon-tools/src/main/java/com/forgon/tools/date/DateTools.java (.../DateTools.java) (revision 36253) @@ -1042,6 +1042,19 @@ return YMDFORMAT.get().format(c.getTime()); } /** + * 获取N个月后的月份 可以为负数 + * @param year 年 + * @param mm 月 + * @param num 差值 注意0位加一个月 -1为不变 -2才是减一个月 + * @return yyyy-mm + */ + public static String getNextMonth(String year,String mm, int num) { + Calendar c = Calendar.getInstance(); + c.set(Integer.parseInt(year), Integer.parseInt(mm), 1); + c.add(Calendar.MONTH, num); + return YMFORMAT.get().format(c.getTime()); + } + /** * 获取一个月中的天数 * @param year * @param mm