瀏覽代碼

档案图标上传显示等相关功能开发完毕

1037015548@qq.com 2 年之前
父節點
當前提交
c5a461b828

+ 6 - 0
ruoyi-admin/pom.xml

@@ -67,6 +67,12 @@
             <artifactId>ruoyi-generator</artifactId>
             <artifactId>ruoyi-generator</artifactId>
         </dependency>
         </dependency>
 
 
+        <!--判断文件是否为图片-->
+        <dependency>
+            <groupId>es.gob.afirma.lib</groupId>
+            <artifactId>afirma-lib-jmimemagic</artifactId>
+            <version>0.0.6</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
     <build>
     <build>

+ 34 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@@ -4,9 +4,12 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.web.util.ImageCheck;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -36,8 +39,17 @@ public class CommonController
     @Autowired
     @Autowired
     private ServerConfig serverConfig;
     private ServerConfig serverConfig;
 
 
+    @Autowired
+    private ImageCheck imageCheck;
+
     private static final String FILE_DELIMETER = ",";
     private static final String FILE_DELIMETER = ",";
 
 
+    @Value("${imgPath}")
+    private String imgPath;
+
+    @Value("${filePath}")
+    private String filePath;
+
     /**
     /**
      * 通用下载请求
      * 通用下载请求
      * 
      * 
@@ -75,19 +87,30 @@ public class CommonController
      */
      */
     @PostMapping("/upload")
     @PostMapping("/upload")
     @ResponseBody
     @ResponseBody
-    public AjaxResult uploadFile(MultipartFile file) throws Exception
+    public AjaxResult uploadFile(MultipartFile file, HttpServletRequest request) throws Exception
     {
     {
         try
         try
         {
         {
             // 上传文件路径
             // 上传文件路径
             String filePath = RuoYiConfig.getUploadPath();
             String filePath = RuoYiConfig.getUploadPath();
+            //判断是否为图片, 根据情况处丽fileName 相对路径
+            if(imageCheck.isImage(file)){
+                filePath = filePath.replace("/upload",imgPath);
+            }else{
+                filePath = filePath.replace("/upload",this.filePath);
+            }
             // 上传并返回新文件名称
             // 上传并返回新文件名称
             String fileName = FileUploadUtils.upload(filePath, file);
             String fileName = FileUploadUtils.upload(filePath, file);
+            if(fileName.contains("/profile")){
+                fileName = fileName.replace("/profile","");
+            }
+            log.debug("当前IP:"+request.getRequestURL());
             String url = serverConfig.getUrl() + fileName;
             String url = serverConfig.getUrl() + fileName;
             AjaxResult ajax = AjaxResult.success();
             AjaxResult ajax = AjaxResult.success();
             ajax.put("url", url);
             ajax.put("url", url);
             ajax.put("fileName", fileName);
             ajax.put("fileName", fileName);
-            ajax.put("newFileName", FileUtils.getName(fileName));
+            String newFileName = FileUtils.getName(fileName);
+            ajax.put("newFileName", newFileName);
             ajax.put("originalFilename", file.getOriginalFilename());
             ajax.put("originalFilename", file.getOriginalFilename());
             return ajax;
             return ajax;
         }
         }
@@ -114,8 +137,17 @@ public class CommonController
             List<String> originalFilenames = new ArrayList<String>();
             List<String> originalFilenames = new ArrayList<String>();
             for (MultipartFile file : files)
             for (MultipartFile file : files)
             {
             {
+                //判断是否为图片, 根据情况处丽fileName 相对路径
+                if(imageCheck.isImage(file)){
+                    filePath = filePath.replace("/upload",imgPath);
+                }else{
+                    filePath = filePath.replace("/upload",this.filePath);
+                }
                 // 上传并返回新文件名称
                 // 上传并返回新文件名称
                 String fileName = FileUploadUtils.upload(filePath, file);
                 String fileName = FileUploadUtils.upload(filePath, file);
+                if(fileName.contains("/profile")){
+                    fileName = fileName.replace("/profile","");
+                }
                 String url = serverConfig.getUrl() + fileName;
                 String url = serverConfig.getUrl() + fileName;
                 urls.add(url);
                 urls.add(url);
                 fileNames.add(fileName);
                 fileNames.add(fileName);

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DanganController.java

@@ -105,6 +105,17 @@ public class DanganController extends BaseController
         List<DanganFile> files = danganFileService.selectDanganFileList(danganFile);
         List<DanganFile> files = danganFileService.selectDanganFileList(danganFile);
         mmap.put("fileList", files);
         mmap.put("fileList", files);
 
 
+        //查询icon
+        for (DanganFile danganFile2:files) {
+            if(danganFile2.getFilePath().equals(dangan.getIconInfo())) {
+                mmap.put("icon", danganFile2);
+                //此时删除原fileList集合中的icon数据, 单独领出来,然后break 不会引发集合循环报错
+                files.remove(danganFile2);
+                mmap.put("fileList", files);
+                break;
+            }
+        }
+
         return prefix + "/edit";
         return prefix + "/edit";
     }
     }
 
 

+ 58 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java

@@ -8,12 +8,17 @@ import javax.servlet.http.HttpServletResponse;
 
 
 import com.ruoyi.common.utils.*;
 import com.ruoyi.common.utils.*;
 import com.ruoyi.system.domain.Dangan;
 import com.ruoyi.system.domain.Dangan;
+import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.domain.UserRelate;
 import com.ruoyi.system.domain.UserRelate;
+import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.system.service.IDanganService;
 import com.ruoyi.system.service.IDanganService;
 import com.ruoyi.system.service.IUserRelateService;
 import com.ruoyi.system.service.IUserRelateService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
 import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -52,6 +57,11 @@ public class SysIndexController extends BaseController
     @Autowired
     @Autowired
     private IUserRelateService userRelateService;
     private IUserRelateService userRelateService;
 
 
+    @Autowired
+    private SysConfigMapper configMapper;
+
+    @Value("${ip}")
+    private String ipPort;
 
 
     // 系统首页
     // 系统首页
     @GetMapping("/index")
     @GetMapping("/index")
@@ -154,9 +164,54 @@ public class SysIndexController extends BaseController
         mmap.put("sessionId",sessionId);
         mmap.put("sessionId",sessionId);
         mmap.put("danganList",userRelates);
         mmap.put("danganList",userRelates);
 
 
-
-
-
+        //23年2月14日新增,加入档案信息
+        if(!CollectionUtils.isEmpty(userRelates)) {
+            for (UserRelate relate : userRelates) {
+                Dangan dangan = danganService.selectDanganById(relate.getDanganId());
+                if(!ObjectUtils.isEmpty(dangan)){
+                    if(!StringUtils.isEmpty(dangan.getIconInfo())){
+                        if(dangan.getIconInfo().contains("/upload")){
+                            //期望给用户展示用的可直接访问的URL
+                            String newStr = dangan.getIconInfo();
+                            String[] ipPorts = ipPort.split(",");
+                            //分ip+端口号 和 域名情况
+                            if(ipPorts.length>=2){
+                                //说明是由ip,端口组成的参数
+                                newStr = "http://"+ipPorts[0]+":"+ipPorts[1]+"/iconShow"+newStr;
+                            }else if(ipPorts.length==1){
+                                //说明ip配置的是域名
+                                newStr = "http://"+ipPorts[0]+"/iconShow"+newStr;
+                            }
+                            dangan.setIconInfo(newStr);
+                        }
+                    }else{
+                        //说明档案图标未上传,那么使用默认图标
+                        SysConfig configQuery = new SysConfig();
+                        configQuery.setConfigKey("sys.main.defaultIcon");
+                        SysConfig configEntity = configMapper.selectConfig(configQuery);
+                        if(!ObjectUtils.isEmpty(configEntity)) {
+                            String config = configEntity.getConfigValue();
+                            if (!StringUtils.isEmpty(config)) {
+                                //说明全局config表中已配置
+                                //期望给用户展示用的可直接访问的URL
+                                String newStr = config;
+//                                String[] ipPorts = ipPort.split(",");
+//                                //分ip+端口号 和 域名情况
+//                                if (ipPorts.length >= 2) {
+//                                    //说明是由ip,端口组成的参数
+//                                    newStr = "http://" + ipPorts[0] + ":" + ipPorts[1] + "/iconShow" + newStr;
+//                                } else if (ipPorts.length == 1) {
+//                                    //说明ip配置的是域名
+//                                    newStr = "http://" + ipPorts[0] + "/iconShow" + newStr;
+//                                }
+                                dangan.setIconInfo(newStr);
+                            }
+                        }
+                    }
+                    relate.setDangan(dangan);
+                }
+            }
+        }
         return "main";
         return "main";
     }
     }
 
 

+ 45 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/util/ImageCheck.java

@@ -0,0 +1,45 @@
+package com.ruoyi.web.util;
+
+import net.sf.jmimemagic.Magic;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.activation.MimetypesFileTypeMap;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @ClassName ImageCheck
+ * @Description: TODO
+ * @Author LX
+ * @Date 2023/2/16
+ * @Version V1.0
+ **/
+@Component
+public class ImageCheck {
+    private MimetypesFileTypeMap mtftp;
+
+    public ImageCheck(){
+        mtftp = new MimetypesFileTypeMap();
+        /* 不添加下面的类型会造成误判 详见:http://stackoverflow.com/questions/4855627/java-mimetypesfiletypemap-always-returning-application-octet-stream-on-android-e*/
+        mtftp.addMimeTypes("image png tif jpg jpeg bmp");
+    }
+    public  boolean isImage(File file){
+        String mimetype= mtftp.getContentType(file);
+        String type = mimetype.split("/")[0];
+        return type.equals("image");
+    }
+
+    public boolean isImage(MultipartFile mf) {
+            try {
+                String mimeType = Magic.getMagicMatch(mf.getBytes(), false).getMimeType();
+                if (mimeType.startsWith("image/")) {
+                    return true;
+                } else {
+                    return false;
+                }
+            } catch(Exception e) {
+                throw new RuntimeException("图片处理异常");
+            }
+    }
+}

+ 3 - 0
ruoyi-admin/src/main/resources/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.ruoyi.RuoYiApplication
+

+ 5 - 2
ruoyi-admin/src/main/resources/application-dev.yml

@@ -9,8 +9,10 @@ ruoyi:
     # 实例演示开关
     # 实例演示开关
     demoEnabled: false
     demoEnabled: false
     # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
     # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-    profile: D:/ruoyi/uploadPath
+#    profile: D:/ruoyi/uploadPath
+#    profile: /home/ruoyi/uploadPath
 #    profile: D:/工作文档/武汉三环科普睿科/Project/JavaProject\RuoYi
 #    profile: D:/工作文档/武汉三环科普睿科/Project/JavaProject\RuoYi
+    profile: ./
 
 
 
 
     # 获取ip地址开关
     # 获取ip地址开关
@@ -19,7 +21,8 @@ ruoyi:
 # 开发环境配置
 # 开发环境配置
 server:
 server:
     # 服务器的HTTP端口,默认为80
     # 服务器的HTTP端口,默认为80
-    port: 8082
+#    port: 8082
+    port: 8301
 
 
     servlet:
     servlet:
         # 应用的访问路径
         # 应用的访问路径

+ 7 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -111,3 +111,10 @@ xss:
 swagger:
 swagger:
   # 是否开启swagger
   # 是否开启swagger
   enabled: true
   enabled: true
+# 测试服务器IP地址端口 或 域名
+ip: 119.96.165.176,8300
+# 图片上传保存路径
+imgPath: /upload/images
+filePath: /upload/words
+
+

+ 1 - 1
ruoyi-admin/src/main/resources/logback.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
 <configuration>
     <!-- 日志存放路径 -->
     <!-- 日志存放路径 -->
-	<property name="log.path" value="/home/ruoyi/logs" />
+	<property name="log.path" value="./logs" />
     <!-- 日志输出格式 -->
     <!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 
 

二進制
ruoyi-admin/src/main/resources/static/default/favicon.ico


+ 2 - 1
ruoyi-admin/src/main/resources/templates/main.html

@@ -27,7 +27,8 @@
 					<div class="col-sm-3" th:each="dangan:${danganList}">
 					<div class="col-sm-3" th:each="dangan:${danganList}">
 						<div class="float-e-margins" style="text-align: center;border: none">
 						<div class="float-e-margins" style="text-align: center;border: none">
 							<div     >
 							<div     >
-								<button class="btn btn-primary dim" type="button"   th:onclick="opennewpage([[${dangan.danganUrl}]] ,[[${dangan.danganNums} ]]);"   ><i class="fa fa-money"></i>
+								<!--<input type="text" th:value="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort()}">-->
+								<button class="btn btn-primary dim" type="button" th:style="'background:url(' +${dangan.dangan.iconInfo}+') no-repeat center center;width:50px;height:50px;background-size:100% 100%'" th:onclick="opennewpage([[${dangan.danganUrl}]] ,[[${dangan.danganNums} ]]);">
 								</button>
 								</button>
 								<h3 class="no-margins" style="color:#1e9fff" th:text="${dangan.danganName}"></h3>
 								<h3 class="no-margins" style="color:#1e9fff" th:text="${dangan.danganName}"></h3>
 								<h4 th:text="${@dict.getLabel('sys_dangan_status', dangan.danganStatus)}" ></h4><br>
 								<h4 th:text="${@dict.getLabel('sys_dangan_status', dangan.danganStatus)}" ></h4><br>

+ 65 - 8
ruoyi-admin/src/main/resources/templates/system/dangan/add.html

@@ -331,6 +331,18 @@
                         </div>
                         </div>
                     </div>
                     </div>
                 </div>
                 </div>
+                <div class="col-sm-6">
+                    <div class="form-group">
+                        <input type="hidden" id="iconName" name="iconName">
+                        <input type="hidden" id="iconPath" name="iconPath">
+                        <label class="col-sm-3 control-label ">档案图标信息:</label>
+                        <div class="col-sm-8">
+                            <input id="icon" name="icon" class="form-control" type="file"  onchange="uploadIcon();" multiple >
+                            <div id="iconinfo">
+                            </div>
+                        </div>
+                    </div>
+                </div>
             </div>
             </div>
             <div class="row">
             <div class="row">
                 <div class="col-sm-12">
                 <div class="col-sm-12">
@@ -386,18 +398,20 @@
 
 
         function uploadFile(){
         function uploadFile(){
             var formData = new FormData();
             var formData = new FormData();
-            if ($('#file')[0].files[0] == null) {
+            if ($('#file')[0].files[0] == null || $('#file')[0].files[0]==undefined) {
                 $.modal.alertWarning("请先选择文件路径");
                 $.modal.alertWarning("请先选择文件路径");
                 return false;
                 return false;
             }
             }
-            var this_1=  document.getElementById('file');
-            var files = this_1.files;
-
-            for (var i = 0, len = files.length; i < len; i++) {
-                formData.append('files', files[i]);
-            }
+            // var this_1=  document.getElementById('file');
+            // var files = this_1.files;
+            //
+            // for (var i = 0, len = files.length; i < len; i++) {
+            //     formData.append('files', files[i]);
+            // }
+            // 将文件装入FormData对象
+            formData.append("file",$('#file')[0].files[0]);
             $.ajax({
             $.ajax({
-                url: ctx + "common/uploadMultipart",
+                url: ctx + "common/upload",
                 type: 'post',
                 type: 'post',
                 cache: false,
                 cache: false,
                 data: formData,
                 data: formData,
@@ -426,6 +440,49 @@
             });
             });
         }
         }
 
 
+        function uploadIcon(){
+            var formData = new FormData();
+            if ($('#icon')[0].files[0] == null || $('#icon')[0].files[0]==undefined) {
+                $.modal.alertWarning("请先选择文件路径");
+                return false;
+            }
+            // var this_1=  document.getElementById('file');
+            // var files = this_1.files;
+            //
+            // for (var i = 0, len = files.length; i < len; i++) {
+            //     formData.append('files', files[i]);
+            // }
+            // 将文件装入FormData对象
+            formData.append("file",$('#icon')[0].files[0]);
+            $.ajax({
+                url: ctx + "common/upload",
+                type: 'post',
+                cache: false,
+                data: formData,
+                processData: false,
+                contentType: false,
+                dataType: "json",
+                success: function(result) {
+                    console.log(result);
+                    if(result.code == '0'){
+                        $("#iconName").val(result.fileName);
+                        $("#iconPath").val(result.url);
+                        var fileArr = new Array();
+                        var fileNames =result.fileName;
+                        if(null!=fileNames && fileNames.length>0){
+                            $("#iconinfo").empty();
+                            fileArr = fileNames.split(",");
+                            for(var i=0;i<fileArr.length;i++){
+                                var html = "";
+                                html = "<input type='text' value='"+fileArr[i]+"' class='form-control' style='border: none;' readonly>";
+                                $("#iconinfo").append(html);
+                            }
+                        }
+
+                    }
+                }
+            });
+        }
 
 
         function submitHandler() {
         function submitHandler() {
             if ($.validate.form()) {
             if ($.validate.form()) {

+ 76 - 10
ruoyi-admin/src/main/resources/templates/system/dangan/edit.html

@@ -332,6 +332,23 @@
                             </div>
                             </div>
                         </div>
                         </div>
                     </div>
                     </div>
+                    <div class="form-group">
+                        <input type="hidden" id="iconName" name="iconName">
+                        <input type="hidden" id="iconPath" name="iconPath">
+                        <label  class="col-sm-3 control-label "  >档案图标信息:</label>
+                        <div class="col-sm-8">
+                            <input id="icon" class="form-control" type="file" onchange="uploadIcon();" multiple>
+                            <div id="iconinfo"></div>
+                            <br>
+                            <div class="input-group m-b" th:if="${icon!=null}" >
+                                <input type="hidden" name="iconId" th:value="@{${icon.fileId}}">
+                                <input type="hidden" th:id="${fileList.size()>0?(fileList.size()+1):0}" th:value="@{${icon.filePath}}">
+                                <span class="input-group-addon" th:onclick="preview([[@{${icon.filePath}}]])"><i class="fa fa-file"></i></span>
+                                <span class="input-group-addon" th:onclick="removeIcon([[${fileList.size()>0?(fileList.size()+1):0}]])"><i class="fa fa-remove"></i></span>
+                                <input type="text" class="form-control" th:value="${icon.fileName}" disabled="disabled">
+                            </div>
+                        </div>
+                    </div>
                 </div>
                 </div>
             </div>
             </div>
             <div class="row">
             <div class="row">
@@ -369,6 +386,10 @@
             $("#" + id).remove();
             $("#" + id).remove();
             this.danganFileList.splice(id, 1);
             this.danganFileList.splice(id, 1);
         }
         }
+        function removeIcon(id) {
+            $("#" + id).parent().remove();
+            this.danganFileList.splice(id, 1);
+        }
 
 
         function preview(pdfPath){
         function preview(pdfPath){
             console.log("pdfPath="+pdfPath);
             console.log("pdfPath="+pdfPath);
@@ -381,14 +402,16 @@
                 $.modal.alertWarning("请先选择文件路径");
                 $.modal.alertWarning("请先选择文件路径");
                 return false;
                 return false;
             }
             }
-            var this_1 = document.getElementById('file');
-            var files = this_1.files;
-
-            for (var i = 0, len = files.length; i < len; i++) {
-                formData.append('files', files[i]);
-            }
+            // var this_1=  document.getElementById('file');
+            // var files = this_1.files;
+            //
+            // for (var i = 0, len = files.length; i < len; i++) {
+            //     formData.append('files', files[i]);
+            // }
+            // 将文件装入FormData对象
+            formData.append("file",$('#file')[0].files[0]);
             $.ajax({
             $.ajax({
-                url: ctx + "common/uploadMultipart",
+                url: ctx + "common/upload",
                 type: 'post',
                 type: 'post',
                 cache: false,
                 cache: false,
                 data: formData,
                 data: formData,
@@ -397,10 +420,10 @@
                 dataType: "json",
                 dataType: "json",
                 success: function (result) {
                 success: function (result) {
                     if (result.code == '0') {
                     if (result.code == '0') {
-                        $("#fileName").val(result.fileName);
-                        $("#filePath").val(result.url);
+                        $("#fileName").val(result.newFileName);
+                        $("#filePath").val(result.fileName);
                         var fileArr = new Array();
                         var fileArr = new Array();
-                        var fileNames =result.fileName;
+                        var fileNames =result.newFileName;
                         if(null!=fileNames && fileNames.length>0){
                         if(null!=fileNames && fileNames.length>0){
                             $("#fileinfo").empty();
                             $("#fileinfo").empty();
                             fileArr = fileNames.split(",");
                             fileArr = fileNames.split(",");
@@ -415,6 +438,49 @@
             });
             });
         }
         }
 
 
+        function uploadIcon(){
+            var formData = new FormData();
+            if ($('#icon')[0].files[0] == null || $('#icon')[0].files[0]==undefined) {
+                $.modal.alertWarning("请先选择文件路径");
+                return false;
+            }
+            // var this_1=  document.getElementById('file');
+            // var files = this_1.files;
+            //
+            // for (var i = 0, len = files.length; i < len; i++) {
+            //     formData.append('files', files[i]);
+            // }
+            // 将文件装入FormData对象
+            formData.append("file",$('#icon')[0].files[0]);
+            $.ajax({
+                url: ctx + "common/upload",
+                type: 'post',
+                cache: false,
+                data: formData,
+                processData: false,
+                contentType: false,
+                dataType: "json",
+                success: function(result) {
+                    console.log(result);
+                    if(result.code == '0'){
+                        $("#iconName").val(result.newFileName);
+                        $("#iconPath").val(result.fileName);
+                        var fileArr = new Array();
+                        var fileNames =result.newFileName;
+                        if(null!=fileNames && fileNames.length>0){
+                            $("#iconinfo").empty();
+                            fileArr = fileNames.split(",");
+                            for(var i=0;i<fileArr.length;i++){
+                                var html = "";
+                                html = "<input type='text' value='"+fileArr[i]+"' class='form-control' style='border: none;' readonly>";
+                                $("#iconinfo").append(html);
+                            }
+                        }
+
+                    }
+                }
+            });
+        }
 
 
         function submitHandler() {
         function submitHandler() {
             if ($.validate.form()) {
             if ($.validate.form()) {

+ 3 - 0
ruoyi-common/src/main/java/com/ruoyi/common/config/ServerConfig.java

@@ -1,6 +1,9 @@
 package com.ruoyi.common.config;
 package com.ruoyi.common.config;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.ServletUtils;
 
 

+ 42 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/Dangan.java

@@ -149,6 +149,47 @@ public class Dangan extends BaseEntity
 
 
     private String filePath;
     private String filePath;
 
 
+    @Excel(name = "图标信息")
+    private String iconInfo;
+
+    //图标id
+    private Long iconId;
+
+    private String iconName;
+
+    private String iconPath;
+
+    public Long getIconId() {
+        return iconId;
+    }
+
+    public void setIconId(Long iconId) {
+        this.iconId = iconId;
+    }
+
+    public String getIconName() {
+        return iconName;
+    }
+
+    public void setIconName(String iconName) {
+        this.iconName = iconName;
+    }
+
+    public String getIconPath() {
+        return iconPath;
+    }
+
+    public void setIconPath(String iconPath) {
+        this.iconPath = iconPath;
+    }
+
+    public String getIconInfo() {
+        return iconInfo;
+    }
+
+    public void setIconInfo(String iconInfo) {
+        this.iconInfo = iconInfo;
+    }
 
 
     public String getDanganNo() {
     public String getDanganNo() {
         return danganNo;
         return danganNo;
@@ -494,6 +535,7 @@ public class Dangan extends BaseEntity
             .append("chargeUnit", getChargeUnit())
             .append("chargeUnit", getChargeUnit())
             .append("mode", getMode())
             .append("mode", getMode())
             .append("fileInfo", getFileInfo())
             .append("fileInfo", getFileInfo())
+            .append("iconInfo", getFileInfo())
             .append("createBy", getCreateBy())
             .append("createBy", getCreateBy())
             .append("createTime", getCreateTime())
             .append("createTime", getCreateTime())
             .append("updateBy", getUpdateBy())
             .append("updateBy", getUpdateBy())

+ 27 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DanganServiceImpl.java

@@ -90,6 +90,11 @@ public class DanganServiceImpl implements IDanganService
             danganFileMapper.deleteFileByDanganId(dangan.getDanganId());
             danganFileMapper.deleteFileByDanganId(dangan.getDanganId());
             saveFileInfo(dangan);
             saveFileInfo(dangan);
         }
         }
+        if(StringUtils.isNotEmpty(dangan.getIconName()) && StringUtils.isNotEmpty(dangan.getIconPath())){
+            //删除以前的附件
+            danganFileMapper.deleteFileByDanganId(dangan.getIconId());
+            saveIconInfo(dangan);
+        }
         return danganMapper.updateDangan(dangan);
         return danganMapper.updateDangan(dangan);
     }
     }
 
 
@@ -142,6 +147,28 @@ public class DanganServiceImpl implements IDanganService
             }
             }
         }
         }
     }
     }
+    //往附件表中添加icon
+    public void saveIconInfo(Dangan dangan){
+        if(StringUtils.isNotEmpty(dangan.getIconName()) && StringUtils.isNotEmpty(dangan.getIconPath())){
+            String[] fileNames = dangan.getIconName().split(",");
+            String[] filePaths = dangan.getIconPath().split(",");
+            if(fileNames.length == filePaths.length){
+                List<DanganFile> fileInfoList = new ArrayList<DanganFile>();
+                for(int i = 0; i < fileNames.length; i++){
+                    DanganFile fileInfo = new DanganFile();
+                    fileInfo.setFileName(fileNames[i]);
+                    fileInfo.setFilePath(filePaths[i]);
+                    fileInfo.setDanganId(dangan.getDanganId());
+                    fileInfoList.add(fileInfo);
+                }
+                if(fileInfoList.size() > 0){
+                    danganFileMapper.batchFileInfo(fileInfoList);
+                }
+            }
+            //修改iconInfo
+            dangan.setIconInfo(dangan.getIconPath());
+        }
+    }
 
 
     /**
     /**
      * 校验名称是否唯一
      * 校验名称是否唯一

+ 6 - 1
ruoyi-system/src/main/resources/mapper/system/DanganMapper.xml

@@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="chargeUnit"    column="charge_unit"    />
         <result property="chargeUnit"    column="charge_unit"    />
         <result property="mode"    column="mode"    />
         <result property="mode"    column="mode"    />
         <result property="fileInfo"    column="file_info"    />
         <result property="fileInfo"    column="file_info"    />
+        <result property="iconInfo"    column="icon_info"    />
         <result property="createBy"    column="create_by"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateBy"    column="update_by"    />
@@ -50,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select dangan_id,
         select dangan_id,
         key_id,
         key_id,
         dangan_no,dangan_name, status,
         dangan_no,dangan_name, status,
-         sys_person, file_type, model, project_id, brand, run_device_id, relate_device_id, maintain_item_id, factory_time, project_time, use_unit, medium, maintain_time, page_address, test_address, build_factory, build_factory_time, factory_person, factory_person_phone, language, server_ip, server_location, server_info, server_based_yes_no, ops_person, charge_unit, mode, file_info, create_by, create_time, update_by, update_time, remark from sys_dangan
+         sys_person, file_type, model, project_id, brand, run_device_id, relate_device_id, maintain_item_id, factory_time, project_time, use_unit, medium, maintain_time, page_address, test_address, build_factory, build_factory_time, factory_person, factory_person_phone, language, server_ip, server_location, server_info, server_based_yes_no, ops_person, charge_unit, mode, file_info,icon_info, create_by, create_time, update_by, update_time, remark from sys_dangan
     </sql>
     </sql>
 
 
     <select id="selectDanganList" parameterType="Dangan" resultMap="DanganResult">
     <select id="selectDanganList" parameterType="Dangan" resultMap="DanganResult">
@@ -89,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="chargeUnit != null  and chargeUnit != ''"> and charge_unit = #{chargeUnit}</if>
             <if test="chargeUnit != null  and chargeUnit != ''"> and charge_unit = #{chargeUnit}</if>
             <if test="mode != null  and mode != ''"> and mode = #{mode}</if>
             <if test="mode != null  and mode != ''"> and mode = #{mode}</if>
             <if test="fileInfo != null  and fileInfo != ''"> and file_info = #{fileInfo}</if>
             <if test="fileInfo != null  and fileInfo != ''"> and file_info = #{fileInfo}</if>
+            <if test="iconInfo != null  and iconInfo != ''"> and icon_info = #{iconInfo}</if>
         </where>
         </where>
     </select>
     </select>
     
     
@@ -133,6 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="chargeUnit != null">charge_unit,</if>
             <if test="chargeUnit != null">charge_unit,</if>
             <if test="mode != null">mode,</if>
             <if test="mode != null">mode,</if>
             <if test="fileInfo != null">file_info,</if>
             <if test="fileInfo != null">file_info,</if>
+            <if test="iconInfo != null">icon_info,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateBy != null">update_by,</if>
@@ -173,6 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="chargeUnit != null">#{chargeUnit},</if>
             <if test="chargeUnit != null">#{chargeUnit},</if>
             <if test="mode != null">#{mode},</if>
             <if test="mode != null">#{mode},</if>
             <if test="fileInfo != null">#{fileInfo},</if>
             <if test="fileInfo != null">#{fileInfo},</if>
+            <if test="iconInfo != null">#{iconInfo},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
@@ -217,6 +221,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="chargeUnit != null">charge_unit = #{chargeUnit},</if>
             <if test="chargeUnit != null">charge_unit = #{chargeUnit},</if>
             <if test="mode != null">mode = #{mode},</if>
             <if test="mode != null">mode = #{mode},</if>
             <if test="fileInfo != null">file_info = #{fileInfo},</if>
             <if test="fileInfo != null">file_info = #{fileInfo},</if>
+            <if test="iconInfo != null">icon_info = #{iconInfo},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>