|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.google.gson.reflect.TypeToken;
|
|
@@ -19,8 +20,12 @@ import com.jeeplus.test.cw.projectReport.domain.CwProjectReport;
|
|
import com.jeeplus.test.cw.projectReport.domain.CwProjectReportData;
|
|
import com.jeeplus.test.cw.projectReport.domain.CwProjectReportData;
|
|
import com.jeeplus.test.cw.projectReport.domain.CwProjectReportSignature;
|
|
import com.jeeplus.test.cw.projectReport.domain.CwProjectReportSignature;
|
|
import com.jeeplus.test.cw.projectReport.mapper.CwProjectReportSignatureMapper;
|
|
import com.jeeplus.test.cw.projectReport.mapper.CwProjectReportSignatureMapper;
|
|
|
|
+import com.jeeplus.test.cw.projectReport.mapper.ProjectReportWorkAttachmentMapper;
|
|
import com.jeeplus.test.cw.projectReport.service.CwProjectReportService;
|
|
import com.jeeplus.test.cw.projectReport.service.CwProjectReportService;
|
|
|
|
+import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
|
|
+import com.jeeplus.test.oss.service.OSSClientService;
|
|
import com.jeeplus.test.signature.domain.PresignCallBack;
|
|
import com.jeeplus.test.signature.domain.PresignCallBack;
|
|
|
|
+import com.jeeplus.test.signature.utils.SignaturePostUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.flowable.engine.TaskService;
|
|
import org.flowable.engine.TaskService;
|
|
import org.flowable.task.api.Task;
|
|
import org.flowable.task.api.Task;
|
|
@@ -30,7 +35,12 @@ import org.springframework.http.ResponseEntity;
|
|
import org.springframework.security.core.userdetails.User;
|
|
import org.springframework.security.core.userdetails.User;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.*;
|
|
import java.lang.reflect.Type;
|
|
import java.lang.reflect.Type;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@@ -44,8 +54,14 @@ import java.util.*;
|
|
public class CwProjectReportSignatureCallBackController {
|
|
public class CwProjectReportSignatureCallBackController {
|
|
|
|
|
|
|
|
|
|
|
|
+ private static final String DIRECTORY = "/attachment-file";
|
|
|
|
+
|
|
|
|
+ private static final String ALIYUNURL = "http://oss.gangwaninfo.com";
|
|
|
|
+
|
|
private CwProjectReportService cwProjectReportService = SpringContextHolder.getBean(CwProjectReportService.class);
|
|
private CwProjectReportService cwProjectReportService = SpringContextHolder.getBean(CwProjectReportService.class);
|
|
|
|
+ private OSSClientService ossClientService = SpringContextHolder.getBean(OSSClientService.class);
|
|
private CwProjectReportSignatureMapper cwProjectReportSignatureMapper = SpringContextHolder.getBean(CwProjectReportSignatureMapper.class);
|
|
private CwProjectReportSignatureMapper cwProjectReportSignatureMapper = SpringContextHolder.getBean(CwProjectReportSignatureMapper.class);
|
|
|
|
+ private ProjectReportWorkAttachmentMapper attachmentMapper = SpringContextHolder.getBean(ProjectReportWorkAttachmentMapper.class);
|
|
|
|
|
|
private static final String HTTPTOP = Global.getConfig("signature_http_top");
|
|
private static final String HTTPTOP = Global.getConfig("signature_http_top");
|
|
|
|
|
|
@@ -67,7 +83,7 @@ public class CwProjectReportSignatureCallBackController {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "/getApprovalCallBackCoordinates", method= RequestMethod.POST)
|
|
@RequestMapping(value = "/getApprovalCallBackCoordinates", method= RequestMethod.POST)
|
|
- public String getApprovalCallBackCoordinates(PresignCallBack presignCallBack) throws Exception {
|
|
|
|
|
|
+ public String getApprovalCallBackCoordinates(PresignCallBack presignCallBack, HttpServletResponse response) throws Exception {
|
|
// 在redis中取回流程审核所需的参数
|
|
// 在redis中取回流程审核所需的参数
|
|
CommitParamDTO<CwProjectReportData> commitParamDTO = (CommitParamDTO<CwProjectReportData>)redisUtils.get("cw_report_signature_" + presignCallBack.getContractId());
|
|
CommitParamDTO<CwProjectReportData> commitParamDTO = (CommitParamDTO<CwProjectReportData>)redisUtils.get("cw_report_signature_" + presignCallBack.getContractId());
|
|
// 将取回的数据转换为审核通过所需要的参数
|
|
// 将取回的数据转换为审核通过所需要的参数
|
|
@@ -143,10 +159,255 @@ public class CwProjectReportSignatureCallBackController {
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- @PostMapping(value = "/aaa")
|
|
|
|
- public ResponseEntity<String> updateSignatureStatusById() {
|
|
|
|
- String s = "projectReportService.updateSignatureStatusById(data);";
|
|
|
|
- return ResponseEntity.ok(s);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "/getApprovalCallBackAccomplish", method= RequestMethod.POST)
|
|
|
|
+ public String getApprovalCallBackAccomplish(PresignCallBack presignCallBack, HttpServletResponse response) {
|
|
|
|
+// //根据contractId查询对应的报告信息
|
|
|
|
+ CwProjectReportData projectReportData = cwProjectReportService.queryByContractId(presignCallBack.getContractId());
|
|
|
|
+ //对文件回调路径进行处理并保存
|
|
|
|
+ String signatureUrl = null;
|
|
|
|
+ if(StringUtils.isNotBlank(presignCallBack.getStoragePath())){
|
|
|
|
+ signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
|
|
|
|
+ signatureUrl = signatureUrl.replace("/xg-qz","");
|
|
|
|
+ projectReportData.setSignatureUrl(signatureUrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //将签章完成地址保存到数据库对应报告信息中
|
|
|
|
+ cwProjectReportService.updateSignatureUrl(projectReportData);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //将文件下载并对原有文件地址进行替换
|
|
|
|
+ String deleteFile = null;
|
|
|
|
+ String unzipFileStr = null;
|
|
|
|
+ try{
|
|
|
|
+ String path = null;
|
|
|
|
+ if(System.getProperty("os.name").toLowerCase().contains("win")){
|
|
|
|
+ path = "D:/attachment-file/";
|
|
|
|
+ }else{
|
|
|
|
+ path = "/attachment-file/";
|
|
|
|
+ }
|
|
|
|
+ String aliyunUrl = Global.getAliyunUrl();
|
|
|
|
+ String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String file = aliyunUrl + signatureUrl;
|
|
|
|
+ file = file.replace("amp;","");
|
|
|
|
+ String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
|
+ String cons = "";
|
|
|
|
+ if (file.contains(aliyunUrl)){
|
|
|
|
+ cons = aliyunUrl;
|
|
|
|
+ }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
|
|
|
|
+ cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
|
+ }else {
|
|
|
|
+ cons = aliDownloadUrl;
|
|
|
|
+ }
|
|
|
|
+ String ossKey = file.split(cons+"/")[1];
|
|
|
|
+ ossClientService.downQzByStreamSaveLocal(ossKey,fileName,path+fileName);
|
|
|
|
+ //将下载下来的文件转换为file文件
|
|
|
|
+ File srcFile = new File(path+fileName);
|
|
|
|
+ deleteFile = path+fileName;
|
|
|
|
+
|
|
|
|
+ //截取文件名称
|
|
|
|
+ String srcFileName = srcFile.getName().substring(0,srcFile.getName().lastIndexOf("."));
|
|
|
|
+
|
|
|
|
+ //解压后文件地址
|
|
|
|
+ unzipFileStr = path + srcFileName;
|
|
|
|
+
|
|
|
|
+ //将下载后的文件进行解压
|
|
|
|
+ SignaturePostUtil.unZipFile(srcFile,unzipFileStr);
|
|
|
|
+
|
|
|
|
+ //遍历解压后文件夹中的所有文件信息
|
|
|
|
+ File unZipFile = new File(unzipFileStr);
|
|
|
|
+
|
|
|
|
+ File[] unZipFileList = unZipFile.listFiles();
|
|
|
|
+
|
|
|
|
+ for (File f : unZipFileList) {
|
|
|
|
+ String filepath = "";
|
|
|
|
+ //取得上传文件
|
|
|
|
+ //将文件上传到oss云盘中
|
|
|
|
+ MultipartFile cMultiFile = new MockMultipartFile("file", f.getName(), null, new FileInputStream(f));
|
|
|
|
+ if (cMultiFile != null && !cMultiFile.isEmpty()) {
|
|
|
|
+ // 文件保存路径
|
|
|
|
+ String realPath =DIRECTORY.replace("/","")+"/cw_project_report_file"+ossClientService.datePath()+"/"+ System.currentTimeMillis();
|
|
|
|
+ //文件原名称
|
|
|
|
+ String newName = cMultiFile.getOriginalFilename();
|
|
|
|
+ newName = newName.substring(13, newName.length());
|
|
|
|
+ ossClientService.uploadFile2OSS(cMultiFile.getInputStream(),realPath,newName);
|
|
|
|
+ filepath = "/" + realPath + newName;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println(f.getName());
|
|
|
|
+ //截取文件后缀名
|
|
|
|
+ String substring = f.getName().substring(f.getName().lastIndexOf(".")+1, f.getName().length());
|
|
|
|
+ //遍历该contractId对应的报告信息,将报告信息中的附件地址进行替换
|
|
|
|
+
|
|
|
|
+ //查询报告文件信息(电子章)
|
|
|
|
+ List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(projectReportData.getId());
|
|
|
|
+ if(fileList.size()>0){
|
|
|
|
+ for (WorkAttachment workattachment : fileList) {
|
|
|
|
+ //根据url截取文件名成
|
|
|
|
+ String workattachmentName = workattachment.getUrl().substring(workattachment.getUrl().lastIndexOf("/")+1, workattachment.getUrl().length());
|
|
|
|
+
|
|
|
|
+ if(f.getName().contains(workattachmentName)){
|
|
|
|
+ workattachment.setUrl(filepath);
|
|
|
|
+ workattachment.setType(substring);
|
|
|
|
+ workattachment.setAttachmentName(f.getName());
|
|
|
|
+ attachmentMapper.updateByIdOnSignature(workattachment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+ if(StringUtils.isNotBlank(deleteFile)){
|
|
|
|
+ //根据路径创建文件对象
|
|
|
|
+ File file = new File(deleteFile);
|
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ File file = new File(unzipFileStr);
|
|
|
|
+ deleteFile(file);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "/download", method= RequestMethod.POST)
|
|
|
|
+ public String download(String signatureUrl) {
|
|
|
|
+// //根据contractId查询对应的报告信息
|
|
|
|
+ CwProjectReportData projectReportData = cwProjectReportService.queryByContractId("3032604994397941821");
|
|
|
|
+
|
|
|
|
+ //将文件下载并对原有文件地址进行替换
|
|
|
|
+ String deleteFile = null;
|
|
|
|
+ String unzipFileStr = null;
|
|
|
|
+ try{
|
|
|
|
+ String path = null;
|
|
|
|
+ if(System.getProperty("os.name").toLowerCase().contains("win")){
|
|
|
|
+ path = "D:/attachment-file/";
|
|
|
|
+ }else{
|
|
|
|
+ path = "/attachment-file/";
|
|
|
|
+ }
|
|
|
|
+ String aliyunUrl = Global.getAliyunUrl();
|
|
|
|
+ String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String file = aliyunUrl + signatureUrl;
|
|
|
|
+ file = file.replace("amp;","");
|
|
|
|
+ String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
|
+ String cons = "";
|
|
|
|
+ if (file.contains(aliyunUrl)){
|
|
|
|
+ cons = aliyunUrl;
|
|
|
|
+ }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
|
|
|
|
+ cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
|
+ }else {
|
|
|
|
+ cons = aliDownloadUrl;
|
|
|
|
+ }
|
|
|
|
+ String ossKey = file.split(cons+"/")[1];
|
|
|
|
+ ossClientService.downQzByStreamSaveLocal(ossKey,fileName,path+fileName);
|
|
|
|
+ //将下载下来的文件转换为file文件
|
|
|
|
+ File srcFile = new File(path+fileName);
|
|
|
|
+ deleteFile = path+fileName;
|
|
|
|
+
|
|
|
|
+ //截取文件名称
|
|
|
|
+ String srcFileName = srcFile.getName().substring(0,srcFile.getName().lastIndexOf("."));
|
|
|
|
+
|
|
|
|
+ //解压后文件地址
|
|
|
|
+ unzipFileStr = path + srcFileName;
|
|
|
|
+
|
|
|
|
+ //将下载后的文件进行解压
|
|
|
|
+ SignaturePostUtil.unZipFile(srcFile,unzipFileStr);
|
|
|
|
+
|
|
|
|
+ //遍历解压后文件夹中的所有文件信息
|
|
|
|
+ File unZipFile = new File(unzipFileStr);
|
|
|
|
+
|
|
|
|
+ File[] unZipFileList = unZipFile.listFiles();
|
|
|
|
+
|
|
|
|
+ for (File f : unZipFileList) {
|
|
|
|
+ String filepath = "";
|
|
|
|
+ //取得上传文件
|
|
|
|
+ //将文件上传到oss云盘中
|
|
|
|
+ MultipartFile cMultiFile = new MockMultipartFile("file", f.getName(), null, new FileInputStream(f));
|
|
|
|
+ if (cMultiFile != null && !cMultiFile.isEmpty()) {
|
|
|
|
+ // 文件保存路径
|
|
|
|
+ String realPath =DIRECTORY.replace("/","")+"/cw_project_report_file"+ossClientService.datePath()+"/"+ System.currentTimeMillis();
|
|
|
|
+ //文件原名称
|
|
|
|
+ String newName = cMultiFile.getOriginalFilename();
|
|
|
|
+ newName = newName.substring(13, newName.length());
|
|
|
|
+ ossClientService.uploadFile2OSS(cMultiFile.getInputStream(),realPath,newName);
|
|
|
|
+ filepath = "/" + realPath + newName;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println(f.getName());
|
|
|
|
+ //截取文件后缀名
|
|
|
|
+ String substring = f.getName().substring(f.getName().lastIndexOf(".")+1, f.getName().length());
|
|
|
|
+ //遍历该contractId对应的报告信息,将报告信息中的附件地址进行替换
|
|
|
|
+
|
|
|
|
+ //查询报告文件信息(电子章)
|
|
|
|
+ List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(projectReportData.getId());
|
|
|
|
+ if(fileList.size()>0){
|
|
|
|
+ for (WorkAttachment workattachment : fileList) {
|
|
|
|
+ //根据url截取文件名成
|
|
|
|
+ String workattachmentName = workattachment.getUrl().substring(workattachment.getUrl().lastIndexOf("/")+1, workattachment.getUrl().length());
|
|
|
|
+
|
|
|
|
+ if(f.getName().contains(workattachmentName)){
|
|
|
|
+ workattachment.setUrl(filepath);
|
|
|
|
+ workattachment.setType(substring);
|
|
|
|
+ workattachment.setAttachmentName(f.getName());
|
|
|
|
+ attachmentMapper.updateByIdOnSignature(workattachment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+ if(StringUtils.isNotBlank(deleteFile)){
|
|
|
|
+ //根据路径创建文件对象
|
|
|
|
+ File file = new File(deleteFile);
|
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ File file = new File(unzipFileStr);
|
|
|
|
+ deleteFile(file);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static Boolean deleteFile(File file) {
|
|
|
|
+ //判断文件不为null或文件目录存在
|
|
|
|
+ if (file == null || !file.exists()) {
|
|
|
|
+ System.out.println("文件删除失败,请检查文件是否存在以及文件路径是否正确");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ //获取目录下子文件
|
|
|
|
+ File[] files = file.listFiles();
|
|
|
|
+ //遍历该目录下的文件对象
|
|
|
|
+ for (File f : files) {
|
|
|
|
+ //判断子目录是否存在子目录,如果是文件则删除
|
|
|
|
+ if (f.isDirectory()) {
|
|
|
|
+ //递归删除目录下的文件
|
|
|
|
+ deleteFile(f);
|
|
|
|
+ } else {
|
|
|
|
+ //文件删除
|
|
|
|
+ f.delete();
|
|
|
|
+ //打印文件名
|
|
|
|
+ System.out.println("文件名:" + f.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //文件夹删除
|
|
|
|
+ file.delete();
|
|
|
|
+ System.out.println("目录名:" + file.getName());
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|