Commit d1cbeeae authored by suhuiguang's avatar suhuiguang

1.安全管理报表

2.二维码工具类
parent 6f7e8a74
...@@ -50,5 +50,10 @@ ...@@ -50,5 +50,10 @@
<groupId>com.yeejoin</groupId> <groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId> <artifactId>amos-component-rule</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -3,14 +3,19 @@ package com.yeejoin.equipmanage.common.utils; ...@@ -3,14 +3,19 @@ package com.yeejoin.equipmanage.common.utils;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter; import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.apache.commons.lang3.StringUtils;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date; import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Random; import java.util.Random;
...@@ -19,8 +24,8 @@ import java.util.concurrent.locks.ReentrantLock; ...@@ -19,8 +24,8 @@ import java.util.concurrent.locks.ReentrantLock;
/** /**
* 二维码工具类 * 二维码工具类
* @author Administrator
* *
* @author Administrator
*/ */
public class QRCodeUtil { public class QRCodeUtil {
...@@ -33,22 +38,20 @@ public class QRCodeUtil { ...@@ -33,22 +38,20 @@ public class QRCodeUtil {
private static final int QRCODE_SIZE = 45; private static final int QRCODE_SIZE = 45;
private static int randomNumForQrCode; private static int randomNumForQrCode;
/** /**
*
* <pre> * <pre>
* 根据当前记录ID生成QRCode * 根据当前记录ID生成QRCode
* </pre> * </pre>
* *
* @return * @return
*/ */
public static String generateQRCode(Date dateCreated, String pointNo) public static String generateQRCode(Date dateCreated, String pointNo) {
{
return String.valueOf(dateCreated.getTime() + pointNo); return String.valueOf(dateCreated.getTime() + pointNo);
} }
/** /**
*
* <pre> * <pre>
* 生成QRCode * 生成QRCode
* </pre> * </pre>
...@@ -56,25 +59,24 @@ public class QRCodeUtil { ...@@ -56,25 +59,24 @@ public class QRCodeUtil {
* @param id * @param id
* @return * @return
*/ */
public static String generateQRCode() public static String generateQRCode() {
{
String res; String res;
//加锁生成随机数,保证自增后释放 //加锁生成随机数,保证自增后释放
Lock lock = new ReentrantLock(); Lock lock = new ReentrantLock();
lock.lock(); lock.lock();
randomNumForQrCode+=1; randomNumForQrCode += 1;
//return String.valueOf(dateCreated.getTime() + id); //return String.valueOf(dateCreated.getTime() + id);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
try { try {
res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(5,8) + String.valueOf(IdWorker.getFlowIdWorkerInstance().nextId()).substring(0,10)+randomNumForQrCode; res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(5, 8) + String.valueOf(IdWorker.getFlowIdWorkerInstance().nextId()).substring(0, 10) + randomNumForQrCode;
}catch (Exception e){ } catch (Exception e) {
Random random = new Random(System.currentTimeMillis()); Random random = new Random(System.currentTimeMillis());
String tmp = ""; String tmp = "";
for (int i=0; i<13; i++){ for (int i = 0; i < 13; i++) {
tmp += random.nextInt(10); tmp += random.nextInt(10);
} }
res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(2,8) + tmp.substring(0,10)+randomNumForQrCode; res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(2, 8) + tmp.substring(0, 10) + randomNumForQrCode;
}finally { } finally {
lock.unlock(); lock.unlock();
} }
return res; return res;
...@@ -88,7 +90,7 @@ public class QRCodeUtil { ...@@ -88,7 +90,7 @@ public class QRCodeUtil {
*/ */
public static String temporaryQrCode() { public static String temporaryQrCode() {
long qrCode = -1 * System.currentTimeMillis(); long qrCode = -1 * System.currentTimeMillis();
qrCode += (long)(random.nextDouble() * 10000000); qrCode += (long) (random.nextDouble() * 10000000);
return String.valueOf(qrCode); return String.valueOf(qrCode);
} }
...@@ -132,4 +134,96 @@ public class QRCodeUtil { ...@@ -132,4 +134,96 @@ public class QRCodeUtil {
} }
return null; return null;
} }
/**
* 生成简单的二维码
*
* @param text 二维码内容
* @param width 二维码宽度
* @param height 二维码高度
* @return String 图片base64
*/
public static String genQrCodeBase64Png(String text, int width, int height) {
ByteArrayOutputStream outputStream;
Base64.Encoder encoder;
try {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
outputStream = new ByteArrayOutputStream();
MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream);
encoder = Base64.getEncoder();
} catch (Exception e) {
throw new RuntimeException("二维码生成失败");
}
return encoder.encodeToString(outputStream.toByteArray());
}
/**
* 生成带文字说明的二维码
*
* @param text 二维码内容
* @param width 二维码宽度
* @param height 二维码高度
* @param word 二维码下方文字说明
* @param wordHeight 二维码下方文字高度
* @return String 图片base64
*/
public static String genQrCodeBase64PngWithWord(String text, int width, int height, String word, int wordHeight) {
ByteArrayOutputStream outputStream;
Base64.Encoder encoder;
try {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
BufferedImage image = MatrixToImageWriter.toBufferedImage(bitMatrix);
BufferedImage outImage = null;
if (StringUtils.isNotBlank(word)) {
outImage = new BufferedImage(width, wordHeight, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D outg = outImage.createGraphics();
// 画二维码到新的面板
outg.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
// 画文字到新的面板
outg.setColor(Color.BLACK);
// 字体、字型、字号
outg.setFont(new Font("微软雅黑", Font.PLAIN, 16));
int strWidth = outg.getFontMetrics().stringWidth(word);
int singleFd = outg.getFontMetrics().stringWidth("2");
int grow = width / singleFd - 1;
//长度过长就截取超出二维码宽度部分换行
if (strWidth > width) {
String serialNum1 = word.substring(0, grow);
String serialNum2 = word.substring(grow, word.length());
outg.drawString(serialNum1, 5, image.getHeight() + (outImage.getHeight() - image.getHeight()) / 2);
BufferedImage outImage2 = new BufferedImage(width, wordHeight, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D outg2 = outImage2.createGraphics();
outg2.drawImage(outImage, 0, 0, outImage.getWidth(), outImage.getHeight(), null);
outg2.setColor(Color.BLACK);
// 字体、字型、字号
outg2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
//参数:显示的内容、起始位置x、起始的y
outg2.drawString(serialNum2, 5, outImage.getHeight() + (outImage2.getHeight() - outImage.getHeight()) / 2);
outg2.dispose();
outImage2.flush();
outImage = outImage2;
} else {
// 画文字
outg.drawString(word, (width - strWidth) / 2, image.getHeight() + (outImage.getHeight() - image.getHeight()) / 3);
}
outg.dispose();
outImage.flush();
image.flush();
}
outputStream = new ByteArrayOutputStream();
ImageIO.write(outImage, "PNG", outputStream);
encoder = Base64.getEncoder();
} catch (Exception e) {
throw new RuntimeException("二维码生成失败");
}
return encoder.encodeToString(outputStream.toByteArray());
}
public static void main(String[] args) {
System.out.println(genQrCodeBase64Png("101",100,100));
System.out.println(genQrCodeBase64PngWithWord("101",100,100,"sd",100));
}
} }
package com.yeejoin.equipmanage.common.utils; package com.yeejoin.equipmanage.common.utils;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.WordUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.MediaType;
import org.springframework.util.ResourceUtils;
import com.aspose.words.License; import com.aspose.words.License;
import com.aspose.words.SaveFormat; import com.aspose.words.SaveFormat;
import com.itextpdf.text.pdf.BaseFont;
import freemarker.cache.ClassTemplateLoader;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
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.Properties;
public class WordTemplateUtils { public class WordTemplateUtils {
private static String fileUploadDir; private static String fileUploadDir;
private Configuration configuration = null; private Configuration configuration;
private static WordTemplateUtils wordTemplateUtils; private static WordTemplateUtils wordTemplateUtils;
...@@ -58,8 +29,8 @@ public class WordTemplateUtils { ...@@ -58,8 +29,8 @@ public class WordTemplateUtils {
configuration.setDefaultEncoding("utf-8"); configuration.setDefaultEncoding("utf-8");
} }
public static synchronized WordTemplateUtils getInstance(){ public static synchronized WordTemplateUtils getInstance() {
if(wordTemplateUtils == null){ if (wordTemplateUtils == null) {
//添加你的内容 //添加你的内容
Properties props; Properties props;
try { try {
...@@ -77,25 +48,8 @@ public class WordTemplateUtils { ...@@ -77,25 +48,8 @@ public class WordTemplateUtils {
public void exportMillCertificateWord(HttpServletRequest request, HttpServletResponse response, Map map, public void exportMillCertificateWord(HttpServletRequest request, HttpServletResponse response, Map map,
String title, String ftlFile) throws IOException { String title, String ftlFile) throws IOException {
URL resourcePath = this.getClass().getClassLoader().getResource("ftl");
Resource resource = new ClassPathResource("ftl");// 配置路径 /config.xml
configuration.setClassForTemplateLoading(this.getClass(), "/ftl"); configuration.setClassForTemplateLoading(this.getClass(), "/ftl");
// InputStream is = resource.getInputStream(); Template freemarkerTemplate = configuration.getTemplate(ftlFile, "UTF-8");
// InputStreamReader isr = new InputStreamReader(is);
// BufferedReader br = new BufferedReader(isr);
// String data = null;
// while((data = br.readLine()) != null) {
// //System.out.println(data);
// }
// br.close();
// isr.close();
// is.close();
//String path = ResourceUtils.getURL("classpath:").getPath();
//System.out.println(path);
//configuration.setDirectoryForTemplateLoading(new File(path));
// configuration.setTemplateLoader(new ClassTemplateLoader(
// this.getClass().getClassLoader(), "/ftl"));
Template freemarkerTemplate = configuration.getTemplate(ftlFile,"UTF-8");
File file = null; File file = null;
InputStream fin = null; InputStream fin = null;
ServletOutputStream out = null; ServletOutputStream out = null;
...@@ -112,34 +66,31 @@ public class WordTemplateUtils { ...@@ -112,34 +66,31 @@ public class WordTemplateUtils {
"attachment;filename=".concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8")))); "attachment;filename=".concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8"))));
out = response.getOutputStream(); out = response.getOutputStream();
// 缓冲区
byte[] buffer = new byte[512]; // 缓冲区 byte[] buffer = new byte[512];
int bytesToRead = -1; int bytesToRead = -1;
// 通过循环将读入的Word文件的内容输出到浏览器中 // 通过循环将读入的Word文件的内容输出到浏览器中
while ((bytesToRead = fin.read(buffer)) != -1) { while ((bytesToRead = fin.read(buffer)) != -1) {
out.write(buffer, 0, bytesToRead); out.write(buffer, 0, bytesToRead);
} }
} finally { } finally {
if (fin != null){ if (fin != null) {
fin.close();} fin.close();
if (out != null){ }
out.close();} if (out != null) {
if (file != null){ out.close();
file.delete(); }// 删除临时文件 }
if (file != null) {
file.delete();
}// 删除临时文件
} }
} }
public File getWordFileItem(Map map,String title,String ftlFile) throws IOException { public File getWordFileItem(Map map, String title, String ftlFile) throws IOException {
URL resourcePath = this.getClass().getClassLoader().getResource("ftl");
configuration.setClassForTemplateLoading(this.getClass(), "/ftl"); configuration.setClassForTemplateLoading(this.getClass(), "/ftl");
Template freemarkerTemplate = configuration.getTemplate(ftlFile,"UTF-8"); Template freemarkerTemplate = configuration.getTemplate(ftlFile, "UTF-8");
FileItemFactory factory = new DiskFileItemFactory(16, null);
String textFieldName = "file";
File file = null; File file = null;
File filepdf = new File("sellPlan.pdf"); File filepdf = new File("sellPlan.pdf");
int bytesRead = 0;
byte[] buffer = new byte[10 * 1024 * 1024];
InputStream fin = null; InputStream fin = null;
OutputStream os = null; OutputStream os = null;
try { try {
...@@ -150,12 +101,15 @@ public class WordTemplateUtils { ...@@ -150,12 +101,15 @@ public class WordTemplateUtils {
wordTopdfByAspose(fin, os); wordTopdfByAspose(fin, os);
return filepdf; return filepdf;
} finally { } finally {
if (fin != null){ if (fin != null) {
fin.close();} fin.close();
if (os != null){ }
os.close();} if (os != null) {
if (file != null){ os.close();
file.delete(); }// 删除临时文件 }
if (file != null) {
file.delete();
}// 删除临时文件
} }
} }
...@@ -189,7 +143,7 @@ public class WordTemplateUtils { ...@@ -189,7 +143,7 @@ public class WordTemplateUtils {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
}finally { } finally {
if (outputStream != null) { if (outputStream != null) {
try { try {
outputStream.flush(); outputStream.flush();
...@@ -218,15 +172,18 @@ public class WordTemplateUtils { ...@@ -218,15 +172,18 @@ public class WordTemplateUtils {
return result; return result;
} }
// 获得图片的base64码
/**
* 获得图片的base64码
* @param src 图片路径
* @return String
*/
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String getImageBase(String src) { public String getImageBase(String src) {
if (src == null || src == "") { if (!StringUtil.isNotEmpty(src)) {
return ""; return "";
} }
if (StringUtil.isNotEmpty(src)) {
src = src.replaceAll("\\.\\.", ""); src = src.replaceAll("\\.\\.", "");
}
String fileName = fileUploadDir + src; String fileName = fileUploadDir + src;
File file = new File(fileName); File file = new File(fileName);
if (!file.exists()) { if (!file.exists()) {
......
...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto; import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
import com.yeejoin.equipmanage.service.IFireAutoSysManageReportService; import com.yeejoin.equipmanage.service.IFireAutoSysManageReportService;
import com.yeejoin.equipmanage.service.IFirePatrolReportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
...@@ -38,7 +37,7 @@ public class FireAutoSysManageReportController extends BaseController { ...@@ -38,7 +37,7 @@ public class FireAutoSysManageReportController extends BaseController {
@ApiOperation(value = "下载报表", notes = "下载报表") @ApiOperation(value = "下载报表", notes = "下载报表")
@GetMapping(value = "/download") @GetMapping(value = "/download")
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY)
public void download(HttpServletRequest request, HttpServletResponse response, public void download(HttpServletRequest request, HttpServletResponse response,
@ApiParam(value = "换流站编码", required = true) @RequestParam String stationCode, @ApiParam(value = "换流站编码", required = true) @RequestParam String stationCode,
@ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
...@@ -48,7 +47,7 @@ public class FireAutoSysManageReportController extends BaseController { ...@@ -48,7 +47,7 @@ public class FireAutoSysManageReportController extends BaseController {
@ApiOperation(value = "预览报表", notes = "预览报表") @ApiOperation(value = "预览报表", notes = "预览报表")
@GetMapping(value = "/preview") @GetMapping(value = "/preview")
@TycloudOperation(ApiLevel = UserType.PUBLIC) @TycloudOperation(ApiLevel = UserType.AGENCY)
public String preview( public String preview(
@ApiParam(value = "换流站编码", required = true) @RequestParam String stationCode, @ApiParam(value = "换流站编码", required = true) @RequestParam String stationCode,
@ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
...@@ -59,7 +58,7 @@ public class FireAutoSysManageReportController extends BaseController { ...@@ -59,7 +58,7 @@ public class FireAutoSysManageReportController extends BaseController {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ApiOperation(value = "所有站查询列表", notes = "所有站查询列表") @ApiOperation(value = "所有站查询列表", notes = "所有站查询列表")
@GetMapping(value = "/allPage") @GetMapping(value = "/allPage")
@TycloudOperation(ApiLevel = UserType.PUBLIC) @TycloudOperation(ApiLevel = UserType.AGENCY)
public IPage<AnalysisReportLogDto> allPage(Page page, @RequestParam Integer reportType, public IPage<AnalysisReportLogDto> allPage(Page page, @RequestParam Integer reportType,
@ApiParam(value = "开始日期") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @ApiParam(value = "开始日期") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
@ApiParam(value = "结束日期") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate, @ApiParam(value = "结束日期") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
......
...@@ -277,6 +277,7 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService { ...@@ -277,6 +277,7 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService {
*/ */
public static StandardChartTheme createChartTheme(String fontName) { public static StandardChartTheme createChartTheme(String fontName) {
StandardChartTheme theme = new StandardChartTheme("unicode") { StandardChartTheme theme = new StandardChartTheme("unicode") {
@Override
public void apply(JFreeChart chart) { public void apply(JFreeChart chart) {
chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
...@@ -379,9 +380,10 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService { ...@@ -379,9 +380,10 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService {
WordTemplateUtils instance = WordTemplateUtils.getInstance(); WordTemplateUtils instance = WordTemplateUtils.getInstance();
Map<String, Object> map = getWordMap(code, startDate, endDate); Map<String, Object> map = getWordMap(code, startDate, endDate);
String urlString=""; String urlString="";
File filepdf = null;
try { try {
//instance.pdfCreate(map, (String) map.get("document_number"), WordTemplateTypeEum.firePatrolReport.getTemplateFile()); //instance.pdfCreate(map, (String) map.get("document_number"), WordTemplateTypeEum.firePatrolReport.getTemplateFile());
File filepdf = instance.getWordFileItem(map,(String) map.get("document_number"), WordTemplateTypeEum.firePatrolReport.getTemplateFile()); filepdf = instance.getWordFileItem(map,(String) map.get("document_number"), WordTemplateTypeEum.firePatrolReport.getTemplateFile());
//MultipartFile multipartFile = new CommonsMultipartFile(item); //MultipartFile multipartFile = new CommonsMultipartFile(item);
filepdf.getAbsolutePath(); filepdf.getAbsolutePath();
// File file = new File("F:\\application-dev.yml"); // File file = new File("F:\\application-dev.yml");
...@@ -396,6 +398,10 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService { ...@@ -396,6 +398,10 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService {
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(filepdf != null){
filepdf.delete();
}
} }
return urlString; return urlString;
} }
......
...@@ -259,8 +259,9 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep ...@@ -259,8 +259,9 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep
WordTemplateUtils instance = WordTemplateUtils.getInstance(); WordTemplateUtils instance = WordTemplateUtils.getInstance();
Map<String, Object> map = getWordMap(code, startDate, endDate); Map<String, Object> map = getWordMap(code, startDate, endDate);
String urlString = ""; String urlString = "";
File filePdf = null;
try { try {
File filePdf = instance.getWordFileItem(map, (String) map.get("document_number"), WordTemplateTypeEum.fireAutoSysManageReport.getTemplateFile()); filePdf = instance.getWordFileItem(map, "消防自动化综合管理报表", WordTemplateTypeEum.fireAutoSysManageReport.getTemplateFile());
MultipartFile multipartFile = new MyByteArrayMultipartFile("file", "file.pdf", "application/pdf", file2byte(filePdf)); MultipartFile multipartFile = new MyByteArrayMultipartFile("file", "file.pdf", "application/pdf", file2byte(filePdf));
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile); FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile);
if (result != null) { if (result != null) {
...@@ -270,6 +271,10 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep ...@@ -270,6 +271,10 @@ public class FireAutoSysManageReportServiceImpl implements IFireAutoSysManageRep
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(filePdf != null){
filePdf.delete();
}
} }
return urlString; return urlString;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment