|
@@ -4,11 +4,16 @@ import cn.hutool.extra.spring.SpringUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.jeeplus.common.redis.RedisUtils;
|
|
import com.jeeplus.common.redis.RedisUtils;
|
|
import com.jeeplus.common.utils.ResponseUtil;
|
|
import com.jeeplus.common.utils.ResponseUtil;
|
|
|
|
+import com.jeeplus.finance.invoice.util.SignaturePostUtil;
|
|
import com.jeeplus.finance.projectReport.domain.PresignCallBack;
|
|
import com.jeeplus.finance.projectReport.domain.PresignCallBack;
|
|
|
|
+import com.jeeplus.finance.signatureDaily.mapper.SignatureDailyOfficeWorkMapper;
|
|
import com.jeeplus.finance.signatureDaily.mapper.SignatureProjectReportMapper;
|
|
import com.jeeplus.finance.signatureDaily.mapper.SignatureProjectReportMapper;
|
|
import com.jeeplus.finance.signatureDaily.service.SignatureProjectReportService;
|
|
import com.jeeplus.finance.signatureDaily.service.SignatureProjectReportService;
|
|
import com.jeeplus.finance.signatureDaily.service.dto.SignatureProjectReportRelationDTO;
|
|
import com.jeeplus.finance.signatureDaily.service.dto.SignatureProjectReportRelationDTO;
|
|
|
|
+import com.jeeplus.finance.utils.Global;
|
|
|
|
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
|
|
import com.jeeplus.sys.feign.IUserApi;
|
|
import com.jeeplus.sys.feign.IUserApi;
|
|
|
|
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.utils.StringUtils;
|
|
import com.jeeplus.utils.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -16,15 +21,19 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.util.Date;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileInputStream;
|
|
|
|
+import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -37,6 +46,9 @@ import java.util.concurrent.TimeUnit;
|
|
public class DailyReportSignatureCallBackController {
|
|
public class DailyReportSignatureCallBackController {
|
|
private static Logger logger = LoggerFactory.getLogger(ResponseUtil.class);
|
|
private static Logger logger = LoggerFactory.getLogger(ResponseUtil.class);
|
|
|
|
|
|
|
|
+ private static final String DIRECTORY = Global.getConfig("directory");
|
|
|
|
+
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private SignatureProjectReportService signatureProjectReportService;
|
|
private SignatureProjectReportService signatureProjectReportService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -45,6 +57,9 @@ public class DailyReportSignatureCallBackController {
|
|
private SignatureProjectReportMapper signatureProjectReportMapper;
|
|
private SignatureProjectReportMapper signatureProjectReportMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private SignatureDailyOfficeWorkMapper signatureDailyOfficeWorkMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
// private final DailyOfficeWorkDao dailyOfficeWorkDao = SpringContextHolder.getBean(DailyOfficeWorkDao.class);
|
|
// private final DailyOfficeWorkDao dailyOfficeWorkDao = SpringContextHolder.getBean(DailyOfficeWorkDao.class);
|
|
@@ -92,7 +107,8 @@ public class DailyReportSignatureCallBackController {
|
|
String signatureUrl = null;
|
|
String signatureUrl = null;
|
|
if(StringUtils.isNotBlank(presignCallBack.getStoragePath())){
|
|
if(StringUtils.isNotBlank(presignCallBack.getStoragePath())){
|
|
signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
|
|
signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
|
|
-
|
|
|
|
|
|
+ //必须得再进行一次替换,否则无法下载到本地
|
|
|
|
+ signatureUrl = signatureUrl.replace("/xg-qz","");
|
|
dailyOfficeWork.setSignatureUrl(signatureUrl);
|
|
dailyOfficeWork.setSignatureUrl(signatureUrl);
|
|
dailyOfficeWork.setSignatureUrlFlag(1);
|
|
dailyOfficeWork.setSignatureUrlFlag(1);
|
|
|
|
|
|
@@ -113,6 +129,155 @@ public class DailyReportSignatureCallBackController {
|
|
//修改签章对应信息文件
|
|
//修改签章对应信息文件
|
|
signatureProjectReportMapper.updateSignatureInfo(dailyOfficeWork);
|
|
signatureProjectReportMapper.updateSignatureInfo(dailyOfficeWork);
|
|
|
|
|
|
|
|
+ UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getById (dailyOfficeWork.getCreateById());
|
|
|
|
+ //将文件下载并对原有文件地址进行替换
|
|
|
|
+ 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 = "http://cdn.gangwaninfo.com";
|
|
|
|
+ String aliDownloadUrl = "http://oss.gangwaninfo.com";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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];
|
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).downQzByStreamSaveLocal(ossKey,fileName,path+fileName);
|
|
|
|
+// 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();
|
|
|
|
+
|
|
|
|
+ if(null != unZipFileList && unZipFileList.length>0){
|
|
|
|
+ for (File f : unZipFileList) {
|
|
|
|
+ String filepath = "";
|
|
|
|
+ //取得上传文件
|
|
|
|
+ //将文件上传到oss云盘中
|
|
|
|
+ MultipartFile cMultiFile = new MockMultipartFile("file", f.getName(), null, new FileInputStream(f));
|
|
|
|
+ if (!cMultiFile.isEmpty()) {
|
|
|
|
+ // 文件保存路径
|
|
|
|
+ String realPath =DIRECTORY.replace("/","")+"/cw_signature_report_file"+SpringUtil.getBean ( IWorkAttachmentApi.class ).datePath()+"/"+ System.currentTimeMillis();
|
|
|
|
+ //文件原名称
|
|
|
|
+ String newName = cMultiFile.getOriginalFilename();
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isNotBlank(newName)){
|
|
|
|
+ newName = newName.substring(13, newName.length());
|
|
|
|
+ //SpringUtil.getBean ( IWorkAttachmentApi.class ).uploadFile2OSS(cMultiFile.getInputStream(),realPath,newName);
|
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).uploadFileSignatureOSS(f.getPath(),realPath,newName);
|
|
|
|
+ filepath = "/" + realPath + newName;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println(f.getName());
|
|
|
|
+ //截取文件后缀名
|
|
|
|
+ String substring = f.getName().substring(f.getName().lastIndexOf(".")+1, f.getName().length());
|
|
|
|
+
|
|
|
|
+ String newFileName = f.getName().substring(13, f.getName().length());
|
|
|
|
+
|
|
|
|
+ //将签章完成的附件进行保存到附件表中
|
|
|
|
+ WorkAttachmentInfo workattachment = new WorkAttachmentInfo();
|
|
|
|
+ workattachment.setDelFlag(0);
|
|
|
|
+ workattachment.setUrl(filepath);
|
|
|
|
+ workattachment.setType(substring);
|
|
|
|
+ workattachment.setAttachmentName(newFileName);
|
|
|
|
+ workattachment.setAttachmentFlag("signatured_report");
|
|
|
|
+ workattachment.setFileSize(String.valueOf(f.length()));
|
|
|
|
+ workattachment.setAttachmentId(dailyOfficeWork.getId());
|
|
|
|
+ workattachment.setAttachmentType("");
|
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
+ workattachment.setId(id);
|
|
|
|
+ workattachment.setCreateTime(new Date());
|
|
|
|
+ workattachment.setUpdateTime(new Date());
|
|
|
|
+ //先查询数据库中是否已经对数据进行保存
|
|
|
|
+ //若未保存,则进行保存,否则直接跳过
|
|
|
|
+ List<WorkAttachmentInfo> byAttachmentIdAndUrl = SpringUtil.getBean ( IWorkAttachmentApi.class ).getByAttachmentIdAndUrlAndAttachmentFlag(workattachment);
|
|
|
|
+ if(byAttachmentIdAndUrl.size() == 0){
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+ String workAttachment = JSON.toJSONString((workattachment));
|
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
|
+// ossServiceMapper.insert(workattachment);
|
|
|
|
+
|
|
|
|
+ //将附件信息添加到签章附件信息表中
|
|
|
|
+// CwSignatureDailyFile cwSignatureDailyFile = new CwSignatureDailyFile();
|
|
|
|
+// cwSignatureDailyFile.setDelFlag(0);
|
|
|
|
+// cwSignatureDailyFile.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+// cwSignatureDailyFile.setCreateById(dailyOfficeWork.getCreateById());
|
|
|
|
+// cwSignatureDailyFile.setUpdateById(dailyOfficeWork.getCreateById());
|
|
|
|
+// cwSignatureDailyFile.setCreateTime(new Date());
|
|
|
|
+// cwSignatureDailyFile.setUpdateTime(new Date());
|
|
|
|
+// cwSignatureDailyFile.setReportFileId(id);
|
|
|
|
+// cwSignatureDailyFile.setFileAffiliation("1");
|
|
|
|
+// signatureDailyOfficeWorkMapper.insertFile(cwSignatureDailyFile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //遍历该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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //将报告数据中的盖章状态更改为已盖章
|
|
|
|
+ //cwProjectReportService.updateReportSealType(projectReportData);
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isNotBlank(deleteFile)){
|
|
|
|
+ //根据路径创建文件对象
|
|
|
|
+ File file = new File(deleteFile);
|
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ File file = new File(unzipFileStr);
|
|
|
|
+ deleteFile(file);
|
|
|
|
+ }
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -144,4 +309,31 @@ public class DailyReportSignatureCallBackController {
|
|
}
|
|
}
|
|
return null;
|
|
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;
|
|
|
|
+ }
|
|
}
|
|
}
|