|
@@ -6,6 +6,9 @@ import com.jeeplus.common.persistence.Page;
|
|
|
import com.jeeplus.common.service.CrudService;
|
|
|
import com.jeeplus.common.utils.Collections3;
|
|
|
import com.jeeplus.common.utils.MenuStatusEnum;
|
|
|
+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.projectFilingBatch.dao.ProjectFilingBatchDao;
|
|
|
import com.jeeplus.modules.projectFilingBatch.dao.ProjectFilingbatchRelationDao;
|
|
|
import com.jeeplus.modules.projectFilingBatch.entity.ProjectFilingBatch;
|
|
@@ -22,6 +25,10 @@ import com.jeeplus.modules.sys.entity.User;
|
|
|
import com.jeeplus.modules.sys.service.OfficeService;
|
|
|
import com.jeeplus.modules.sys.utils.DictUtils;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import com.jeeplus.modules.utils.SftpClientUtil;
|
|
|
+import com.jeeplus.modules.utils.ZipCompressUtil;
|
|
|
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
|
|
|
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
|
|
|
import com.jeeplus.modules.workclientinfo.entity.WorkClientInfo;
|
|
|
import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
|
|
|
import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
|
|
@@ -32,6 +39,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -498,4 +511,216 @@ public class RuralProjectRecordsCaseBaseService extends CrudService<RuralProject
|
|
|
return recordsList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取项目附件模板类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<MainDictDetail> attachmentTemplateList(){
|
|
|
+ return DictUtils.getMainDictList("attachment_template_type");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取项目附件模板类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<MainDictDetail> attachmentTemplateListToCloud(){
|
|
|
+ return DictUtils.getMainDictListById("attachment_template_type");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目相应文件批量下载并压缩
|
|
|
+ * @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();
|
|
|
+ }
|
|
|
+
|
|
|
+ File resultFile = null;
|
|
|
+ File file = null;
|
|
|
+ try {
|
|
|
+ //遍历项目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());
|
|
|
+ //Integer approvalMoney = 2;
|
|
|
+ String money=records.getSubmitMoney();
|
|
|
+ Integer approvalMoney=null;
|
|
|
+ if(com.jeeplus.common.utils.StringUtils.isBlank(money)){
|
|
|
+ approvalMoney=1;
|
|
|
+ }else{
|
|
|
+ approvalMoney=Integer.parseInt(money);
|
|
|
+ }
|
|
|
+ switch (approvalMoney){
|
|
|
+ case 0:
|
|
|
+ //金额为0
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney(null);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ //500w以下金额状态
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney("1");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //500w以上金额状态
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney("2");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //添加报告类型
|
|
|
+ relateInfo.setRequiredStage(1);
|
|
|
+ relateInfo.setId(records.getId());
|
|
|
+ //查询报告文件、依据性文件、其他文件必填列表以及数据
|
|
|
+ List<MainDictDetail> mainDictDetails = attachmentTemplateList();
|
|
|
+ String downloadPath = path +"/案例文件" + "/" + records.getProjectReportNumber() + "_" + records.getProjectName();
|
|
|
+ for (MainDictDetail mainDict : mainDictDetails) {
|
|
|
+ relateInfo.setAttachType(mainDict.getValue());
|
|
|
+ switch (mainDict.getValue()) {
|
|
|
+ case "14":
|
|
|
+ File dirMaterialFile=new File(downloadPath + "/甲供材料清单");
|
|
|
+ File dirSupplierFile=new File(downloadPath + "/乙供材料清单");
|
|
|
+ //查询没有被选择必填项的数据并查询是否已经上传附件,若有则添加到展示列中
|
|
|
+ relateInfo.setAttachName("甲供材料清单");
|
|
|
+ List<ProjectTemplateInfo> materialProjectTemplateList = projectTemplateDao.getProjectAccessoryListByParentId(relateInfo);
|
|
|
+ List<ProjectTemplateInfo> projectTemplateListA = this.getProjectTemplateList(relateInfo, materialProjectTemplateList);
|
|
|
+ this.disposeFileList(projectTemplateListA,dirMaterialFile.getPath());
|
|
|
+
|
|
|
+ relateInfo.setAttachName("乙供材料清单");
|
|
|
+ List<ProjectTemplateInfo> supplierProjectTemplateList1 = projectTemplateDao.getProjectAccessoryListByParentId(relateInfo);
|
|
|
+ List<ProjectTemplateInfo> projectTemplateListB = this.getProjectTemplateList(relateInfo, supplierProjectTemplateList1);
|
|
|
+ this.disposeFileList(projectTemplateListB,dirSupplierFile.getPath());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //处理完之后进行打包压缩并删除之前的文件
|
|
|
+ ZipCompressUtil zipUtil = new ZipCompressUtil();
|
|
|
+ resultFile = new File(path);
|
|
|
+ file = zipUtil.zipCompress(resultFile, true);
|
|
|
+
|
|
|
+ }catch (IOException e) {
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
+ if(resultFile.isFile()&&resultFile.exists()){
|
|
|
+ resultFile.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return file.getPath();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkClientAttachmentDao workClientAttachmentDao;
|
|
|
+ @Autowired
|
|
|
+ private ProjectTemplateDao projectTemplateDao;
|
|
|
+
|
|
|
+ public List<ProjectTemplateInfo> getProjectTemplateList(ProjectAccessoryRelationInfo projectTemplateInfo, List<ProjectTemplateInfo> otherProjectTemplateList){
|
|
|
+ for (ProjectTemplateInfo otherInfo: otherProjectTemplateList) {
|
|
|
+ if("甲供材料清单".equals(otherInfo.getAttachName()) || "乙供材料清单".equals(otherInfo.getAttachName())){
|
|
|
+ WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
+ attchment.setProjectId(projectTemplateInfo.getId());
|
|
|
+ attchment.setAttachmentId(otherInfo.getId());
|
|
|
+ List<WorkClientAttachment> attachments = workClientAttachmentDao.getList(attchment);
|
|
|
+ if(!attachments.isEmpty()){
|
|
|
+ otherInfo.setWorkAttachments(attachments);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return otherProjectTemplateList;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 处理文件信息
|
|
|
+ * @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();
|
|
|
+ if(null != workAttachments && !workAttachments.isEmpty()){
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ File file = new File(downloadPath);
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.mkdirs();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public RuralProjectRecords getQueryProjectUsers(String id) {
|
|
|
+ RuralProjectRecords projectRecords = super.get(id);
|
|
|
+ List<User> users = workProjectUserDao.queryProjectUsers(projectRecords.getId(), "1");
|
|
|
+ projectRecords.setLeaderNameStr(Collections3.extractToString(users, "name", ","));
|
|
|
+ if (StringUtils.isNotBlank(projectRecords.getWorkContractInfo().getId())) {
|
|
|
+ WorkContractInfo workContractInfo = contractInfoService.get(projectRecords.getWorkContractInfo().getId());
|
|
|
+// workContractInfo.setConstructionProjectTypeStr(DictUtils.getDictLabel(String.valueOf(workContractInfo.getConstructionProjectType()), "construction_project_type", ""));
|
|
|
+ projectRecords.setWorkContractInfo(workContractInfo);
|
|
|
+ }
|
|
|
+ return projectRecords;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 下载压缩文件
|
|
|
+ * @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) {
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|