Search in sources :

Example 21 with JeecgEntityExcelView

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

the class SysCategoryController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
    // Step.1 组装查询条件查询数据
    QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
    List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    // 过滤选中数据
    String selections = request.getParameter("selections");
    if (oConvertUtils.isEmpty(selections)) {
        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    } else {
        List<String> selectionList = Arrays.asList(selections.split(","));
        List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
        mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
    }
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
    mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:" + user.getRealname(), "导出信息"));
    return mv;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) ImportParams(org.jeecgframework.poi.excel.entity.ImportParams) ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) MultipartHttpServletRequest(org.springframework.web.multipart.MultipartHttpServletRequest) DictModel(org.jeecg.common.system.vo.DictModel) Autowired(org.springframework.beans.factory.annotation.Autowired) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) HttpServletRequest(javax.servlet.http.HttpServletRequest) LoginUser(org.jeecg.common.system.vo.LoginUser) org.jeecg.common.util.oConvertUtils(org.jeecg.common.util.oConvertUtils) SysCategory(org.jeecg.modules.system.entity.SysCategory) ISysCategoryService(org.jeecg.modules.system.service.ISysCategoryService) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) QueryGenerator(org.jeecg.common.system.query.QueryGenerator) Result(org.jeecg.common.api.vo.Result) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) TreeSelectModel(org.jeecg.modules.system.model.TreeSelectModel) NormalExcelConstants(org.jeecgframework.poi.excel.def.NormalExcelConstants) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) ModelAndView(org.springframework.web.servlet.ModelAndView) Slf4j(lombok.extern.slf4j.Slf4j) JSON(com.alibaba.fastjson.JSON) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) ExcelImportUtil(org.jeecgframework.poi.excel.ExcelImportUtil) IPage(com.baomidou.mybatisplus.core.metadata.IPage) SecurityUtils(org.apache.shiro.SecurityUtils) ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) SysCategory(org.jeecg.modules.system.entity.SysCategory) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 22 with JeecgEntityExcelView

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

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 23 with JeecgEntityExcelView

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

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 24 with JeecgEntityExcelView

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

the class JeecgOrderMainController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, JeecgOrderMain jeecgOrderMain) {
    // Step.1 组装查询条件
    QueryWrapper<JeecgOrderMain> queryWrapper = QueryGenerator.initQueryWrapper(jeecgOrderMain, request.getParameterMap());
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    // 获取当前用户
    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    List<JeecgOrderMainPage> pageList = new ArrayList<JeecgOrderMainPage>();
    List<JeecgOrderMain> jeecgOrderMainList = jeecgOrderMainService.list(queryWrapper);
    for (JeecgOrderMain orderMain : jeecgOrderMainList) {
        JeecgOrderMainPage vo = new JeecgOrderMainPage();
        BeanUtils.copyProperties(orderMain, vo);
        // 查询机票
        List<JeecgOrderTicket> jeecgOrderTicketList = jeecgOrderTicketService.selectTicketsByMainId(orderMain.getId());
        vo.setJeecgOrderTicketList(jeecgOrderTicketList);
        // 查询客户
        List<JeecgOrderCustomer> jeecgOrderCustomerList = jeecgOrderCustomerService.selectCustomersByMainId(orderMain.getId());
        vo.setJeecgOrderCustomerList(jeecgOrderCustomerList);
        pageList.add(vo);
    }
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "一对多订单示例");
    // 注解对象Class
    mv.addObject(NormalExcelConstants.CLASS, JeecgOrderMainPage.class);
    // 自定义表格参数
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("自定义导出Excel内容标题", "导出人:" + sysUser.getRealname(), "自定义Sheet名字"));
    // 导出数据列表
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
Also used : JeecgOrderMain(org.jeecg.modules.demo.test.entity.JeecgOrderMain) JeecgOrderTicket(org.jeecg.modules.demo.test.entity.JeecgOrderTicket) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) LoginUser(org.jeecg.common.system.vo.LoginUser) ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) JeecgOrderMainPage(org.jeecg.modules.demo.test.vo.JeecgOrderMainPage) JeecgOrderCustomer(org.jeecg.modules.demo.test.entity.JeecgOrderCustomer) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with JeecgEntityExcelView

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

the class JoaDemoController method exportXls.

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

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