如果startDate和endDate用数据库里的created_time,那么取出来的数据就会少,例如
select * from pds_daily_production_report where company_id = "1" and uwi = "20191101eee"
and created_time>= "2019-10-01" and created_time<= "2019-10-30" order by created_time asc
它就会少 2019-10-30这一天的数据,因为created_time是date类型,拼起来的sql是到 2019-10-30 00:00:00,所以就会少截至日期一天的数据,所以每次都要加一天,如下边代码
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar instance = Calendar.getInstance();
String uwi = params.getString("uwi");
Long companyId = UserContext.getCompanyId();
String startDate = params.getString("startDate");
String date = params.getString("endDate");
String endDate = "";
if (date != null) {
Date parse1 = formatter.parse(date);
instance.setTime(parse1);
instance.add(Calendar.DAY_OF_MONTH,1);
endDate = simpleDateFormat.format(instance.getTime());
}
Integer page = params.getIntValue("page");
Integer pageSize = params.getIntValue("pageSize");
if(page == 0){
page = 1;
}
if(pageSize == 0){
pageSize = 20;
}
PageHelper.startPage(page, pageSize);
List<DailyProductionVo> dailyProductionVos = dailyProductionMapper.listByCompanyIdUwiStartEndDate(companyId, uwi, startDate, endDate);