Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 11 months ago
parent
commit
431c868709
  1. 6
      hzims-service-api/hzims-operational-api/pom.xml
  2. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperConstructionEntity.java
  3. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/ConstructionVo.java
  4. 23
      hzims-service/operational/pom.xml
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/ConstructionController.java
  6. 155
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java
  7. 320
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/PdfUtils.java
  8. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java
  9. 127
      hzims-service/operational/src/main/resources/log/logback-dev.xml
  10. 127
      hzims-service/operational/src/main/resources/log/logback-prod.xml
  11. 127
      hzims-service/operational/src/main/resources/log/logback-test.xml
  12. BIN
      hzims-service/operational/src/main/resources/template/excel/constructio_template.xlsx
  13. BIN
      hzims-service/operational/src/main/resources/template/word/constructio_template.docx

6
hzims-service-api/hzims-operational-api/pom.xml

@ -67,6 +67,12 @@
<groupId>com.hnac.hzims</groupId>
<artifactId>middle-api</artifactId>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>4.4.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

6
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;

20
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;
}

23
hzims-service/operational/pom.xml

@ -18,6 +18,23 @@
</properties>
<dependencies>
<!--转pdf-->
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>${documents4j.version}</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>${documents4j.version}</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-UTIL-ALL</artifactId>
<version>${documents4j.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
@ -232,6 +249,12 @@
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>3.9.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

2
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));
}

155
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<ConstructionMapper, OperConstructionEntity> 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<ConstructionMapper,
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = servletRequestAttributes.getResponse();
//准备数据
OperConstructionEntity construction = this.record(id);
ConstructionVo construction = this.record(id);
Map<String,Object> 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<ConstructionMapper,
* @param id
* @return
*/
private OperConstructionEntity record(Long id) {
private ConstructionVo record(Long id) {
OperConstructionEntity entity = this.getById(id);
if(ObjectUtil.isEmpty(entity)){
throw new ServiceException("施工日志记录不存在!");
}
return entity;
ConstructionVo construction = BeanUtil.copy(entity,ConstructionVo.class);
if(StringUtil.isNotBlank(construction.getConstructionImg())){
String[] imgArr = construction.getConstructionImg().split(",");
if(imgArr.length > 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;
}
}

320
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<String, Object> objectToMap(Object obj) {
Map<String, Object> result = new HashMap<>();
if (ObjectUtil.isNotEmpty(obj)) {
Class clazz = obj.getClass();
List<Field> 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<String, Object> objectToMap(Object obj, boolean isWordFlag) {
Map<String, Object> result = new HashMap<>();
if (ObjectUtil.isNotEmpty(obj)) {
Class clazz = obj.getClass();
List<Field> 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<String, Object> objectToMapResult(Object obj, Map<String, Object> map) {
Map<String, Object> result = new HashMap<>();
if (ObjectUtil.isNotEmpty(obj)) {
Class clazz = obj.getClass();
List<Field> 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();
}
}
}
}

13
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;

127
hzims-service/operational/src/main/resources/log/logback-dev.xml

@ -1,127 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<!-- 自定义参数监听 -->
<contextListener class="org.springblade.core.log.listener.LoggerStartupListener"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<property name="log.pattern"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%X{traceId}] %-5level %logger{50} - %msg%n"/>
<!-- 生成日志文件 -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/info/info-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存10天 一天24个文件,一小时生成一个-->
<MaxHistory>240</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 生成日志文件 -->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/error/error-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存15天 一天24个文件,一小时生成一个-->
<MaxHistory>360</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志输出级别 -->
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="INFO"/>-->
<appender-ref ref="ERROR"/>
</root>
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="druid.sql" level="ERROR"/>
<!-- MyBatis log configure -->
<logger name="com.apache.ibatis" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="java.sql.Connection" level="ERROR"/>
<logger name="java.sql.Statement" level="ERROR"/>
<logger name="java.sql.PreparedStatement" level="ERROR"/>
<!-- 减少部分debug日志 -->
<logger name="druid.sql" level="ERROR"/>
<logger name="org.apache.shiro" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="com.baomidou.mybatisplus" level="ERROR"/>
<logger name="org.apache.ibatis.io" level="ERROR"/>
<logger name="org.apache.velocity" level="ERROR"/>
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="io.undertow" level="ERROR"/>
<logger name="org.xnio.nio" level="ERROR"/>
<logger name="org.thymeleaf" level="ERROR"/>
<logger name="springfox.documentation" level="ERROR"/>
<logger name="org.hibernate.validator" level="ERROR"/>
<logger name="com.netflix.loadbalancer" level="ERROR"/>
<logger name="com.netflix.hystrix" level="ERROR"/>
<logger name="com.netflix.zuul" level="ERROR"/>
<logger name="de.codecentric" level="ERROR"/>
<!-- cache ERROR -->
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="org.springframework.cache" level="ERROR"/>
<!-- cloud -->
<logger name="org.apache.http" level="ERROR"/>
<logger name="com.netflix.discovery" level="ERROR"/>
<logger name="com.netflix.eureka" level="ERROR"/>
<!-- 业务日志 -->
<Logger name="org.springblade" level="ERROR"/>
<Logger name="org.springblade.core.version" level="ERROR"/>
<!-- 减少nacos日志 -->
<logger name="com.alibaba.nacos" level="ERROR"/>
</configuration>

127
hzims-service/operational/src/main/resources/log/logback-prod.xml

@ -1,127 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<!-- 自定义参数监听 -->
<contextListener class="org.springblade.core.log.listener.LoggerStartupListener"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<property name="log.pattern"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%X{traceId}] %-5level %logger{50} - %msg%n"/>
<!-- 生成日志文件 -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/info/info-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存10天 一天24个文件,一小时生成一个-->
<MaxHistory>240</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 生成日志文件 -->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/error/error-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存15天 一天24个文件,一小时生成一个-->
<MaxHistory>360</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志输出级别 -->
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="INFO"/>-->
<appender-ref ref="ERROR"/>
</root>
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="druid.sql" level="ERROR"/>
<!-- MyBatis log configure -->
<logger name="com.apache.ibatis" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="java.sql.Connection" level="ERROR"/>
<logger name="java.sql.Statement" level="ERROR"/>
<logger name="java.sql.PreparedStatement" level="ERROR"/>
<!-- 减少部分debug日志 -->
<logger name="druid.sql" level="ERROR"/>
<logger name="org.apache.shiro" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="com.baomidou.mybatisplus" level="ERROR"/>
<logger name="org.apache.ibatis.io" level="ERROR"/>
<logger name="org.apache.velocity" level="ERROR"/>
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="io.undertow" level="ERROR"/>
<logger name="org.xnio.nio" level="ERROR"/>
<logger name="org.thymeleaf" level="ERROR"/>
<logger name="springfox.documentation" level="ERROR"/>
<logger name="org.hibernate.validator" level="ERROR"/>
<logger name="com.netflix.loadbalancer" level="ERROR"/>
<logger name="com.netflix.hystrix" level="ERROR"/>
<logger name="com.netflix.zuul" level="ERROR"/>
<logger name="de.codecentric" level="ERROR"/>
<!-- cache INFO -->
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="org.springframework.cache" level="ERROR"/>
<!-- cloud -->
<logger name="org.apache.http" level="ERROR"/>
<logger name="com.netflix.discovery" level="ERROR"/>
<logger name="com.netflix.eureka" level="ERROR"/>
<!-- 业务日志 -->
<Logger name="org.springblade" level="ERROR"/>
<Logger name="org.springblade.core.version" level="ERROR"/>
<!-- 减少nacos日志 -->
<logger name="com.alibaba.nacos" level="ERROR"/>
</configuration>

127
hzims-service/operational/src/main/resources/log/logback-test.xml

@ -1,127 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<!-- 自定义参数监听 -->
<contextListener class="org.springblade.core.log.listener.LoggerStartupListener"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<property name="log.pattern"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%X{traceId}] %-5level %logger{50} - %msg%n"/>
<!-- 生成日志文件
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
&lt;!&ndash; 日志文件输出的文件名 &ndash;&gt;
<fileNamePattern>log/info/info-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
&lt;!&ndash;设置保存10天 一天24个文件,一小时生成一个&ndash;&gt;
<MaxHistory>240</MaxHistory>
&lt;!&ndash;给定日志文件大小,超过指定的大小就新建一个日志文件&ndash;&gt;
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> &lt;!&ndash; 总日志大小 &ndash;&gt;
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
&lt;!&ndash; 打印日志级别 &ndash;&gt;
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>-->
<!-- 生成日志文件 -->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/error/error-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存15天 一天24个文件,一小时生成一个-->
<MaxHistory>360</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志输出级别 -->
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="INFO"/>-->
<appender-ref ref="ERROR"/>
</root>
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="druid.sql" level="ERROR"/>
<!-- MyBatis log configure -->
<logger name="com.apache.ibatis" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="java.sql.Connection" level="ERROR"/>
<logger name="java.sql.Statement" level="ERROR"/>
<logger name="java.sql.PreparedStatement" level="ERROR"/>
<!-- 减少部分debug日志 -->
<logger name="druid.sql" level="ERROR"/>
<logger name="org.apache.shiro" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="com.baomidou.mybatisplus" level="ERROR"/>
<logger name="org.apache.ibatis.io" level="ERROR"/>
<logger name="org.apache.velocity" level="ERROR"/>
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="io.undertow" level="ERROR"/>
<logger name="org.xnio.nio" level="ERROR"/>
<logger name="org.thymeleaf" level="ERROR"/>
<logger name="springfox.documentation" level="ERROR"/>
<logger name="org.hibernate.validator" level="ERROR"/>
<logger name="com.netflix.loadbalancer" level="ERROR"/>
<logger name="com.netflix.hystrix" level="ERROR"/>
<logger name="com.netflix.zuul" level="ERROR"/>
<logger name="de.codecentric" level="ERROR"/>
<!-- cache INFO -->
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="org.springframework.cache" level="ERROR"/>
<!-- cloud -->
<logger name="org.apache.http" level="ERROR"/>
<logger name="com.netflix.discovery" level="ERROR"/>
<logger name="com.netflix.eureka" level="ERROR"/>
<!-- 业务日志 -->
<Logger name="org.springblade" level="ERROR"/>
<Logger name="org.springblade.core.version" level="ERROR"/>
<!-- 减少nacos日志 -->
<logger name="com.alibaba.nacos" level="ERROR"/>
</configuration>

BIN
hzims-service/operational/src/main/resources/template/excel/constructio_template.xlsx

Binary file not shown.

BIN
hzims-service/operational/src/main/resources/template/word/constructio_template.docx

Binary file not shown.
Loading…
Cancel
Save