Browse Source

实现驱动下载功能

lwx_dev
erdanergou 3 years ago
parent
commit
51bb02dd35
  1. 52
      src/main/java/com/dreamchaser/depository_manage/controller/DownLoadFileController.java
  2. 1
      src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java
  3. 4
      src/main/resources/static/js/JcPrinter/index_Demo.js
  4. 12
      src/main/resources/templates/pages/JcPrinter/PrinterIndex.html
  5. 1
      src/main/resources/templates/pages/warehouse/warehouseByParentId.html
  6. 4
      target/classes/static/js/JcPrinter/index_Demo.js
  7. 12
      target/classes/templates/pages/JcPrinter/PrinterIndex.html
  8. 1
      target/classes/templates/pages/warehouse/warehouseByParentId.html

52
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();
}
}
}

1
src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java

@ -260,6 +260,7 @@ public class PlaceServiceImpl implements PlaceService {
/**
* 添加物料到库位
*
* @param map
* @return
*/

4
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 打印页数

12
src/main/resources/templates/pages/JcPrinter/PrinterIndex.html

@ -12,12 +12,14 @@
<input style="display:none;" id="materialCode" th:value="${mcode}">
<input style="display:none;" id="name" th:value="${name}">
<input style="display:none;" id="version" th:value="${version}">
<!-- <div class="title">-->
<!-- <H2>刷新</H2>-->
<!-- <div><el-button @click="initSdkApi()" type="primary">SDK初始化</el-button></div>-->
<!-- </div>
<div class="title">
<H2>刷新</H2>
<div>
<el-button @click="downLoadServer()" type="primary">下载打印服务</el-button>
</div>
</div>
<br>
<br>
<br>-->
<div class="link">
<H2>打印设备</H2>
<el-row>

1
src/main/resources/templates/pages/warehouse/warehouseByParentId.html

@ -377,6 +377,5 @@
};
});
</script>
</body>
</html>

4
target/classes/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 打印页数

12
target/classes/templates/pages/JcPrinter/PrinterIndex.html

@ -12,12 +12,14 @@
<input style="display:none;" id="materialCode" th:value="${mcode}">
<input style="display:none;" id="name" th:value="${name}">
<input style="display:none;" id="version" th:value="${version}">
<!-- <div class="title">-->
<!-- <H2>刷新</H2>-->
<!-- <div><el-button @click="initSdkApi()" type="primary">SDK初始化</el-button></div>-->
<!-- </div>
<div class="title">
<H2>刷新</H2>
<div>
<el-button @click="downLoadServer()" type="primary">下载打印服务</el-button>
</div>
</div>
<br>
<br>
<br>-->
<div class="link">
<H2>打印设备</H2>
<el-row>

1
target/classes/templates/pages/warehouse/warehouseByParentId.html

@ -377,6 +377,5 @@
};
});
</script>
</body>
</html>
Loading…
Cancel
Save