代码更新
This commit is contained in:
@@ -6,6 +6,7 @@ public enum SignTaskConstants {
|
|||||||
LOGINNAME("",""),
|
LOGINNAME("",""),
|
||||||
updateAccountName("",""),
|
updateAccountName("",""),
|
||||||
DEAFULTTASKCREATOR("demo1","签署任务默认创建者"),
|
DEAFULTTASKCREATOR("demo1","签署任务默认创建者"),
|
||||||
|
SignTaskOrgName("","签署企业主体名"),
|
||||||
;
|
;
|
||||||
|
|
||||||
SignTaskConstants(String defaultValue, String description) {
|
SignTaskConstants(String defaultValue, String description) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class SignTaskCallBackController extends BaseController {
|
|||||||
String tableName = request.getParameter("tablename");
|
String tableName = request.getParameter("tablename");
|
||||||
String updatefield = request.getParameter("updatefield");
|
String updatefield = request.getParameter("updatefield");
|
||||||
String statusfield = request.getParameter("statusfield");
|
String statusfield = request.getParameter("statusfield");
|
||||||
|
String appId = request.getParameter("xId");
|
||||||
BufferedReader reader = request.getReader();
|
BufferedReader reader = request.getReader();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
@@ -50,7 +51,7 @@ public class SignTaskCallBackController extends BaseController {
|
|||||||
log.info("签署回调当前流程: " + flowId);
|
log.info("签署回调当前流程: " + flowId);
|
||||||
if(action.equals("SIGN_FLOW_COMPLETE")) {
|
if(action.equals("SIGN_FLOW_COMPLETE")) {
|
||||||
if(callbackParams.getSignFlowStatus() == 2) {
|
if(callbackParams.getSignFlowStatus() == 2) {
|
||||||
Object[] fileInfos = esignUploadFileService.getDownloadFileInfo(flowId);
|
Object[] fileInfos = esignUploadFileService.getDownloadFileInfo(appId,flowId);
|
||||||
callbackService.handleSuccessSignCallbackBiz(tableName,updatefield,statusfield,formId,fileInfos);
|
callbackService.handleSuccessSignCallbackBiz(tableName,updatefield,statusfield,formId,fileInfos);
|
||||||
}else if(callbackParams.getSignFlowStatus() == 5){
|
}else if(callbackParams.getSignFlowStatus() == 5){
|
||||||
//合同过期
|
//合同过期
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.seeyon.apps.src_signtask.job;
|
|||||||
|
|
||||||
import com.seeyon.apps.esign.po.param.JsonParamSource;
|
import com.seeyon.apps.esign.po.param.JsonParamSource;
|
||||||
import com.seeyon.apps.esign.service.ContractCreateService;
|
import com.seeyon.apps.esign.service.ContractCreateService;
|
||||||
|
import com.seeyon.apps.esign.service.TokenCacheManager;
|
||||||
import com.seeyon.apps.ext.quartz.AbstractQuartzTask;
|
import com.seeyon.apps.ext.quartz.AbstractQuartzTask;
|
||||||
import com.seeyon.apps.src_signtask.config.SignTaskConfigProvider;
|
import com.seeyon.apps.src_signtask.config.SignTaskConfigProvider;
|
||||||
import com.seeyon.apps.src_signtask.constants.SignTaskConstants;
|
import com.seeyon.apps.src_signtask.constants.SignTaskConstants;
|
||||||
@@ -22,6 +23,7 @@ public class SignTaskJob extends AbstractQuartzTask {
|
|||||||
private static final Log log = LogFactory.getLog(SignTaskJob.class);
|
private static final Log log = LogFactory.getLog(SignTaskJob.class);
|
||||||
private SignTaskConfigProvider signTaskConfigProvider = (SignTaskConfigProvider) AppContext.getBean("signTaskConfigProvider");
|
private SignTaskConfigProvider signTaskConfigProvider = (SignTaskConfigProvider) AppContext.getBean("signTaskConfigProvider");
|
||||||
private ContractCreateService contractCreateService = (ContractCreateService) AppContext.getBean("contractCreateService");
|
private ContractCreateService contractCreateService = (ContractCreateService) AppContext.getBean("contractCreateService");
|
||||||
|
private TokenCacheManager tokenCacheManager = (TokenCacheManager) AppContext.getBean("tokenCacheManager");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String taskRun(String s) throws Exception {
|
public String taskRun(String s) throws Exception {
|
||||||
@@ -60,6 +62,7 @@ public class SignTaskJob extends AbstractQuartzTask {
|
|||||||
dataMap.put("signers",fieldsMap.get("签署方配置"));
|
dataMap.put("signers",fieldsMap.get("签署方配置"));
|
||||||
JsonParamSource jsonParamSource = new JsonParamSource(dataMap);
|
JsonParamSource jsonParamSource = new JsonParamSource(dataMap);
|
||||||
jsonParamSource.setCallbackBaseUrl("/signtaskcallback.do?method=callback");
|
jsonParamSource.setCallbackBaseUrl("/signtaskcallback.do?method=callback");
|
||||||
|
jsonParamSource.setAppId(tokenCacheManager.getAppIdByOrgName(signTaskConfigProvider.getBizConfigByKey(SignTaskConstants.SignTaskOrgName)));
|
||||||
List<FormWhereCondition> updateConditions = new ArrayList<FormWhereCondition>();
|
List<FormWhereCondition> updateConditions = new ArrayList<FormWhereCondition>();
|
||||||
List<FormUpdateField> updateFields = new ArrayList<>();
|
List<FormUpdateField> updateFields = new ArrayList<>();
|
||||||
updateConditions.add(FormWhereCondition.build().display("ID").value(formColumn.getId()));
|
updateConditions.add(FormWhereCondition.build().display("ID").value(formColumn.getId()));
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package com.seeyon.apps.src_signtask.service;
|
package com.seeyon.apps.src_signtask.service;
|
||||||
|
|
||||||
import com.seeyon.ctp.common.AppContext;
|
import com.seeyon.ctp.common.AppContext;
|
||||||
|
import com.seeyon.ctp.common.file.model.CtpFile;
|
||||||
import com.seeyon.ctp.common.filemanager.manager.AttachmentManager;
|
import com.seeyon.ctp.common.filemanager.manager.AttachmentManager;
|
||||||
import com.seeyon.ctp.common.filemanager.manager.FileManager;
|
import com.seeyon.ctp.common.filemanager.manager.FileManager;
|
||||||
import com.seeyon.ctp.common.po.filemanager.Attachment;
|
import com.seeyon.ctp.common.po.filemanager.Attachment;
|
||||||
|
import org.springframework.core.io.FileSystemResource;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@@ -16,33 +22,90 @@ public class FileHandlerService {
|
|||||||
|
|
||||||
private AttachmentManager attachmentManager = (AttachmentManager) AppContext.getBean("attachmentManager");
|
private AttachmentManager attachmentManager = (AttachmentManager) AppContext.getBean("attachmentManager");
|
||||||
private FileManager fileManager = (FileManager) AppContext.getBean("fileManager");
|
private FileManager fileManager = (FileManager) AppContext.getBean("fileManager");
|
||||||
|
private static final String TEMP_DIR = System.getProperty("java.io.tmpdir") + File.separator + "seeyontempfile";
|
||||||
|
|
||||||
public void handleFile(String refId, HttpServletResponse response) throws Exception {
|
public void handleFile(String refId, HttpServletResponse response) throws Exception {
|
||||||
File file = null;
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
Attachment attachment = attachmentManager.getAttachmentByFileURL(Long.valueOf(refId));
|
Attachment attachment = attachmentManager.getAttachmentByFileURL(Long.valueOf(refId));
|
||||||
InputStream inputStream = fileManager.getFileInputStream(attachment.getFileUrl());
|
inputStream = fileManager.getFileInputStream(attachment.getFileUrl());
|
||||||
|
|
||||||
|
// ⭐ 关键:重置
|
||||||
|
response.reset();
|
||||||
|
|
||||||
|
// ⭐ 必须设置类型
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
|
||||||
|
// ⭐ 文件名处理
|
||||||
String encodedFileName = URLEncoder.encode(attachment.getFilename(), "UTF-8")
|
String encodedFileName = URLEncoder.encode(attachment.getFilename(), "UTF-8")
|
||||||
.replaceAll("\\+", "%20");
|
.replaceAll("\\+", "%20");
|
||||||
|
|
||||||
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
response.setHeader(
|
response.setHeader(
|
||||||
"Content-Disposition",
|
"Content-Disposition",
|
||||||
"attachment; filename=\"" + attachment.getFilename() + "\"; " +
|
"attachment; filename=\"" + attachment.getFilename() + "\"; filename*=UTF-8''" + encodedFileName
|
||||||
"filename*=UTF-8''" + encodedFileName
|
|
||||||
);
|
);
|
||||||
try (OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
|
|
||||||
byte[] buffer = new byte[2048];
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
||||||
outputStream.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
outputStream.flush();
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
|
// ⭐ 输出流
|
||||||
|
OutputStream outputStream = response.getOutputStream();
|
||||||
|
|
||||||
|
byte[] buffer = new byte[2048];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
while ((len = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, len);
|
||||||
}
|
}
|
||||||
}finally {
|
|
||||||
if(file != null) {
|
outputStream.flush();
|
||||||
file.delete();
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace(); // ❗不要吞异常
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (inputStream != null) inputStream.close();
|
||||||
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public ResponseEntity<Resource> downloadFileStream(String refId) {
|
||||||
|
// InputStream inputStream = null;
|
||||||
|
// OutputStream ops = null;
|
||||||
|
// try {
|
||||||
|
// Attachment attachment = attachmentManager.getAttachmentByFileURL(Long.valueOf(refId));
|
||||||
|
// inputStream = fileManager.getFileInputStream(attachment.getFileUrl());
|
||||||
|
// //下载到本地临时文件夹
|
||||||
|
// // 创建输出流,将文件保存到本地
|
||||||
|
// ops = new FileOutputStream(TEMP_DIR);
|
||||||
|
// // 设置缓冲区
|
||||||
|
// byte[] buffer = new byte[4096];
|
||||||
|
// int bytesRead;
|
||||||
|
// while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
// ops.write(buffer, 0, bytesRead);
|
||||||
|
// }
|
||||||
|
// ops.flush();
|
||||||
|
// ops.close();
|
||||||
|
// File file = new File(TEMP_DIR);
|
||||||
|
// if (!file.exists()) {
|
||||||
|
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||||
|
// }
|
||||||
|
// // 封装文件为资源对象
|
||||||
|
// Resource resource = new FileSystemResource(file);
|
||||||
|
// String fileName = attachment.getFilename();
|
||||||
|
// // 设置响应头
|
||||||
|
// String encodeName = URLEncoder.encode(fileName, "UTF-8");
|
||||||
|
// String header = "attachment;filename=" + encodeName;
|
||||||
|
// return ResponseEntity.ok()
|
||||||
|
// .header(HttpHeaders.CONTENT_DISPOSITION, header)
|
||||||
|
// .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
|
||||||
|
// .body(resource);
|
||||||
|
//
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// e.printStackTrace(); // ❗不要吞异常
|
||||||
|
// } finally {
|
||||||
|
// try {
|
||||||
|
// if (inputStream != null) inputStream.close();
|
||||||
|
// } catch (Exception ignored) {}
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user