From 1f3c4b17ee2d01b0dba89ed326ef138ce8f1dc05 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Fri, 23 May 2025 11:26:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=EF=BC=9A=E5=A2=9E=E5=8A=A0=E3=80=90=E7=8E=AF=E4=BF=9D?= =?UTF-8?q?=E2=80=9C=E4=B8=80=E5=A1=94=E4=B8=89=E5=9B=BE=E2=80=9D=E3=80=91?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SynthesisQueryController.java | 7 + .../backstage/dao/SynthesisQueryDao.java | 18 + .../entity/OneTowerThreeDiagramsVo.java | 57 + .../backstage/entity/QueryParamDto.java | 7 + .../service/SynthesisQueryService.java | 24 +- .../impl/SynthesisQueryServiceImpl.java | 118 +- .../template/util/FreeMarkerUtil.java | 143 + .../backstage/template/util/WordUtils.java | 250 ++ src/main/resources/download/demo.ftl | 2874 +++++++++++++++++ .../backstage/SynthesisQueryMapper.xml | 27 + .../static/img/synthesisQuery/more.png | Bin 0 -> 732 bytes src/main/resources/static/index.html | 4 +- .../js/synthesisQuery/fillEnvironProForm.js | 42 + .../synthesisQuery/proClassifyStatistics.js | 114 +- src/main/resources/static/login.html | 2 +- .../synthesisQuery/fillEnvironProForm.html | 60 + 16 files changed, 3691 insertions(+), 56 deletions(-) create mode 100644 src/main/java/com/bonus/imgTool/backstage/entity/OneTowerThreeDiagramsVo.java create mode 100644 src/main/java/com/bonus/imgTool/backstage/template/util/FreeMarkerUtil.java create mode 100644 src/main/java/com/bonus/imgTool/backstage/template/util/WordUtils.java create mode 100644 src/main/resources/download/demo.ftl create mode 100644 src/main/resources/static/img/synthesisQuery/more.png create mode 100644 src/main/resources/static/js/synthesisQuery/fillEnvironProForm.js create mode 100644 src/main/resources/static/pages/synthesisQuery/fillEnvironProForm.html diff --git a/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java b/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java index 2237e8f..9a6f873 100644 --- a/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java +++ b/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java @@ -98,6 +98,13 @@ public class SynthesisQueryController { synthesisQueryService.downloadExcel(dto.getData(),response); } + @PostMapping("downloadWord") + @DecryptAndVerify(decryptedClass = QueryParamDto.class)//加解密统一管理 + @LogAnnotation(operModul = "综合查询-项目分类统计", operation = "导出环保一塔三图", operDesc = "系统级事件",operType="导出") + public void downloadWord(HttpServletResponse response, EncryptedReq dto) { + synthesisQueryService.downloadWord(dto.getData(),response); + } + @ApiOperation("项目分类统计-查看图片") @PostMapping(value = "getProImgList") @DecryptAndVerify(decryptedClass = QueryParamDto.class) diff --git a/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java b/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java index 7148ed0..8096d10 100644 --- a/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java +++ b/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java @@ -167,4 +167,22 @@ public interface SynthesisQueryDao { * @return */ List getPhotoImgList(QueryParamDto dto); + + /** + * 环保“一塔三图” + * @param dto + * @return List + * @author cwchen + * @date 2025/5/23 10:03 + */ + List getData(QueryParamDto dto); + + /** + * 获取环保“一塔三图”图片 + * @param vo + * @return List + * @author cwchen + * @date 2025/5/23 10:17 + */ + List getXtImgs(OneTowerThreeDiagramsVo vo); } diff --git a/src/main/java/com/bonus/imgTool/backstage/entity/OneTowerThreeDiagramsVo.java b/src/main/java/com/bonus/imgTool/backstage/entity/OneTowerThreeDiagramsVo.java new file mode 100644 index 0000000..2bbd42f --- /dev/null +++ b/src/main/java/com/bonus/imgTool/backstage/entity/OneTowerThreeDiagramsVo.java @@ -0,0 +1,57 @@ +package com.bonus.imgTool.backstage.entity; + +import cn.hutool.bloomfilter.filter.SDBMFilter; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @className:OneTowerThreeDiagramsVo + * @author:cwchen + * @date:2025-05-22-17:51 + * @version:1.0 + * @description: 环保“一塔三图”-vo + */ +@Data +public class OneTowerThreeDiagramsVo { + + private Long id; + + private String proName = ""; + + private String line = ""; + + private int num = 0; + + private String qz = ""; + + private String bd = ""; + + private String mainUser = ""; + + private String unit = ""; + + private String tower = ""; + + private String time = ""; + private String time2 = ""; + private String time3 = ""; + private String time4 = ""; + + private List imgList; + private List imgList2; + private List imgList3; + private List imgList4 = new ArrayList<>(); + + @Data + public static class imgVo { + private Long index; + private String path; + private String suffix; + private String base64Url; + private String sourceType; + private String createTime; + } + +} diff --git a/src/main/java/com/bonus/imgTool/backstage/entity/QueryParamDto.java b/src/main/java/com/bonus/imgTool/backstage/entity/QueryParamDto.java index 44a70b0..025b5cc 100644 --- a/src/main/java/com/bonus/imgTool/backstage/entity/QueryParamDto.java +++ b/src/main/java/com/bonus/imgTool/backstage/entity/QueryParamDto.java @@ -101,6 +101,13 @@ public class QueryParamDto { private String userName; + /**长度km*/ + private String line; + /**塔基数*/ + private int num; + /**起止塔号*/ + private String qz; + private int pageNum = 1; private int pageSize = 15; } diff --git a/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java b/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java index 318760f..5f2d8fb 100644 --- a/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java +++ b/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java @@ -18,6 +18,7 @@ public interface SynthesisQueryService { /** * 综合查询-照片综合查询-照片数量 + * * @param data * @return ServerResponse * @author cwchen @@ -27,6 +28,7 @@ public interface SynthesisQueryService { /** * 照片综合查询 + * * @param data * @return ServerResponse * @author cwchen @@ -36,6 +38,7 @@ public interface SynthesisQueryService { /** * 收藏/取消收藏图片 + * * @param data * @return ServerResponse * @author cwchen @@ -45,6 +48,7 @@ public interface SynthesisQueryService { /** * 综合查询新增 + * * @param comprehensiveQueryVo * @return ServerResponse */ @@ -52,6 +56,7 @@ public interface SynthesisQueryService { /** * 综合查询修改 + * * @param comprehensiveQueryVo * @return ServerResponse */ @@ -59,6 +64,7 @@ public interface SynthesisQueryService { /** * 生成水印 + * * @param data * @return ServerResponse * @author cwchen @@ -68,6 +74,7 @@ public interface SynthesisQueryService { /** * 项目分类统计查询 + * * @param data * @return ServerResponse * @author cwchen @@ -79,12 +86,14 @@ public interface SynthesisQueryService { /** * 综合查询删除 + * * @param id */ - void deleteComprehensiveQuery(Long id,String uploadType); + void deleteComprehensiveQuery(Long id, String uploadType); /** * 项目分类统计-查看图片 + * * @param data * @return ServerResponse * @author cwchen @@ -94,6 +103,7 @@ public interface SynthesisQueryService { /** * 项目分类统计-查看列表 + * * @param data * @return ServerResponse * @author cwchen @@ -103,8 +113,20 @@ public interface SynthesisQueryService { /** * 影像上传-查看图片 + * * @param data * @return */ ServerResponse getPhotoImgList(QueryParamDto data); + + /** + * 导出环保一塔三图 + * + * @param data + * @param response + * @return void + * @author cwchen + * @date 2025/5/22 17:29 + */ + void downloadWord(QueryParamDto data, HttpServletResponse response); } diff --git a/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java b/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java index d188fe9..cdb6fe9 100644 --- a/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java +++ b/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java @@ -6,15 +6,15 @@ import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import com.bonus.imgTool.backstage.dao.SynthesisQueryDao; import com.bonus.imgTool.backstage.entity.*; import com.bonus.imgTool.backstage.service.SynthesisQueryService; +import com.bonus.imgTool.backstage.template.util.FreeMarkerUtil; +import com.bonus.imgTool.backstage.template.util.WordUtils; import com.bonus.imgTool.system.vo.LoginUser; -import com.bonus.imgTool.utils.HighQualityWatermark; -import com.bonus.imgTool.utils.ServerResponse; -import com.bonus.imgTool.utils.SystemUtils; -import com.bonus.imgTool.utils.UserUtil; +import com.bonus.imgTool.utils.*; import com.bonus.imgTool.webResult.Constants; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.stereotype.Service; @@ -49,7 +49,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { try { String roleLevel = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getRoleLevel).orElse("0"); String proIds = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getProIds).orElse("-1"); - if(Objects.equals(roleLevel, Constants.ROLE_LEVEL)){ // 项目部级 + if (Objects.equals(roleLevel, Constants.ROLE_LEVEL)) { // 项目部级 List proList = Arrays.stream(proIds.split(",")).map(String::trim).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); dto.setProIds(proList); } @@ -57,7 +57,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { SynthesisNumVo vo = Optional.ofNullable(synthesisQueryDao.getImgNum(dto)).orElseGet(SynthesisNumVo::new); return ServerResponse.createSuccess(vo); } catch (Exception e) { - log.error(e.toString(),e); + log.error(e.toString(), e); return ServerResponse.createErroe("查询失败"); } } @@ -70,7 +70,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { dto.setUserId(userId); String roleLevel = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getRoleLevel).orElse("0"); String proIds = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getProIds).orElse("-1"); - if(Objects.equals(roleLevel, Constants.ROLE_LEVEL)){ // 项目部级 + if (Objects.equals(roleLevel, Constants.ROLE_LEVEL)) { // 项目部级 List proList = Arrays.stream(proIds.split(",")).map(String::trim).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); dto.setProIds(proList); } @@ -101,6 +101,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { /** * 综合查询新增 + * * @param comprehensiveQueryVo * @return ServerResponse */ @@ -111,6 +112,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { /** * 综合查询修改 + * * @param comprehensiveQueryVo * @return ServerResponse */ @@ -128,12 +130,12 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { return ServerResponse.createErroe("原照片不存在"); } String syPath = synthesisQueryDao.getSyData(vo); - if(StringUtils.isBlank(syPath)){ + if (StringUtils.isBlank(syPath)) { syPath = generateWatermarkData(vo); } vo.setWatermarkFilePath(syPath); synthesisQueryDao.updateSyData(vo); - return ServerResponse.createSuccess("操作成功",syPath); + return ServerResponse.createSuccess("操作成功", syPath); } catch (Exception e) { log.error(e.toString(), e); return ServerResponse.createErroe("操作失败"); @@ -141,11 +143,11 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { } @Override - public void deleteComprehensiveQuery(Long id,String uploadType) { - synthesisQueryDao.deleteComprehensiveQuery(id,uploadType); + public void deleteComprehensiveQuery(Long id, String uploadType) { + synthesisQueryDao.deleteComprehensiveQuery(id, uploadType); } - public String generateWatermarkData(SynthesisQueryVo vo){ + public String generateWatermarkData(SynthesisQueryVo vo) { // 准备多行水印文本 List watermarkLines = new ArrayList<>(); String uploadTime = new SimpleDateFormat("yyyy-MM-dd").format(vo.getUploadTime()); @@ -159,8 +161,8 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { sourceTypeName = vo.getSourceTypeName().split("-")[1]; } watermarkLines.add(sourceTypeName); - String localPath = SystemUtils.getUploadPath() +File.separator+ vo.getOriginalFilePath(); - return HighQualityWatermark.generateWatermark(watermarkLines,localPath); + String localPath = SystemUtils.getUploadPath() + File.separator + vo.getOriginalFilePath(); + return HighQualityWatermark.generateWatermark(watermarkLines, localPath); } @Override @@ -169,14 +171,14 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { try { String roleLevel = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getRoleLevel).orElse("0"); String proIds = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getProIds).orElse("-1"); - if(Objects.equals(roleLevel, Constants.ROLE_LEVEL)){ // 项目部级 + if (Objects.equals(roleLevel, Constants.ROLE_LEVEL)) { // 项目部级 List proList = Arrays.stream(proIds.split(",")).map(String::trim).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); dto.setProIds(proList); } dto.setRoleLevel(roleLevel); list = Optional.ofNullable(synthesisQueryDao.getProClassifyStatisticsList(dto)).orElseGet(ArrayList::new); } catch (Exception e) { - log.error(e.toString(),e); + log.error(e.toString(), e); } PageInfo pageInfo = new PageInfo<>(list); return ServerResponse.createSuccessPage(pageInfo, dto.getPageNum(), dto.getPageSize()); @@ -227,7 +229,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { dto.setUserId(userId); List list = Optional.ofNullable(synthesisQueryDao.getListData(dto)).orElseGet(ArrayList::new); PageHelper.clearPage(); - list.forEach(item->{ + list.forEach(item -> { item.setUserId(userId); ProClassifyStatisticDetailVo detailVo = setDataList(item); item.setPhotoList(detailVo.getPhotoList()); @@ -245,6 +247,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { /** * 影像上传-查看图片 + * * @param data * @return */ @@ -263,37 +266,94 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { /** * 查询图片上传类型:1.安全违章、2.质量检查、3.安全措施落实、4.协调照片、5.重要事项及宣传 + * * @param detailVo * @return ProClassifyStatisticDetailVo * @author cwchen * @date 2025/4/6 18:44 */ - public ProClassifyStatisticDetailVo setDataList(ProClassifyStatisticDetailVo detailVo){ + public ProClassifyStatisticDetailVo setDataList(ProClassifyStatisticDetailVo detailVo) { try { - switch (detailVo.getUploadType()){ + switch (detailVo.getUploadType()) { case "1": - detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,1)).orElseGet(ArrayList::new)); - detailVo.setPhotoList2(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,2)).orElseGet(ArrayList::new)); + detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 1)).orElseGet(ArrayList::new)); + detailVo.setPhotoList2(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 2)).orElseGet(ArrayList::new)); break; case "2": - detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,3)).orElseGet(ArrayList::new)); - detailVo.setPhotoList2(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,4)).orElseGet(ArrayList::new)); + detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 3)).orElseGet(ArrayList::new)); + detailVo.setPhotoList2(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 4)).orElseGet(ArrayList::new)); break; case "3": - detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,5)).orElseGet(ArrayList::new)); + detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 5)).orElseGet(ArrayList::new)); break; case "4": - detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,6)).orElseGet(ArrayList::new)); - detailVo.setPhotoList2(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,7)).orElseGet(ArrayList::new)); - detailVo.setPhotoList3(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,8)).orElseGet(ArrayList::new)); + detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 6)).orElseGet(ArrayList::new)); + detailVo.setPhotoList2(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 7)).orElseGet(ArrayList::new)); + detailVo.setPhotoList3(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 8)).orElseGet(ArrayList::new)); break; case "5": - detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo,9)).orElseGet(ArrayList::new)); + detailVo.setPhotoList(Optional.ofNullable(synthesisQueryDao.getImgs(detailVo, 9)).orElseGet(ArrayList::new)); break; } + } catch (Exception e) { + log.error(e.toString(), e); + } + return detailVo; + } + + @Override + public void downloadWord(QueryParamDto dto, HttpServletResponse response) { + Map data = new HashMap<>(16); + List dataList = new ArrayList<>(); + try { + List list = Optional.ofNullable(synthesisQueryDao.getData(dto)).orElseGet(ArrayList::new); + if (CollectionUtils.isNotEmpty(list)) { + for (OneTowerThreeDiagramsVo vo : list) { + List imgList = Optional.ofNullable(synthesisQueryDao.getXtImgs(vo)).orElseGet(ArrayList::new); + OneTowerThreeDiagramsVo oneTowerThreeDiagramsVo = handleVo(vo, imgList); + // 先设置为空 + oneTowerThreeDiagramsVo.setMainUser(""); + dataList.add(oneTowerThreeDiagramsVo); + } + } + data.put("list",dataList); + WordUtils.exportMillCertificateWord(null, response, data, "test", "demo.ftl"); + } catch (Exception e) { + log.error("一塔三图下载", e); + } + } + + private OneTowerThreeDiagramsVo handleVo(OneTowerThreeDiagramsVo vo, List imgList) { + try { + List list = imgList.stream().filter(imgVo -> Objects.equals(imgVo.getSourceType(), "6")).collect(Collectors.toList()); + List list2 = imgList.stream().filter(imgVo -> Objects.equals(imgVo.getSourceType(), "7")).collect(Collectors.toList()); + List list3 = imgList.stream().filter(imgVo -> Objects.equals(imgVo.getSourceType(), "8")).collect(Collectors.toList()); + for (OneTowerThreeDiagramsVo.imgVo imgVo : list) { + imgVo.setBase64Url(FreeMarkerUtil.getImageBase(SystemUtils.getUploadPath() + imgVo.getPath())); + } + for (OneTowerThreeDiagramsVo.imgVo imgVo : list2) { + imgVo.setBase64Url(FreeMarkerUtil.getImageBase(SystemUtils.getUploadPath() + imgVo.getPath())); + } + for (OneTowerThreeDiagramsVo.imgVo imgVo : list3) { + imgVo.setBase64Url(FreeMarkerUtil.getImageBase(SystemUtils.getUploadPath() + imgVo.getPath())); + } + vo.setImgList(list); + vo.setImgList2(list2); + vo.setImgList3(list3); + if (CollectionUtils.isNotEmpty(list)) { + vo.setTime(list.get(0).getCreateTime()); + } + if (CollectionUtils.isNotEmpty(list2)) { + vo.setTime2(list2.get(0).getCreateTime()); + } + if (CollectionUtils.isNotEmpty(list3)) { + vo.setTime3(list3.get(0).getCreateTime()); + } } catch (Exception e) { log.error(e.toString(),e); } - return detailVo; + return vo; } + + } diff --git a/src/main/java/com/bonus/imgTool/backstage/template/util/FreeMarkerUtil.java b/src/main/java/com/bonus/imgTool/backstage/template/util/FreeMarkerUtil.java new file mode 100644 index 0000000..eb7b24b --- /dev/null +++ b/src/main/java/com/bonus/imgTool/backstage/template/util/FreeMarkerUtil.java @@ -0,0 +1,143 @@ +package com.bonus.imgTool.backstage.template.util; + +import freemarker.template.Configuration; +import freemarker.template.DefaultObjectWrapper; +import freemarker.template.Template; +import freemarker.template.TemplateExceptionHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.util.Base64; +import java.util.Locale; +import java.util.Map; + +/** + * @Auther: ccw + * @Date: 2021/06/30/16:04 + * @description: + */ +public class FreeMarkerUtil { + private static Logger logger = LoggerFactory.getLogger(FreeMarkerUtil.class); + private static final String ENCODING = "UTF-8"; + private static Configuration cfg = new Configuration(); + + //初始化cfg + static { + //设置模板所在文件夹 + cfg.setClassForTemplateLoading(FreeMarkerUtil.class, "/templates/word"); + // setEncoding这个方法一定要设置国家及其编码,不然在ftl中的中文在生成html后会变成乱码 + cfg.setEncoding(Locale.getDefault(), ENCODING); + // 设置对象的包装器 + cfg.setObjectWrapper(new DefaultObjectWrapper()); + // 设置异常处理器,这样的话就可以${a.b.c.d}即使没有属性也不会出错 + cfg.setTemplateExceptionHandler(TemplateExceptionHandler.IGNORE_HANDLER); + + } + + //获取模板对象 + public static Template getTemplate(String templateFileName) throws IOException { + return cfg.getTemplate(templateFileName, ENCODING); + } + + /** + * 45 * 据数据及模板生成文件 + * 46 * @param data Map的数据结果集 + * 47 * @param templateFileName ftl模版文件名 + * 48 * @param outFilePath 生成文件名称(可带路径) + * 49 + */ + public static File crateFile(Map data, String templateFileName, String outFilePath) { + Writer out = null; + File outFile = new File(outFilePath); + try { + // 获取模板,并设置编码方式,这个编码必须要与页面中的编码格式一致 + Template template = getTemplate(templateFileName); + if (!outFile.getParentFile().exists()) { + outFile.getParentFile().mkdirs(); + } + out = new OutputStreamWriter(new FileOutputStream(outFile), ENCODING); + // 处理模版 + template.process(data, out); + out.flush(); + logger.info("由模板文件" + templateFileName + "生成" + outFilePath + "成功."); + } catch (Exception e) { + logger.error("由模板文件" + templateFileName + "生成" + outFilePath + "出错"); + e.printStackTrace(); + } finally { + try { + if (out != null) { + out.close(); + } + } catch (IOException e) { + logger.error("关闭Write对象出错", e); + e.printStackTrace(); + } + } + return outFile; + } + + //获得图片的base64码 + public static String getImageBase(String src) throws Exception { + try { + if (src == null || src == "") { + return ""; + } + File file = new File(src); + if (!file.exists()) { + return ""; + } + InputStream in = null; + byte[] data = null; + + in = new FileInputStream(file); + data = new byte[in.available()]; + in.read(data); + in.close(); + // 编码 + return Base64.getEncoder().encodeToString(data); + } catch (IOException e) { + e.printStackTrace(); + return ""; + } + } + + public static String getsuffix(String url) { + String suffix = url.substring(url.lastIndexOf(".")); + String replaceStr = url.replace(suffix, ".png"); + return replaceStr; + } + + public static void main(String[] args) { + try { + String imageBase = getImageBase(getsuffix("C:\\Users\\bonus\\Desktop\\按钮\\选中\\微信图片_20210129113032.jpg")); + System.err.println(getsuffix("C:\\Users\\bonus\\Desktop\\按钮\\选中\\微信图片_20210129113032.jpg")); +// Map data = new HashMap(); +// data.put("orgName", "段然涛"); +// data.put("proName", "男"); +// data.put("inspectionUser", "测试李"); +// data.put("inspectionDate", "1994-03-14"); +// List> RectificationList = new ArrayList<>(); +// Map paramsMap = new HashMap(); +// paramsMap.put("index", "1"); +// paramsMap.put("content", "2008-09"); +// paramsMap.put("rectifyRemark", "2012-06"); +// Map paramsMap2 = new HashMap(); +// paramsMap2.put("index", "2"); +// paramsMap2.put("content", "2012-09"); +// paramsMap2.put("rectifyRemark", "2016-07"); +// RectificationList.add(paramsMap); +// RectificationList.add(paramsMap2); +// data.put("RectificationList", RectificationList); +// List images = new LinkedList(); +// images.add(0,getImageBase(getsuffix("C:\\Users\\bonus\\Desktop\\按钮\\选中\\微信图片_20210129113032.jpg"))); +// images.add(1,getImageBase(getsuffix("C:\\Users\\bonus\\Desktop\\按钮\\选中\\背景.jpg"))); +// data.put("images", images); +//// logger.error("图片的数量"+images.size()); +// crateFile(data, "质量巡查问题整改单5.ftl", "C:\\Users\\bonus\\Desktop\\文档\\简历5.doc"); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/com/bonus/imgTool/backstage/template/util/WordUtils.java b/src/main/java/com/bonus/imgTool/backstage/template/util/WordUtils.java new file mode 100644 index 0000000..b6b6a43 --- /dev/null +++ b/src/main/java/com/bonus/imgTool/backstage/template/util/WordUtils.java @@ -0,0 +1,250 @@ +package com.bonus.imgTool.backstage.template.util; + +import freemarker.template.Configuration; +import freemarker.template.Template; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.util.Map; +import java.util.Objects; + +/** + * @Auther: ccw + * @Date: 2021/07/22/9:57 + * @description: + */ +public class WordUtils { + + //配置信息,代码本身写的还是很可读的,就不过多注解了 + private static Configuration configuration = null; + + //这里注意的是利用WordUtils的类加载器动态获得模板文件的位置 +// private static final String templateFolder = WordUtils.class.getClassLoader().getResource("../../").getPath() + "/templates/word"; + static { + configuration = new Configuration(); + configuration.setDefaultEncoding("utf-8"); + configuration.setClassForTemplateLoading(WordUtils.class, "/download/"); + } + + private WordUtils() { + throw new AssertionError(); + } + + public static void exportMillCertificateWord(HttpServletRequest request, HttpServletResponse response, Map map, String title, String ftlFile) throws IOException { + Template freemarkerTemplate = configuration.getTemplate(ftlFile); + File file = null; + InputStream fin = null; + ServletOutputStream out = null; + try { + // 调用工具类的createDoc方法生成Word文档 + file = createDoc(map, freemarkerTemplate); + fin = new FileInputStream(file); + + response.setCharacterEncoding("utf-8"); + response.setContentType("application/msword"); + // 设置浏览器以下载的方式处理该文件名 + String fileName = title + ".docx"; + response.setHeader("Content-Disposition", "attachment;filename=" + .concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8")))); + + out = response.getOutputStream(); + byte[] buffer = new byte[512]; // 缓冲区 + int bytesToRead = -1; + // 通过循环将读入的Word文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + } finally { + if (fin != null) {fin.close();} + if (out != null) {out.close();} + // 删除临时文件 + if (file != null) {file.delete();} + } + } + + private static File createDoc(Map dataMap, Template template) { + String name = "sellPlan.doc"; + File f = new File(name); + Template t = template; + try { + // 这个地方不能使用FileWriter因为需要指定编码类型否则生成的Word文档会因为有无法识别的编码而无法打开 + Writer w = new OutputStreamWriter(new FileOutputStream(f), "utf-8"); + t.process(dataMap, w); + w.close(); + } catch (Exception ex) { + ex.printStackTrace(); + throw new RuntimeException(ex); + } + return f; + } + + public static void exportMillCertificateWord2(HttpServletRequest request, HttpServletResponse response, Map map, String title, String ftlFile, String path) throws IOException { + Template freemarkerTemplate = configuration.getTemplate(ftlFile); + File file = null; + InputStream fin = null; + OutputStream out = null; +// String systemName = System.getProperty("os.name"); + String uploadPath = path + "word" + File.separator; + try { + // 调用工具类的createDoc方法生成Word文档 + file = createDoc(map, freemarkerTemplate); + fin = new FileInputStream(file); + + File file2 = new File(uploadPath); + // 生成文件夹 + if (!file2.exists()) { + file2.mkdirs(); + } + String fileName = uploadPath + File.separator + title + ".doc"; + out = new FileOutputStream(new File(fileName)); + byte[] buffer = new byte[512]; // 缓冲区 + int bytesToRead = -1; + // 通过循环将读入的Word文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + } finally { + if (fin != null) {fin.close();} + if (out != null) {out.close();} + // 删除临时文件 + if (file != null) {file.delete();} + } + } + + public static void exportPDF(HttpServletRequest request, HttpServletResponse response, String titleName, String fileName) throws IOException { + File file = null; + InputStream fin = null; + ServletOutputStream out = null; + try { + file = new File(fileName); + fin = new FileInputStream(file); + + response.setCharacterEncoding("utf-8"); + response.setContentType("application/pdf"); + // 设置浏览器以下载的方式处理该文件名 + response.setHeader("Content-Disposition", "attachment;filename=" + .concat(String.valueOf(URLEncoder.encode(titleName, "UTF-8")))); + out = response.getOutputStream(); + // 缓冲区 + byte[] buffer = new byte[512]; + int bytesToRead = -1; + // 通过循环将读入的pdf文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + } finally { + if (fin != null) {fin.close();} + if (out != null) {out.close();} + } + } + + public static void exportFile(HttpServletRequest request, HttpServletResponse response,String fileName,byte[] decode) throws IOException { + InputStream fin = null; + ServletOutputStream out = null; + try { + fin = new ByteArrayInputStream(decode); + response.setCharacterEncoding("utf-8"); + String subfix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()); + if(Objects.equals(subfix,"pdf")){ + response.setContentType("application/pdf"); + }else if(Objects.equals(subfix,"doc") || Objects.equals(subfix,"docx")){ + response.setContentType("application/msword"); + } + // 设置浏览器以下载的方式处理该文件名 + response.setHeader("Content-Disposition", "attachment;filename=" + .concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8")))); + out = response.getOutputStream(); + // 缓冲区 + byte[] buffer = new byte[512]; + int bytesToRead = -1; + // 通过循环将读入的pdf文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + } finally { + if (fin != null) {fin.close();} + if (out != null) {out.close();} + } + } + + /** + * @return void + * @author cw chen + * @description 下载word文件 + * @Param request + * @Param response + * @Param titleName + * @Param fileName + * @date 2023-04-17 11:07 + */ + public static void exportWord(HttpServletRequest request, HttpServletResponse response, String titleName, String fileName) throws IOException { + File file = null; + InputStream fin = null; + ServletOutputStream out = null; + try { + file = new File(fileName); + fin = new FileInputStream(file); + + response.setCharacterEncoding("utf-8"); + response.setContentType("application/msword"); + // 设置浏览器以下载的方式处理该文件名 + response.setHeader("Content-Disposition", "attachment;filename=" + .concat(String.valueOf(URLEncoder.encode(titleName, "UTF-8")))); + out = response.getOutputStream(); + // 缓冲区 + byte[] buffer = new byte[512]; + int bytesToRead = -1; + // 通过循环将读入的pdf文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + } finally { + if (fin != null) {fin.close();} + if (out != null) {out.close();} + } + } + + /** + * @return void + * @author cw chen + * @description 下载word文件 + * @Param request + * @Param response + * @Param titleName + * @Param fileName + * @date 2023-04-17 11:07 + */ + public static void exportVideo(HttpServletRequest request, HttpServletResponse response, String titleName, String fileName) throws IOException { + File file = null; + InputStream fin = null; + ServletOutputStream out = null; + try { + file = new File(fileName); + fin = new FileInputStream(file); + response.setCharacterEncoding("utf-8"); + response.setContentType("video/mp4"); + // 设置浏览器以下载的方式处理该文件名 + response.setHeader("Content-Disposition", "attachment;filename=" + .concat(String.valueOf(URLEncoder.encode(titleName, "UTF-8")))); + out = response.getOutputStream(); + // 缓冲区 + byte[] buffer = new byte[512]; + int bytesToRead = -1; + // 通过循环将读入的pdf文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + } finally { + if (fin != null) { + fin.close(); + } + if (out != null) { + out.close(); + } + file.delete(); + } + } +} diff --git a/src/main/resources/download/demo.ftl b/src/main/resources/download/demo.ftl new file mode 100644 index 0000000..02799c2 --- /dev/null +++ b/src/main/resources/download/demo.ftl @@ -0,0 +1,2874 @@ + + + + 白玉彬 + SONE文少 + 5 + 2019-11-27T03:49:00Z + 2025-05-22T05:52:00Z + 2 + 362 + 424 + 461 + 130 + 527 + 14 + + + 2052-12.1.0.21171 + 62A925BBD5D647EC9782C693304F69F7_13 + + eyJoZGlkIjoiM2ZmMzVlOTM2M2IwZWJlNDdlYzlhMTI5MzRkNWY1YWEiLCJ1c2VySWQiOiI0NTA1NDkzNTIifQ== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <#if list?? && (list?size>0)> + <#list list as vo> + + + + + + + + + + + + + + + + + + 输电线路“一塔三图”记录表 + + + + + + + + + + + + + + + + + + + + 编号: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 项目名称: + + + + + + + + + ${vo.proName} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 子工程名称: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 标段 + + + + + + + + + + + + + + + + + ${vo.bd} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 标段 + + + + + + + + + + + + + + + + + + 概况 + + + + + + + + + + + + + + + + + + + + + + + + + 长度(km) + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.line} + + + + + + + + + + + + + + + + + + + + + + + + + 塔基数 + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.num} + + + + + + + + + + + + + + + + + + + + + + + + + + 起止塔号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.qz} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 总占地面积 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 其中永久占地面积 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 临时占地面积 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 塔基 + + + + + + + + + + + + + + + + + + 情况 + + + + + + + + + + + + + + + + + + + + + + + + + 杆塔号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.tower} + + + + + + + + + + + + + + + + + + + + + + + + + 占地类型 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 基础型式 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 占地面积 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 其中永久占地面积 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 临时占地面积 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 水土保持 + + + + + + + + + + + + + + + + + + 防护措施 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 挡土墙 + + + + + + + + + + + + + + + + 护坡 + + + + + + + + + + + + + + + + 截(排)水沟 + + + + + + + + + + + + + + + + 其他 + + + + + + + _________ + + + + + + + + + + + + + + + + + + + + + + + + + + 性质 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 临时 + + + + + + + + + + + + + + + + + + + + + + + + + + + 永久 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 施工前照片 + + + + + + + + + + + <#if vo.imgList ?? && (vo.imgList?size>0)> + <#list vo.imgList as img> + + + + + + + + + + + + + + + + + ${img.base64Url} + + + + + + + + + + + + + + <#else> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 录入时间 + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.time} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 施工期照片 + + + + + + + + + + + <#if vo.imgList2 ?? && (vo.imgList2?size>0)> + <#list vo.imgList2 as img> + + + + + + + + + + + + + + + + + ${img.base64Url} + + + + + + + + + + + + + + <#else> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 录入时间 + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.time2} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 竣工(恢复)后 + + + + + + + + + + + + + + + + + + 照片 + + + + + + + + + + + <#if vo.imgList3 ?? && (vo.imgList3?size>0)> + <#list vo.imgList3 as img> + + + + + + + + + + + + + + + + + + + ${img.base64Url} + + + + + + + + + + + + + + <#else> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 录入时间 + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.time3} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 水保防护措施照片 + + + + + + + + + + + <#if vo.imgList4 ?? && (vo.imgList4?size>0)> + <#list vo.imgList4 as img> + + + + + + + + + + + + + + + + + + + ${img.base64Url} + + + + + + + + + + + + + + <#else> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 录入时间 + + + + + + + + + + + + + + + + + + + + + + + + + + + ${vo.time4} + + + + + + + + + + + + + + + + + + + + + + + + + <#if vo.mainUser?? && vo.mainUser?has_content> + + + + + + + + + + + + + + + + + + + + + + + 记录单位: + + + + + + + + ${vo.unit} + + + + + + + 主要记录人员: + + + + + + + + ${vo.mainUser} + + + + <#else> + + + + + + + + + + + + + + + + + + + + + + 记录单位: 主要记录人员: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1. + + + + + + + + 此表由施工单位、监理单位分别填写并存档 + + + + + + + + + + + + + + + + + + + + + + + + + + + 2. “一塔”指杆塔的塔基区,每一基杆塔都必须对应填写此记录表。 + + + + + + + + + + + + + + + + + + + 3.“水土保持防护措施”一栏必须如实记录,如实施了水土保持防护措施,则必须在“水保防护措施 + + + + + + + + + + + + + + + + + + + 照片”一栏中录入相应措施的照片。 + + + + + + + + + + + + + + + + + + + 4. 除表中照片外,还须保留拍照时的视频影像。 + + + + + + + + + + + + + + + + + + + 5. 照片和视频影像须能清晰反映塔基区的原始地貌及生态环境现状。 + + + + + + + + + + + + + + + + + + + + + <#if !vo?is_last> + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml b/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml index 0333c4e..4410733 100644 --- a/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml +++ b/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml @@ -544,6 +544,33 @@ AND tcq.is_active = '1' ORDER BY sfr.create_time DESC + + + + diff --git a/src/main/resources/static/img/synthesisQuery/more.png b/src/main/resources/static/img/synthesisQuery/more.png new file mode 100644 index 0000000000000000000000000000000000000000..871788884ab1181be4c196537592aa39e6553afd GIT binary patch literal 732 zcmV<20wev2P)Px%mPtfGR9HvNS50oyKotI-!=kH%iZ#MH0|y{I0pk@VXC_E;*0%&3xDvTHZ z^L#Cz4?+;X0ywP6a(PJM-rQ ztO}y)&=!Dbad!-2QSDHd_X>MQBxF>jQ>EQ)0LzUK5;Q{jn^Q36LLrGqUIVH(2pt8&Tn{M&z=Wt4{>l92Af1nY^|`P~ zCn}xfG>M-c340a*m4BwG9vZJd{di7;Ctm=(1n`X?e!uzp?%DUE&r4%;58{v7Bd3lj z@=Vu(4S;2p8UWGd-Fq;fm!1=SNKS?q1%Ty7$`^<3lX!R_fjM;KP7!m#1;Dh)?g5xK z*LC(kr9e$Ut3q{vcUFYUjTmxbNtK1()P`k#`c%D-Y@`QWV;jmf+BhzKjCaXY22nZa zDx+90BGac`hJD|6j^d()Oq=X_8R_EX8zFI$2=B00Ic39=YolbQ zARTnd1*FC)D?Ff_p>0MgOh$;U!1?DcZrDsp+d1Xm(Q+UK(;9eCbbAmY;1}Rx$OuBC zPbaPO+WU&C394-ycV)my#cf3|09wKG(@dnP^+TkJx)%W7>hB}BcL0xTlFu-|((J7O O0000 - 后台管理系统 + 项目全过程影像管理工具 @@ -34,7 +34,7 @@