Prechádzať zdrojové kódy

签章申请定时任务处理功能

user5 3 rokov pred
rodič
commit
516943798e

+ 9 - 0
src/main/java/com/jeeplus/modules/projectcontentinfo/entity/ProjectReportData.java

@@ -124,6 +124,7 @@ public class ProjectReportData extends ActEntity<ProjectReportData> {
 	private String signatureDocumentId;		//签章documentid
 	private String signatureContractId;		//签章contractid
 	private String signatureUrl;		//审定单签章文件路径
+	private Integer signatureUrlFlag;		//审定单签章文件路径(判定条件)
 	private String signatureInvalidDocumentId;		//无效的签章documentid
 	private String signatureFileName;		//签章文件名称
 	private User signatureUploadFileUser;		//签章文件上传人信息
@@ -880,4 +881,12 @@ public class ProjectReportData extends ActEntity<ProjectReportData> {
 	public void setSignatureUrl(String signatureUrl) {
 		this.signatureUrl = signatureUrl;
 	}
+
+	public Integer getSignatureUrlFlag() {
+		return signatureUrlFlag;
+	}
+
+	public void setSignatureUrlFlag(Integer signatureUrlFlag) {
+		this.signatureUrlFlag = signatureUrlFlag;
+	}
 }

+ 340 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/service/RuralProjectSignatureOldMessageDisposeService.java

@@ -0,0 +1,340 @@
+package com.jeeplus.modules.ruralprojectrecords.service;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
+import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
+import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
+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.utils.SftpClientUtil;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import org.activiti.engine.HistoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目签章老数据信息文件下载上传阿里临时功能
+ * @author 徐滕
+ * @version 2021-11-04
+ */
+@Service
+@Transactional(readOnly = true)
+public class RuralProjectSignatureOldMessageDisposeService {
+
+
+    private final static String directory = Global.getConfig("remoteServer.directory");
+
+    @Autowired
+    private RuralProjectRecordsService projectRecordsService;
+    @Autowired
+    private ProjectReportDataService projectReportDataService;
+    @Autowired
+    protected HistoryService historyService;
+    @Autowired
+    private WorkattachmentService workattachmentService;
+
+
+    private static final String HTTPTOP = Global.getConfig("signature_http_top");
+
+    private final static String apptoken = Global.getConfig("apptoken");
+    private final static String appsecret = Global.getConfig("appsecret");
+    private final static String signature = Global.getConfig("signature");
+
+
+    /**
+     * 签章文件处理
+     * @param type 1:审定单;2:报告签章;
+     * @param count
+     * @return
+     */
+    @Transactional(readOnly = false)
+    public Map<String,Object> ossUploading(Integer type,Integer count){
+        Map<String,Object> map = new HashMap<>();
+        List<String> projectNumber = Lists.newArrayList();
+        switch (type){
+            case 1:
+                map.put("success",true);
+                map.put("type",type);
+                //查询审定单签章没有对应url下载路径的信息
+                // count为处理的项目信息条数
+                List<ProjectReportData> projectReportDataList = projectReportDataService.getProjectReportDataSignatureByCount(count);
+                for (ProjectReportData info: projectReportDataList) {
+                    try {
+                        downLoadApprovalAttach(info.getSignatureContractId());
+                        projectNumber.add(info.getNumber());
+                    }catch (Exception e){
+
+                    }finally {
+                        //修改签章对应信息文件
+                        info.setSignatureUrlFlag(1);
+                        projectReportDataService.updateSignatureInfo(info);
+                    }
+                }
+                if(projectNumber.size()>0){
+                    String numbersStr = String.join(",", projectNumber);
+                    map.put("reportNumber","审定单签章已处理" + projectNumber.size() + " 条。项目报告号为:" +numbersStr);
+                }else{
+                    map.put("reportNumber","这次没有处理审定单签章信息");
+                }
+                //查询剩余未处理的项目数量
+                Integer approvalCount = projectReportDataService.approvalSignaturesCount();
+                map.put("remainingCount","审定单签章未处理的项目还有:" +approvalCount + " 条");
+                break;
+            case 2:
+                map.put("success",true);
+                map.put("type",type);
+                //查询报告签章没有对应url下载路径的信息
+                // count为处理的项目信息条数
+                List<RuralProjectRecords> ruralProjectRecordsList = projectRecordsService.getProjectRecordsSignatureByCount(count);
+                for (RuralProjectRecords info: ruralProjectRecordsList) {
+                    //进行文件处理
+                    try {
+                        downLoadReportAttach(info.getReportSignatureContractId());
+                        projectNumber.add(info.getProjectReportNumber());
+                    }catch (Exception e){
+
+                    }finally {
+                        info.setReportSignatureUrlFlag(1);
+                        //修改签章对应信息文件
+                        projectReportDataService.updateReportSignatureInfo(info);
+                    }
+                }
+                if(projectNumber.size()>0){
+                    String numbersStr = String.join(",", projectNumber);
+                    map.put("reportNumber","报告签章已处理" + projectNumber.size() + " 条。项目报告号为:" +numbersStr);
+                }else{
+                    map.put("reportNumber","这次没有处理报告签章信息");
+                }
+                //查询剩余未处理的项目数量
+                Integer recordsCount = projectRecordsService.recordSignaturesCount();
+                map.put("remainingCount","报告签章未处理的项目还有:" +recordsCount + " 条。");
+                break;
+            case 3:
+
+                break;
+            default:
+                break;
+        }
+        return map;
+    }
+
+
+    /**
+     * 下载审定单附件
+     */
+    @Transactional(readOnly = false)
+    public void downLoadApprovalAttach(String contractId) {
+        //根据contractId查询对应的报告信息
+        ProjectReportData projectReportData = projectReportDataService.getProjectReportDataByContractId(contractId);
+        //根据contractId查询对应的报告信息
+        RuralProjectRecords ruralProjectRecords = projectRecordsService.get(projectReportData.getProject().getId());
+        if(null == projectReportData || StringUtils.isBlank(projectReportData.getSignatureContractId())){
+            return ;
+        }
+        //根据contractId将文件下载下来 并上传到阿里云服务种
+        //添加请求头
+        Map<String,String> requestHeaderMap = new HashMap<>();
+        requestHeaderMap.put("x-qys-accesstoken", apptoken);
+        requestHeaderMap.put("x-qys-signature", signature);
+        requestHeaderMap.put("x-qys-timestamp", "0");
+        Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId="+contractId,requestHeaderMap,projectReportData.getSignatureFileName()+".zip","");
+        //获取处理结果,若为true 则进行文件上传阿里云操作并写入数据库,否则不进行处理
+        Boolean bool = (Boolean) map.get("success");
+        if(bool){
+            //将文件上传到阿里云中
+            String fileName = (String) map.get("fileName");
+            String filePath = (String) map.get("filePath");
+            Map<String, Object> loadMap = oosLoad(filePath + fileName, "approval");
+            //判定是否上传成功
+            Boolean loadBool = (Boolean) loadMap.get("success");
+            if(loadBool){
+                //签章完成则进行数据的保存
+                String loadFilePath = (String) loadMap.get("filePath");
+                String fileLength = (String) loadMap.get("fileLength");
+                projectReportData.setSignatureUrl(loadFilePath);
+
+                //将文件存储到对应的档案信息中的“咨询报告书正文”中
+                WorkClientAttachment attchment = new WorkClientAttachment();
+                attchment.setProjectId(ruralProjectRecords.getId());
+                attchment.setAttachmentId("058ef76b128a4d629acb039017f19161");
+                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(fileLength);
+                User user = UserUtils.get(ruralProjectRecords.getCreateBy().getId());
+                attchment.setCreateBy(user);
+                attchment.setUpdateBy(user);
+                attchment.setUrl(loadFilePath);
+                attchment.setType(fileSuffix);
+                attchment.setAttachmentUser(ruralProjectRecords.getCreateBy().getId());
+                attchment.setAttachmentName(fileName);
+                attchment.setAttachmentFlag("100");
+                attchment.setSort(fileCount.toString());
+                workattachmentService.insertOnWorkClientAttachment(attchment);
+                //修改签章对应信息文件
+                projectReportDataService.updateSignatureInfo(projectReportData);
+            }
+        }
+    }
+
+    /**
+     * 下载报告附件
+     */
+    @Transactional(readOnly = false)
+    public void downLoadReportAttach(String contractId) {
+        //根据contractId查询对应的报告信息
+        RuralProjectRecords ruralProjectRecords = projectRecordsService.getProjectRecordsByContractId(contractId);
+        if(null == ruralProjectRecords || StringUtils.isBlank(ruralProjectRecords.getReportSignatureContractId())){
+            return ;
+        }
+        //根据contractId将文件下载下来 并上传到阿里云服务种
+        //添加请求头
+        Map<String,String> requestHeaderMap = new HashMap<>();
+        requestHeaderMap.put("x-qys-accesstoken", apptoken);
+        requestHeaderMap.put("x-qys-signature", signature);
+        requestHeaderMap.put("x-qys-timestamp", "0");
+        Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId=" + contractId, requestHeaderMap, ruralProjectRecords.getReportSignatureFileName() + ".zip", "");
+        //获取处理结果,若为true 则进行文件上传阿里云操作并写入数据库,否则不进行处理
+        Boolean bool = (Boolean) map.get("success");
+        if(bool){
+            //将文件上传到阿里云中
+            String fileName = (String) map.get("fileName");
+            String filePath = (String) map.get("filePath");
+            Map<String, Object> loadMap = oosLoad(filePath + fileName, "report");
+            //判定是否上传成功
+            Boolean loadBool = (Boolean) loadMap.get("success");
+            if(loadBool){
+                //签章完成则进行数据的保存
+                String loadFilePath = (String) loadMap.get("filePath");
+                String fileLength = (String) loadMap.get("fileLength");
+                ruralProjectRecords.setReportSignatureUrl(loadFilePath);
+
+                //将文件存储到对应的档案信息中的“咨询报告书正文”中
+                WorkClientAttachment attchment = new WorkClientAttachment();
+                attchment.setProjectId(ruralProjectRecords.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(fileLength);
+                User user = UserUtils.get(ruralProjectRecords.getCreateBy().getId());
+                attchment.setCreateBy(user);
+                attchment.setUpdateBy(user);
+                attchment.setUrl(loadFilePath);
+                attchment.setType(fileSuffix);
+                attchment.setAttachmentUser(ruralProjectRecords.getCreateBy().getId());
+                attchment.setAttachmentName(fileName);
+                attchment.setAttachmentFlag("100");
+                attchment.setSort(fileCount.toString());
+                workattachmentService.insertOnWorkClientAttachment(attchment);
+                //修改签章对应信息文件
+                projectReportDataService.updateReportSignatureInfo(ruralProjectRecords);
+            }
+        }
+
+
+
+    }
+
+    /**
+     * 文件上传阿里云
+     * @param filePath 文件路径
+     * @param storeAs 存储文件夹名称
+     * @return
+     */
+    @Transactional(readOnly = false)
+    public Map<String,Object> oosLoad(String filePath,String storeAs){
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("success",false);
+        File mfile = new File(filePath);
+        SftpClientUtil sftpClientUtil = new SftpClientUtil();
+        //File转MultipartFile文件
+        MultipartFile file = sftpClientUtil.transformFile(mfile);
+        try {
+            String filepath = "";
+            if (!file.isEmpty()) {
+                // 文件保存路径
+
+                String realPath =directory.replace("/","")+datePath()+"/signature/"+storeAs+"/";
+                OSSClientUtil ossUtil = new OSSClientUtil();
+                String newName = file.getName();
+
+                try {
+                    ossUtil.uploadFile2OSS(file.getInputStream(),realPath,newName);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+                filepath = "/" + realPath + newName;
+                map.put("filePath",filepath);
+                long length = mfile.length();
+                map.put("fileLength", String.valueOf(length));
+                map.put("success",true);
+            }
+        }catch (Exception e){
+
+        }finally {
+            mfile.delete();
+        }
+
+        return map;
+    }
+
+    public static String datePath(){
+
+        Calendar date = Calendar.getInstance();
+        String year = String.valueOf(date.get(Calendar.YEAR));
+        String month = String.valueOf(date.get(Calendar.MONTH)+1);
+        String day = String.valueOf(date.get(Calendar.DAY_OF_MONTH));
+        String path = "/"+year+"/"+month+"/"+day;
+        return path;
+    }
+
+    /**
+     * 下载审定内附件
+     */
+    @Transactional(readOnly = false)
+    public void downLoadJudgementAttach(String contractId) {
+        //根据contractId查询对应的报告信息
+        RuralProjectRecords ruralProjectRecords = projectRecordsService.getJudgementProjectRecordsByContractId(contractId);
+        if(null == ruralProjectRecords || StringUtils.isBlank(ruralProjectRecords.getQualitySignatureContractId())){
+            return ;
+        }
+        //根据contractId将文件下载下来 并上传到阿里云服务种
+        //添加请求头
+        Map<String,String> requestHeaderMap = new HashMap<>();
+        requestHeaderMap.put("x-qys-accesstoken", apptoken);
+        requestHeaderMap.put("x-qys-signature", signature);
+        requestHeaderMap.put("x-qys-timestamp", "0");
+        Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId="+contractId,requestHeaderMap,ruralProjectRecords.getQualitySignatureFileName()+".zip","");
+    }
+
+}

+ 26 - 214
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectSignatureOldMessageDisposeController.java

@@ -9,6 +9,7 @@ import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
 import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
 import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
+import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectSignatureOldMessageDisposeService;
 import com.jeeplus.modules.sys.entity.User;
 import com.jeeplus.modules.sys.service.WorkattachmentService;
 import com.jeeplus.modules.sys.utils.UserUtils;
@@ -33,10 +34,8 @@ import java.util.*;
  * @author 徐滕
  * @version 2021-11-04
  */
-/*@Controller
-@RequestMapping(value = "${adminPath}/ruralProject/signatureOldMessageDispose")*/
-@Service
-@Transactional(readOnly = true)
+@Controller
+@RequestMapping(value = "${adminPath}/ruralProject/signatureOldMessageDispose")
 public class RuralProjectSignatureOldMessageDisposeController extends BaseController {
 
 
@@ -49,7 +48,7 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
     @Autowired
     protected HistoryService historyService;
     @Autowired
-    private WorkattachmentService workattachmentService;
+    private RuralProjectSignatureOldMessageDisposeService service;
 
 
     private static final String HTTPTOP = Global.getConfig("signature_http_top");
@@ -63,11 +62,10 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
      * 签章文件处理
      * @param type 1:审定单;2:报告签章;
      * @param count
-     * @param response
      * @return
      */
-    /*@RequestMapping(value = "/ossUploading")
-    @ResponseBody*/
+    @RequestMapping(value = "/ossUploading")
+    @ResponseBody
     public Map<String,Object> ossUploading(@RequestParam("type") Integer type,@RequestParam("count")Integer count){
         Map<String,Object> map = new HashMap<>();
         List<String> projectNumber = Lists.newArrayList();
@@ -79,8 +77,16 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
                 // count为处理的项目信息条数
                 List<ProjectReportData> projectReportDataList = projectReportDataService.getProjectReportDataSignatureByCount(count);
                 for (ProjectReportData info: projectReportDataList) {
-                    downLoadApprovalAttach(info.getSignatureContractId());
-                    projectNumber.add(info.getNumber());
+                    try {
+                        service.downLoadApprovalAttach(info.getSignatureContractId());
+                        projectNumber.add(info.getNumber());
+                    }catch (Exception e){
+                        logger.error("审定单文件处理异常:",e);
+                    }finally {
+                        //修改签章对应信息文件
+                        info.setSignatureUrlFlag(1);
+                        projectReportDataService.updateSignatureInfo(info);
+                    }
                 }
                 if(projectNumber.size()>0){
                     String numbersStr = String.join(",", projectNumber);
@@ -100,8 +106,16 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
                 List<RuralProjectRecords> ruralProjectRecordsList = projectRecordsService.getProjectRecordsSignatureByCount(count);
                 for (RuralProjectRecords info: ruralProjectRecordsList) {
                     //进行文件处理
-                    downLoadReportAttach(info.getReportSignatureContractId());
-                    projectNumber.add(info.getProjectReportNumber());
+                    try {
+                        service.downLoadReportAttach(info.getReportSignatureContractId());
+                        projectNumber.add(info.getProjectReportNumber());
+                    }catch (Exception e){
+                        logger.error("报告签章文件处理异常:",e);
+                    }finally {
+                        info.setReportSignatureUrlFlag(1);
+                        //修改签章对应信息文件
+                        projectReportDataService.updateReportSignatureInfo(info);
+                    }
                 }
                 if(projectNumber.size()>0){
                     String numbersStr = String.join(",", projectNumber);
@@ -122,206 +136,4 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
         return map;
     }
 
-
-    /**
-     * 下载审定单附件
-     */
-    private void downLoadApprovalAttach(String contractId) {
-        //根据contractId查询对应的报告信息
-        ProjectReportData projectReportData = projectReportDataService.getProjectReportDataByContractId(contractId);
-        //根据contractId查询对应的报告信息
-        RuralProjectRecords ruralProjectRecords = projectRecordsService.get(projectReportData.getProject().getId());
-        if(null == projectReportData || StringUtils.isBlank(projectReportData.getSignatureContractId())){
-            return ;
-        }
-        //根据contractId将文件下载下来 并上传到阿里云服务种
-        //添加请求头
-        Map<String,String> requestHeaderMap = new HashMap<>();
-        requestHeaderMap.put("x-qys-accesstoken", apptoken);
-        requestHeaderMap.put("x-qys-signature", signature);
-        requestHeaderMap.put("x-qys-timestamp", "0");
-        Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId="+contractId,requestHeaderMap,projectReportData.getSignatureFileName()+".zip","");
-        //获取处理结果,若为true 则进行文件上传阿里云操作并写入数据库,否则不进行处理
-        Boolean bool = (Boolean) map.get("success");
-        if(bool){
-            //将文件上传到阿里云中
-            String fileName = (String) map.get("fileName");
-            String filePath = (String) map.get("filePath");
-            Map<String, Object> loadMap = oosLoad(filePath + fileName, "approval");
-            //判定是否上传成功
-            Boolean loadBool = (Boolean) loadMap.get("success");
-            if(loadBool){
-                //签章完成则进行数据的保存
-                String loadFilePath = (String) loadMap.get("filePath");
-                String fileLength = (String) loadMap.get("fileLength");
-                projectReportData.setSignatureUrl(loadFilePath);
-
-                //将文件存储到对应的档案信息中的“咨询报告书正文”中
-                WorkClientAttachment attchment = new WorkClientAttachment();
-                attchment.setProjectId(ruralProjectRecords.getId());
-                attchment.setAttachmentId("058ef76b128a4d629acb039017f19161");
-                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(fileLength);
-                User user = UserUtils.get(ruralProjectRecords.getCreateBy().getId());
-                attchment.setCreateBy(user);
-                attchment.setUpdateBy(user);
-                attchment.setUrl(loadFilePath);
-                attchment.setType(fileSuffix);
-                attchment.setAttachmentUser(ruralProjectRecords.getCreateBy().getId());
-                attchment.setAttachmentName(fileName);
-                attchment.setAttachmentFlag("100");
-                attchment.setSort(fileCount.toString());
-                workattachmentService.insertOnWorkClientAttachment(attchment);
-                //修改签章对应信息文件
-                projectReportDataService.updateSignatureInfo(projectReportData);
-            }
-        }
-    }
-
-    /**
-     * 下载报告附件
-     */
-    private void downLoadReportAttach(String contractId) {
-        //根据contractId查询对应的报告信息
-        RuralProjectRecords ruralProjectRecords = projectRecordsService.getProjectRecordsByContractId(contractId);
-        if(null == ruralProjectRecords || StringUtils.isBlank(ruralProjectRecords.getReportSignatureContractId())){
-            return ;
-        }
-        //根据contractId将文件下载下来 并上传到阿里云服务种
-        //添加请求头
-        Map<String,String> requestHeaderMap = new HashMap<>();
-        requestHeaderMap.put("x-qys-accesstoken", apptoken);
-        requestHeaderMap.put("x-qys-signature", signature);
-        requestHeaderMap.put("x-qys-timestamp", "0");
-        Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId=" + contractId, requestHeaderMap, ruralProjectRecords.getReportSignatureFileName() + ".zip", "");
-        //获取处理结果,若为true 则进行文件上传阿里云操作并写入数据库,否则不进行处理
-        Boolean bool = (Boolean) map.get("success");
-        if(bool){
-            //将文件上传到阿里云中
-            String fileName = (String) map.get("fileName");
-            String filePath = (String) map.get("filePath");
-            Map<String, Object> loadMap = oosLoad(filePath + fileName, "report");
-            //判定是否上传成功
-            Boolean loadBool = (Boolean) loadMap.get("success");
-            if(loadBool){
-                //签章完成则进行数据的保存
-                String loadFilePath = (String) loadMap.get("filePath");
-                String fileLength = (String) loadMap.get("fileLength");
-                ruralProjectRecords.setReportSignatureUrl(loadFilePath);
-
-                //将文件存储到对应的档案信息中的“咨询报告书正文”中
-                WorkClientAttachment attchment = new WorkClientAttachment();
-                attchment.setProjectId(ruralProjectRecords.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(fileLength);
-                User user = UserUtils.get(ruralProjectRecords.getCreateBy().getId());
-                attchment.setCreateBy(user);
-                attchment.setUpdateBy(user);
-                attchment.setUrl(loadFilePath);
-                attchment.setType(fileSuffix);
-                attchment.setAttachmentUser(ruralProjectRecords.getCreateBy().getId());
-                attchment.setAttachmentName(fileName);
-                attchment.setAttachmentFlag("100");
-                attchment.setSort(fileCount.toString());
-                workattachmentService.insertOnWorkClientAttachment(attchment);
-                //修改签章对应信息文件
-                projectReportDataService.updateReportSignatureInfo(ruralProjectRecords);
-            }
-        }
-
-
-
-    }
-
-    /**
-     * 文件上传阿里云
-     * @param filePath 文件路径
-     * @param storeAs 存储文件夹名称
-     * @return
-     */
-    private Map<String,Object> oosLoad(String filePath,String storeAs){
-
-        Map<String,Object> map = new HashMap<>();
-        map.put("success",false);
-        File mfile = new File(filePath);
-        SftpClientUtil sftpClientUtil = new SftpClientUtil();
-        //File转MultipartFile文件
-        MultipartFile file = sftpClientUtil.transformFile(mfile);
-        try {
-            String filepath = "";
-            if (!file.isEmpty()) {
-                // 文件保存路径
-
-                String realPath =directory.replace("/","")+datePath()+"/signature/"+storeAs+"/";
-                OSSClientUtil ossUtil = new OSSClientUtil();
-                String newName = file.getName();
-
-                try {
-                    ossUtil.uploadFile2OSS(file.getInputStream(),realPath,newName);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                    logger.error("Exception e:"+e);
-                }
-                filepath = "/" + realPath + newName;
-                map.put("filePath",filepath);
-                long length = mfile.length();
-                map.put("fileLength", String.valueOf(length));
-                map.put("success",true);
-            }
-        }catch (Exception e){
-
-        }finally {
-            mfile.delete();
-        }
-
-        return map;
-    }
-
-    private static String datePath(){
-
-        Calendar date = Calendar.getInstance();
-        String year = String.valueOf(date.get(Calendar.YEAR));
-        String month = String.valueOf(date.get(Calendar.MONTH)+1);
-        String day = String.valueOf(date.get(Calendar.DAY_OF_MONTH));
-        String path = "/"+year+"/"+month+"/"+day;
-        return path;
-    }
-
-    /**
-     * 下载审定内附件
-     */
-    private void downLoadJudgementAttach(String contractId) {
-        //根据contractId查询对应的报告信息
-        RuralProjectRecords ruralProjectRecords = projectRecordsService.getJudgementProjectRecordsByContractId(contractId);
-        if(null == ruralProjectRecords || StringUtils.isBlank(ruralProjectRecords.getQualitySignatureContractId())){
-            return ;
-        }
-        //根据contractId将文件下载下来 并上传到阿里云服务种
-        //添加请求头
-        Map<String,String> requestHeaderMap = new HashMap<>();
-        requestHeaderMap.put("x-qys-accesstoken", apptoken);
-        requestHeaderMap.put("x-qys-signature", signature);
-        requestHeaderMap.put("x-qys-timestamp", "0");
-        Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId="+contractId,requestHeaderMap,ruralProjectRecords.getQualitySignatureFileName()+".zip","");
-    }
-
 }

+ 11 - 19
src/main/java/com/jeeplus/modules/workcalendar/service/WorkCalendarTaskService.java

@@ -4,13 +4,8 @@
 package com.jeeplus.modules.workcalendar.service;
 
 import com.jeeplus.common.utils.DateUtils;
-import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectRecordsDao;
-import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
-import com.jeeplus.modules.ruralprojectrecords.web.RuralProjectSignatureOldMessageDisposeController;
-import com.jeeplus.modules.sys.entity.MainDictDetail;
-import com.jeeplus.modules.sys.utils.DictUtils;
-import com.jeeplus.modules.workcalendar.dao.WorkCalendarDao;
+import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectSignatureOldMessageDisposeService;
 import com.jeeplus.modules.workcalendar.entity.WorkCalendar;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -20,7 +15,6 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.servlet.http.HttpServletResponse;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -43,7 +37,7 @@ public class WorkCalendarTaskService  {
     @Autowired
     private RuralProjectRecordsService projectRecordsService;
     @Autowired
-    private RuralProjectSignatureOldMessageDisposeController ruralProjectSignatureOldMessageDispose;
+    private RuralProjectSignatureOldMessageDisposeService ruralProjectSignatureOldMessageDispose;
 
     @Scheduled(cron= "0 0/1 * * * ?")
     public void notifyTask() {
@@ -143,10 +137,9 @@ public class WorkCalendarTaskService  {
 
     /**
      * 月度报表
-     *//*
+     */
     //每个月最后一天晚上23点推送
-    //@Scheduled(cron= "0 0 23 L * ?")
-    @Scheduled(cron= "0 0 23 28-31 * ?")
+    //@Scheduled(cron= "0 0 23 28-31 * ?")
     public void getStatementCompanyComprehensiveOnMonth() {
         final Calendar c = Calendar.getInstance();
         if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)){
@@ -181,12 +174,11 @@ public class WorkCalendarTaskService  {
 
     }
 
-    *//**
+    /**
      * 季度报表
-     *//*
+     */
     //每个季度最后一天晚上23点推送
-    //@Scheduled(cron= "0 0 23 L 3,6,9,12 ?")
-    @Scheduled(cron= "0 0 23 28-31 3,6,9,12 ?")
+    //@Scheduled(cron= "0 0 23 28-31 3,6,9,12 ?")
     public void getStatementCompanyComprehensiveOnQuarter() {
         final Calendar c = Calendar.getInstance();
         if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)){
@@ -220,11 +212,11 @@ public class WorkCalendarTaskService  {
         }
     }
 
-    *//**
+    /**
      * 年度报表
-     *//*
+     */
     //每年最后一天晚上23点推送
-    @Scheduled(cron= "0 0 23 31 12 ?")
+    //@Scheduled(cron= "0 0 23 31 12 ?")
     public void getStatementCompanyComprehensiveOnYear() {
         logger.info("-----------公司级—项目年度报表(开始)------------------");
         projectRecordsService.saveProjectReportedListByAdvent();
@@ -252,6 +244,6 @@ public class WorkCalendarTaskService  {
         logger.info("-----------部门级—合同年度报表(开始)------------------");
         projectRecordsService.saveProjectRecordListByAdvent();
         logger.info("------------部门级—合同年度报表(结束)------------------");
-    }*/
+    }
 
 }

+ 8 - 0
src/main/resources/mappings/modules/projectcontentinfo/ProjectReportDataDao.xml

@@ -1119,6 +1119,9 @@
 			<if test="signatureUrl != null and signatureUrl != ''">
 				,signature_url = #{signatureUrl}
 			</if>
+			<if test="signatureUrlFlag != null and signatureUrlFlag != ''">
+				,signature_url_flag = #{signatureUrlFlag}
+			</if>
 			<if test="signatureInvalidDocumentId != null and signatureInvalidDocumentId != ''">
 				,signature_invalid_document_id = #{signatureInvalidDocumentId}
 			</if>
@@ -1148,6 +1151,9 @@
 			<if test="reportSignatureUrl != null and reportSignatureUrl != ''">
 				,report_signature_url = #{reportSignatureUrl}
 			</if>
+			<if test="reportSignatureUrlFlag != null and reportSignatureUrlFlag != ''">
+				,report_signature_url_flag = #{reportSignatureUrlFlag}
+			</if>
 			<if test="reportSignatureInvalidDocumentId != null and reportSignatureInvalidDocumentId != ''">
 				,report_signature_invalid_document_id = #{reportSignatureInvalidDocumentId}
 			</if>
@@ -1245,6 +1251,7 @@
 			pas.status = 5
 			and (a.signature_url is null or a.signature_url = '')
 			and (a.signature_contract_id is not null or a.signature_contract_id != '')
+			and a.signature_url_flag  = 0
 		</where>
 		order by a.number asc
 		limit #{count}
@@ -1260,6 +1267,7 @@
 			pas.status = 5
 			and (a.signature_url is null or a.signature_url = '')
 			and (a.signature_contract_id is not null or a.signature_contract_id != '')
+			and a.signature_url_flag  = 0
 		</where>
 	</select>
 </mapper>

+ 2 - 0
src/main/resources/mappings/modules/ruralprojectrecords/RuralProjectRecordsDao.xml

@@ -2024,6 +2024,7 @@
 		<include refid="projectRecordsJoins"/>
 		<where>
 			prs.status = 5
+			and a.report_signature_url_flag = 0
 			and (a.report_signature_url is null or a.report_signature_url = '')
 			and (a.report_signature_contract_id is not null or a.report_signature_contract_id != '')
 		</where>
@@ -2039,6 +2040,7 @@
 		left join project_report_signature prs on prs.project_id = a.id
 		<where>
 			prs.status = 5
+			and a.report_signature_url_flag = 0
 			and (a.report_signature_url is null or a.report_signature_url = '')
 			and (a.report_signature_contract_id is not null or a.report_signature_contract_id != '')
 		</where>