Procházet zdrojové kódy

修改在线客服

zhoufan %!s(int64=2) %!d(string=před) roky
rodič
revize
f06352b0e7

+ 9 - 44
zxkf-api/src/main/java/api/controller/common/CommonController.java

1
 package api.controller.common;
1
 package api.controller.common;
2
 
2
 
3
-import com.alibaba.excel.util.StringUtils;
4
 import api.controller.BaseController;
3
 import api.controller.BaseController;
5
 import api.model.AjaxResult;
4
 import api.model.AjaxResult;
5
+import api.util.helper.DateHelper;
6
+import api.util.helper.FileUploadHelper;
6
 import io.swagger.annotations.ApiOperation;
7
 import io.swagger.annotations.ApiOperation;
7
 import lombok.extern.slf4j.Slf4j;
8
 import lombok.extern.slf4j.Slf4j;
8
 import org.springframework.web.bind.annotation.GetMapping;
9
 import org.springframework.web.bind.annotation.GetMapping;
18
 import java.net.URLConnection;
19
 import java.net.URLConnection;
19
 import java.net.URLEncoder;
20
 import java.net.URLEncoder;
20
 import java.util.HashMap;
21
 import java.util.HashMap;
21
-import java.util.UUID;
22
 
22
 
23
 /**
23
 /**
24
  * 通用请求处理
24
  * 通用请求处理
39
         if (files == null || files.length == 0) {
39
         if (files == null || files.length == 0) {
40
             return Error("无文件");
40
             return Error("无文件");
41
         }
41
         }
42
-        //新文件名
43
-        StringBuilder newFileName;
44
-
45
-        //全部文件名,若多个,则逗号分隔
46
-        StringBuilder allFileNames = new StringBuilder();
47
-
48
         //上传路径
42
         //上传路径
49
-        String fileSavePath = "files";
50
-
43
+        String fileSavePath = "files/common/"+ DateHelper.getDate();
51
         //若文件夹不存在,则创建文件夹
44
         //若文件夹不存在,则创建文件夹
52
         File pFile = new File(fileSavePath);
45
         File pFile = new File(fileSavePath);
53
-        if (!pFile.exists()) {
54
-            pFile.mkdirs();
55
-        }
46
+        if (!pFile.exists()) { pFile.mkdirs(); }
56
 
47
 
48
+        HashMap<String, String> fileInfo =new HashMap<>();
57
         //遍历所有文件
49
         //遍历所有文件
58
         for (MultipartFile file : files) {
50
         for (MultipartFile file : files) {
59
-            //得到原始文件名
60
-            newFileName = new StringBuilder(file.getOriginalFilename());
61
-            //查询文件名中点号所处位置
62
-            int i = newFileName.lastIndexOf(".");
63
-            //若点号位置大于0,则文件名正常
64
-            if (i > 0) {
65
-                //在点号前拼接UUID防止文件重名
66
-                newFileName.insert(i, "_" + UUID.randomUUID().toString().substring(0, 5));
67
-            } else {
68
-                //若点号位置小于等于0,则文件名不规范
69
-                return Error("文件'" + newFileName + "'名称不规范");
70
-            }
51
+            String filePath="";
71
             try {
52
             try {
72
-                // 保存文件
73
-                file.transferTo(new File(pFile.getAbsolutePath()+"/" + newFileName));
74
-                //若全部文件名为空,则此为第一个文件,直接追加此文件名
75
-                if (StringUtils.isBlank(allFileNames.toString())) {
76
-                    allFileNames.append(newFileName);
77
-                } else {
78
-                    //若全部文件名不为空,则追加逗号和文件名
79
-                    allFileNames.append(",").append(newFileName).toString();
80
-                }
53
+                filePath= FileUploadHelper.upload(fileSavePath,file);
81
             } catch (IOException e) {
54
             } catch (IOException e) {
82
-                log.error("上传失败",e);
83
-                return Error("上传失败");
55
+                throw new RuntimeException(e);
84
             }
56
             }
57
+            fileInfo.put(file.getOriginalFilename(),filePath);
85
         }
58
         }
86
 
59
 
87
-        //返回全部文件名和文件路径
88
-        HashMap<String, String> fileInfo = new HashMap<String, String>(2) {{
89
-            put("fileNames", allFileNames.toString());
90
-            put("filePath", fileSavePath);
91
-        }};
92
-        //返回信息
93
         return Success("上传成功", fileInfo);
60
         return Success("上传成功", fileInfo);
94
     }
61
     }
95
 
62
 
105
             File file = new File(path);
72
             File file = new File(path);
106
             // 获取文件名
73
             // 获取文件名
107
             String filename = file.getName();
74
             String filename = file.getName();
108
-            // 获取文件后缀名
109
-            String e1xt = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
110
 
75
 
111
             // 将文件写入输入流
76
             // 将文件写入输入流
112
             FileInputStream fileInputStream = new FileInputStream(file);
77
             FileInputStream fileInputStream = new FileInputStream(file);

+ 7 - 6
zxkf-service/src/main/java/api/service/websocket/WebSocket.java

192
                 msg.setKhUser(userCode);
192
                 msg.setKhUser(userCode);
193
                 msg.setKhSource(source);
193
                 msg.setKhSource(source);
194
                 String kf = khkfs.get(userCode);
194
                 String kf = khkfs.get(userCode);
195
-                if (StringHelper.isEmpty(kf)) {
195
+                if (StringHelper.isEmpty(kf)||servicers.get(kf)==2) {
196
                     kf = servicerQueue.poll();
196
                     kf = servicerQueue.poll();
197
-                    if(!StringHelper.isEmpty(kf)) {
197
+                    if (!StringHelper.isEmpty(kf)) {
198
                         servicerQueue.add(kf);
198
                         servicerQueue.add(kf);
199
                         khkfs.put(userCode, kf);
199
                         khkfs.put(userCode, kf);
200
                     }
200
                     }
260
         String msg = "客户已下线";
260
         String msg = "客户已下线";
261
         if(!(servicers.containsKey(kf)&&kfsessionPool.containsKey(kf))){
261
         if(!(servicers.containsKey(kf)&&kfsessionPool.containsKey(kf))){
262
             msg = "此客服未签入";
262
             msg = "此客服未签入";
263
-        }
264
-        else if (!StringHelper.isEmpty(kh)) {
263
+        } else if(servicers.get(kf)==2) {
264
+            msg = "此客服忙碌";
265
+        } else if (!StringHelper.isEmpty(kh)) {
265
             if (customers.containsKey(kh)) {
266
             if (customers.containsKey(kh)) {
266
                 if (khkfs.containsKey(kh)) {
267
                 if (khkfs.containsKey(kh)) {
267
                     if (khkfs.get(kh).equals(kf) ) {
268
                     if (khkfs.get(kh).equals(kf) ) {
458
         };
459
         };
459
 
460
 
460
         String kf = khkfs.get(sendUser);
461
         String kf = khkfs.get(sendUser);
461
-        if (StringHelper.isEmpty(kf)) {
462
+        if (StringHelper.isEmpty(kf)||servicers.get(kf)==2) {
462
             kf = servicerQueue.poll();
463
             kf = servicerQueue.poll();
463
-            if(!StringHelper.isEmpty(kf)) {
464
+            if (!StringHelper.isEmpty(kf)) {
464
                 servicerQueue.add(kf);
465
                 servicerQueue.add(kf);
465
                 khkfs.put(sendUser, kf);
466
                 khkfs.put(sendUser, kf);
466
             }
467
             }

+ 1 - 5
zxkf-util/pom.xml

63
                 </exclusion>
63
                 </exclusion>
64
             </exclusions>
64
             </exclusions>
65
         </dependency>
65
         </dependency>
66
-        <dependency>
67
-            <groupId>com.alibaba</groupId>
68
-            <artifactId>easyexcel</artifactId>
69
-            <version>3.0.5</version>
70
-        </dependency>
66
+        <!-- excel -->
71
         <dependency>
67
         <dependency>
72
             <groupId>org.apache.poi</groupId>
68
             <groupId>org.apache.poi</groupId>
73
             <artifactId>poi-ooxml</artifactId>
69
             <artifactId>poi-ooxml</artifactId>