Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

user5 vor 4 Jahren
Ursprung
Commit
d33953f390

+ 86 - 0
src/main/java/com/jeeplus/common/bos/BosController.java

@@ -311,4 +311,90 @@ public class BosController {
         return map;
     }
 
+    /**
+     * 阿里云上传图片
+     * 公告内容上传图片
+     * @param request
+     * @param response
+     * @param file
+     * @param multiRequest
+     */
+    @RequestMapping(value="/uploadImg")
+    public void uploadImg(HttpServletRequest request, HttpServletResponse response, MultipartFile file, MultipartHttpServletRequest multiRequest) {
+        String DirectoryName = request.getParameter("storeAs");
+        String newName="";
+        String filepath = "";
+        try {
+
+            if("1".equals(uploadMode)){
+                try {
+                    //MultipartFile转File
+                    File srcFile = transformMultipartFile(file);
+                    String path = directory+"/"+DirectoryName+datePath()+"/"+ System.currentTimeMillis()+srcFile.getName();
+                    BOSClientUtil bosClientUtil = new BOSClientUtil();
+                    InputStream inputStream = file.getInputStream();
+                    String upload = bosClientUtil.upload(path, inputStream);
+                    if(srcFile.exists()){
+                        srcFile.delete();
+                    }
+                }catch (Exception e){
+                }
+            }else if("2".equals(uploadMode)){
+                LayFileJsonData data = new LayFileJsonData();
+                // 判断文件是否为空
+                Iterator<String> fileNames = multiRequest.getFileNames();
+                while(fileNames.hasNext()) {
+                    //取得上传文件
+                    file = multiRequest.getFile(fileNames.next());
+                    if (!file.isEmpty()) {
+                        // 文件保存路径
+                        String realPath =directory.replace("/","")+"/"+DirectoryName+datePath()+"/"+ System.currentTimeMillis();
+                        OSSClientUtil ossUtil = new OSSClientUtil();
+                        newName = file.getOriginalFilename();
+
+                        try {
+                            ossUtil.uploadFile2OSS(file.getInputStream(),realPath,newName);
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                        filepath = Global.getAliDownloadUrl() + "/" + realPath + newName;
+
+                        data.setName(file.getOriginalFilename());
+                        data.setSrc(filepath);
+                    }
+                }
+
+            }else{
+
+                try {
+                    //MultipartFile转File
+                    File srcFile = transformMultipartFile(file);
+                    SftpClientUtil fileUploadUtil = new SftpClientUtil();
+                    String uploadPath = "/" + DirectoryName + datePath();
+                    String uploadFile = fileUploadUtil.uploadFile(uploadPath, srcFile, srcFile.getName());
+                    if(srcFile.exists()){
+                        srcFile.delete();
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            // 结合ckeditor功能
+            // imageContextPath为图片在服务器地址,如upload/123.jpg,非绝对路径
+            OSSClientUtil ossUtil = new OSSClientUtil();
+            String imageContextPath =ossUtil.getFileTemporaryLookUrl(filepath);
+            response.setContentType("text/html;charset=UTF-8");
+            String callback = request.getParameter("CKEditorFuncNum");
+            PrintWriter out = response.getWriter();
+            out.println("<script type=\"text/javascript\">");
+            out.println("window.parent.CKEDITOR.tools.callFunction(" + callback + ",'" + imageContextPath + "',''" + ")");
+            out.println("</script>");
+            out.flush();
+            out.close();
+        } catch (IllegalStateException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 8 - 2
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectViewController.java

@@ -520,8 +520,13 @@ public class RuralProjectViewController extends BaseController {
     @RequestMapping(value = "formRecordModify")
     public String formRecordModify(RuralProjectRecords projectRecords, Model model) {
         projectRecords = projectRecordsService.get(projectRecords.getId());
-        if (null == projectRecords.getPrrId()){
-            model.addAttribute("projectReportRecord", null);
+        if (null != projectRecords) {
+            if (StringUtils.isBlank(projectRecords.getPrrId())) {
+                model.addAttribute("projectRecords", projectRecords);
+                return "modules/ruralprojectrecords/view/projectReportRecordView";
+            }
+        }else{
+            model.addAttribute("projectRecords", projectRecords);
             return "modules/ruralprojectrecords/view/projectReportRecordView";
         }
         ProjectReportRecord projectReportRecord = projectReportRecordService.get(projectRecords.getPrrId());
@@ -599,6 +604,7 @@ public class RuralProjectViewController extends BaseController {
         //}
 
         model.addAttribute("projectReportRecord", projectReportRecord);
+        model.addAttribute("projectRecords", projectReportRecord);
         model.addAttribute("project", projectReportRecord.getReport().getProject());
         return "modules/ruralprojectrecords/view/projectReportRecordView";
     }

+ 1 - 1
src/main/webapp/WEB-INF/tags/sys/ckeditor.tag

@@ -9,5 +9,5 @@
 	${replace}Ckeditor.config.height = "${height}";//<c:if test="${not empty uploadPath}">
 	${replace}Ckeditor.config.ckfinderPath="${pageContext.request.contextPath}/static/ckfinder";
 	var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
-	${replace}Ckeditor.config.ckfinderUploadPath="${uploadPath}/"+year+"/"+month+"/";//</c:if>
+	${replace}Ckeditor.config.ckfinderUploadPath="${uploadPath}";//</c:if>
 </script>

+ 7 - 4
src/main/webapp/static/ckeditor/config.js

@@ -35,11 +35,14 @@ CKEDITOR.editorConfig = function( config ) {
 	];
 	config.toolbar = 'default';
 	if(config.ckfinderPath){
-		config.filebrowserBrowseUrl = config.ckfinderPath+'/ckfinder.html?type=files&start=files:'+config.ckfinderUploadPath;
-		config.filebrowserImageBrowseUrl = config.ckfinderPath+'/ckfinder.html?type=images&start=images:'+config.ckfinderUploadPath;
-		config.filebrowserFlashBrowseUrl = config.ckfinderPath+'/ckfinder.html?type=flash&start=flash:'+config.ckfinderUploadPath;
+		config.removeDialogTabs = 'image:advanced;image:Link';//隐藏超链接与高级选项
+		config.filebrowserImageUploadUrl = realPath+'/bos/uploadImg?storeAs='+config.ckfinderUploadPath;//上传图片的地址
+
+		// config.filebrowserBrowseUrl = config.ckfinderPath+'/ckfinder.html?type=files&start=files:'+config.ckfinderUploadPath;
+		// config.filebrowserImageBrowseUrl = config.ckfinderPath+'/ckfinder.html?type=images&start=images:'+config.ckfinderUploadPath;
+		// config.filebrowserFlashBrowseUrl = config.ckfinderPath+'/ckfinder.html?type=flash&start=flash:'+config.ckfinderUploadPath;
 		config.filebrowserUploadUrl = config.ckfinderPath+'/core/connector/java/connector.java?command=QuickUpload&type=files&currentFolder='+config.ckfinderUploadPath;
-		config.filebrowserImageUploadUrl = config.ckfinderPath+'/core/connector/java/connector.java?command=QuickUpload&type=images&currentFolder='+config.ckfinderUploadPath;
+		// config.filebrowserImageUploadUrl = realPath+'/bos/upload?storeAs='+config.ckfinderUploadPath;
 		config.filebrowserFlashUploadUrl = config.ckfinderPath+'/core/connector/java/connector.java?command=QuickUpload&type=flash&currentFolder='+config.ckfinderUploadPath;
 		config.filebrowserWindowWidth = '1000';
 		config.filebrowserWindowHeight = '700';

+ 1 - 1
src/main/webapp/webpage/modules/ruralprojectrecords/view/projectAccessoryView.jsp

@@ -138,7 +138,7 @@
 									<c:otherwise>
 										<c:choose>
 											<c:when test="${fileAttachment.flag == 0}">
-												<td class="tabMove"  style="text-align:left;">${fileAttachment.attachName}<input type="hidden" value="${fileAttachment.attachName}"</td>
+												<td class="tabMove"  style="text-align:left;">${fileAttachment.attachName}<input type="hidden" value="${fileAttachment.attachName}"/></td>
 											</c:when>
 											<c:otherwise>
 												<td></td>