Antiloveg 8 years ago
parent
commit
5a4a192b5a

+ 18 - 9
src/main/java/com/goafanti/admin/controller/AdminAchievementApiController.java

@@ -29,13 +29,12 @@ import com.goafanti.common.utils.StringUtils;
 public class AdminAchievementApiController extends CertifyApiController {
 	@Resource
 	private AchievementService achievementService;
-	
-	
+
 	/**
-	 * 下载文本文件(成熟度)
+	 * 下载文本文件
 	 */
 	@RequestMapping(value = "/download", method = RequestMethod.GET)
-	public Result download(HttpServletResponse response, String id) {
+	public Result download(HttpServletResponse response, String id, String sign) {
 		Result res = new Result();
 
 		if (StringUtils.isEmpty(id)) {
@@ -49,21 +48,31 @@ public class AdminAchievementApiController extends CertifyApiController {
 			return res;
 		}
 
-		downloadUnPrivateFile(response, a.getMaturityTextFileDownloadFileName(), a.getMaturityTextFileUrl());
+		AttachmentType attachmentType = AttachmentType.getField(sign);
+		if (attachmentType == AttachmentType.ACHIEVEMENT_MATURITY_TEXT_FILE) {
+			downloadUnPrivateFile(response, a.getMaturityTextFileDownloadFileName(), a.getMaturityTextFileUrl());
+		} else if (attachmentType == AttachmentType.ACHIEVEMENT_TECH_PLAN){
+			downloadUnPrivateFile(response, a.getTechPlanDownloadFileName(), a.getTechPlanUrl());
+		} else if (attachmentType == AttachmentType.ACHIEVEMENT_BUSINESS_PLAN){
+			downloadUnPrivateFile(response, a.getBusinessPlanDownloadFileName(), a.getBusinessPlanUrl());
+		} else {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
+		}
 		return res;
 	}
-	
+
 	/**
-	 * 成熟度文本文件上传
+	 * 文本文件上传
 	 */
 	@RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
 	public Result uploadTextFile(HttpServletRequest req, String sign) {
 		Result res = new Result();
 
-
 		AttachmentType attachmentType = AttachmentType.getField(sign);
 
-		if (attachmentType == AttachmentType.ACHIEVEMENT_MATURITY_TEXT_FILE) {
+		if (attachmentType == AttachmentType.ACHIEVEMENT_MATURITY_TEXT_FILE
+				|| attachmentType == AttachmentType.ACHIEVEMENT_TECH_PLAN
+				|| attachmentType == AttachmentType.ACHIEVEMENT_BUSINESS_PLAN) {
 			res.setData(handleFiles(res, "/achievement/", false, req, sign, "achievement"));
 		} else {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));

+ 3 - 1
src/main/java/com/goafanti/common/enums/AttachmentType.java

@@ -16,7 +16,9 @@ public enum AttachmentType {
 	DEMAND_PICTURE("demand_picture", "科技需求图片资料"), DEMAND_TEXT_FILE("demand_text_file", "科技需求文本文件资料"),
 	ACHIEVEMENT_TECHNICAL_PICTURE("achievement_technical_picture", "科技成果技术图片"), 
 	ACHIEVEMENT_MATURITY_PICTURE("achievement_maturity_picture", "科技成果成熟度资料图片"),
-	ACHIEVEMENT_MATURITY_TEXT_FILE("achievement_maturity_text_file", "科技成果成熟度资料文本文件");
+	ACHIEVEMENT_MATURITY_TEXT_FILE("achievement_maturity_text_file", "科技成果成熟度资料文本文件"),
+	ACHIEVEMENT_TECH_PLAN("achievement_tech_plan", "科技成果技术方案文件"),
+	ACHIEVEMENT_BUSINESS_PLAN("achievement_business_plan", "科技成果商业计划书");
 
 	private AttachmentType(String code, String desc) {
 		this.code = code;

+ 24 - 0
src/main/java/com/goafanti/common/model/Achievement.java

@@ -681,4 +681,28 @@ public class Achievement {
 	public void setMaturityTextFileUrlDownloadFileName(String maturityTextFileDownloadFileName) {
 
 	}
+	
+	public String getBusinessPlanDownloadFileName() {
+		if (StringUtils.isBlank(this.businessPlanUrl)) {
+			return null;
+		} else {
+			return FileUtils.getDownloadFileName(this.businessPlanUrl);
+		}
+	}
+
+	public void setBusinessPlanDownloadFileName(String businessPlanDownloadFileName) {
+
+	}
+	
+	public String getTechPlanDownloadFileName() {
+		if (StringUtils.isBlank(this.techPlanUrl)) {
+			return null;
+		} else {
+			return FileUtils.getDownloadFileName(this.techPlanUrl);
+		}
+	}
+
+	public void setTechPlanDownloadFileName(String techPlanDownloadFileName) {
+
+	}
 }

+ 29 - 59
src/main/java/com/goafanti/common/utils/FileUtils.java

@@ -16,6 +16,8 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.multipart.MultipartFile;
 
+import com.goafanti.common.enums.AttachmentType;
+
 public class FileUtils {
 	@Value(value = "${upload.private.path}")
 	private String					uploadPrivatePath	= null;
@@ -130,84 +132,52 @@ public class FileUtils {
 		}
 		String prefix = "附件";
 		String suffix = path.substring(path.lastIndexOf("."));
-		if (path.indexOf("patent_prory_statement") != -1) {
+		if (path.indexOf(AttachmentType.PATENT_PRORY_STATEMENT.getCode()) != -1) {
 			prefix = "专利代理委托书";
-		}
-
-		if (path.indexOf("patent_writing") != -1) {
+		} else if (path.indexOf(AttachmentType.PATENT_WRITING.getCode()) != -1) {
 			prefix = "专利稿件";
-		}
-
-		if (path.indexOf("authorization_notice") != -1) {
+		} else if (path.indexOf(AttachmentType.AUTHORIZATION_NOTICE.getCode()) != -1) {
 			prefix = "授权通知书";
-		}
-
-		if (path.indexOf("patent_certificate") != -1) {
+		} else if (path.indexOf(AttachmentType.PATENT_CERTIFICATE.getCode()) != -1) {
 			prefix = "专利证书";
-		}
-
-		if (path.indexOf("proof") != -1) {
+		} else if (path.indexOf(AttachmentType.PROOF.getCode()) != -1) {
 			prefix = "立项证明材料";
-		}
-
-		if (path.indexOf("activity_cost_account") != -1) {
+		} else if (path.indexOf(AttachmentType.ACTIVITY_COST_ACCOUNT.getCode()) != -1) {
 			prefix = "研发活动费用台帐";
-		}
-
-		if (path.indexOf("tech_product") != -1) {
+		} else if (path.indexOf(AttachmentType.TECH_PRODUCT.getCode()) != -1) {
 			prefix = "高新技术产品台帐";
-		}
-
-		if (path.indexOf("property_ritht") != -1) {
+		} else if (path.indexOf(AttachmentType.PROPERTY_RIGHT.getCode()) != -1) {
 			prefix = "知识产权证书";
-		}
-
-		if (path.indexOf("roster") != -1) {
+		} else if (path.indexOf(AttachmentType.ROSTER.getCode()) != -1) {
 			prefix = subStr(path) + "花名册";
-		}
-
-		if (path.indexOf("social_security") != -1) {
+		} else if (path.indexOf(AttachmentType.SOCIAL_SECURITY.getCode()) != -1) {
 			prefix = subStr(path) + "社保情况";
-		}
-
-		if (path.indexOf("honor") != -1) {
+		} else if (path.indexOf(AttachmentType.HONOR.getCode()) != -1) {
 			prefix = "荣誉材料证明";
-		}
-
-		if (path.indexOf("achievement") != -1) {
+		} else if (path.indexOf(AttachmentType.ACHIEVEMENT.getCode()) != -1) {
 			prefix = "科技成果附件";
-		}
-
-		if (path.indexOf("institution") != -1) {
+		} else if (path.indexOf(AttachmentType.INSTITUTION.getCode()) != -1) {
 			prefix = "制度目录";
-		}
-
-		if (path.indexOf("protocol") != -1) {
+		} else if (path.indexOf(AttachmentType.PROTOCOL.getCode()) != -1) {
 			prefix = "技术协议";
-		}
-
-		if (path.indexOf("finance") != -1) {
+		} else if (path.indexOf(AttachmentType.FINANCE.getCode()) != -1) {
 			prefix = subStr(path) + "财务报表";
-		}
-
-		if (path.indexOf("ratepay") != -1) {
+		} else if (path.indexOf(AttachmentType.RATEPAY.getCode()) != -1) {
 			prefix = subStr(path) + "纳税申报表";
-		}
-
-		if (path.indexOf("tech_project") != -1) {
+		} else if (path.indexOf(AttachmentType.TECH_PROJECT.getCode()) != -1) {
 			prefix = "科技项目资料";
-		}
-
-		if (path.indexOf("standard") != -1) {
+		} else if (path.indexOf(AttachmentType.STANDARD.getCode()) != -1) {
 			prefix = "标准制定";
-		}
-
-		if (path.indexOf("manuscript") != -1) {
+		} else if (path.indexOf(AttachmentType.MANUSCRIPT.getCode()) != -1) {
 			prefix = "稿件";
-		}
-		
-		if (path.indexOf("demand") != -1){
-			prefix = "科技需求";
+		} else if (path.indexOf(AttachmentType.DEMAND_TEXT_FILE.getCode()) != -1) {
+			prefix = "科技需求文本文件资料";
+		} else if (path.indexOf(AttachmentType.ACHIEVEMENT_MATURITY_TEXT_FILE.getCode()) != -1) {
+			prefix = "科技成果成熟度资料文本文件";
+		} else if (path.indexOf(AttachmentType.ACHIEVEMENT_TECH_PLAN.getCode()) != -1) {
+			prefix = "科技成果技术方案文件";
+		} else if (path.indexOf(AttachmentType.ACHIEVEMENT_BUSINESS_PLAN.getCode()) != -1) {
+			prefix = "科技成果商业计划书";
 		}
 
 		return prefix + suffix;