diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DownLoadFileController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DownLoadFileController.java new file mode 100644 index 00000000..8b5a8459 --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DownLoadFileController.java @@ -0,0 +1,52 @@ +package com.dreamchaser.depository_manage.controller; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/download") +public class DownLoadFileController { + + /** + * @param response + * @功能描述 下载文件: + */ + @RequestMapping("/download") + public void download(HttpServletRequest request,HttpServletResponse response) { + try { + ClassPathResource classPathResource = new ClassPathResource("static/upload/PrintServer.zip"); + File file = classPathResource.getFile(); + InputStream inputStream = classPathResource.getInputStream(); + //输出文件 + InputStream fis = new BufferedInputStream(inputStream); + byte[] buffer = new byte[fis.available()]; + fis.read(buffer); + fis.close(); + response.reset(); + + //获取文件的名字再浏览器下载页面 + String name = file.getName(); + response.addHeader("Content-Disposition", "attachment;filename=" + new String(name.getBytes(), "iso-8859-1")); + response.addHeader("Content-Length", "" + file.length()); + OutputStream out = new BufferedOutputStream(response.getOutputStream()); + response.setContentType("application/octet-stream"); + out.write(buffer); + out.flush(); + out.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java index 55a766fb..60725838 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java @@ -260,6 +260,7 @@ public class PlaceServiceImpl implements PlaceService { /** * 添加物料到库位 + * * @param map * @return */ diff --git a/src/main/resources/static/js/JcPrinter/index_Demo.js b/src/main/resources/static/js/JcPrinter/index_Demo.js index 397afc85..3a731521 100644 --- a/src/main/resources/static/js/JcPrinter/index_Demo.js +++ b/src/main/resources/static/js/JcPrinter/index_Demo.js @@ -555,7 +555,6 @@ var app = new Vue({ DrawLableGraphApiDemo(callbackFunction) { DrawLableGraph(this.DrawLableGraphParamDemo, callbackFunction); }, - DrawLableLineApiDemo(DrawLableLineParamDemo, callbackFunction) { DrawLableLine(DrawLableLineParamDemo, callbackFunction); }, @@ -566,6 +565,9 @@ var app = new Vue({ DrawLableQrCode(drawLableQrCodeParamDemo, callableFunction) }, + downLoadServer(){ + window.open("/download/download","_self"); + }, /** * 开始打印任务 * @param {*} pageCount 打印页数 diff --git a/src/main/resources/templates/pages/JcPrinter/PrinterIndex.html b/src/main/resources/templates/pages/JcPrinter/PrinterIndex.html index 989a441c..24b1acb1 100644 --- a/src/main/resources/templates/pages/JcPrinter/PrinterIndex.html +++ b/src/main/resources/templates/pages/JcPrinter/PrinterIndex.html @@ -12,12 +12,14 @@ - - - -