Search in sources :

Example 26 with JeecgEntityExcelView

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

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) ImportExcelUtil(org.jeecg.common.util.ImportExcelUtil) 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) CommonConstant(org.jeecg.common.constant.CommonConstant) 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 27 with JeecgEntityExcelView

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

the class SysAnnouncementController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysAnnouncement sysAnnouncement, HttpServletRequest request) {
    // Step.1 组装查询条件
    LambdaQueryWrapper<SysAnnouncement> queryWrapper = new LambdaQueryWrapper<SysAnnouncement>(sysAnnouncement);
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    queryWrapper.eq(SysAnnouncement::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
    List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper);
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
    mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.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) SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) LoginUser(org.jeecg.common.system.vo.LoginUser) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 28 with JeecgEntityExcelView

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

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);
    // 获取当前登录用户
    // update-begin---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("定时任务列表数据", "导出人:" + user.getRealname(), "导出信息"));
    // update-end---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
    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) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 29 with JeecgEntityExcelView

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

the class SysAnnouncementController method exportXls.

/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysAnnouncement sysAnnouncement, HttpServletRequest request) {
    // Step.1 组装查询条件
    LambdaQueryWrapper<SysAnnouncement> queryWrapper = new LambdaQueryWrapper<SysAnnouncement>(sysAnnouncement);
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    queryWrapper.eq(SysAnnouncement::getDelFlag, CommonConstant.DEL_FLAG_0);
    List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper);
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
    mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.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) SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) LoginUser(org.jeecg.common.system.vo.LoginUser) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 30 with JeecgEntityExcelView

use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kykms 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)

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