|
@@ -11,6 +11,7 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -110,6 +111,8 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
bpmProcess.setCreateTime(DateUtils.getNowDate());
|
|
|
bpmProcess.setCreateBy(SecurityUtils.getUsername());
|
|
|
bpmProcess.setProcessVersion(0L);
|
|
|
+ bpmProcess.setProcessType(0L);
|
|
|
+ bpmProcess.setStartEventType(0L);
|
|
|
return bpmProcessMapper.insertBpmProcess(bpmProcess);
|
|
|
}
|
|
|
|
|
@@ -197,16 +200,19 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
|
|
|
List<BpmProcess> bpmProcessList = bpmProcessMapper.selectBpmProcessByProcessIds(processIds);
|
|
|
String localPath = RuoYiConfig.getProfile();
|
|
|
- List<String> list = bpmProcessList.stream().map(m ->localPath + StringUtils.substringAfter(m.getProcessXmlPath(), Constants.RESOURCE_PREFIX)).collect(Collectors.toList());
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(list)){
|
|
|
+// List<String> list = bpmProcessList.stream().map(m ->localPath + StringUtils.substringAfter(m.getProcessXmlPath(), Constants.RESOURCE_PREFIX)).collect(Collectors.toList());
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ bpmProcessList.forEach(item -> {
|
|
|
+ list.add(localPath.substring(0, localPath.length() - 1) + StringUtils.substringAfter(item.getProcessXmlPath(), Constants.RESOURCE_PREFIX));
|
|
|
+ });
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
throw new Exception("请选择要下载文件/图片");
|
|
|
}
|
|
|
-
|
|
|
//设置响应头信息
|
|
|
response.reset();
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
response.setContentType("multipart/form-data");
|
|
|
+ response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
//设置压缩包的名字,date为时间戳
|
|
|
String date = String.valueOf(System.currentTimeMillis());
|
|
|
String downloadName = "压缩包" + date + ".zip";
|
|
@@ -221,18 +227,18 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
downloadName = new String(downloadName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ System.err.println(e);
|
|
|
log.error("系统异常", e);
|
|
|
}
|
|
|
|
|
|
- if (list.size()>1){
|
|
|
- //多文件/图压缩下载
|
|
|
- batchFileDownLoad(list,downloadName,response);
|
|
|
-
|
|
|
- }else {
|
|
|
- //单文件/图直接下载
|
|
|
- singleFileDownLoad(list,bpmProcessList.get(0).getProcessName(),response);
|
|
|
-
|
|
|
- }
|
|
|
+// if (list.size()>1){
|
|
|
+ //多文件/图压缩下载
|
|
|
+ batchFileDownLoad(list, downloadName, response);
|
|
|
+// }else {
|
|
|
+// //单文件/图直接下载
|
|
|
+// singleFileDownLoad(list,bpmProcessList.get(0).getProcessName(),response);
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -254,7 +260,7 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
//文件存储路径
|
|
|
String path = t;
|
|
|
//压缩文件中每个文件的文件名称
|
|
|
- String name = t.substring(t.lastIndexOf("\\")+1);
|
|
|
+ String name = t.substring(t.lastIndexOf("\\") + 1);
|
|
|
log.info("batchDownloadFile:[filePath:{}]", path);
|
|
|
File file = new File(path);
|
|
|
if (!file.exists()) {
|
|
@@ -263,7 +269,7 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
FileInputStream fs = null;
|
|
|
try {
|
|
|
//添加ZipEntry,并将ZipEntry中写入文件流
|
|
|
- zipOs.putNextEntry(new ZipEntry(name));
|
|
|
+ zipOs.putNextEntry(new ZipEntry(URLEncoder.encode(name, StandardCharsets.UTF_8.toString()) + ".bpmn"));
|
|
|
os = new DataOutputStream(zipOs);
|
|
|
fs = new FileInputStream(file);
|
|
|
byte[] b = new byte[100];
|
|
@@ -305,27 +311,28 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
|
|
|
/**
|
|
|
* 单文件直接下载
|
|
|
- * @param list 文件/图片路径
|
|
|
+ *
|
|
|
+ * @param list 文件/图片路径
|
|
|
* @param response
|
|
|
*/
|
|
|
- private void singleFileDownLoad(List<String> list,String processName, HttpServletResponse response) throws UnsupportedEncodingException {
|
|
|
+ private void singleFileDownLoad(List<String> list, String processName, HttpServletResponse response) throws UnsupportedEncodingException {
|
|
|
|
|
|
FileInputStream fis = null;
|
|
|
OutputStream out = null;
|
|
|
String path = list.get(0);
|
|
|
- String name = path.substring(path.lastIndexOf("\\")+1);
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(processName, StandardCharsets.UTF_8.toString())+".bpmn");
|
|
|
+ String name = path.substring(path.lastIndexOf("\\") + 1);
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(processName, StandardCharsets.UTF_8.toString()) + ".bpmn");
|
|
|
try {
|
|
|
fis = new FileInputStream(path);
|
|
|
out = response.getOutputStream();
|
|
|
byte[] b = new byte[1024];
|
|
|
int len = 0;
|
|
|
- while((len = fis.read(b))!=-1){
|
|
|
+ while ((len = fis.read(b)) != -1) {
|
|
|
out.write(b, 0, len);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
try {
|
|
|
if (out != null) {
|
|
|
out.flush();
|