java报表查询_报表统计——java实现查询某年某月每天数据,没数据补0

@OverridepublicYJLResponseModel getOrderNewDayCountByYearAndMonth(String condtionStr) {

setYjlResponseModel(newYJLResponseModel());

PageData pageData= JSON.parseObject(condtionStr, PageData.class);//按年+月获取每一天数据

List orderCountList =ordOrderNewMapper.getOrderNewDayCountByYearAndMonth(pageData);//初始化====================//java获取当前年份

Calendar cale =Calendar.getInstance();int currentYear = cale.get(Calendar.YEAR);int currentMonth= cale.get(Calendar.MONTH)+ 1;//判断是否是当前年月,不是的话取满月,是的话,取当前截止日期

int argYear = Integer.parseInt(pageData.getString("year"));int argMonth = Integer.parseInt(pageData.getString("month"));//定义最大天数,默认取满天

int maxDays=getMaxDay(argYear,argMonth);//如果有数据,补充数据===================

if(orderCountList!=null && orderCountList.size()>0) {if (argYear == currentYear && argMonth ==currentMonth) {//获取最后一天日期

PageData lastDay = orderCountList.get(orderCountList.size() - 1);//获取截止天数

maxDays = Integer.parseInt(lastDay.get("day").toString());

}

}//定义最大天数数组

int[] count = new int[maxDays];int[] days = new int[maxDays];//补全日期到数组中

for(int i=0;i

days[i]= i+1;

}if(orderCountList!=null && orderCountList.size()>0) {//将获取到不同年份不同月份不同日期对应不同的订单量放在数组中

for (int i=0;i

PageData oc= orderCountList.get(i);//获取对应天

if(oc!=null){

count[Integer.parseInt(oc.get("day").toString())-1] = Integer.parseInt(oc.get("count").toString());

}

}

}

pageData.put("count",count);

pageData.put("days",days);

getYjlResponseModel().setData(pageData);

getYjlResponseModel().setSuccess(true);returngetYjlResponseModel();

}

@OverridepublicYJLResponseModel getOrderNewDayCountByYear(String condtionStr) {

setYjlResponseModel(newYJLResponseModel());

PageData pageData= JSON.parseObject(condtionStr, PageData.class);//按年获取每一天数据

List orderCountList =ordOrderNewMapper.getOrderNewDayCountByYear(pageData);//初始化数据==============================//定义最大月数数组,默认除了当前年之前年是12个月,当期年是截止月//获取传参年数

int argYear = Integer.parseInt(pageData.getString("year"));//java获取当前年份

Calendar cale =Calendar.getInstance();int currentYear = cale.get(Calendar.YEAR);//定义某年月数,默认12

int maxMonths = 12;//优化数据,补充数据=======================

if(orderCountList!=null && orderCountList.size()>0){if(argYear==currentYear){//获取最后一个月份

PageData lastMonth = orderCountList.get(orderCountList.size()-1);//获取截止月份

maxMonths= Integer.parseInt(lastMonth.get("month").toString());

}

}//定义返回数据格式,默认都是0

int[] count = new int[maxMonths];int[] months = new int[maxMonths];//补全月份到数组中

for(int i=0;i

months[i]= i+1;

}if(orderCountList!=null && orderCountList.size()>0){//将获取到不同年份不同月份对应的订单量放在数组中

for (int i=0;i

PageData oc= orderCountList.get(i);//获取对应天

if(oc!=null){

count[Integer.parseInt(oc.get("month").toString())-1] = Integer.parseInt(oc.get("count").toString());

}

}

}

pageData.put("count",count);

pageData.put("month",months);

getYjlResponseModel().setData(pageData);

getYjlResponseModel().setSuccess(true);returngetYjlResponseModel();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值