From 92910e636a7693fbb5fc757900769236012a55d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=9B=AA=E4=BC=9F?= Date: Sat, 23 Nov 2024 16:12:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=B4=E4=BF=AE=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=92=8C=E9=9B=B6=E9=83=A8=E4=BB=B6=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw-modules/hw-dms/pom.xml | 5 ++ .../DmsBillsFaultInstanceController.java | 3 +- .../hw/dms/domain/DmsFaultCompentsParts.java | 12 ++++ .../com/hw/dms/utils/TemplateExcelUtils.java | 63 ++++++++++++++++++ .../hw-dms/src/main/resources/weixiu.xlsx | Bin 0 -> 11370 bytes 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsFaultCompentsParts.java create mode 100644 hw-modules/hw-dms/src/main/java/com/hw/dms/utils/TemplateExcelUtils.java create mode 100644 hw-modules/hw-dms/src/main/resources/weixiu.xlsx diff --git a/hw-modules/hw-dms/pom.xml b/hw-modules/hw-dms/pom.xml index 2138820..9872b70 100644 --- a/hw-modules/hw-dms/pom.xml +++ b/hw-modules/hw-dms/pom.xml @@ -87,6 +87,11 @@ com.hw hw-api-system + + net.sf.jxls + jxls-core + 1.0.3 + diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsBillsFaultInstanceController.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsBillsFaultInstanceController.java index ff776d6..68df1c8 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsBillsFaultInstanceController.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsBillsFaultInstanceController.java @@ -6,9 +6,8 @@ import java.util.List; import java.io.IOException; import java.util.Map; import javax.servlet.http.HttpServletResponse; - -import com.hw.dms.TemplateExcelUtils; import com.hw.dms.domain.DmsFaultInstanceActivity; +import com.hw.dms.utils.TemplateExcelUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsFaultCompentsParts.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsFaultCompentsParts.java new file mode 100644 index 0000000..3ca7f02 --- /dev/null +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsFaultCompentsParts.java @@ -0,0 +1,12 @@ +package com.hw.dms.domain; + +import lombok.Data; + +@Data +public class DmsFaultCompentsParts { + private Long compentsPartsId; + private Long faultId; + private String partName; + private String partSpecifications; + private Integer amount; +} diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/utils/TemplateExcelUtils.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/utils/TemplateExcelUtils.java new file mode 100644 index 0000000..aa4a525 --- /dev/null +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/utils/TemplateExcelUtils.java @@ -0,0 +1,63 @@ +package com.hw.dms.utils; + + +import net.sf.jxls.transformer.XLSTransformer; +import org.apache.poi.ss.usermodel.Workbook; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.util.Map; + +public class TemplateExcelUtils { + + /** + * 根据模板导出数据 + * @param fileName + * @param sourcePath resource/template文件夹下路径 + * @param beanParams + * @param response + * @throws Exception + */ + public static void downLoadExcel(String fileName,String sourcePath, Map beanParams, HttpServletResponse response) + throws Exception { + try{ + OutputStream os = getOutputStream(fileName,response); + //读取模板 + InputStream is = TemplateExcelUtils.class.getResourceAsStream("/weixiu.xlsx"); + XLSTransformer transformer = new XLSTransformer(); +// beanParams.put("title","titl"); + //向模板中写入内容 + Workbook workbook = transformer.transformXLS(is, beanParams); + //写入成功后转化为输出流 + workbook.write(os); + }catch (Exception e){ + e.printStackTrace(); + throw e; + } + } + + /** + * 导出文件时为Writer生成OutputStream. + * @param fileName 文件名 + * @param response response + * @return "" + */ + private static OutputStream getOutputStream(String fileName, + HttpServletResponse response) throws Exception { + try { + fileName = URLEncoder.encode(fileName, "UTF-8"); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf8"); + response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls"); + response.setHeader("Pragma", "public"); + response.setHeader("Cache-Control", "no-store"); + response.addHeader("Cache-Control", "max-age=0"); + return response.getOutputStream(); + } catch (IOException e) { + throw new Exception("导出excel表格失败!", e); + } + } +} diff --git a/hw-modules/hw-dms/src/main/resources/weixiu.xlsx b/hw-modules/hw-dms/src/main/resources/weixiu.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..a61e6fadc629eb67de928b464795d0245608bdea GIT binary patch literal 11370 zcmeHtgP0pzG+ibD8uI@C+JEs1l&bdIbg^NyzS|QLZ&UxA6;xb| zK-@&EO|=W3=p3yK2U7REv%CJj6n<0M zMtPm1-aWtXcx0$rrsC8Wr$&p-2;{RQ;2D^!FR$z~^MIBKSm6rs(HY;w{lb4u-tTjc}@&0gWg3vIalYwJI1?>?7n9W{>65o_8pe?0ki;%6xpP&&vLiFtE2?n6_7d5R_W1~EWa8C~M6d9tX zdJZO5KvtIDuK!cd|6-l|)6`3&-l@@nt`-3rx7RcZ6r4afp|+FJ0@w z{5W+nb(th3<3jhbHG-j}p)gCfe}z)=`-ylJ#wg1>LPYF5;y_%%Bpps;QXqnO7R7JG`QB z(KEK{I1^84$9`~UR!Hqrrr^T5<`|XgrOv$Y(yHM)8BBBO;X&*!={xTC4IwLBhIp*M zD~ZqR*n~64iZnr#gb;uL3P0F#L%RxF)hmqV;kslG~D~~iW_Ym2K%Cu zu`n15))m|8i2s@G@Yyg7g5g0Ksjt*CY%K8Je#rqcS~3v3@pW_`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