소스 검색

归档完成生成备考表和目录信息表

user5 4 년 전
부모
커밋
e9d9d31df1

+ 83 - 1
src/main/java/com/jeeplus/common/utils/ResponseUtil.java

@@ -1,5 +1,7 @@
 package com.jeeplus.common.utils;
 
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.modules.utils.SftpClientUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -9,9 +11,11 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.net.URLEncoder;
+import java.util.Calendar;
 
 public class ResponseUtil {
     private static Logger logger = LoggerFactory.getLogger(ResponseUtil.class);
+    private final static String directory = Global.getConfig("remoteServer.directory");
 
     public static void docResponse(String fileName, File file, HttpServletResponse response) {
         ServletOutputStream out = null;
@@ -44,7 +48,12 @@ public class ResponseUtil {
         }
     }
     public static String preViewResponse(String fileName, File file, HttpServletResponse response) {
-        String path = "D:/attachment-file/"+fileName;
+        String path = null;
+        if(System.getProperty("os.name").toLowerCase().contains("win")){
+            path = "D:/attachment-file/"+fileName;;
+        }else{
+            path = "/attachment-file/"+fileName;;
+        }
         try {
             SftpClientUtil sftpClientUtil = new SftpClientUtil();
             //File转MultipartFile文件
@@ -68,4 +77,77 @@ public class ResponseUtil {
         }
         return path;
     }
+
+    /**
+     * 文件下载本地并返回MultipartFile文件信息
+     * @param fileName
+     * @param file
+     * @return
+     */
+    public static String returnViewResponse(String fileName, File file) {
+        String path = null;
+        if(System.getProperty("os.name").toLowerCase().contains("win")){
+            path = "D:/attachment-file/"+fileName;;
+        }else{
+            path = "/attachment-file/"+fileName;;
+        }
+        try {
+            SftpClientUtil sftpClientUtil = new SftpClientUtil();
+            //File转MultipartFile文件
+            MultipartFile mFile = sftpClientUtil.transformFile(file);
+            InputStream in = mFile.getInputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            File newFile = new File(path);
+            File fileParent = newFile.getParentFile();
+            if (!fileParent.exists()) {
+                fileParent.mkdirs();
+            }
+            OutputStream out = new FileOutputStream(path);
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+        } catch (Exception e) {
+            logger.error("导出模板文件发生错误!",e);
+        }
+        return path;
+    }
+
+    public static String uploadOss(MultipartFile file,String storeAs){
+        String filepath = "";
+        if (!file.isEmpty()) {
+            // 文件保存路径
+
+            String realPath =directory.replace("/","")+"/"+storeAs+datePath()+"/"+ System.currentTimeMillis()+"/";
+            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 = Global.getAliDownloadUrl() + "/" + realPath + newName;
+
+            /*data.setName(file.getOriginalFilename());
+            data.setSrc(filepath);*/
+        }
+        return filepath;
+    }
+
+    /**
+     * 获取当前时间年月日
+     * @return
+     */
+    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;
+    }
 }

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

@@ -54,6 +54,7 @@ public class ProjectReportRecord extends ActEntity<ProjectReportRecord> {
 	private String condition;    //判定条件
 	private String flag;    //判定条件
 	private String holdFlag;    //暂存判定条件
+	private String referenceRemarks;    //备考表内容信息
 
 	private List<ProjectTemplateInfo> fileAttachmentList;   //报告文件
 	private List<ProjectTemplateInfo> fileGistdataList;   //依据性文件
@@ -404,4 +405,12 @@ public class ProjectReportRecord extends ActEntity<ProjectReportRecord> {
 	public void setChargeCriterionList(List<String> chargeCriterionList) {
 		this.chargeCriterionList = chargeCriterionList;
 	}
+
+	public String getReferenceRemarks() {
+		return referenceRemarks;
+	}
+
+	public void setReferenceRemarks(String referenceRemarks) {
+		this.referenceRemarks = referenceRemarks;
+	}
 }

+ 272 - 0
src/main/java/com/jeeplus/modules/projectcontentinfo/service/ProjectReportRecordService.java

@@ -4,18 +4,25 @@
 package com.jeeplus.modules.projectcontentinfo.service;
 
 import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BosController;
+import com.jeeplus.common.config.Global;
 import com.jeeplus.common.persistence.Page;
 import com.jeeplus.common.service.CrudService;
+import com.jeeplus.common.utils.FreemarkerUtil;
 import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.modules.act.entity.Act;
 import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.projectAccessory.dao.ProjectTemplateDao;
+import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
 import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportRecordDao;
 import com.jeeplus.modules.projectcontentinfo.entity.ProjectMaterialDefectRecord;
 import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
 import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportRecord;
 import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectMessageDao;
 import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
+import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectcontentinfo;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectMessageService;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
 import com.jeeplus.modules.sys.dao.WorkattachmentDao;
@@ -24,6 +31,7 @@ import com.jeeplus.modules.sys.entity.User;
 import com.jeeplus.modules.sys.entity.Workattachment;
 import com.jeeplus.modules.sys.service.WorkattachmentService;
 import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.utils.SftpClientUtil;
 import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
 import com.jeeplus.modules.workactivity.entity.Activity;
 import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
@@ -31,16 +39,27 @@ import com.jeeplus.modules.workactivity.service.ActivityService;
 import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
 import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
 import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+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;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
 import org.activiti.engine.*;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.task.Task;
+import org.apache.http.entity.ContentType;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -86,6 +105,8 @@ public class ProjectReportRecordService extends CrudService<ProjectReportRecordD
 	@Autowired
 	private RuralProjectRecordsService ruralProjectRecordsService;
 	@Autowired
+	private ProjectTemplateDao projectTemplateDao;
+	@Autowired
 	ProjectReportRecordDao projectReportRecordDao;
 	public ProjectReportRecord get(String id) {
 		ProjectReportRecord projectReportRecord= super.get(id);
@@ -601,6 +622,44 @@ public class ProjectReportRecordService extends CrudService<ProjectReportRecordD
 			}
 			users.add(projectReportRecord.getCreateBy());
 			if ("yes".equals(flag)) {
+
+				//判定为非全过程项目进行备考表信息处理
+				if(!"3".equals(record.getProjectType())){
+					//查询其他资料对应附件结构信息
+					ProjectTemplateInfo templateInfo = projectTemplateDao.getProjectTemplateInfoByName("其他资料");
+					//获取上传阿里云盘文件地址
+					String uploadFilePath = downloadReference(reportRecord, record);
+					if(StringUtils.isNotBlank(uploadFilePath)){
+						//将备考表添加到附件中
+						Workattachment workattachment = new Workattachment();
+						workattachment.setAttachmentId(templateInfo.getId());
+						workattachment.setProjectId(record.getId());
+						workattachment.setUrl(uploadFilePath);
+						workattachment.setType("doc");
+						workattachment.setAttachmentFlag("100");
+						workattachment.setAttachmentName("备考表.doc");
+						workattachment.setAttachmentUser(UserUtils.getUser().getId());
+						workattachmentService.insertOnWorkAttachment(workattachment);
+					}
+					//生成文件目录
+					//获取上传阿里云盘文件地址
+					String uploadCatalogueFilePath = downloadCatalogue(record.getId());
+
+					if(StringUtils.isNotBlank(uploadCatalogueFilePath)){
+						//将备考表添加到附件中
+						Workattachment workattachment = new Workattachment();
+						workattachment.setAttachmentId(templateInfo.getId());
+						workattachment.setProjectId(record.getId());
+						workattachment.setUrl(uploadCatalogueFilePath);
+						workattachment.setType("doc");
+						workattachment.setAttachmentFlag("100");
+						workattachment.setAttachmentName("文件目录.doc");
+						workattachment.setAttachmentUser(UserUtils.getUser().getId());
+						workattachment.setCompanyId(UserUtils.getSelectCompany().getId());
+						workattachmentService.insertOnWorkAttachment(workattachment);
+					}
+				}
+
 				ProjectReportData projectReportData =projectReportRecord.getReport();
 				projectReportData.setFileStatus("3");
 				projectReportDataService.updateFileStatus(projectReportData);
@@ -1205,4 +1264,217 @@ public class ProjectReportRecordService extends CrudService<ProjectReportRecordD
 		}
 		return "保存审核意见成功!";
 	}
+
+	/**
+	 * 将备考表下载到本地
+	 * @param projectReportRecord
+	 */
+	public String downloadReference(ProjectReportRecord projectReportRecord, RuralProjectRecords record)  {
+		Map data = referenceData(projectReportRecord,record);
+		//模板对象
+		Template template=null;
+		//freemaker模板路径
+		File path = new File(this.getClass().getResource("/").getPath()+"/freemarker");
+		Configuration cfg = new Configuration();
+		try {
+			cfg.setDirectoryForTemplateLoading(path);
+			//选择对应的ftl文件
+			template = cfg.getTemplate("reference.ftl","UTF-8");
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		//获取当前时间戳
+		long time = new Date().getTime();
+		File docFile = new File(time+"备考表.doc");
+		FreemarkerUtil.generateFile(data,template,docFile);
+		String filePath = ResponseUtil.returnViewResponse(time + "备考表.doc", docFile);
+		//本地备考表信息生成file文件
+		File file = new File(filePath);
+		//File转MultipartFile文件
+		SftpClientUtil sftpClientUtil = new SftpClientUtil();
+		MultipartFile mFile = sftpClientUtil.transformFile(docFile);
+		//文件上传oss
+		String uploadPath = null;
+		try {
+			uploadPath = ResponseUtil.uploadOss(mFile, "reportRecord");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}finally {
+			//删除本地文件
+			if (!file.isDirectory()) {
+				file.delete();
+			}
+		}
+		return uploadPath;
+	}
+
+	private Map<String,Object> referenceData(ProjectReportRecord projectReportRecord, RuralProjectRecords record){
+		//freemarker参数值准备
+		Map<String,Object> data  = new LinkedHashMap<>();
+		//本卷情况说明
+		if(StringUtils.isNotBlank(projectReportRecord.getReferenceRemarks())){
+			data.put("informationNote",projectReportRecord.getReferenceRemarks());
+		}else{
+
+			data.put("informationNote","");
+		}
+		//立卷人(项目负责人)
+		//查询项目负责人
+		if(StringUtils.isNotBlank(record.getProjectMasterId())){
+			User masterUser = UserUtils.get(record.getProjectMasterId());
+			if(null != masterUser && StringUtils.isNotBlank(masterUser.getName())){
+				data.put("projectLeader",masterUser.getName());
+			}else{
+				data.put("projectLeader","");
+			}
+		}else{
+			data.put("projectLeader","");
+		}
+		//检查人(档案管理员,即当前登陆人)
+		if(StringUtils.isNotBlank(UserUtils.getUser().getName())){
+			data.put("archivist",UserUtils.getUser().getName());
+		}else{
+
+			data.put("archivist","");
+		}
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+		String dateString = formatter.format(new Date());
+		//立卷时间(审批通过时间,即当前时间)
+		data.put("approvalTime",dateString);
+		return data;
+	}
+
+
+
+
+
+
+
+
+
+
+
+	//生成目录
+	public String downloadCatalogue(String projectId)  {
+		Map data = catalogueData(projectId);
+		//模板对象
+		Template template=null;
+		//freemaker模板路径
+		File path = new File(this.getClass().getResource("/").getPath()+"/freemarker");
+		Configuration cfg = new Configuration();
+		try {
+			cfg.setDirectoryForTemplateLoading(path);
+			//选择对应的ftl文件
+			template = cfg.getTemplate("catalogue.ftl","UTF-8");
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		//获取当前时间戳
+		long time = new Date().getTime();
+		File docFile = new File(time + "文件目录.doc");
+		FreemarkerUtil.generateFile(data,template,docFile);
+		String filePath = ResponseUtil.returnViewResponse(time + "文件目录.doc", docFile);
+
+		//本地备考表信息生成file文件
+		File file = new File(filePath);
+		//File转MultipartFile文件
+		SftpClientUtil sftpClientUtil = new SftpClientUtil();
+		MultipartFile mFile = sftpClientUtil.transformFile(docFile);
+		//文件上传oss
+		String uploadPath = null;
+		try {
+			uploadPath = ResponseUtil.uploadOss(mFile, "reportRecord");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}finally {
+			//删除本地文件
+			if (!file.isDirectory()) {
+				file.delete();
+			}
+		}
+		return uploadPath;
+	}
+
+	//获取数据
+	private Map<String,Object> catalogueData(String projectId){
+		//获取数据
+		RuralProjectRecords projectRecords = ruralProjectRecordsService.getQueryProjectUsers(projectId);
+		//文件信息获取
+		RuralProjectcontentinfo ruralProjectcontentinfo = ruralProjectRecordsService.formAccessory(projectRecords);
+		//目录
+		List<Map<String,String>> list=new LinkedList<>();
+		//序号
+		int count=1;
+		//成果文件
+		if (ruralProjectcontentinfo.getFileAttachmentList().size()>0){
+			List<ProjectTemplateInfo> infos=ruralProjectcontentinfo.getFileAttachmentList();
+			for (int i=0;i<infos.size();i++){
+				if (infos.get(i).getWorkAttachments().size()>0){
+					for (WorkClientAttachment attachment:infos.get(i).getWorkAttachments()){
+						Map<String,String> map=new HashMap<>();
+						map.put("count",count+"");
+						map.put("type","成果文件");
+						map.put("content",infos.get(i).getAttachName());
+						map.put("fileName",attachment.getAttachmentName());
+						map.put("remarks","");
+						count++;
+						list.add(map);
+					}
+				}
+			}
+		}
+		//依据性文件
+		if (ruralProjectcontentinfo.getFileGistdataList().size()>0){
+			List<ProjectTemplateInfo> infos=ruralProjectcontentinfo.getFileGistdataList();
+			for (int i=0;i<infos.size();i++){
+				if (infos.get(i).getWorkAttachments().size()>0){
+					for (WorkClientAttachment attachment:infos.get(i).getWorkAttachments()){
+						Map<String,String> map=new HashMap<>();
+						map.put("count",count+"");
+						map.put("type","依据文件");
+						map.put("content",infos.get(i).getAttachName());
+						map.put("fileName",attachment.getAttachmentName());
+						map.put("remarks","");
+						count++;
+						list.add(map);
+					}
+				}
+			}
+		}
+		//其它文件
+		if (ruralProjectcontentinfo.getFileGistdataList().size()>0){
+			List<ProjectTemplateInfo> infos=ruralProjectcontentinfo.getFileOtherList();
+			for (int i=0;i<infos.size();i++){
+				if (infos.get(i).getWorkAttachments().size()>0){
+					for (WorkClientAttachment attachment:infos.get(i).getWorkAttachments()){
+						Map<String,String> map=new HashMap<>();
+						map.put("count",count+"");
+						map.put("type","其它文件");
+						map.put("content",infos.get(i).getAttachName());
+						map.put("fileName",attachment.getAttachmentName());
+						map.put("remarks","");
+						count++;
+						list.add(map);
+					}
+				}
+			}
+		}
+		//freemarker参数值准备
+		Map<String,Object> data  = new LinkedHashMap<>();
+		//获取报告
+		ProjectReportData projectReportData = projectReportDataService.getReportDataByProjectId(projectRecords.getId());
+		if (null!=projectReportData){
+			if(StringUtils.isNotBlank(projectReportData.getNumber())){
+				data.put("number",projectReportData.getNumber());
+			}else{
+				data.put("number","");
+			}
+		}else{
+			//文号
+			data.put("number","");
+		}
+		data.put("list",list);
+		return data;
+	}
+
 }

+ 14 - 5
src/main/java/com/jeeplus/modules/sys/entity/Workattachment.java

@@ -31,6 +31,7 @@ public class Workattachment extends DataEntity<Workattachment> {
 
 	private String collectFlag;		// 收藏判定
 	private String fileSize;	//文件大小
+	private String projectId;	//项目id
 
 
 	public String getDivIdType() {
@@ -57,7 +58,7 @@ public class Workattachment extends DataEntity<Workattachment> {
 	public void setUrl(String url) {
 		this.url = url;
 	}
-	
+
 	@ExcelField(title="附件类型", align=2, sort=8)
 	public String getType() {
 		return type;
@@ -66,7 +67,7 @@ public class Workattachment extends DataEntity<Workattachment> {
 	public void setType(String type) {
 		this.type = type;
 	}
-	
+
 	@ExcelField(title="附件id", align=2, sort=9)
 	public String getAttachmentId() {
 		return attachmentId;
@@ -75,7 +76,7 @@ public class Workattachment extends DataEntity<Workattachment> {
 	public void setAttachmentId(String attachmentId) {
 		this.attachmentId = attachmentId;
 	}
-	
+
 	@ExcelField(title="上传人", align=2, sort=10)
 	public String getAttachmentUser() {
 		return attachmentUser;
@@ -84,7 +85,7 @@ public class Workattachment extends DataEntity<Workattachment> {
 	public void setAttachmentUser(String attachmentUser) {
 		this.attachmentUser = attachmentUser;
 	}
-	
+
 	@ExcelField(title="文件名", align=2, sort=11)
 	public String getAttachmentName() {
 		return attachmentName;
@@ -157,4 +158,12 @@ public class Workattachment extends DataEntity<Workattachment> {
 	public void setFileSize(String fileSize) {
 		this.fileSize = fileSize;
 	}
-}
+
+	public String getProjectId() {
+		return projectId;
+	}
+
+	public void setProjectId(String projectId) {
+		this.projectId = projectId;
+	}
+}

+ 2 - 2
src/main/java/com/jeeplus/modules/workfullmanage/web/WorkFullManageController.java

@@ -1587,9 +1587,9 @@ public class WorkFullManageController extends BaseController {
 			e.printStackTrace();
 		}
 
-		File docFile = new File("备考表(自动).doc");
+		File docFile = new File("备考表.doc");
 		FreemarkerUtil.generateFile(data,template,docFile);
-		ResponseUtil.docResponse("备考表(自动).doc",docFile,response);
+		ResponseUtil.preViewResponse("备考表.doc",docFile,response);
 	}
 
 	private Map<String,Object> referenceData(ProjectReportData projectReportData){

+ 9 - 1
src/main/java/com/jeeplus/modules/workprojectnotify/web/WorkProjectNotifyController.java

@@ -3483,7 +3483,15 @@ public class WorkProjectNotifyController extends BaseController {
 									projectReportRecord.setFileGistdataList(projectTemplateList);
 									break;
 								case "13":
-									projectReportRecord.setFileOtherList(projectTemplateService.getProjectTemplateListByArchive(relateInfo));
+									List<ProjectTemplateInfo> fileOtherList = projectTemplateService.getProjectTemplateListByArchive(relateInfo);
+									for (ProjectTemplateInfo info: fileOtherList) {
+										info.setAttachTypes(info.getAttachTypes().toLowerCase());
+										if(engineeringId.equals(ruralProjectRecords.getEngineeringType())){
+											if("其他资料".equals(info.getAttachName())){
+											}
+										}
+									}
+									projectReportRecord.setFileOtherList(fileOtherList);
 									break;
 							}
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1212 - 1167
src/main/resources/freemarker/catalogue.ftl


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 25 - 210
src/main/resources/freemarker/reference.ftl


+ 2 - 0
src/main/resources/mappings/modules/sys/WorkattachmentDao.xml

@@ -277,6 +277,7 @@
 			company_id,
 			attachment_flag,
 			div_id_type,
+			project_id,
 		    file_size
 		) VALUES (
 			#{id},
@@ -294,6 +295,7 @@
 			#{companyId},
 			#{attachmentFlag},
 			#{divIdType},
+			#{projectId},
 		    #{fileSize}
 		)
 	</insert>

+ 9 - 0
src/main/webapp/webpage/modules/projectcontentinfo/projectReportRecordAudit.jsp

@@ -817,6 +817,15 @@
 							</div>
 
 
+							<div class="form-group layui-row">
+								<div class="form-group-label"><h2>备考表</h2></div>
+								<div class="layui-item layui-col-sm11 with-textarea">
+									<label class="layui-form-label ">备考表:</label>
+									<div class="layui-input-block">
+										<form:textarea placeholder="请输入备考表内容" path="referenceRemarks" htmlEscape="false" rows="7"  maxlength="500"  class="form-control "/>
+									</div>
+								</div>
+							</div>
 
 				</div>
 				<div class="form-group layui-row first hide" id="subProjectInfo">