自动化立体仓库 - WMS系统
pang.jiabao
2024-12-19 e8cdc81123495b0a3aa3473554fb7c0465386f44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.zy.common.utils;
 
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.Node;
import com.zy.asrs.entity.Tag;
import com.zy.asrs.service.NodeService;
import com.zy.asrs.service.TagService;
import com.zy.common.entity.NodeExcel;
import org.springframework.web.bind.annotation.RequestMapping;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
 
/**
 * Created by vincent on 2021/1/19
 */
public class NodeUtils {
 
    public StringBuilder path = new StringBuilder();
 
    public StringBuilder pathName = new StringBuilder();
 
    public void executePath(Node node) {
        NodeService bean = SpringUtils.getBean(NodeService.class);
        Node parent = bean.selectById(node.getParentId());
        if (null != parent) {
            path.insert(0, parent.getId()).insert(0,",");
            pathName.insert(0, parent.getName()).insert(0,",");
            if (parent.getParentId() != null) {
                executePath(parent);
            } else {
                path.deleteCharAt(0);
                pathName.deleteCharAt(0);
            }
        }
    }
 
    public void executePath(Tag tag) {
        TagService bean = SpringUtils.getBean(TagService.class);
        Tag parent = bean.selectById(tag.getParentId());
        if (null != parent) {
            path.insert(0, parent.getId()).insert(0,",");
            pathName.insert(0, parent.getName()).insert(0,",");
            if (parent.getParentId() != null) {
                executePath(parent);
            } else {
                path.deleteCharAt(0);
                pathName.deleteCharAt(0);
            }
        }
    }
 
    public void executePath(Long parentId) {
        TagService bean = SpringUtils.getBean(TagService.class);
        Tag parent = bean.selectById(parentId);
        if (null != parent) {
            path.insert(0, parent.getId()).insert(0,",");
            pathName.insert(0, parent.getName()).insert(0,",");
            if (parent.getParentId() != null) {
                executePath(parent);
            } else {
                path.deleteCharAt(0);
                pathName.deleteCharAt(0);
            }
        }
    }
    /*************************************** 数据相关 ***********************************************/
 
    /**
     * excel导入模板下载
     */
    @RequestMapping(value = "/node/excel/import/mould")
    public void nodeExcelImportMould(HttpServletResponse response) throws IOException {
        List<NodeExcel> excels = new ArrayList<>();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        String fileName = URLEncoder.encode("货位档案Excel导入模板", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
        EasyExcel.write(response.getOutputStream(), NodeExcel.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .sheet("sheet1")
                .doWrite(excels);
    }
 
}