Parcourir la source

签章文件保存到文档目录

user5 il y a 3 ans
Parent
commit
b30883776a

+ 31 - 0
src/main/java/com/jeeplus/common/oss/OSSClientUtil.java

@@ -873,4 +873,35 @@ public class OSSClientUtil {
         }
         return simplifiedObjectMeta.getSize();
     }
+
+    /**
+     * 阿里云获取临时文件大小
+     * @param file
+     */
+    public Long getQzSimplifiedObjectMeta(String file){
+        URL url = null;
+        SimplifiedObjectMeta simplifiedObjectMeta = new SimplifiedObjectMeta();
+        try {
+
+            file = file.replace("amp;","");
+            String aliyunUrl = Global.getAliyunUrl();
+            String aliDownloadUrl = Global.getAliDownloadUrl();
+            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 key = file.split(cons+"/")[1];
+            simplifiedObjectMeta = ossClient.getSimplifiedObjectMeta(qzBucketName, key);
+            System.out.println(simplifiedObjectMeta.getSize());
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+        return simplifiedObjectMeta.getSize();
+    }
 }

+ 71 - 2
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectSignatureCallBackController.java

@@ -14,9 +14,11 @@ import com.jeeplus.modules.ruralprojectrecords.enums.ProjectStatusEnum;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectMessageElectronicSealService;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
 import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.service.WorkattachmentService;
 import com.jeeplus.modules.sys.utils.UserUtils;
 import com.jeeplus.modules.tools.utils.SignaturePostUtil;
 import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
 import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
 import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
 import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
@@ -44,6 +46,8 @@ public class RuralProjectSignatureCallBackController extends BaseController {
     protected HistoryService historyService;
     @Autowired
     private RuralProjectMessageElectronicSealService ruralProjectMessageElectronicSealService;
+    @Autowired
+    private WorkattachmentService workattachmentService;
 
     private ProjectReportDataDao projectReportDataDao = SpringContextHolder.getBean(ProjectReportDataDao.class);
 
@@ -153,8 +157,9 @@ public class RuralProjectSignatureCallBackController extends BaseController {
         projectReportData.setSignatureContractId(presignCallBack.getContractId());
         projectReportData.setSignatureUploadDate(new Date());
         //对文件回调路径进行处理并保存
+        String signatureUrl = null;
         if(StringUtils.isNotBlank(presignCallBack.getStoragePath())){
-            String signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
+            signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
             projectReportData.setSignatureUrl(signatureUrl);
         }
         //修改签章对应信息文件
@@ -164,6 +169,40 @@ public class RuralProjectSignatureCallBackController extends BaseController {
         dao.updateApprovalSignature(projectApprovalSignature);
         long t2 = System.currentTimeMillis();
         System.out.println("审定单回调运行耗时:" + (t2-t1) + " 毫秒");
+
+        //将文件存储到项目审定单列表中
+        //签章完成则进行数据的保存
+
+        //将文件存储到对应的档案信息中的“咨询报告书正文”中
+        WorkClientAttachment attchment = new WorkClientAttachment();
+        attchment.setProjectId(records.getId());
+        attchment.setAttachmentId("058ef76b128a4d629acb039017f19161");
+        attchment.setDivIdType("signature");
+        //删除原有的数据信息
+        workattachmentService.deleteByAttachIdAndProject(attchment);
+        //查询原有文件的数据量
+        Integer fileCount = workattachmentService.getAttachmentCountByAttachmentIdAndProjectId(attchment);
+        if( null == fileCount){
+            fileCount = 0;
+        }
+        fileCount = fileCount + 1;
+        if(StringUtils.isNotBlank(signatureUrl)){
+            String fileName = signatureUrl.substring(signatureUrl.lastIndexOf("/")+1,signatureUrl.length());
+            String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length());
+            attchment.setFileSize("");
+            User user = UserUtils.get(records.getCreateBy().getId());
+            attchment.setCreateBy(user);
+            attchment.setUpdateBy(user);
+            attchment.setUrl(signatureUrl);
+            attchment.setType(fileSuffix);
+            attchment.setAttachmentUser(records.getCreateBy().getId());
+            attchment.setAttachmentName(fileName);
+            attchment.setAttachmentFlag("100");
+            attchment.setSort(fileCount.toString());
+            workattachmentService.insertOnWorkClientAttachment(attchment);
+        }
+
+
         return null;
     }
 
@@ -242,8 +281,9 @@ public class RuralProjectSignatureCallBackController extends BaseController {
         records.setReportSignatureContractId(presignCallBack.getContractId());
         records.setReportSignatureUploadDate(new Date());
         //对文件回调路径进行处理并保存
+        String signatureUrl = null;
         if(StringUtils.isNotBlank(presignCallBack.getStoragePath())){
-            String signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
+            signatureUrl = presignCallBack.getStoragePath().replace("oss:/","");
             records.setReportSignatureUrl(signatureUrl);
         }
         //修改签章对应信息文件
@@ -298,6 +338,35 @@ public class RuralProjectSignatureCallBackController extends BaseController {
 
         long t2 = System.currentTimeMillis();
         System.out.println("报告签章回调运行耗时:" + (t2-t1) + " 毫秒");
+
+        if(StringUtils.isNotBlank(signatureUrl)) {
+            String fileName = signatureUrl.substring(signatureUrl.lastIndexOf("/")+1,signatureUrl.length());
+            //将文件存储到对应的档案信息中的“咨询报告书正文”中
+            WorkClientAttachment attchment = new WorkClientAttachment();
+            attchment.setProjectId(records.getId());
+            attchment.setAttachmentId("6c68d29ea00e4cdb8cf17fb54ee30f0f");
+            attchment.setDivIdType("signature");
+            //删除原有的数据信息
+            workattachmentService.deleteByAttachIdAndProject(attchment);
+            //查询原有文件的数据量
+            Integer fileCount = workattachmentService.getAttachmentCountByAttachmentIdAndProjectId(attchment);
+            if (null == fileCount) {
+                fileCount = 0;
+            }
+            fileCount = fileCount + 1;
+            String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
+            attchment.setFileSize("");
+            User user = UserUtils.get(records.getCreateBy().getId());
+            attchment.setCreateBy(user);
+            attchment.setUpdateBy(user);
+            attchment.setUrl(signatureUrl);
+            attchment.setType(fileSuffix);
+            attchment.setAttachmentUser(records.getCreateBy().getId());
+            attchment.setAttachmentName(fileName);
+            attchment.setAttachmentFlag("100");
+            attchment.setSort(fileCount.toString());
+            workattachmentService.insertOnWorkClientAttachment(attchment);
+        }
         return null;
     }
 

+ 13 - 2
src/main/java/com/jeeplus/modules/sys/service/WorkattachmentService.java

@@ -546,8 +546,14 @@ public class WorkattachmentService extends CrudService<WorkattachmentDao, Workat
 					break;
 				case "2":
 					if(StringUtils.isBlank(info.getFileSize())){
+						Long fileSizeBytes = null;
 						//从阿里云获取文件大小
-						Long fileSizeBytes = new OSSClientUtil().getSimplifiedObjectMeta(info.getUrl());
+						if(info.getUrl().contains("/xg-qz")){
+							String url = info.getUrl().replace("/xg-qz","");
+							fileSizeBytes = new OSSClientUtil().getQzSimplifiedObjectMeta(url);
+						}else{
+							fileSizeBytes = new OSSClientUtil().getSimplifiedObjectMeta(info.getUrl());
+						}
 						if(null != fileSizeBytes){
 							Double fileSize = (double)fileSizeBytes/1024/1024;
 							info.setFileSize(String.format("%.2f", fileSize));
@@ -558,7 +564,12 @@ public class WorkattachmentService extends CrudService<WorkattachmentDao, Workat
 						Double fileSize = Double.valueOf(info.getFileSize())/1024/1024;
 						info.setFileSize(String.format("%.2f", fileSize));
 					}
-					info.setTemporaryUrl(new OSSClientUtil().getFileTemporaryLookUrl(info.getUrl()));
+					if(info.getUrl().contains("/xg-qz")){
+						String url = info.getUrl().replace("/xg-qz","");
+						info.setTemporaryUrl(new OSSClientUtil().getQzFileTemporaryLookUrl(url));
+					}else{
+						info.setTemporaryUrl(new OSSClientUtil().getFileTemporaryLookUrl(info.getUrl()));
+					}
 					break;
 
 			}

+ 1 - 1
src/main/resources/mappings/modules/ruralprojectrecords/RuralProjectMessageAllDao.xml

@@ -996,7 +996,7 @@ END) as projectScale*/
 			a.status = 5
 			and prd.status = 5
 			AND  a.status != 7 AND a.del_flag = #{DEL_FLAG_NORMAL}
-			and prr.status is not null
+			and prr.status = 7
 			<choose>
 				<when test="emergencyProject != null and emergencyProject != '' and emergencyProject == 1">
 				/*B类紧急*/