Search in sources :

Example 6 with JeecgEntityExcelView

use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project jeecg-boot by jeecgboot.

the class SysDepartController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDepart sysDepart, HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysDepart> pageList = sysDepartService.list(queryWrapper);
    // 按字典排序
    Collections.sort(pageList, new Comparator<SysDepart>() {

        @Override
        public int compare(SysDepart arg0, SysDepart arg1) {
            return arg0.getOrgCode().compareTo(arg1.getOrgCode());
        }
    });
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
    mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:" + user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
Also used : ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) SysDepart(org.jeecg.modules.system.entity.SysDepart) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 7 with JeecgEntityExcelView

use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project jeecg-boot by jeecgboot.

the class SysDictController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDict sysDict, HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysDictPage> pageList = new ArrayList<SysDictPage>();
    List<SysDict> sysDictList = sysDictService.list(queryWrapper);
    for (SysDict dictMain : sysDictList) {
        SysDictPage vo = new SysDictPage();
        BeanUtils.copyProperties(dictMain, vo);
        // 查询机票
        List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByMainId(dictMain.getId());
        vo.setSysDictItemList(sysDictItemList);
        pageList.add(vo);
    }
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "数据字典");
    // 注解对象Class
    mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
    // 自定义表格参数
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:" + user.getRealname(), "数据字典"));
    // 导出数据列表
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
Also used : ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) SysDictPage(org.jeecg.modules.system.vo.SysDictPage) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) SysDict(org.jeecg.modules.system.entity.SysDict) ModelAndView(org.springframework.web.servlet.ModelAndView) SysDictItem(org.jeecg.modules.system.entity.SysDictItem) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 8 with JeecgEntityExcelView

use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kms by mahonelau.

the class QuartzJobController method exportXls.

/**
 * 导出excel
 *
 * @param request
 * @param quartzJob
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, QuartzJob quartzJob) {
    // Step.1 组装查询条件
    QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, request.getParameterMap());
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<QuartzJob> pageList = quartzJobService.list(queryWrapper);
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "定时任务列表");
    mv.addObject(NormalExcelConstants.CLASS, QuartzJob.class);
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("定时任务列表数据", "导出人:Jeecg", "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
Also used : ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) QuartzJob(org.jeecg.modules.quartz.entity.QuartzJob) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 9 with JeecgEntityExcelView

use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kms by mahonelau.

the class JeecgController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title) {
    // Step.1 组装查询条件
    QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    // Step.2 获取导出数据
    List<T> pageList = service.list(queryWrapper);
    List<T> exportList = null;
    // 过滤选中数据
    String selections = request.getParameter("selections");
    if (oConvertUtils.isNotEmpty(selections)) {
        List<String> selectionList = Arrays.asList(selections.split(","));
        exportList = pageList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
    } else {
        exportList = pageList;
    }
    // Step.3 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    // 此处设置的filename无效 ,前端会重更新设置一下
    mv.addObject(NormalExcelConstants.FILE_NAME, title);
    mv.addObject(NormalExcelConstants.CLASS, clazz);
    // update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
    ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
    exportParams.setImageBasePath(upLoadPath);
    // update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
    mv.addObject(NormalExcelConstants.PARAMS, exportParams);
    mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
    return mv;
}
Also used : ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 10 with JeecgEntityExcelView

use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kms by mahonelau.

the class SysPositionController method exportXls.

/**
 * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
    // Step.1 组装查询条件
    QueryWrapper<SysPosition> queryWrapper = null;
    try {
        String paramsStr = request.getParameter("paramsStr");
        if (oConvertUtils.isNotEmpty(paramsStr)) {
            String deString = URLDecoder.decode(paramsStr, "UTF-8");
            SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
            queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysPosition> pageList = sysPositionService.list(queryWrapper);
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
    mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:Jeecg", "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
Also used : SysPosition(org.jeecg.modules.system.entity.SysPosition) ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

ExportParams (org.jeecgframework.poi.excel.entity.ExportParams)33 JeecgEntityExcelView (org.jeecgframework.poi.excel.view.JeecgEntityExcelView)33 ModelAndView (org.springframework.web.servlet.ModelAndView)33 LoginUser (org.jeecg.common.system.vo.LoginUser)28 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)6 IPage (com.baomidou.mybatisplus.core.metadata.IPage)6 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 JSON (com.alibaba.fastjson.JSON)3 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)3 IOException (java.io.IOException)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Slf4j (lombok.extern.slf4j.Slf4j)3 StringUtils (org.apache.commons.lang.StringUtils)3 SecurityUtils (org.apache.shiro.SecurityUtils)3 Result (org.jeecg.common.api.vo.Result)3