Browse Source

签章文件由签章服务器同步至阿里云方法功能

user5 3 years ago
parent
commit
ba493b60d6
17 changed files with 678 additions and 7 deletions
  1. 13 0
      src/main/java/com/jeeplus/modules/projectcontentinfo/dao/ProjectReportDataDao.java
  2. 9 0
      src/main/java/com/jeeplus/modules/projectcontentinfo/entity/ProjectReportData.java
  3. 17 0
      src/main/java/com/jeeplus/modules/projectcontentinfo/service/ProjectReportDataService.java
  4. 14 0
      src/main/java/com/jeeplus/modules/ruralprojectrecords/dao/RuralProjectRecordsDao.java
  5. 39 1
      src/main/java/com/jeeplus/modules/ruralprojectrecords/entity/RuralProjectRecords.java
  6. 16 0
      src/main/java/com/jeeplus/modules/ruralprojectrecords/service/RuralProjectRecordsService.java
  7. 14 2
      src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectMessageElectronicSealController.java
  8. 323 0
      src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectSignatureOldMessageDisposeController.java
  9. 7 0
      src/main/java/com/jeeplus/modules/sys/dao/WorkattachmentDao.java
  10. 8 0
      src/main/java/com/jeeplus/modules/sys/service/WorkattachmentService.java
  11. 104 0
      src/main/java/com/jeeplus/modules/tools/utils/SignaturePostUtil.java
  12. 41 0
      src/main/resources/mappings/modules/projectcontentinfo/ProjectReportDataDao.xml
  13. 2 0
      src/main/resources/mappings/modules/ruralprojectrecords/RuralProjectMessageAllDao.xml
  14. 33 0
      src/main/resources/mappings/modules/ruralprojectrecords/RuralProjectRecordsDao.xml
  15. 29 3
      src/main/resources/mappings/modules/sys/WorkattachmentDao.xml
  16. 1 0
      src/main/resources/spring-context-shiro.xml
  17. 8 1
      src/main/webapp/webpage/modules/ruralprojectrecords/ruralporjectmessage/electronicSeal/ruralProjectMessageElectronicSealList.jsp

+ 13 - 0
src/main/java/com/jeeplus/modules/projectcontentinfo/dao/ProjectReportDataDao.java

@@ -183,4 +183,17 @@ public interface ProjectReportDataDao extends CrudDao<ProjectReportData> {
      * @return
      */
     ProjectReportData getProjectReportDataByDocumentId(String documentId);
+
+    /**
+     * 查询审定单签章没有url路径的信息
+     * @param count
+     * @return
+     */
+    List<ProjectReportData> getProjectReportDataSignatureByCount(Integer count);
+
+    /**
+     * 查询审定单签章未处理的数量
+     * @return
+     */
+    Integer approvalSignaturesCount();
 }

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

@@ -123,6 +123,7 @@ public class ProjectReportData extends ActEntity<ProjectReportData> {
 	private Integer signatureFlag;		//是否审定单签章(1为已签章)
 	private String signatureDocumentId;		//签章documentid
 	private String signatureContractId;		//签章contractid
+	private String signatureUrl;		//审定单签章文件路径
 	private String signatureInvalidDocumentId;		//无效的签章documentid
 	private String signatureFileName;		//签章文件名称
 	private User signatureUploadFileUser;		//签章文件上传人信息
@@ -871,4 +872,12 @@ public class ProjectReportData extends ActEntity<ProjectReportData> {
 	public void setFirstAuditDate(Date firstAuditDate) {
 		this.firstAuditDate = firstAuditDate;
 	}
+
+	public String getSignatureUrl() {
+		return signatureUrl;
+	}
+
+	public void setSignatureUrl(String signatureUrl) {
+		this.signatureUrl = signatureUrl;
+	}
 }

+ 17 - 0
src/main/java/com/jeeplus/modules/projectcontentinfo/service/ProjectReportDataService.java

@@ -1669,4 +1669,21 @@ public class ProjectReportDataService extends CrudService<ProjectReportDataDao,
 	public ProjectReportData findByNum(String number) {
 		return dao.findByNum(number);
 	}
+
+	/**
+	 * 查询审定单签章没有url路径的信息
+	 * @param count
+	 * @return
+	 */
+	public List<ProjectReportData> getProjectReportDataSignatureByCount(Integer count) {
+		return dao.getProjectReportDataSignatureByCount(count);
+	}
+
+	/**
+	 * 查询报告签章未处理的数量
+	 * @return
+	 */
+	public Integer approvalSignaturesCount() {
+		return dao.approvalSignaturesCount();
+	}
 }

+ 14 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/dao/RuralProjectRecordsDao.java

@@ -316,4 +316,18 @@ public interface RuralProjectRecordsDao extends CrudDao<RuralProjectRecords> {
      * @return
      */
     RuralProjectRecords getProjectByProjectId(String projectId);
+
+
+    /**
+     * 查询报告签章没有下载路径的并且已经签订结束的数据信息
+     * @param count 查询的数据量
+     * @return
+     */
+    List<RuralProjectRecords> getProjectRecordsSignatureByCount(Integer count);
+
+    /**
+     * 查询报告签章未处理的数量
+     * @return
+     */
+    Integer recordSignaturesCount();
 }

+ 39 - 1
src/main/java/com/jeeplus/modules/ruralprojectrecords/entity/RuralProjectRecords.java

@@ -263,6 +263,7 @@ public class RuralProjectRecords extends ActEntity<RuralProjectRecords> {
 	private String whetherReportNumber; //是否需要报告号
 	private String signatureFlag; //审定单签章状态
 	private String signatureContractId; //审定单签章contractId
+	private String signatureUrl; //审定单签章url
 	private String signatureFileName;		//签章文件名称
 	private String operateFlag; //操作状态
 
@@ -275,7 +276,8 @@ public class RuralProjectRecords extends ActEntity<RuralProjectRecords> {
 	private String signatureDownloadUrl; //报告签章文档下载链接
 
 
-	private Integer reportSignatureFlag;		//是否审定单签章(1为已签章)
+	private Integer reportSignatureFlag;		//是否报告签章(1为已签章)
+	private String reportSignatureUrl;		//报告签章id
 	private String reportSignatureDocumentId;		//签章documentid
 	private String reportSignatureContractId;		//签章contractid
 	private String reportSignatureInvalidDocumentId;		//无效的签章documentid
@@ -295,6 +297,10 @@ public class RuralProjectRecords extends ActEntity<RuralProjectRecords> {
 	private String projectFilingBatchesId;
 
 
+	private Integer reportSignatureUrlFlag;		//报告签章url状态
+	private Integer approvalSignatureUrlFlag;		//审定单签章url状态
+
+
 	private List<String> civilProjectList = Lists.newArrayList();
 	private List<WorkClientAttachment> workAttachments = Lists.newArrayList();
 
@@ -2136,4 +2142,36 @@ public class RuralProjectRecords extends ActEntity<RuralProjectRecords> {
 	public void setPaperProjectAuditNotifyFlag(Integer paperProjectAuditNotifyFlag) {
 		this.paperProjectAuditNotifyFlag = paperProjectAuditNotifyFlag;
 	}
+
+	public String getReportSignatureUrl() {
+		return reportSignatureUrl;
+	}
+
+	public void setReportSignatureUrl(String reportSignatureUrl) {
+		this.reportSignatureUrl = reportSignatureUrl;
+	}
+
+	public Integer getReportSignatureUrlFlag() {
+		return reportSignatureUrlFlag;
+	}
+
+	public void setReportSignatureUrlFlag(Integer reportSignatureUrlFlag) {
+		this.reportSignatureUrlFlag = reportSignatureUrlFlag;
+	}
+
+	public Integer getApprovalSignatureUrlFlag() {
+		return approvalSignatureUrlFlag;
+	}
+
+	public void setApprovalSignatureUrlFlag(Integer approvalSignatureUrlFlag) {
+		this.approvalSignatureUrlFlag = approvalSignatureUrlFlag;
+	}
+
+	public String getSignatureUrl() {
+		return signatureUrl;
+	}
+
+	public void setSignatureUrl(String signatureUrl) {
+		this.signatureUrl = signatureUrl;
+	}
 }

+ 16 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/service/RuralProjectRecordsService.java

@@ -2921,6 +2921,22 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
 	}
 
 
+	/**
+	 * 查询报告签章没有下载路径的并且已经签订结束的数据信息
+	 * @param count 查询得数据量
+	 * @return
+	 */
+	public List<RuralProjectRecords> getProjectRecordsSignatureByCount(Integer count) {
+		return dao.getProjectRecordsSignatureByCount(count);
+	}
+
+	/**
+	 * 查询报告签章未处理的数量
+	 * @return
+	 */
+	public Integer recordSignaturesCount() {
+		return dao.recordSignaturesCount();
+	}
 
 
 }

+ 14 - 2
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectMessageElectronicSealController.java

@@ -1,6 +1,7 @@
 package com.jeeplus.modules.ruralprojectrecords.web;
 
 import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.common.persistence.Page;
 import com.jeeplus.common.utils.*;
 import com.jeeplus.common.utils.excel.ImportExcelNew;
@@ -59,6 +60,10 @@ import java.util.*;
 @Controller
 @RequestMapping(value = "${adminPath}/ruralProject/electronicSeal")
 public class RuralProjectMessageElectronicSealController extends BaseController {
+    /**
+     * 阿里云文件服务器前缀
+     */
+    private final static String aliyunUrl = Global.getConfig("aliyunUrl");
     @Autowired
     private RuralProjectRecordsService projectRecordsService;
     @Autowired
@@ -142,8 +147,15 @@ public class RuralProjectMessageElectronicSealController extends BaseController
         }
         //无合同状态下,获取委托方的名称
         List<RuralProjectRecords> list = page.getList();
-        /*for (int i = 0; i < list.size(); i++) {
+        for (int i = 0; i < list.size(); i++) {
             RuralProjectRecords records1 = list.get(i);
+            if(StringUtils.isNotBlank(records1.getReportSignatureUrl())){
+                records1.setReportSignatureUrlFlag(1);
+                records1.setReportSignatureUrl(new OSSClientUtil().getFileTemporaryLookUrl(aliyunUrl + records1.getReportSignatureUrl()));
+                //处理文件路径
+            }else{
+                records1.setReportSignatureUrlFlag(0);
+            }
             if (records1.getWorkContractInfo() == null) {
                 projectRecordsService.queryLinkmanInfos(records1);
                 if (records1.getWorkClientLinkmanList() != null && records1.getWorkClientLinkmanList().size() > 0) {
@@ -156,7 +168,7 @@ public class RuralProjectMessageElectronicSealController extends BaseController
             }
             //将生成的文件上传到阿里云中
             ruralProjectMessageElectronicSealService.getFile(records1);
-        }*/
+        }
         if(StringUtils.isNotBlank(oldSubmitMoney)){
             projectRecords.setSubmitMoney(oldSubmitMoney);
         }

+ 323 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectSignatureOldMessageDisposeController.java

@@ -0,0 +1,323 @@
+package com.jeeplus.modules.ruralprojectrecords.web;
+
+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.common.web.BaseController;
+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.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.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * 项目签章老数据信息文件下载上传阿里临时功能
+ * @author 徐滕
+ * @version 2021-11-04
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/ruralProject/signatureOldMessageDispose")
+public class RuralProjectSignatureOldMessageDisposeController extends BaseController {
+
+
+    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
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/ossUploading")
+    @ResponseBody
+    public Map<String,Object> ossUploading(@RequestParam("type") Integer type,@RequestParam("count")Integer count,HttpServletResponse response){
+        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) {
+                    downLoadApprovalAttach(info.getSignatureContractId(),response);
+                    projectNumber.add(info.getNumber());
+                }
+                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) {
+                    //进行文件处理
+                    downLoadReportAttach(info.getReportSignatureContractId(),response);
+                    projectNumber.add(info.getProjectReportNumber());
+                }
+                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;
+    }
+
+
+    /**
+     * 下载审定单附件
+     */
+    private void downLoadApprovalAttach(String contractId,HttpServletResponse response) {
+        //根据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","",response);
+        //获取处理结果,若为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,HttpServletResponse response) {
+        //根据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", "", response);
+        //获取处理结果,若为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,HttpServletResponse response) {
+        //根据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","",response);
+    }
+
+}

+ 7 - 0
src/main/java/com/jeeplus/modules/sys/dao/WorkattachmentDao.java

@@ -73,6 +73,13 @@ public interface WorkattachmentDao extends CrudDao<Workattachment> {
     void deleteByAttachIdAndProject(WorkClientAttachment workattachment);
 
     /**
+     * 根据信息查询数据量
+     * @param workattachment
+     * @return
+     */
+    Integer getAttachmentCountByAttachmentIdAndProjectId(WorkClientAttachment workattachment);
+
+    /**
      * 删除信息
      * @param id
      */

+ 8 - 0
src/main/java/com/jeeplus/modules/sys/service/WorkattachmentService.java

@@ -679,6 +679,14 @@ public class WorkattachmentService extends CrudService<WorkattachmentDao, Workat
 	}
 
 	/**
+	 * 根据信息查询数据量
+	 * @param workattachment
+	 */
+	public Integer getAttachmentCountByAttachmentIdAndProjectId(WorkClientAttachment workattachment) {
+		return dao.getAttachmentCountByAttachmentIdAndProjectId(workattachment);
+	}
+
+	/**
 	 * 删除对应数据信息
 	 * @param id
 	 */

+ 104 - 0
src/main/java/com/jeeplus/modules/tools/utils/SignaturePostUtil.java

@@ -160,6 +160,110 @@ public class SignaturePostUtil {
     }
 
     /**
+     * 下载文件并保存到指定位置
+     * @param requestUrl 请求url
+     * @param requestHeader 请求头
+     * @param fileName 下载文件名称
+     * @param responseEncoding 响应编码
+     * @return 页面响应html
+     */
+    public static Map<String,Object> downloadZipDesignated(String requestUrl, Map<String, String> requestHeader, String fileName, String responseEncoding, HttpServletResponse response) {
+        Map<String,Object> map = new HashMap<>();
+        BufferedReader reader = null;
+        try {
+            if (requestUrl == null || requestUrl.isEmpty()) {
+                map.put("success",false);
+                map.put("message",fileName + " 的请求路径为空");
+                map.put("fileName",fileName);
+                map.put("filePath","");
+                return map;
+            }
+            URL realUrl = new URL(requestUrl);
+            URLConnection connection = realUrl.openConnection();
+            connection.setRequestProperty("accept", "text/html, application/xhtml+xml, image/jxr, */*");
+            connection.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0");
+            if (requestHeader != null && requestHeader.size() > 0) {
+                for (Entry<String, String> entry : requestHeader.entrySet()) {
+                    connection.setRequestProperty(entry.getKey(), entry.getValue());
+                }
+            }
+            connection.setRequestProperty("Content-Type", "application/zip");
+            connection.connect();
+            if (responseEncoding == null || responseEncoding.isEmpty()) {
+                responseEncoding = "UTF-8";
+            }
+            InputStream inputStream = connection.getInputStream();
+
+            BufferedInputStream bis = new BufferedInputStream(inputStream);
+            //判断文件的保存路径后面是否以/结尾
+            String filePath = null;
+            if(System.getProperty("os.name").toLowerCase().contains("win")){
+                filePath = "D:/attachment-file/";
+            }else{
+                filePath = "/attachment-file/";
+            }
+            //写入到文件(注意文件保存路径的后面一定要加上文件的名称)
+            fileName = fileName.replaceAll("\\\\","");
+            fileName = fileName.replaceAll("/","");
+            fileName = fileName.replaceAll("\\*","");
+            fileName = fileName.replaceAll("\\?","");
+            fileName = fileName.replaceAll("\"","");
+            fileName = fileName.replaceAll("<","");
+            fileName = fileName.replaceAll(">","");
+            fileName = fileName.replaceAll("\\|","");
+            fileName = fileName.replaceAll("\\’","'");
+            fileName = fileName.replaceAll("\\”","\"");
+            fileName = fileName.replaceAll("【","(");
+            fileName = fileName.replaceAll("\\{","(");
+            fileName = fileName.replaceAll("】",")");
+            fileName = fileName.replaceAll("}",")");
+            fileName = fileName.replaceAll(",",",");
+            fileName = fileName.replaceAll(":",":");
+            fileName = fileName.replaceAll("—","-");
+            fileName = fileName.replaceAll("……","");
+            fileName = fileName.replaceAll("±","");
+            fileName = fileName.replaceAll("#","");
+            fileName = fileName.replaceAll("%","");
+            fileName = fileName.replaceAll("Π","");
+
+            FileOutputStream fileOut = new FileOutputStream(filePath + fileName);
+            BufferedOutputStream bos = new BufferedOutputStream(fileOut);
+
+            byte[] buf = new byte[4096];
+            int length = bis.read(buf);
+            //保存文件
+            while(length != -1)
+            {
+                bos.write(buf, 0, length);
+                length = bis.read(buf);
+            }
+            //response.getOutputStream().close();
+            bos.close();
+            fileOut.close();
+            bis.close();
+            if(inputStream!=null){
+                inputStream.close();
+            }
+            map.put("success",true);
+            map.put("message","下载成功");
+            map.put("fileName",fileName);
+            map.put("filePath",filePath);
+        } catch (Exception e) {
+            System.out.println("发送GET请求出现异常!");
+            e.printStackTrace();
+        } finally {
+            try {
+                if (reader != null) {
+                    reader.close();
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return map;
+    }
+
+    /**
      * 从输入流中获取字节数组
      * @param inputStream
      * @return

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

@@ -59,6 +59,7 @@
 		a.signature_invalid_document_id as "signatureInvalidDocumentId",
 		a.signature_contract_id as "signatureContractId",
 		a.signature_file_name as "signatureFileName",
+		a.signature_url as "signatureUrl",
 		a.signature_upload_file_user as "signatureUploadFileUser.id",
 		a.signature_upload_date as "signatureUploadDate",
 		a.first_audit_date as "firstAuditDate"
@@ -1115,6 +1116,9 @@
 			<if test="signatureDocumentId != null and signatureDocumentId != ''">
 				signature_document_id = #{signatureDocumentId}
 			</if>
+			<if test="signatureUrl != null and signatureUrl != ''">
+				,signature_url = #{signatureUrl}
+			</if>
 			<if test="signatureInvalidDocumentId != null and signatureInvalidDocumentId != ''">
 				,signature_invalid_document_id = #{signatureInvalidDocumentId}
 			</if>
@@ -1141,6 +1145,9 @@
 			<if test="reportSignatureDocumentId != null and reportSignatureDocumentId != ''">
 				report_signature_document_id = #{reportSignatureDocumentId}
 			</if>
+			<if test="reportSignatureUrl != null and reportSignatureUrl != ''">
+				,report_signature_url = #{reportSignatureUrl}
+			</if>
 			<if test="reportSignatureInvalidDocumentId != null and reportSignatureInvalidDocumentId != ''">
 				,report_signature_invalid_document_id = #{reportSignatureInvalidDocumentId}
 			</if>
@@ -1221,4 +1228,38 @@
 	</select>
 
 
+
+	<select id="getProjectReportDataSignatureByCount" resultType="ProjectReportData" >
+		SELECT
+		<include refid="projectReportDataColumns"/>
+		FROM project_report_data a
+		<include refid="projectReportDataJoins"/>
+		LEFT JOIN sys_office o ON o.id = a.office_id
+		LEFT JOIN sys_user uo ON uo.id = a.sign_cost_one
+		LEFT JOIN sys_user ut ON ut.id = a.sign_cost_two
+		LEFT JOIN project_records r ON r.id = a.project_id
+		LEFT JOIN work_contract_info wci on r.contract_id = wci.id
+		LEFT JOIN work_client_info wct on wci.client_id = wct.id
+		LEFT JOIN project_approval_signature pas on pas.project_id = a.project_id
+		<where>
+			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 != '')
+		</where>
+		order by a.number asc
+		limit #{count}
+	</select>
+
+
+	<select id="approvalSignaturesCount" resultType="java.lang.Integer">
+		select
+		count(1)
+		FROM project_report_data a
+		LEFT JOIN project_approval_signature pas on pas.project_id = a.project_id
+		<where>
+			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 != '')
+		</where>
+	</select>
 </mapper>

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

@@ -377,7 +377,9 @@ END) as projectScale*/
 		,prd.ZiXunShouRu as "money"
 		,prd.signature_flag as "signatureFlag"
 		,prd.signature_contract_id as "signatureContractId"
+		,prd.signature_url as "signatureUrl"
 		,a.report_signature_flag as "reportSignatureFlag"
+		,a.report_signature_url as "reportSignatureUrl"
 		,a.report_signature_contract_id as "reportSignatureContractId"
 		,prsi.id as "prsiId"
 		FROM rural_project_records a

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

@@ -59,6 +59,7 @@
 		a.report_signature_flag as "reportSignatureFlag",
 		a.report_signature_document_id as "reportSignatureDocumentId",
 		a.report_signature_contract_id as "reportSignatureContractId",
+		a.report_signature_url as "reportSignatureUrl",
 		a.report_signature_invalid_document_id as "reportSignatureInvalidDocumentId",
 		a.report_signature_file_name as "reportSignatureFileName",
 		a.report_signature_upload_file_user as "reportSignatureUploadFileUser.id",
@@ -2010,4 +2011,36 @@
 		where project_id = #{projectId}
 		and status in(2,3,5)
 	</select>
+
+
+
+	<select id="getProjectRecordsSignatureByCount" resultType="RuralProjectRecords">
+		select
+		<include refid="projectRecordsColumns"/>
+		,prd.number AS "projectReportNumber"
+		FROM rural_project_records a
+		left join project_report_data prd on prd.project_id = a.id
+		left join project_report_signature prs on prs.project_id = a.id
+		<include refid="projectRecordsJoins"/>
+		<where>
+			prs.status = 5
+			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>
+		order by prd.number asc
+		limit #{count}
+	</select>
+
+
+	<select id="recordSignaturesCount" resultType="java.lang.Integer">
+		select
+		count(1)
+		FROM rural_project_records a
+		left join project_report_signature prs on prs.project_id = a.id
+		<where>
+			prs.status = 5
+			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>
+	</select>
 </mapper>

+ 29 - 3
src/main/resources/mappings/modules/sys/WorkattachmentDao.xml

@@ -363,11 +363,37 @@
 
 	<delete id="deleteByAttachIdAndProject">
 		DELETE FROM work_attachment
-		WHERE attachment_id = #{attachmentId}
-		and attachment_name = #{attachmentName}
-		and project_id = #{projectId}
+		<where>
+			<if test="null != attachmentId and '' != attachmentId">
+				and attachment_id = #{attachmentId}
+			</if>
+			<if test="null != attachmentName and '' != attachmentName">
+				and attachment_name = #{attachmentName}
+			</if>
+			<if test="null != projectId and '' != projectId">
+				and project_id = #{projectId}
+			</if>
+			<if test="null != divIdType and '' != divIdType">
+				and div_id_type = #{divIdType}
+			</if>
+		</where>
 	</delete>
 
+	<select id="getAttachmentCountByAttachmentIdAndProjectId" resultType="java.lang.Integer">
+		select count(1) from work_attachment
+		<where>
+			<if test="null != attachmentId and '' != attachmentId">
+				and attachment_id = #{attachmentId}
+			</if>
+			<if test="null != attachmentName and '' != attachmentName">
+				and attachment_name = #{attachmentName}
+			</if>
+			<if test="null != projectId and '' != projectId">
+				and project_id = #{projectId}
+			</if>
+		</where>
+	</select>
+
 	<delete id="deleteById">
 		DELETE FROM work_attachment
 		WHERE id = #{id}

+ 1 - 0
src/main/resources/spring-context-shiro.xml

@@ -17,6 +17,7 @@
                 /static/** = anon
                 /userfiles/** = anon
                 ${adminPath}/workMaterialCollect/total/** = anon
+                ${adminPath}/ruralProject/signatureOldMessageDispose/** = anon
                 ${adminPath}/weChatCallBack/** = anon
                 ${adminPath}/ruralProject/ruralProjectRecords/getDownloadProjectView = anon
                 ${adminPath}/ruralProject/signatureCallBack/** = anon

+ 8 - 1
src/main/webapp/webpage/modules/ruralprojectrecords/ruralporjectmessage/electronicSeal/ruralProjectMessageElectronicSealList.jsp

@@ -928,7 +928,12 @@
                 //自动生成电子签章报告(在有报告的前提下可使用,没有报告信息则不进行展示该按钮)
                 //xml+="<a href=\"${ctx}/ruralProject/electronicSeal/downloadMassControl?id="+ d.pidId +"\" onclick=\"return confirmx('确认要自动生成报告签章吗?', this.href)\" class=\"layui-btn  layui-btn-xs\" > 自动生成报告签章</a>";
                 </shiro:hasPermission>--%>
-				xml+="<a href=\"${ctx}/ruralProject/signatureCallBack/downLoadReportAttach?contractId="+ d.reportSignatureContractId +"\" class=\"layui-btn  layui-btn-xs layui-bg-orange\" style='height:32px;margin-top: 5px;margin-bottom: 5px;'>报告签章下载</a>"
+				if(d.reportSignatureUrlFlag == 1){
+					xml+="<a href=\""+ d.reportSignatureUrl +"\" class=\"layui-btn  layui-btn-xs layui-bg-orange\" style='height:32px;margin-top: 5px;margin-bottom: 5px;'>报告签章下载</a>"
+				}else{
+					xml+="<a href=\"${ctx}/ruralProject/signatureCallBack/downLoadReportAttach?contractId="+ d.reportSignatureContractId +"\" class=\"layui-btn  layui-btn-xs layui-bg-orange\" style='height:32px;margin-top: 5px;margin-bottom: 5px;'>报告签章下载</a>"
+				}
+
 			}
 			xml+="</div>";
 			return[xml].join('');
@@ -1445,6 +1450,8 @@
 					,"reportSignatureProcessInstanceId":"${projectRecords.reportSignatureProcessInstanceId}"
 					,"prsiId":"${projectRecords.prsiId}"
 					,"signatureDownloadUrl":"${projectRecords.signatureDownloadUrl}"
+					,"reportSignatureUrlFlag":"${projectRecords.reportSignatureUrlFlag}"
+					,"reportSignatureUrl":"${projectRecords.reportSignatureUrl}"
 					,"falg":
 					<c:choose>
 						<c:when test="${fns:getUser().id == projectRecords.leaderIds || fns:getUser().id eq projectRecords.createBy.id}">