|
@@ -5,6 +5,7 @@ package com.jeeplus.modules.ruralprojectrecords.service;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
+import com.jeeplus.common.config.Global;
|
|
import com.jeeplus.common.persistence.Page;
|
|
import com.jeeplus.common.persistence.Page;
|
|
import com.jeeplus.common.service.CrudService;
|
|
import com.jeeplus.common.service.CrudService;
|
|
import com.jeeplus.common.utils.Collections3;
|
|
import com.jeeplus.common.utils.Collections3;
|
|
@@ -14,10 +15,16 @@ import com.jeeplus.common.utils.MenuStatusEnum;
|
|
import com.jeeplus.modules.act.entity.Act;
|
|
import com.jeeplus.modules.act.entity.Act;
|
|
import com.jeeplus.modules.act.service.ActTaskService;
|
|
import com.jeeplus.modules.act.service.ActTaskService;
|
|
import com.jeeplus.modules.act.utils.ProcessDefCache;
|
|
import com.jeeplus.modules.act.utils.ProcessDefCache;
|
|
|
|
+import com.jeeplus.modules.projectAccessory.dao.ProjectTemplateDao;
|
|
|
|
+import com.jeeplus.modules.projectAccessory.entity.ProjectAccessoryRelationInfo;
|
|
|
|
+import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
|
|
|
|
+import com.jeeplus.modules.projectAccessory.service.ProjectAccessoryRelationService;
|
|
|
|
+import com.jeeplus.modules.projectAccessory.service.ProjectTemplateService;
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportDataDao;
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportDataDao;
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectcontentinfoDao;
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectcontentinfoDao;
|
|
import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
|
|
import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
|
|
import com.jeeplus.modules.projectcontentinfo.entity.Projectcontentinfo;
|
|
import com.jeeplus.modules.projectcontentinfo.entity.Projectcontentinfo;
|
|
|
|
+import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
|
|
import com.jeeplus.modules.projectrecord.entity.ProjectRecords;
|
|
import com.jeeplus.modules.projectrecord.entity.ProjectRecords;
|
|
import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectClientLinkmanDao;
|
|
import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectClientLinkmanDao;
|
|
import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectRecordsDao;
|
|
import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectRecordsDao;
|
|
@@ -33,6 +40,8 @@ import com.jeeplus.modules.sys.service.OfficeService;
|
|
import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
import com.jeeplus.modules.sys.utils.DictUtils;
|
|
import com.jeeplus.modules.sys.utils.DictUtils;
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
|
+import com.jeeplus.modules.utils.SftpClientUtil;
|
|
|
|
+import com.jeeplus.modules.utils.ZipCompressUtil;
|
|
import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
|
|
import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
|
|
import com.jeeplus.modules.workactivity.entity.Activity;
|
|
import com.jeeplus.modules.workactivity.entity.Activity;
|
|
import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
|
|
import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
|
|
@@ -65,8 +74,14 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.zip.ZipEntry;
|
|
|
|
+import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 项目登记Service
|
|
* 项目登记Service
|
|
@@ -119,6 +134,21 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
|
|
private WorkActivityProcessDao workActivityProcessDao;
|
|
private WorkActivityProcessDao workActivityProcessDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ProjectReportDataDao projectReportDataDao;
|
|
private ProjectReportDataDao projectReportDataDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProjectReportDataService projectReportDataService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProjectAccessoryRelationService projectAccessoryRelationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProjectTemplateDao projectTemplateDao;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取项目附件模板类型
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static List<MainDictDetail> attachmentTemplateList(){
|
|
|
|
+ return DictUtils.getMainDictList("attachment_template_type");
|
|
|
|
+ }
|
|
|
|
|
|
private static byte[] SYN_BYTE = new byte[0];
|
|
private static byte[] SYN_BYTE = new byte[0];
|
|
|
|
|
|
@@ -1442,4 +1472,177 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
|
|
dao.updateProjectReportedState(idList);
|
|
dao.updateProjectReportedState(idList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 项目相应文件批量下载并压缩
|
|
|
|
+ * @param idList
|
|
|
|
+ */
|
|
|
|
+ public String exportAll(List<String> idList) throws Exception {
|
|
|
|
+ //设置下载的压缩包名(固定字符+时间戳)
|
|
|
|
+ long timeMillis = System.currentTimeMillis();
|
|
|
|
+ String fileLocality = "项目附件_"+ timeMillis;
|
|
|
|
+ //判定当前系统
|
|
|
|
+ String path = null;
|
|
|
|
+ if(System.getProperty("os.name").toLowerCase().contains("win")){
|
|
|
|
+ path = Global.getConfig("remoteServer.winDirectory");
|
|
|
|
+ }else{
|
|
|
|
+ path = Global.getConfig("remoteServer.directory");
|
|
|
|
+ }
|
|
|
|
+ path = path + "/" + fileLocality;
|
|
|
|
+ //检查该路径对应的目录是否存在. 如果不存在则创建目录
|
|
|
|
+ File dir=new File(path);
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
+ dir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ //遍历项目id并查询对应数据信息
|
|
|
|
+ for (String projectId: idList) {
|
|
|
|
+ //获取项目信息
|
|
|
|
+ RuralProjectRecords records = this.getQueryProjectUsers(projectId);
|
|
|
|
+ //根据项目id查询项目报告信息
|
|
|
|
+ ProjectReportData projectReportData = projectReportDataService.getReportDataByProjectId(records.getId());
|
|
|
|
+ projectReportData = projectReportDataService.get(projectReportData.getId());
|
|
|
|
+ ProjectAccessoryRelationInfo relateInfo = new ProjectAccessoryRelationInfo();
|
|
|
|
+
|
|
|
|
+ //添加项目类型
|
|
|
|
+ relateInfo.setAttachmentProjectType(records.getProjectType());
|
|
|
|
+ relateInfo.setAttachmentProjectSort(records.getAttachmentProjectSort());
|
|
|
|
+
|
|
|
|
+ //查看送审金额是否为500w以上金额
|
|
|
|
+ Integer approvalMoney = projectAccessoryRelationService.decideAttachmentProjectApprovalMoney(projectReportData.getReviewFee());
|
|
|
|
+ if(0 == approvalMoney){
|
|
|
|
+ //金额为0
|
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney(null);
|
|
|
|
+ }else if(1 == approvalMoney){
|
|
|
|
+ //500w以下金额状态
|
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney("1");
|
|
|
|
+ }else{
|
|
|
|
+ //500w以上金额状态
|
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney("2");
|
|
|
|
+ }
|
|
|
|
+ //添加报告类型
|
|
|
|
+ relateInfo.setRequiredStage(1);
|
|
|
|
+ relateInfo.setId(records.getId());
|
|
|
|
+ //查询报告文件、依据性文件、其他文件必填列表以及数据
|
|
|
|
+ List<MainDictDetail> mainDictDetails = this.attachmentTemplateList();
|
|
|
|
+ List<ProjectTemplateInfo> projectTemplateList = null;
|
|
|
|
+ String downloadPath = path + "/" + records.getProjectName();
|
|
|
|
+ for (MainDictDetail mainDict : mainDictDetails) {
|
|
|
|
+ relateInfo.setAttachType(mainDict.getValue());
|
|
|
|
+ File dirFile = null;
|
|
|
|
+ switch (mainDict.getValue()) {
|
|
|
|
+ case "11":
|
|
|
|
+ dirFile=new File(downloadPath+"/成果文件");
|
|
|
|
+ projectTemplateList = Lists.newArrayList();
|
|
|
|
+ projectTemplateList = this.getProjectTemplateList(relateInfo);
|
|
|
|
+ this.disposeFileList(projectTemplateList,dirFile.getPath());
|
|
|
|
+ break;
|
|
|
|
+ case "12":
|
|
|
|
+ dirFile=new File(downloadPath+"/依据性资料");
|
|
|
|
+ projectTemplateList = Lists.newArrayList();
|
|
|
|
+ projectTemplateList = this.getProjectTemplateList(relateInfo);
|
|
|
|
+ this.disposeFileList(projectTemplateList,dirFile.getPath());
|
|
|
|
+ break;
|
|
|
|
+ case "13":
|
|
|
|
+ dirFile=new File(downloadPath+"/其他文件");
|
|
|
|
+ projectTemplateList = Lists.newArrayList();
|
|
|
|
+ projectTemplateList = this.getProjectTemplateList(relateInfo);
|
|
|
|
+ this.disposeFileList(projectTemplateList,dirFile.getPath());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //处理完之后进行打包压缩并删除之前的文件
|
|
|
|
+ ZipCompressUtil zipUtil = new ZipCompressUtil();
|
|
|
|
+ File resultFile = new File(path);
|
|
|
|
+ File file = zipUtil.zipCompress(resultFile, true);
|
|
|
|
+ return file.getPath();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载压缩文件
|
|
|
|
+ * @param filePath
|
|
|
|
+ * @param response
|
|
|
|
+ */
|
|
|
|
+ public void downloadZipFile(String filePath,HttpServletResponse response){
|
|
|
|
+ File file = new File(filePath);
|
|
|
|
+ // 取得文件名。
|
|
|
|
+ String fileName = file.getName();
|
|
|
|
+ InputStream in = null;
|
|
|
|
+ try {
|
|
|
|
+ fileName = URLEncoder.encode(fileName,"UTF8");
|
|
|
|
+ in = new FileInputStream(file);
|
|
|
|
+ response.reset();//重置 响应头
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/x-download");
|
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
|
|
|
+
|
|
|
|
+ byte[] b = new byte[1024];
|
|
|
|
+ int len;
|
|
|
|
+ while ((len = in.read(b)) > 0){
|
|
|
|
+ response.getOutputStream().write(b, 0, len);
|
|
|
|
+ }
|
|
|
|
+ in.close();
|
|
|
|
+ response.getOutputStream().close();
|
|
|
|
+ }catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ finally {
|
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 处理文件信息
|
|
|
|
+ * @param projectTemplateList
|
|
|
|
+ * @param downloadPath
|
|
|
|
+ */
|
|
|
|
+ public void disposeFileList(List<ProjectTemplateInfo> projectTemplateList,String downloadPath) throws IOException {
|
|
|
|
+ SftpClientUtil sftpClientUtil = new SftpClientUtil();
|
|
|
|
+ for (ProjectTemplateInfo info: projectTemplateList) {
|
|
|
|
+ List<WorkClientAttachment> workAttachments = info.getWorkAttachments();
|
|
|
|
+ for (WorkClientAttachment attachment:workAttachments) {
|
|
|
|
+ sftpClientUtil.downloadRuralProject(attachment.getUrl().substring(0,attachment.getUrl().lastIndexOf("/")),attachment.getUrl().substring(attachment.getUrl().lastIndexOf("/") + 1, attachment.getUrl().length()),downloadPath,attachment.getAttachmentName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public List<ProjectTemplateInfo> getProjectTemplateList(ProjectAccessoryRelationInfo projectTemplateInfo){
|
|
|
|
+ //查询所有被选择为必填项展示列,并查询附件信息
|
|
|
|
+ List<ProjectTemplateInfo> projectTemplateList = projectTemplateDao.getProjectTemplateList(projectTemplateInfo);
|
|
|
|
+ for (ProjectTemplateInfo info: projectTemplateList) {
|
|
|
|
+ WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
|
+ attchment.setProjectId(projectTemplateInfo.getId());
|
|
|
|
+ attchment.setAttachmentId(info.getId());
|
|
|
|
+ List<WorkClientAttachment> attachments = workClientAttachmentDao.getList(attchment);
|
|
|
|
+ info.setWorkAttachments(attachments);
|
|
|
|
+ //判断是否为必填项,若为必填项则添加必填判定字段
|
|
|
|
+ if(info.getRequiredStage() == projectTemplateInfo.getRequiredStage()){
|
|
|
|
+ info.setMustFlag(1);
|
|
|
|
+ } else {
|
|
|
|
+ info.setMustFlag(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //查询没有被选择必填项的数据并查询是否已经上传附件,若有则添加到展示列中
|
|
|
|
+ List<ProjectTemplateInfo> otherProjectTemplateList = projectTemplateDao.projectAccessoryListByParentId(projectTemplateInfo);
|
|
|
|
+ for (ProjectTemplateInfo otherInfo: otherProjectTemplateList) {
|
|
|
|
+ WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
|
+ attchment.setProjectId(projectTemplateInfo.getId());
|
|
|
|
+ attchment.setAttachmentId(otherInfo.getId());
|
|
|
|
+ List<WorkClientAttachment> attachments = workClientAttachmentDao.getList(attchment);
|
|
|
|
+ if(attachments.size()>0){
|
|
|
|
+ otherInfo.setWorkAttachments(attachments);
|
|
|
|
+
|
|
|
|
+ otherInfo.setMustFlag(0);
|
|
|
|
+ projectTemplateList.add(otherInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return projectTemplateList;
|
|
|
|
+ }
|
|
}
|
|
}
|