| | |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.kmood.datahandle.DocumentProducer; |
| | | import com.kmood.utils.FileUtils; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.listen.ComMngPopulationServeExcelListen; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import sun.applet.Main; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URL; |
| | | import java.util.ArrayList; |
| | | import java.util.Base64; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "导出图片测试") |
| | | @GetMapping("/export/picture") |
| | | public static void testPictureOutModel () { |
| | | try { |
| | | Class<? extends Class> aClass = Main.class.getClass(); |
| | | ClassLoader classLoader = aClass.getClassLoader(); |
| | | if (classLoader == null){ |
| | | classLoader = ClassLoader.getSystemClassLoader(); |
| | | } |
| | | String ActualModelPath = classLoader.getResource("model/").toURI().getPath(); |
| | | String xmlPath = classLoader.getResource("model").toURI().getPath(); |
| | | String ExportFilePath = classLoader.getResource(".").toURI().getPath() + "/picture.doc"; |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | //读取输出图片 |
| | | URL introUrl = classLoader.getResource("./picture/微信图片_20210805165019.jpg"); |
| | | // URL codeUrl = classLoader.getResource("./picture/exportTestPicture-code.png"); |
| | | // URL titleUrl = classLoader.getResource("./picture/exportTestPicture-title.png"); |
| | | |
| | | String intro = Base64.getEncoder().encodeToString(FileUtils.readToBytesByFilepath(introUrl.toURI().getPath())); |
| | | map.put("intro", intro); |
| | | // String code = Base64.getEncoder().encodeToString(FileUtils.readToBytesByFilepath(codeUrl.toURI().getPath())); |
| | | // map.put("code", code); |
| | | // map.put("title", Base64.getEncoder().encodeToString(FileUtils.readToBytesByFilepath(titleUrl.toURI().getPath()))); |
| | | //编译输出 |
| | | DocumentProducer dp = new DocumentProducer(ActualModelPath); |
| | | // String complie = dp.Complie(xmlPath, "picture.xml", true); |
| | | dp.produce(map, ExportFilePath); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private List<List<String>> headDataFilling(){ |
| | | List<List<String>> list = new ArrayList<List<String>>(); |
| | | List<String> head0 = new ArrayList<String>(); |