Pārlūkot izejas kodu

ccpm下载其他系统附件

lizhenhao 2 gadi atpakaļ
vecāks
revīzija
a2e4538804

+ 16 - 0
src/main/java/com/jeeplus/common/oss/OSSClientUtil.java

@@ -6,6 +6,7 @@ import com.aliyun.oss.OSSException;
 import com.aliyun.oss.model.*;
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.utils.Encodes;
+import com.jeeplus.common.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.multipart.MultipartFile;
@@ -620,7 +621,22 @@ public class OSSClientUtil {
      * @param response
      */
     public void downByStream(String key, String fileName, HttpServletResponse response,String agent){
+        downByStream(key,fileName,response,agent,null);
+    }
+
+    /**
+     * 附件下载
+     * @param key
+     * @param fileName
+     * @param response
+     * @param agent
+     * @param bucketName
+     */
+    public void downByStream(String key, String fileName, HttpServletResponse response,String agent,String bucketName){
         try {
+            if (StringUtils.isEmpty(bucketName)) {
+                bucketName = this.bucketName;
+            }
             String newName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20").replaceAll("%28", "\\(").replaceAll("%29", "\\)").replaceAll("%3B", ";").replaceAll("%40", "@").replaceAll("%23", "\\#").replaceAll("%26", "\\&").replaceAll("%2C", "\\,");
             // 创建OSSClient实例
             OSSObject ossObject = ossClient.getObject(bucketName, key);

+ 0 - 3
src/main/java/com/jeeplus/modules/centerservice/service/cpa/reimbursement/ReimbursementService.java

@@ -117,9 +117,6 @@ public class ReimbursementService {
                         if (Objects.nonNull(fileMap.get("url"))) { // 文件地址
                             attachmentDto.setUrl(fileMap.get("url").toString());
                         }
-                        if (Objects.nonNull(fileMap.get("lsUrl"))) { // 文件临时地址
-                            attachmentDto.setTemporaryUrl(fileMap.get("lsUrl").toString());
-                        }
                         attachmentDto.setCreateBy(u); // 创建人
                         attachments.add(attachmentDto);
                     }

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

@@ -601,9 +601,11 @@ public class WorkFullManageController extends BaseController {
 
 	/**
 	 * 下载附件
+	 * @param file
+	 * @param response
+	 * @param bucketName
 	 */
-	@RequestMapping("/downLoadAttach")
-	public String downLoadAttach(String file,HttpServletResponse response) throws IOException {
+	public void downLoadFile(String file,HttpServletResponse response,String bucketName) {
 		file = file.replace("amp;","");
 		String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
 		String aliyunUrl = Global.getAliyunUrl();
@@ -621,7 +623,33 @@ public class WorkFullManageController extends BaseController {
 		logger.info("fileName="+fileName);
 		logger.info("key="+key);
 		logger.info("-----------------------------------------");
-		new OSSClientUtil().downByStream(key,fileName,response,request.getHeader("USER-AGENT"));
+		new OSSClientUtil().downByStream(key,fileName,response,request.getHeader("USER-AGENT"),bucketName);
+	}
+
+	/**
+	 * 下载附件
+	 * @param file
+	 * @param response
+	 * @param belongProject 所属系统
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping("/downLoadAttachOtherService")
+	public void downLoadAttach(String file,HttpServletResponse response,String belongProject) throws IOException {
+		String bucketName = "";
+		if ("cpa".equals(belongProject)) {
+			bucketName = "xgxm-test";
+		}
+		file = "http://oss.gangwaninfo.com" + file;
+		downLoadFile(file,response,bucketName);
+	}
+
+	/**
+	 * 下载附件
+	 */
+	@RequestMapping("/downLoadAttach")
+	public String downLoadAttach(String file,HttpServletResponse response) throws IOException {
+		downLoadFile(file,response,null);
 		return null;
 		/*OutputStream out = null;
 		InputStream in = null;

+ 3 - 16
src/main/webapp/webpage/modules/workreimbursement/workReimbursementAuditCpa.jsp

@@ -342,22 +342,9 @@
 								<td class="op-td">
 									<div class="op-btn-box" >
 											<%--附件下载删除--%>
-										<c:choose>
-											<c:when test="${workReimbursement.uploadMode == 2}">
-												<c:choose>
-													<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'pdf')}">
-														<a href="${workClientAttachment.temporaryUrl}" target="_blank" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
-													</c:when>
-													<c:otherwise>
-														<a href="${workClientAttachment.temporaryUrl}" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
-													</c:otherwise>
-												</c:choose>
-											</c:when>
-											<c:otherwise>
-												<a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent('${workClientAttachment.url}');" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
-											</c:otherwise>
-										</c:choose>
-										<c:if test="${workClientAttachment.collectFlag != 1}">
+												<a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttachOtherService?belongProject=cpa&file='+encodeURIComponent('${workClientAttachment.url}');" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
+
+												<c:if test="${workClientAttachment.collectFlag != 1}">
 											<a href="javascript:void(0)" onclick="collectingAccessory(this,'${ctx}/projectAccessory/projectAccessory/saveCollectAccessory','${workClientAttachment.url}','${workClientAttachment.createBy.id}','${workClientAttachment.fileSize}')" class="op-btn op-btn-delete"  style="background-color: #FFB800"><i class="layui-icon layui-icon-rate"></i>&nbsp;收藏</a>
 										</c:if>
 									</div>