|  |  | 
 |  |  | 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 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); | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     /*************************************** 数据相关 ***********************************************/ | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 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); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |