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

+ 20 - 1
zxkf-api/src/main/java/api/controller/online/MessageController.java

@@ -1,6 +1,8 @@
1 1
 package api.controller.online;
2 2
 
3
+import api.entity.database.system.Customer;
3 4
 import api.entity.input.online.MessageInput;
5
+import api.service.system.ICustomerService;
4 6
 import api.service.websocket.WebSocket;
5 7
 import api.util.helper.AsyncHelper;
6 8
 import api.util.helper.DateHelper;
@@ -27,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
27 29
 import javax.annotation.Resource;
28 30
 import java.io.IOException;
29 31
 import java.util.*;
32
+import java.util.stream.Collectors;
30 33
 
31 34
 @Api(value = "聊天消息",tags = "聊天消息")
32 35
 @RestController
@@ -34,6 +37,8 @@ import java.util.*;
34 37
 public class MessageController extends BaseController {
35 38
     @Autowired
36 39
     private IMessageService messageService;
40
+    @Autowired
41
+    private ICustomerService customerService;
37 42
     @Resource
38 43
     private WebSocket webSocket;
39 44
 
@@ -92,8 +97,22 @@ public class MessageController extends BaseController {
92 97
     public AjaxResult getLeaveList() {
93 98
         LambdaQueryWrapper<Message> qw = new QueryWrapper().select("kh_user user,count(*) as count").lambda();
94 99
         qw.eq( Message::getSend, 1).isNull( Message::getKfUser).groupBy(Message::getKhUser);
100
+        List<Map<String,Object>> list=messageService.getMaps(qw);
101
+        List<String> users=list.stream().map(p->p.get("user").toString()).collect(Collectors.toList());
102
+        LambdaQueryWrapper<Customer> qw1=new LambdaQueryWrapper<>();
103
+        qw1.in(Customer::getCustomerNo,users).select(Customer::getCustomerNo,Customer::getCustomerName);
104
+        List<Map<String,Object>> userlist=customerService.getMaps(qw1);
105
+        for (Map<String,Object> map:list) {
106
+            String user = map.get("user").toString();
107
+            List<Map<String, Object>> mapUsers = userlist.stream().filter(p -> p.get("customer_no").equals(user)).collect(Collectors.toList());
108
+            if (mapUsers != null && mapUsers.size() > 0) {
109
+                map.put("name", mapUsers.get(0).get("customer_name"));
110
+            } else {
111
+                map.put("name", "");
112
+            }
113
+        }
95 114
 
96
-        return Success("成功", messageService.getMaps(qw));
115
+        return Success("成功", list);
97 116
     }
98 117
 
99 118
     @ApiOperation("接入留言客户")