Commit 296af2a0 by HlQ

[chg] Myexcel 附件导出工具类更换为 AttachmentV2ExportUtil

1 parent 3415e6ca
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
......@@ -25,7 +26,6 @@ import vion.model.RContractStore;
import vion.model.RContractUser;
import vion.service.IContractService;
import vion.service.IRContractStoreService;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.ContractVO;
import vion.vo.UserVO;
......@@ -206,7 +206,7 @@ public class ContractController {
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("合同列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("合同列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import io.github.linpeilie.Converter;
import jakarta.servlet.http.HttpServletResponse;
......@@ -15,7 +16,6 @@ import org.dromara.hutool.core.text.StrUtil;
import org.springframework.web.bind.annotation.*;
import vion.dto.InvoiceDTO;
import vion.service.IInvoiceService;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.InvoiceVO;
import vion.vo.UserVO;
......@@ -79,7 +79,7 @@ public class InvoiceController {
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("发票列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("发票列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import io.github.linpeilie.Converter;
import jakarta.servlet.http.HttpServletResponse;
......@@ -15,7 +16,6 @@ import org.dromara.hutool.core.text.StrUtil;
import org.springframework.web.bind.annotation.*;
import vion.dto.PaymentDTO;
import vion.service.IPaymentService;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.PaymentVO;
import vion.vo.UserVO;
......@@ -79,7 +79,7 @@ public class PaymentController {
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("收款列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("收款列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
......@@ -17,7 +18,6 @@ import vion.dto.PointInfoDTO;
import vion.model.RejectInfo;
import vion.service.IPointInfoService;
import vion.third.WechatMod;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.PointInfoVO;
import vion.vo.UserVO;
......@@ -128,7 +128,7 @@ public class PointDesignController {
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("点位设计列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("点位设计列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
......@@ -16,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
import vion.dto.SparePartDTO;
import vion.model.RRepairDevice;
import vion.service.ISparePartService;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.SparePartVO;
import vion.vo.UserVO;
......@@ -92,7 +92,7 @@ public class SparePartController {
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("备件申请列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("备件申请列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
......@@ -21,7 +22,6 @@ import vion.model.FaultLog;
import vion.model.Task;
import vion.service.IFaultLogService;
import vion.service.ITaskService;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.TaskVO;
import vion.vo.UserVO;
......@@ -109,7 +109,7 @@ public class TaskController {
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("任务列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("任务列表_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......@@ -171,4 +171,16 @@ public class TaskController {
Integer source) {
return taskService.summaryAnalysis(startDate, endDate, source);
}
/**
* 客流平台单独使用接口
* 催办工单,催办工单给当前处理人
*
* @param taskId 工单id
* @return java.lang.String
*/
@GetMapping("/task/urge")
public String urgeTask(Long taskId) {
return taskService.urgeTask(taskId, "客户催办");
}
}
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.AttachmentV2ExportUtil;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
......@@ -42,7 +43,6 @@ import vion.model.*;
import vion.service.*;
import vion.third.DingMod;
import vion.utils.JsonUtil;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.ContractVO;
import vion.vo.StoreVO;
import vion.vo.TagVO;
......@@ -652,7 +652,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("项目资料_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
AttachmentV2ExportUtil.export(workbook, StrUtil.format("项目资料_{}", TimeUtil.formatNormal(LocalDateTime.now())), response);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
package vion.utils.excel;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* @author vion
* @date 2024/2/26
*/
public class AttachmentExportUtil {
public static void export(Workbook workbook, String fileName, HttpServletResponse response) {
try {
String suffix = ".xlsx";
if (workbook instanceof HSSFWorkbook) {
if (fileName.endsWith(suffix)) {
fileName = fileName.substring(0, fileName.length() - 1);
}
suffix = ".xls";
response.setContentType("application/vnd.ms-excel");
} else {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
if (!fileName.endsWith(suffix)) {
fileName = fileName + suffix;
}
setAttachmentConfig(fileName, response);
workbook.write(response.getOutputStream());
} catch (IOException var7) {
throw new RuntimeException(var7);
} finally {
clear(workbook);
}
}
private static void clear(Workbook workbook) {
if (workbook instanceof SXSSFWorkbook) {
((SXSSFWorkbook) workbook).dispose();
}
try {
workbook.close();
} catch (IOException var2) {
var2.printStackTrace();
}
}
private static void setAttachmentConfig(String fileName, HttpServletResponse response) throws UnsupportedEncodingException {
response.setCharacterEncoding("UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8").replace("+", "%20"));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!