PageResult多表查询
Mapper
@Mapper
public interface OperateInfoMapper extends BaseDao<OperateInfo> {
@Select("SELECT\n" +
"\tDATE_FORMAT( start_time, \"%Y-%m-%d\" ) AS date ,\n" +
"\tsum( operated_oil ) AS totalOil,\n" +
"\tcount( id ) AS totalNum,\n" +
"\tsum( operated_mileage ) AS totalMileage,\n" +
"\tsum( total_used_time )/3600 AS totalTime ,\n" +
"\tsum( operated_area ) AS totalArea \n" +
"FROM\n" +
"\t`t_operate_info` where deleted = 0 and start_time>= #{startDate} and start_time <= #{endDate} \n" +
"GROUP BY\n" +
"\tDATE_FORMAT( start_time, \"%Y-%m-%d\" )\n" +
"ORDER BY start_time desc")
IPage<OperateDataGroupByDate> getTotalDataByDate(IPage<OperateDataGroupByDate> page,String startDate, String endDate);
}
Service
接口
public interface IOperateInfoService extends IServiceDto<OperateInfo>, IService<OperateInfo> {
PagerResult<OperateDataGroupByDate> getTotalDataByDate(BasePageVo pageVo,String startDate, String endDate);
}
实现类:
@Slf4j
@Service("operateInfoService")
public class OperateInfoServiceImpl extends BaseService<OperateInfoMapper, OperateInfo, OperateInfo> implements IOperateInfoService {
@Override
public PagerResult<OperateDataGroupByDate> getTotalDataByDate(BasePageVo pageVo,String startDate, String endDate) {
IPage<OperateDataGroupByDate> page = new Page(pageVo.getPage(),pageVo.getLimit());
IPage<OperateDataGroupByDate> pageResult = getBaseMapper().getTotalDataByDate(page, startDate, endDate);
PagerResult<OperateDataGroupByDate> result =PagerResult.of(pageResult.getTotal()
,pageResult.getCurrent(),pageResult.getSize(),pageResult.getRecords());
return result;
}
}
OperateDataGroupByDate是要查询的列表,不对应数据库种的任何一张表,多表查询。