自动化立体仓库 - WMS系统
zhangchao
2024-11-04 59f80df1e377e8775969ca4acadfa2eadd6e37ae
src/main/java/com/zy/asrs/controller/LocDetlController.java
@@ -1,7 +1,5 @@
package com.zy.asrs.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -21,9 +19,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
@RestController
@@ -256,24 +251,32 @@
    @Autowired
    private LocDetlMapper LocDetlMapper;
//    @RequestMapping(value = "/locDetl/statis/export")
////    @ManagerAuth
//    public void statisExport(HttpServletResponse response) throws IOException {
//        List<LocDetl> excel = LocDetlMapper.getStockStatisExcel();
//        for (LocDetl locDetl : excel) {
//            Mat mat = matService.selectByMatnr(locDetl.getMatnr());
//            if (mat != null) {
//                locDetl.sync(mat);
//            }
//        }
//        response.setContentType("application/vnd.ms-excel");
//        response.setCharacterEncoding("utf-8");
//        String fileName = URLEncoder.encode("库存明细统计报表", "UTF-8");
//        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
//        EasyExcel.write(response.getOutputStream(), LocDetl.class)
//                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
//                .sheet("表1")
//                .doWrite(excel);
//    }
    @RequestMapping(value = "/locDetl/statis/export")
//    @ManagerAuth
    public void statisExport(HttpServletResponse response) throws IOException {
        List<LocDetl> excel = LocDetlMapper.getStockStatisExcel();
        for (LocDetl locDetl : excel) {
            Mat mat = matService.selectByMatnr(locDetl.getMatnr());
            if (mat != null) {
                locDetl.sync(mat);
            }
        }
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        String fileName = URLEncoder.encode("库存明细统计报表", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
        EasyExcel.write(response.getOutputStream(), LocDetl.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .sheet("表1")
                .doWrite(excel);
    @ManagerAuth(memo = "库位明细导出")
    public synchronized R statisExport(@RequestBody JSONObject param){
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        List<LocDetl> stockStatisExcel = LocDetlMapper.getStockStatisExcel();
        return R.ok(exportSupport(stockStatisExcel, fields));
    }
    /**