diff --git a/hzims-service-api/hzims-operational-api/pom.xml b/hzims-service-api/hzims-operational-api/pom.xml
index 4d40f42..4dc32e8 100644
--- a/hzims-service-api/hzims-operational-api/pom.xml
+++ b/hzims-service-api/hzims-operational-api/pom.xml
@@ -67,6 +67,12 @@
com.hnac.hzims
middle-api
+
+ cn.afterturn
+ easypoi-base
+ 4.4.0
+ compile
+
diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperConstructionEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperConstructionEntity.java
index b164315..8c138e0 100644
--- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperConstructionEntity.java
+++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperConstructionEntity.java
@@ -28,14 +28,14 @@ public class OperConstructionEntity extends TenantEntity {
private String code;
@ApiModelProperty(value = "检修名称")
- private String constructionTime;
-
- @ApiModelProperty(value = "检修名称")
private String overhaulName;
@ApiModelProperty(value = "施工地点")
private String constructionLocation;
+ @ApiModelProperty(value = "施工时间")
+ private Date constructionTime;
+
@ApiModelProperty(value = "检修负责人")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long overhaulHead;
diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/ConstructionVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/ConstructionVo.java
index e7244ad..8c1ee5c 100644
--- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/ConstructionVo.java
+++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/ConstructionVo.java
@@ -1,10 +1,14 @@
package com.hnac.hzims.operational.access.vo;
+import cn.afterturn.easypoi.entity.ImageEntity;
import com.hnac.hzims.operational.access.entity.OperConstructionEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import java.awt.image.BufferedImage;
+import java.io.File;
+
/**
* @author ysj
*/
@@ -17,4 +21,20 @@ public class ConstructionVo extends OperConstructionEntity {
@ApiModelProperty(value = "结束时间")
private String endTime;
+
+ @ApiModelProperty(value = "年")
+ private String year;
+
+ @ApiModelProperty(value = "月")
+ private String mon;
+
+ @ApiModelProperty(value = "日")
+ private String day;
+
+ @ApiModelProperty(value = "图片1")
+ private ImageEntity constructionImg1;
+
+ @ApiModelProperty(value = "图片2")
+ private ImageEntity constructionImg2;
+
}
diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml
index cc0dbf1..fbb805c 100644
--- a/hzims-service/operational/pom.xml
+++ b/hzims-service/operational/pom.xml
@@ -18,6 +18,23 @@
+
+
+ com.documents4j
+ documents4j-local
+ ${documents4j.version}
+
+
+ com.documents4j
+ documents4j-transformer-msoffice-word
+ ${documents4j.version}
+
+
+ com.documents4j
+ documents4j-UTIL-ALL
+ ${documents4j.version}
+
+
redis.clients
jedis
@@ -232,6 +249,12 @@
swagger-bootstrap-ui
${swagger-bootstrap-ui.version}
+
+ e-iceblue
+ spire.xls.free
+ 3.9.1
+ compile
+
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/ConstructionController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/ConstructionController.java
index a27bce0..1653362 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/ConstructionController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/ConstructionController.java
@@ -49,7 +49,7 @@ public class ConstructionController extends BladeController {
@ApiOperation(value = "新增")
public R save(@RequestBody OperConstructionEntity entity) {
entity.setCode("SGRZ" + DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME_MINI));
- entity.setConstructionTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
+ entity.setConstructionTime(entity.getOverhaulTime());
return R.status(service.save(entity));
}
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java
index dddf426..33ed9c8 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java
@@ -1,19 +1,24 @@
package com.hnac.hzims.operational.access.service.impl;
-import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import cn.afterturn.easypoi.entity.ImageEntity;
+import cn.afterturn.easypoi.word.WordExportUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.access.entity.OperConstructionEntity;
import com.hnac.hzims.operational.access.mapper.ConstructionMapper;
import com.hnac.hzims.operational.access.service.ConstructionService;
import com.hnac.hzims.operational.access.vo.ConstructionVo;
-import com.hnac.hzims.operational.util.ExcelUtil;
+import com.hnac.hzims.operational.util.PdfUtils;
+import com.hnac.hzims.operational.util.WordUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.commons.io.IOUtils;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value;
@@ -21,7 +26,12 @@ import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
+import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
@@ -33,12 +43,8 @@ import java.util.Map;
@RequiredArgsConstructor
public class ConstructionServiceImpl extends BaseServiceImpl implements ConstructionService {
-
- @Value("${hzims.operational.construction.save.xlsx}")
- private String constructionSaveXlsxPath;
-
- @Value("${hzims.operational.construction.save.pdf}")
- private String constructionSavePdfPath;
+ @Value("${hzims.operation.construction.save.img}")
+ private String constructionSaveImgPath;
/**
* 施工日志记录分页查询
@@ -67,34 +73,36 @@ public class ConstructionServiceImpl extends BaseServiceImpl params = new HashMap<>();
- /*try {
+ try {
params = PdfUtils.objectToMap(construction);
}catch (Exception e) {
log.error("转换对象失败!");
- }*/
- TemplateExportParams templateExportParams = new TemplateExportParams("template/constructio_template.xlsx", true);
- Workbook workbook = null;
+ }
+ String fileName = construction.getCode() + "_" + construction.getOverhaulName() + "_施工日志" + PdfUtils.DOCX_SUFFIX;
+ XWPFDocument document;
try {
- workbook = ExcelUtil.getWorkbook(templateExportParams,params);
+ document = WordExportUtil.exportWord07("template/word/constructio_template.docx",params);
} catch (Exception e) {
- e.printStackTrace();
+ throw new ServiceException("文件创建失败!");
}
- //上传xlsx至服务器
- //String fileName = DateUtil.format(construction.getConstructionTime(),DateUtil.PATTERN_DATETIME) + "_" + construction.getOverhaulName() + "_施工日志" + PdfUtils.XLSX_SUFFIX;
- /* try {
- ExcelUtil.upload(workbook,constructionSaveXlsxPath,fileName);
- } catch (Exception e) {
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application/vnd.ms-word");
+ ServletOutputStream outputStream;
+ try {
+ //设置docx格式
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+ //创建一个输出流
+ outputStream = response.getOutputStream();
+ //写入数据
+ document.write(outputStream);
+ // 关闭
+ outputStream.close();
+ document.close();
+ } catch (IOException e) {
e.printStackTrace();
- }*/
- //将docx文件转换为pdf并保存
- //String pdfFileName = DateUtil.format(construction.getConstructionTime(),DateUtil.PATTERN_DATETIME) + "_" + construction.getOverhaulName() + "_施工日志" + PdfUtils.PDF_SUFFIX;
- //String xlsxFileName = DateUtil.format(construction.getConstructionTime(),DateUtil.PATTERN_DATETIME) + "_" + construction.getOverhaulName() + "_施工日志" + PdfUtils.XLSX_SUFFIX;
- //PdfUtils.convertPdf(constructionSaveXlsxPath, xlsxFileName, constructionSavePdfPath, pdfFileName);
- //String savePath = constructionSavePdfPath + pdfFileName;
- // 设置response参数,可以打开下载页面
- //PdfUtils.readPdf(response,savePath);
+ }
}
/**
@@ -102,11 +110,96 @@ public class ConstructionServiceImpl extends BaseServiceImpl 1){
+ construction.setConstructionImg1(new ImageEntity(imgToByte(constructionSaveImgPath + downloadFileByUrl(imgArr[0],constructionSaveImgPath)), 225, 163));
+ construction.setConstructionImg2(new ImageEntity(imgToByte(constructionSaveImgPath + downloadFileByUrl(imgArr[1],constructionSaveImgPath)), 225, 163));
+ }else{
+ construction.setConstructionImg1(new ImageEntity(imgToByte(constructionSaveImgPath + downloadFileByUrl(imgArr[0],constructionSaveImgPath)), 225, 163));
+ }
+ }
+ if(StringUtil.isEmpty(construction.getConstructionAttachment())){
+ construction.setConstructionAttachment(" ");
+ }
+ construction.setYear(DateUtil.format(construction.getConstructionTime(),"yyyy"));
+ construction.setMon(DateUtil.format(construction.getConstructionTime(),"MM"));
+ construction.setDay(DateUtil.format(construction.getConstructionTime(),"dd"));
+ return construction;
+ }
+
+ /**
+ * 将图片转化为字节数组
+ *
+ * @return 字节数组
+ */
+ private byte[] imgToByte(String tempImgPath) {
+ File file = new File(tempImgPath);
+ byte[] buffer = null;
+ try {
+ FileInputStream fis = new FileInputStream(file);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
+ byte[] b = new byte[1000];
+ int n;
+ while ((n = fis.read(b)) != -1) {
+ bos.write(b, 0, n);
+ }
+ fis.close();
+ bos.close();
+ buffer = bos.toByteArray();
+ } catch (IOException e) {
+ log.error(e.getMessage());
+ }
+ //删除临时文件
+ file.delete();
+ return buffer;
+ }
+
+ /**
+ * 下载文件
+ * @param fileUrl
+ * @param downloadFileDir
+ * @return
+ */
+ private String downloadFileByUrl(String fileUrl, String downloadFileDir){
+ URL url = null;
+ String fileName = null;
+ try {
+ url = new URL(fileUrl);
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setConnectTimeout(5000);
+ connection.setReadTimeout(5000);
+ connection.connect();
+
+ int responseCode = connection.getResponseCode();
+ if (responseCode == 200) {
+
+ InputStream inputStream = connection.getInputStream();
+
+ int lastSlashIndex = fileUrl.lastIndexOf("/");
+ if (lastSlashIndex > 0){
+ fileName = fileUrl.substring(lastSlashIndex+1);
+ String filePath = downloadFileDir + fileName;
+ File file = new File(filePath);
+ if (file.exists()){
+ file.delete();
+ }
+ OutputStream outputStream = new FileOutputStream(file);
+ // 将文件流拷贝到本地处理
+ IOUtils.copy(inputStream, outputStream);
+ }else {
+ throw new ServiceException("下载文件路径异常:" + downloadFileDir);
+ }
+ }
+ } catch (Exception e) {
+ throw new ServiceException("文件图片下载失败!");
+ }
+ return fileName;
}
}
\ No newline at end of file
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/PdfUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/PdfUtils.java
new file mode 100644
index 0000000..d12e30b
--- /dev/null
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/PdfUtils.java
@@ -0,0 +1,320 @@
+package com.hnac.hzims.operational.util;
+
+import com.documents4j.api.DocumentType;
+import com.documents4j.api.IConverter;
+import com.documents4j.job.LocalConverter;
+import com.hnac.hzims.operational.annotation.DefaultValue;
+import com.hnac.hzims.ticket.constants.TicketConstants;
+import com.spire.xls.FileFormat;
+import com.spire.xls.Workbook;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.IOUtils;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.utils.DateUtil;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.StringUtil;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.lang.reflect.Field;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.time.LocalDateTime;
+import java.util.*;
+
+/**
+ * @author hx
+ */
+@Slf4j
+public class PdfUtils {
+
+ /** 文件后缀名 **/
+ public static String DOC_SUFFIX = ".doc";
+ public static String DOCX_SUFFIX = ".docx";
+ public static String XLS_SUFFIX = ".xls";
+ public static String XLSX_SUFFIX = ".xlsx";
+ public static String PDF_SUFFIX = ".pdf";
+
+ /***
+ * 各文件转换为pdf
+ * @param templatePath 待转换的文件路径
+ * @param templateFileName 待转换的文件名
+ * @param savePath 转换为pdf后的文件路径
+ * @param saveFileName 转换为pdf后的文件名称
+ * @return
+ */
+ public static void convertPdf(String templatePath, String templateFileName, String savePath, String saveFileName) {
+ String templateFilePath = templatePath + templateFileName;
+ String saveFilePath = savePath + saveFileName;
+ log.info("转换前的文件为:{};转换后的路径为:{}", templateFilePath, saveFilePath);
+ File templateFile = new File(templateFilePath);
+ File saveFile = new File(saveFilePath);
+ //获取文件类型
+ String fileType = templateFileName.substring(templateFileName.lastIndexOf("."));
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ try {
+ inputStream = Files.newInputStream(templateFile.toPath());
+ outputStream = Files.newOutputStream(saveFile.toPath());
+ //document4j 转换 pdf linux环境下不支持
+ if (DOCX_SUFFIX.equals(fileType)) {
+ IConverter converter = LocalConverter.builder().build();
+ converter.convert(inputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
+ converter.shutDown();
+ } else if (DOC_SUFFIX.equals(fileType)) {
+ IConverter converter = LocalConverter.builder().build();
+ converter.convert(inputStream).as(DocumentType.DOC).to(outputStream).as(DocumentType.PDF).execute();
+ converter.shutDown();
+ } else if (XLS_SUFFIX.equals(fileType)) {
+ IConverter converter = LocalConverter.builder().build();
+ converter.convert(inputStream).as(DocumentType.XLS).to(outputStream).as(DocumentType.PDF).execute();
+ converter.shutDown();
+ } else if (XLSX_SUFFIX.equals(fileType)) {
+ //此方式行不通
+ //converter.convert(inputStream).as(DocumentType.XLSX).to(outputStream).as(DocumentType.PDF).execute();
+ Workbook wb = new Workbook();
+ wb.loadFromFile(templateFilePath);
+ wb.saveToFile(saveFilePath, FileFormat.PDF);
+ }
+ } catch (Exception e) {
+ log.error("转换失败,错误信息为:{}", e.getMessage());
+ throw new ServiceException(e.getMessage());
+ } finally {
+ inputStream.close();
+ outputStream.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * 对象转化为Map 并设置默认值
+ *
+ * @param obj
+ * @return
+ * @throws Exception
+ */
+ public static Map objectToMap(Object obj) {
+ Map result = new HashMap<>();
+ if (ObjectUtil.isNotEmpty(obj)) {
+ Class clazz = obj.getClass();
+ List fieldList = new ArrayList<>();
+ while (clazz != null) {
+ fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
+ clazz = clazz.getSuperclass();
+ }
+ fieldList.forEach(field -> {
+ field.setAccessible(true);
+ DefaultValue defaultValue = field.getAnnotation(DefaultValue.class);
+ Object value;
+ try {
+ value = field.get(obj);
+ } catch (IllegalAccessException e) {
+ throw new ServiceException("获取属性性出错");
+ }
+ //若为list则不处理
+ if (value instanceof List) {
+ return;
+ }
+ //若为时间格式则进行格式化
+ if (value instanceof LocalDateTime) {
+ value = DateUtil.format((LocalDateTime) value, TicketConstants.TICKET_DATE_PATTERN);
+ }
+ if (value instanceof Date) {
+ value = DateUtil.format((Date) value, TicketConstants.TICKET_DATE_PATTERN);
+ }
+
+ //如果value为空直接跳出
+ // if ((ObjectUtils.isEmpty(value) || value == "") && StringUtil.isNoneBlank(field.getName())){
+ // return;
+ // }
+
+ //属性上是否加入DefaultValue注解 若加入 则判断是否定义属性名以及值 若未定义则取原属性名及值
+ if (ObjectUtil.isNotEmpty(defaultValue)) {
+ result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(),
+ ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value);
+ } else {
+ result.put(field.getName(), Optional.ofNullable(value).orElse(" "));
+
+ }
+ });
+ }
+ return result;
+ }
+
+
+ /**
+ * 对象转化为Map 并设置默认值
+ *
+ * @param obj
+ * @return
+ * @throws Exception
+ */
+ public static Map objectToMap(Object obj, boolean isWordFlag) {
+ Map result = new HashMap<>();
+ if (ObjectUtil.isNotEmpty(obj)) {
+ Class clazz = obj.getClass();
+ List fieldList = new ArrayList<>();
+ while (clazz != null) {
+ fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
+ clazz = clazz.getSuperclass();
+ }
+ fieldList.forEach(field -> {
+ field.setAccessible(true);
+ DefaultValue defaultValue = field.getAnnotation(DefaultValue.class);
+ Object value;
+ try {
+ value = field.get(obj);
+ } catch (IllegalAccessException e) {
+ throw new ServiceException("获取属性性出错");
+ }
+ //若为list则不处理
+ if (value instanceof List) {
+ return;
+ }
+ //若为时间格式则进行格式化
+ if (value instanceof LocalDateTime) {
+ value = DateUtil.format((LocalDateTime) value, TicketConstants.TICKET_DATE_PATTERN);
+ }
+ if (value instanceof Date) {
+ value = DateUtil.format((Date) value, TicketConstants.TICKET_DATE_PATTERN);
+ }
+
+ //如果value为空直接跳出
+ // if ((ObjectUtils.isEmpty(value) || value == "") && StringUtil.isNoneBlank(field.getName())){
+ // return;
+ // }
+
+ //属性上是否加入DefaultValue注解 若加入 则判断是否定义属性名以及值 若未定义则取原属性名及值
+ if (ObjectUtil.isNotEmpty(defaultValue)) {
+ result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(),
+ ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value);
+ } else {
+ if (isWordFlag) {
+ //如果导出word为null会出现{{ ,value设置"\u00A0"
+ result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0"));
+ } else {
+ result.put(field.getName(), Optional.ofNullable(value).orElse(" "));
+ }
+ }
+ });
+ }
+ return result;
+ }
+
+
+ /**
+ * 对象转化为Map 并设置默认值
+ *
+ * @param obj
+ * @return
+ * @throws Exception
+ */
+ public static Map objectToMapResult(Object obj, Map map) {
+ Map result = new HashMap<>();
+ if (ObjectUtil.isNotEmpty(obj)) {
+ Class clazz = obj.getClass();
+ List fieldList = new ArrayList<>();
+ while (clazz != null) {
+ fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
+ clazz = clazz.getSuperclass();
+ }
+ fieldList.forEach(field -> {
+ field.setAccessible(true);
+ DefaultValue defaultValue = field.getAnnotation(DefaultValue.class);
+ Object value;
+ try {
+ value = field.get(obj);
+ } catch (IllegalAccessException e) {
+ throw new ServiceException("获取属性性出错");
+ }
+ //若为list则不处理
+ if (value instanceof List) {
+ return;
+ }
+ //若为时间格式则进行格式化
+ if (value instanceof LocalDateTime) {
+ value = DateUtil.format((LocalDateTime) value, TicketConstants.TICKET_DATE_PATTERN);
+ }
+ if (value instanceof Date) {
+ value = DateUtil.format((Date) value, TicketConstants.TICKET_DATE_PATTERN);
+ }
+
+ if (map.containsKey(field.getName())) {
+ return;
+ }
+
+ //属性上是否加入DefaultValue注解 若加入 则判断是否定义属性名以及值 若未定义则取原属性名及值
+ if (ObjectUtil.isNotEmpty(defaultValue)) {
+ result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(),
+ ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value);
+ } else {
+ //如果导出word为null会出现{{ ,value设置"\u00A0"
+ result.put(field.getName(), Optional.ofNullable(value).orElse(""));
+ }
+ });
+ }
+ return result;
+ }
+
+
+ /**
+ * 读取本地pdf,这里设置的是预览
+ */
+ public static void readPdf(HttpServletResponse response, String filePath) {
+ response.reset();
+ response.setContentType("application/pdf");
+ FileInputStream fileInputStream = null;
+ OutputStream outputStream = null;
+ try {
+ File file = new File(filePath);
+ fileInputStream = new FileInputStream(file);
+ outputStream = response.getOutputStream();
+ IOUtils.write(IOUtils.toByteArray(fileInputStream), outputStream);
+ response.setHeader("Content-Disposition",
+ "inline; filename= " + URLEncoder.encode(file.getName(), "UTF-8"));
+ outputStream.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ fileInputStream.close();
+ outputStream.close();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 读取本地pdf,这里设置的是导出
+ */
+ public static void exportPdf(HttpServletResponse response, String filePath) {
+ response.reset();
+ response.setContentType("application/pdf");
+ FileInputStream fileInputStream = null;
+ OutputStream outputStream = null;
+ try {
+ File file = new File(filePath);
+ fileInputStream = new FileInputStream(file);
+ outputStream = response.getOutputStream();
+ IOUtils.write(IOUtils.toByteArray(fileInputStream), outputStream);
+ response.setHeader("Content-Disposition", "inline; filename= " + URLEncoder.encode(file.getName(), "UTF-8"));
+ outputStream.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ fileInputStream.close();
+ outputStream.close();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java
index 5b28ec5..eafafad 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java
@@ -6,17 +6,16 @@ import cn.hutool.core.lang.Assert;
import com.hnac.hzims.operational.util.pojo.HttpResponse;
import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
-import org.apache.poi.xwpf.usermodel.XWPFTable;
-import org.apache.poi.xwpf.usermodel.XWPFTableCell;
-import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
+import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.UnsupportedEncodingException;
+import java.awt.image.BufferedImage;
+import java.io.*;
import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
@@ -91,7 +90,7 @@ public abstract class WordUtils {
public static XWPFDocument exportWordV2(String templatePath, Map params) {
try {
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, params);
-// 合并第一列相同行的数据
+ //合并第一列相同行的数据
tableIfSame(doc);
return doc;
} catch (Exception e) {
diff --git a/hzims-service/operational/src/main/resources/log/logback-dev.xml b/hzims-service/operational/src/main/resources/log/logback-dev.xml
deleted file mode 100644
index c67cdd9..0000000
--- a/hzims-service/operational/src/main/resources/log/logback-dev.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${CONSOLE_LOG_PATTERN}
- utf8
-
-
-
-
-
-
-
-
- log/info.log
-
-
- log/info/info-%d{yyyy-MM-dd_HH}.%i.log
-
- 240
-
- 20MB
- 10GB
- true
-
-
- ${log.pattern}
-
-
-
- INFO
- ACCEPT
- DENY
-
-
-
-
-
- log/error.log
-
-
- log/error/error-%d{yyyy-MM-dd_HH}.%i.log
-
- 360
-
- 20MB
- 10GB
- true
-
-
- ${log.pattern}
-
-
-
- ERROR
- ACCEPT
- DENY
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hzims-service/operational/src/main/resources/log/logback-prod.xml b/hzims-service/operational/src/main/resources/log/logback-prod.xml
deleted file mode 100644
index 3083e23..0000000
--- a/hzims-service/operational/src/main/resources/log/logback-prod.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${CONSOLE_LOG_PATTERN}
- utf8
-
-
-
-
-
-
-
-
- log/info.log
-
-
- log/info/info-%d{yyyy-MM-dd_HH}.%i.log
-
- 240
-
- 20MB
- 10GB
- true
-
-
- ${log.pattern}
-
-
-
- INFO
- ACCEPT
- DENY
-
-
-
-
-
- log/error.log
-
-
- log/error/error-%d{yyyy-MM-dd_HH}.%i.log
-
- 360
-
- 20MB
- 10GB
- true
-
-
- ${log.pattern}
-
-
-
- ERROR
- ACCEPT
- DENY
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hzims-service/operational/src/main/resources/log/logback-test.xml b/hzims-service/operational/src/main/resources/log/logback-test.xml
deleted file mode 100644
index fb3de3c..0000000
--- a/hzims-service/operational/src/main/resources/log/logback-test.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${CONSOLE_LOG_PATTERN}
- utf8
-
-
-
-
-
-
-
-
-
-
- log/error.log
-
-
- log/error/error-%d{yyyy-MM-dd_HH}.%i.log
-
- 360
-
- 20MB
- 10GB
- true
-
-
- ${log.pattern}
-
-
-
- ERROR
- ACCEPT
- DENY
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hzims-service/operational/src/main/resources/template/excel/constructio_template.xlsx b/hzims-service/operational/src/main/resources/template/excel/constructio_template.xlsx
deleted file mode 100644
index 201df42..0000000
Binary files a/hzims-service/operational/src/main/resources/template/excel/constructio_template.xlsx and /dev/null differ
diff --git a/hzims-service/operational/src/main/resources/template/word/constructio_template.docx b/hzims-service/operational/src/main/resources/template/word/constructio_template.docx
new file mode 100644
index 0000000..c59be0b
Binary files /dev/null and b/hzims-service/operational/src/main/resources/template/word/constructio_template.docx differ