huanghongfa
2021-08-16 c9a39d535c6eb670ddf3610e05f559565865eb44
注释报错代码
1个文件已修改
144 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java 144 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java
@@ -6,8 +6,8 @@
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.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;
@@ -20,9 +20,9 @@
import com.panzhihua.common.service.partybuilding.PartyBuildingService;
import com.panzhihua.common.utlis.SFTPUtil;
import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.Version;
//import freemarker.template.Configuration;
//import freemarker.template.Template;
//import freemarker.template.Version;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -442,73 +442,73 @@
        }
    }
    @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();
        }
    }
    @ApiOperation(value = "导出图片测试")
    @PostMapping("/export/picture")
    public void test(@RequestParam(value = "id") Long id){
        Long communityId = this.getLoginUserInfo().getCommunityId();
        Map<String,Object> dataMap = new HashMap<String, Object>();
        try {
            ComSwSafetyWorkRecordVO comSwSafetyWorkRecordVO = JSONObject.parseObject(JSONObject.toJSONString(communityService.detailSafetyWorkRecord(id, communityId).getData()),ComSwSafetyWorkRecordVO.class);
            //日期
            dataMap.put("date", new SimpleDateFormat("yyyy-MM-dd").format(comSwSafetyWorkRecordVO.getPatrolTime()));
            Configuration configuration = new Configuration(new Version("2.3.0"));
            configuration.setDefaultEncoding("utf-8");
            /**
             * 以下是两种指定ftl文件所在目录路径的方式,注意这两种方式都是
             * 指定ftl文件所在目录的路径,而不是ftl文件的路径
             */
            //指定路径的第一种方式(根据某个类的相对路径指定)
//                configuration.setClassForTemplateLoading(this.getClass(), "");
            //指定路径的第二种方式,我的路径是C:/a.ftl
            configuration.setDirectoryForTemplateLoading(new File("c:/"));
            //输出文档路径及名称
            File outFile = new File("D:/报销信息导出.doc");
            //以utf-8的编码读取ftl文件
            Template template = configuration.getTemplate("报告.ftl", "utf-8");
            Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"), 10240);
            template.process(dataMap, out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
//    @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();
//        }
//    }
//
//    @ApiOperation(value = "导出图片测试")
//    @PostMapping("/export/picture")
//    public void test(@RequestParam(value = "id") Long id){
//        Long communityId = this.getLoginUserInfo().getCommunityId();
//        Map<String,Object> dataMap = new HashMap<String, Object>();
//        try {
//            ComSwSafetyWorkRecordVO comSwSafetyWorkRecordVO = JSONObject.parseObject(JSONObject.toJSONString(communityService.detailSafetyWorkRecord(id, communityId).getData()),ComSwSafetyWorkRecordVO.class);
//            //日期
//            dataMap.put("date", new SimpleDateFormat("yyyy-MM-dd").format(comSwSafetyWorkRecordVO.getPatrolTime()));
//            Configuration configuration = new Configuration(new Version("2.3.0"));
//            configuration.setDefaultEncoding("utf-8");
//
//            /**
//             * 以下是两种指定ftl文件所在目录路径的方式,注意这两种方式都是
//             * 指定ftl文件所在目录的路径,而不是ftl文件的路径
//             */
//            //指定路径的第一种方式(根据某个类的相对路径指定)
////                configuration.setClassForTemplateLoading(this.getClass(), "");
//
//            //指定路径的第二种方式,我的路径是C:/a.ftl
//            configuration.setDirectoryForTemplateLoading(new File("c:/"));
//
//            //输出文档路径及名称
//            File outFile = new File("D:/报销信息导出.doc");
//
//            //以utf-8的编码读取ftl文件
//            Template template = configuration.getTemplate("报告.ftl", "utf-8");
//            Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"), 10240);
//            template.process(dataMap, out);
//            out.close();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
    private List<List<String>> headDataFilling(){
        List<List<String>> list = new ArrayList<List<String>>();