资料导出

This commit is contained in:
zhangqinlin
2021-09-01 16:20:15 +08:00
parent 7aadf30f75
commit ab07ab3056
4 changed files with 45 additions and 7 deletions
@@ -167,7 +167,6 @@ public class JeroController<T, S extends IService<T>> {
// Step.1 组装查询条件 // Step.1 组装查询条件
// Step.2 获取导出数据 // Step.2 获取导出数据
List<T> pageList = service.list(queryWrapper); List<T> pageList = service.list(queryWrapper);
// Step.3 AutoPoi 导出Excel // Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//此处设置的filename无效 ,前端会重更新设置一下 //此处设置的filename无效 ,前端会重更新设置一下
@@ -8,6 +8,7 @@ import javax.validation.Valid;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.aspect.annotation.AutoLog;
@@ -16,13 +17,19 @@ import com.jero.common.system.query.QueryGenerator;
import com.jero.data.entity.DTO.PayCaseCommitteeDTO; import com.jero.data.entity.DTO.PayCaseCommitteeDTO;
import com.jero.data.entity.DTO.PayCaseCommitteeUpdateDTO; import com.jero.data.entity.DTO.PayCaseCommitteeUpdateDTO;
import com.jero.data.entity.PayCaseCommittee; import com.jero.data.entity.PayCaseCommittee;
import com.jero.data.entity.PayCaseCommitteeExcel;
import com.jero.data.entity.VO.payCaseCommitteeSubitemVO;
import com.jero.data.mapper.PayCaseCommitteeSubitemMapper; import com.jero.data.mapper.PayCaseCommitteeSubitemMapper;
import com.jero.data.service.IPayCaseCommitteeService; import com.jero.data.service.IPayCaseCommitteeService;
import com.jero.data.entity.PayCaseCommitteeSubitem; import com.jero.data.entity.PayCaseCommitteeSubitem;
import com.jero.data.service.IPayCaseCommitteeSubitemService; import com.jero.data.service.IPayCaseCommitteeSubitemService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@@ -40,8 +47,12 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping("/payCaseCommittee/payCaseCommittee") @RequestMapping("/payCaseCommittee/payCaseCommittee")
@Slf4j @Slf4j
public class PayCaseCommitteeController extends JeroController<PayCaseCommittee, IPayCaseCommitteeService> { public class PayCaseCommitteeController extends JeroController<PayCaseCommittee, IPayCaseCommitteeService> {
@Value("${jero.path.upload}")
private String upLoadPath;
@Autowired @Autowired
private IPayCaseCommitteeService payCaseCommitteeService; private IPayCaseCommitteeService payCaseCommitteeService;
@Autowired @Autowired
private IPayCaseCommitteeSubitemService payCaseCommitteeSubitemService; private IPayCaseCommitteeSubitemService payCaseCommitteeSubitemService;
@@ -142,15 +153,29 @@ public class PayCaseCommitteeController extends JeroController<PayCaseCommittee,
/** /**
* 导出excel * 导出excel
* *
* @param request *
* @param payCaseCommittee
*/ */
@AutoLog(value = "分标委表-导出") @AutoLog(value = "分标委表-导出")
@ApiOperation(value="分标委表-导出", notes="分标委表-导出") @ApiOperation(value="分标委表-导出", notes="分标委表-导出")
@RequestMapping(value = "/exportXls") @GetMapping(value = "/exportXls",produces = "text/text;charset=utf-8")
public ModelAndView exportXls(HttpServletRequest request, PayCaseCommittee payCaseCommittee) { public ModelAndView customExportXlsList() {
return super.exportXls(request, payCaseCommittee, PayCaseCommittee.class, "分标委表"); QueryWrapper<PayCaseCommitteeSubitem> queryWrapper = Wrappers.query();
List<PayCaseCommitteeExcel> list = payCaseCommitteeSubitemMapper.listExcel(queryWrapper);
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "分标委表"); //此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.CLASS, PayCaseCommitteeExcel.class);
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams("分标委表", "分标委表");
exportParams.setImageBasePath(upLoadPath);
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, list);
return mv;
} }
// /** // /**
// * 批量删除 // * 批量删除
// * // *
@@ -2,9 +2,11 @@ package com.jero.data.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.data.entity.PayCaseCommitteeExcel;
import com.jero.data.entity.PayCaseCommitteeSubitem; import com.jero.data.entity.PayCaseCommitteeSubitem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.data.entity.VO.payCaseCommitteeSubitemVO; import com.jero.data.entity.VO.payCaseCommitteeSubitemVO;
@@ -25,5 +27,8 @@ public interface PayCaseCommitteeSubitemMapper extends BaseMapper<PayCaseCommitt
Page<FindByName> list (IPage<PayCaseCommitteeSubitem> page, @Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper); Page<FindByName> list (IPage<PayCaseCommitteeSubitem> page, @Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper);
List<payCaseCommitteeSubitemVO> list2 (@Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper); List<payCaseCommitteeSubitemVO> list2 (@Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper);
List<PayCaseCommitteeExcel> listExcel(@Param(Constants.WRAPPER) QueryWrapper<PayCaseCommitteeSubitem> queryWrapper);
} }
@@ -30,4 +30,13 @@
left JOIN pay_contacts_management pt on (pm.contacts_id = pt.id) left JOIN pay_contacts_management pt on (pm.contacts_id = pt.id)
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </select>
<select id="listExcel" resultType="com.jero.data.entity.PayCaseCommitteeExcel">
SELECT pe.name as name,pt.name as peopleName,pm.company_name as companyName,pt.post as post,pt.phone as phone
from
pay_case_committee pe
right JOIN pay_case_committee_subitem pm on (pe.id = pm.committee_id)
left JOIN pay_contacts_management pt on (pm.contacts_id = pt.id)
${ew.customSqlSegment}
</select>
</mapper> </mapper>