自动化立体仓库 - WMS系统
zhou zhou
11 小时以前 64d6948806c3dd7d657c359354212fa3eadfaa8e
src/main/java/com/zy/asrs/controller/CheckOrderController.java
@@ -1,5 +1,7 @@
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;
@@ -10,8 +12,10 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.CheckTaskListParam;
import com.zy.asrs.entity.param.OrderDomainParam;
import com.zy.asrs.entity.result.CheckOrderExportDTO;
import com.zy.asrs.service.*;
import com.core.annotations.ManagerAuth;
import com.zy.common.entity.NodeExcel;
import com.zy.common.model.DetlDto;
import com.zy.common.model.LocDto;
import com.zy.common.web.BaseController;
@@ -19,6 +23,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
@@ -247,15 +253,38 @@
//        return R.ok();
//    }
    @RequestMapping(value = "/checkOrder/export/auth")
    @ManagerAuth
    public R export(@RequestBody JSONObject param){
        EntityWrapper<CheckOrder> wrapper = new EntityWrapper<>();
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        Map<String, Object> map = excludeTrash(param.getJSONObject("checkOrder"));
        convert(map, wrapper);
        List<CheckOrder> list = checkOrderService.selectList(wrapper);
        return R.ok(exportSupport(list, fields));
    @PostMapping(value = "/checkOrder/export/auth")
    @ManagerAuth(memo = "盘点单导出")
    public void export(@RequestParam("orderId") Long orderId, HttpServletResponse response) throws IOException {
        CheckOrder checkOrder = checkOrderService.selectById(orderId);
        if (Cools.isEmpty(checkOrder)) {
            throw new CoolException("数据错误");
        }
        List<CheckOrderDetl> checkOrderDetls = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", orderId));
        ArrayList<CheckOrderExportDTO> checkOrderExportDTOS = new ArrayList<>();
        for (CheckOrderDetl checkOrderDetl : checkOrderDetls) {
            CheckOrderExportDTO checkOrderExportDTO = new CheckOrderExportDTO();
            checkOrderExportDTO.sync(checkOrderDetl);
            checkOrderExportDTOS.add(checkOrderExportDTO);
        }
        String fileName = "盘点差异单_"+checkOrder.getOrderNo() + ".xlsx";
        // 设置响应头,指定文件名
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        // 防止中文乱码
        fileName = java.net.URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
        response.setHeader("Content-Disposition", "attachment;filename*=" + fileName);
        EasyExcel.write(response.getOutputStream(), CheckOrderExportDTO.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .sheet("sheet1")
                .doWrite(checkOrderExportDTOS);
    }
    @RequestMapping(value = "/checkOrderQuery/auth")