| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderCheck/printExport/auth") |
| | | // @ManagerAuth(memo = "盘点单导出") |
| | | public void export(HttpServletResponse response,@RequestParam String orderNo) throws IOException { |
| | | //从数据库查询数据 |
| | | EntityWrapper<LocCheck> locCheckEntityWrapper = new EntityWrapper<>(); |
| | | locCheckEntityWrapper.eq("order_no",orderNo); |
| | | List<LocCheck> list = locCheckService.selectList(locCheckEntityWrapper); |
| | | for (LocCheck locCheck:list){ |
| | | locCheck.setRealAnfme(null); |
| | | } |
| | | |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("盘点单", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName+ orderNo + ".xlsx"); |
| | | Set<String> includeColumnFiledNames = new HashSet<String>(); |
| | | includeColumnFiledNames.add("orderNo"); |
| | | includeColumnFiledNames.add("matnr"); |
| | | includeColumnFiledNames.add("maktx"); |
| | | includeColumnFiledNames.add("locNo"); |
| | | includeColumnFiledNames.add("anfme"); |
| | | includeColumnFiledNames.add("owner"); |
| | | includeColumnFiledNames.add("payment"); |
| | | includeColumnFiledNames.add("createTime"); |
| | | includeColumnFiledNames.add("realAnfme"); |
| | | EasyExcel.write(response.getOutputStream(), LocCheck.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .includeColumnFiledNames(includeColumnFiledNames) |
| | | .sheet("表1") |
| | | .doWrite(list); |
| | | } |
| | | |
| | | |
| | | } |