Browse Source

人脸消息

傅行帆 5 years ago
parent
commit
1f19ffda26

+ 10
- 4
src/main/java/com.huiju.welcome/controller/TaCustomerController.java View File

259
 
259
 
260
             List<TaPerson> group = iTaCustomerService.getGroup(cust.getCustomerId());
260
             List<TaPerson> group = iTaCustomerService.getGroup(cust.getCustomerId());
261
             cust.setGroup(group);
261
             cust.setGroup(group);
262
-
262
+            //插入车牌信息
263
+            QueryWrapper<TaCar> queryWrapper = new QueryWrapper<>();
264
+            queryWrapper.eq("plate_number",cust.getPlateNumber());
265
+            TaCar taCar = iTaCarService.getOne(queryWrapper);
266
+            if (null != taCar){
267
+                cust.setCarImage(taCar.getCarImage());
268
+            }
263
             responseBean.addSuccess(cust);
269
             responseBean.addSuccess(cust);
264
         }catch (Exception e){
270
         }catch (Exception e){
265
             e.printStackTrace();
271
             e.printStackTrace();
327
      * @return
333
      * @return
328
      */
334
      */
329
     @RequestMapping(value="/miniapp/customer/visitor/{state}",method= RequestMethod.GET)
335
     @RequestMapping(value="/miniapp/customer/visitor/{state}",method= RequestMethod.GET)
330
-    public ResponseBean visitorCustomerList(@RequestParam(defaultValue = "1") int pageNumber,
336
+    public ResponseBean visitorCustomerList(@RequestParam(defaultValue = "1") int pageNum,
331
                                             @RequestParam(defaultValue = "10") int pageSize,
337
                                             @RequestParam(defaultValue = "10") int pageSize,
332
                                             @PathVariable String state,
338
                                             @PathVariable String state,
333
                                             HttpServletRequest request){
339
                                             HttpServletRequest request){
341
             }
347
             }
342
             //已归属和未归属人员列表 分页
348
             //已归属和未归属人员列表 分页
343
             if (state.equals(CommConstant.CUSTOMER_ATTRIBUTION)) {
349
             if (state.equals(CommConstant.CUSTOMER_ATTRIBUTION)) {
344
-                IPage<TaCustomer> result = iTaCustomerService.getAttributionList(pageNumber, pageSize);
350
+                IPage<TaCustomer> result = iTaCustomerService.getAttributionList(pageNum, pageSize);
345
                 responseBean.addSuccess(result);
351
                 responseBean.addSuccess(result);
346
             }else if (state.equals(CommConstant.CUSTOMER_UNATTRIBUTION)){
352
             }else if (state.equals(CommConstant.CUSTOMER_UNATTRIBUTION)){
347
-                IPage<TaCustomer> result = iTaCustomerService.getUnattributionList(pageNumber, pageSize);
353
+                IPage<TaCustomer> result = iTaCustomerService.getUnattributionList(pageNum, pageSize);
348
                 responseBean.addSuccess(result);
354
                 responseBean.addSuccess(result);
349
             }
355
             }
350
             
356
             

+ 50
- 2
src/main/java/com.huiju.welcome/controller/TaFirstUsherRecordController.java View File

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.huiju.welcome.common.base.BaseController;
6
 import com.huiju.welcome.common.base.BaseController;
7
 import com.huiju.welcome.common.base.ResponseBean;
7
 import com.huiju.welcome.common.base.ResponseBean;
8
+import com.huiju.welcome.model.TaCustomer;
8
 import com.huiju.welcome.model.TaFirstUsherRecord;
9
 import com.huiju.welcome.model.TaFirstUsherRecord;
10
+import com.huiju.welcome.service.ITaCustomerService;
9
 import com.huiju.welcome.service.ITaFirstUsherRecordService;
11
 import com.huiju.welcome.service.ITaFirstUsherRecordService;
10
 import com.huiju.welcome.utils.DateUtils;
12
 import com.huiju.welcome.utils.DateUtils;
11
 import com.huiju.welcome.utils.StatusUtils;
13
 import com.huiju.welcome.utils.StatusUtils;
14
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.web.bind.annotation.*;
17
 import org.springframework.web.bind.annotation.*;
16
 
18
 
19
+import java.time.LocalDateTime;
20
+import java.time.format.DateTimeFormatter;
21
+import java.util.List;
22
+
17
 
23
 
18
 /**
24
 /**
19
  * <p>
25
  * <p>
32
     @Autowired
38
     @Autowired
33
     public ITaFirstUsherRecordService iTaFirstUsherRecordService;
39
     public ITaFirstUsherRecordService iTaFirstUsherRecordService;
34
 
40
 
41
+    @Autowired
42
+    private ITaCustomerService taCustomerService;
35
 
43
 
36
     /**
44
     /**
37
      * 保存对象
45
      * 保存对象
120
         }
128
         }
121
         return responseBean;
129
         return responseBean;
122
     }
130
     }
123
-
131
+    
132
+    /**
133
+     * 根据id查询对象
134
+     * @param id  实体ID
135
+     */
136
+    @RequestMapping(value="/miniapp/firstUsherRecord/{id}",method= RequestMethod.GET)
137
+    public ResponseBean miniappGet(@PathVariable Integer id){
138
+        ResponseBean responseBean = new ResponseBean();
139
+        try {
140
+            TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.getById(id);
141
+            TaCustomer taCustomer = taCustomerService.getCutomerByPhoneAndPlatenumber(taFirstUsherRecord.getPhone(),taFirstUsherRecord.getPlateNumber());
142
+            if (null != taCustomer){
143
+                taFirstUsherRecord.setCustomerName(taCustomer.getCustomerName());
144
+                taFirstUsherRecord.setAvatar(taCustomer.getAvatar());
145
+                taFirstUsherRecord.setCustomerId(taCustomer.getCustomerId());
146
+            }
147
+            responseBean.addSuccess(taFirstUsherRecord);
148
+        }catch (Exception e){
149
+            logger.error("taFirstUsherRecordGetByID -=- {}",e.toString());
150
+            responseBean.addError(e.getMessage());
151
+        }
152
+        return responseBean;
153
+    }
154
+    
124
     /**
155
     /**
125
      * 根据id查询对象
156
      * 根据id查询对象
126
      */
157
      */
147
             queryWrapper.lt(!done, "status", StatusUtils.BizDone);
178
             queryWrapper.lt(!done, "status", StatusUtils.BizDone);
148
         }
179
         }
149
         queryWrapper.orderByDesc("rec_id");
180
         queryWrapper.orderByDesc("rec_id");
150
-
181
+    
182
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
183
+        
151
         IPage<TaFirstUsherRecord> result = iTaFirstUsherRecordService.page(pg, queryWrapper);
184
         IPage<TaFirstUsherRecord> result = iTaFirstUsherRecordService.page(pg, queryWrapper);
185
+        List<TaFirstUsherRecord> taFirstUsherRecordList = result.getRecords();
186
+        taFirstUsherRecordList.stream().forEach(e -> {
187
+            TaCustomer taCustomer = taCustomerService.getByPhoneOrPlate(e.getPhone(),e.getPlateNumber());
188
+            if (null != taCustomer){
189
+                if (formatter.format(taCustomer.getCreateDate()).equals(formatter.format(LocalDateTime.now()))){
190
+                    e.setNewCustomer(true);
191
+                }else {
192
+                    e.setNewCustomer(false);
193
+                }
194
+            }else {
195
+                e.setNewCustomer(true);
196
+            }
197
+        });
198
+    
199
+        result.setRecords(taFirstUsherRecordList);
152
 
200
 
153
 //            if (onlyNew) {
201
 //            if (onlyNew) {
154
 //               iTaFirstUsherRecordService.updateNormal(result.getRecords());
202
 //               iTaFirstUsherRecordService.updateNormal(result.getRecords());

+ 6
- 0
src/main/java/com.huiju.welcome/model/TaCustomer.java View File

213
      */
213
      */
214
     @TableField(exist = false)
214
     @TableField(exist = false)
215
     private LocalDateTime visiteDate;
215
     private LocalDateTime visiteDate;
216
+    
217
+    /**
218
+     * 车辆图片
219
+     */
220
+    @TableField(exist = false)
221
+    private String carImage;
216
 }
222
 }

+ 12
- 0
src/main/java/com.huiju.welcome/model/TaFirstUsherRecord.java View File

65
     private Integer consultantId;
65
     private Integer consultantId;
66
     
66
     
67
     private String realtyConsultant;
67
     private String realtyConsultant;
68
+    
69
+    @TableField(exist = false)
70
+    private String customerName;
71
+    
72
+    @TableField(exist = false)
73
+    private String avatar;
74
+    
75
+    @TableField(exist = false)
76
+    private Integer customerId;
77
+    
78
+    @TableField(exist = false)
79
+    private boolean newCustomer;
68
 }
80
 }

+ 3
- 0
src/main/java/com.huiju.welcome/model/TaMainUsherRecord.java View File

76
 
76
 
77
     @TableField(exist = false)
77
     @TableField(exist = false)
78
     TaMainUsherRecord lastRecord;
78
     TaMainUsherRecord lastRecord;
79
+    
80
+    @TableField(exist = false)
81
+    private boolean newCustomer;
79
 }
82
 }

+ 1
- 0
src/main/java/com.huiju.welcome/model/TaPerson.java View File

1
 package com.huiju.welcome.model;
1
 package com.huiju.welcome.model;
2
 
2
 
3
 import com.baomidou.mybatisplus.annotation.IdType;
3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4
 import com.baomidou.mybatisplus.annotation.TableId;
5
 import com.baomidou.mybatisplus.annotation.TableId;
5
 import lombok.Data;
6
 import lombok.Data;
6
 import lombok.EqualsAndHashCode;
7
 import lombok.EqualsAndHashCode;

+ 2
- 4
src/main/java/com.huiju.welcome/service/ICameraService.java View File

2
 
2
 
3
 import com.huiju.welcome.model.TaCustomer;
3
 import com.huiju.welcome.model.TaCustomer;
4
 import com.huiju.welcome.model.TaDevice;
4
 import com.huiju.welcome.model.TaDevice;
5
+import com.huiju.welcome.model.TaFirstUsherRecord;
6
+import com.huiju.welcome.model.TaMainUsherRecord;
5
 import com.huiju.welcome.model.TaPerson;
7
 import com.huiju.welcome.model.TaPerson;
6
 import com.huiju.welcome.model.TaSnapshotPerson;
8
 import com.huiju.welcome.model.TaSnapshotPerson;
7
 
9
 
9
     String dispatchPerson(TaPerson taPerson, TaDevice ...devices);
11
     String dispatchPerson(TaPerson taPerson, TaDevice ...devices);
10
 
12
 
11
     boolean newPersonByDevice(TaSnapshotPerson taSnapshotPerson);
13
     boolean newPersonByDevice(TaSnapshotPerson taSnapshotPerson);
12
-    
13
-    void sendMessageToBar(TaCustomer taCustomer,Integer personNum);
14
-    
15
-    void sendMessageToConsultManager(TaCustomer taCustomer);
16
 }
14
 }

+ 10
- 0
src/main/java/com.huiju.welcome/service/ITaCustomerService.java View File

50
 	IPage<TaCustomer> getAttributionList(int pageNumber, int pageSize);
50
 	IPage<TaCustomer> getAttributionList(int pageNumber, int pageSize);
51
     
51
     
52
     IPage<TaCustomer> getUnattributionList(int pageNumber, int pageSize);
52
     IPage<TaCustomer> getUnattributionList(int pageNumber, int pageSize);
53
+    
54
+    void notifyFirstUsherConsultantManager(TaFirstUsherRecord taFirstUsherRecord,TaCustomer taCustomer);
55
+    
56
+    TaCustomer getCutomerByPhoneAndPlatenumber(String phone, String plateNumber);
57
+    
58
+    void sendMessageToBar(TaCustomer taCustomer,Integer personNum);
59
+    
60
+    void sendMessageToConsultManager(TaCustomer taCustomer);
61
+    
62
+    void sendMessageAll(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer, TaMainUsherRecord taMainUsherRecord);
53
 }
63
 }

+ 6
- 57
src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java View File

12
 import com.huiju.welcome.model.TaCustomer;
12
 import com.huiju.welcome.model.TaCustomer;
13
 import com.huiju.welcome.model.TaCustomerMap;
13
 import com.huiju.welcome.model.TaCustomerMap;
14
 import com.huiju.welcome.model.TaDevice;
14
 import com.huiju.welcome.model.TaDevice;
15
+import com.huiju.welcome.model.TaFirstUsherRecord;
16
+import com.huiju.welcome.model.TaMainUsherRecord;
15
 import com.huiju.welcome.model.TaPerson;
17
 import com.huiju.welcome.model.TaPerson;
16
 import com.huiju.welcome.model.TaSnapshotPerson;
18
 import com.huiju.welcome.model.TaSnapshotPerson;
17
 import com.huiju.welcome.service.*;
19
 import com.huiju.welcome.service.*;
199
         TaDevice taDevice = taDeviceService.getById(taSnapshotPerson.getDeviceId());
201
         TaDevice taDevice = taDeviceService.getById(taSnapshotPerson.getDeviceId());
200
         if(taDevice.getAfr().equals(CommConstant.DEVICE_AFR_UNFACE)){
202
         if(taDevice.getAfr().equals(CommConstant.DEVICE_AFR_UNFACE)){
201
             sendMessageToConsult(taPerson);
203
             sendMessageToConsult(taPerson);
204
+            
202
     
205
     
203
             // 预写到访日志
206
             // 预写到访日志
204
             visitingLogService.newLogByDevice(taSnapshotPerson, taPerson);
207
             visitingLogService.newLogByDevice(taSnapshotPerson, taPerson);
213
             // 推送消息
216
             // 推送消息
214
             taPersonService.send2Front(taPerson);
217
             taPersonService.send2Front(taPerson);
215
         }
218
         }
216
-
219
+    
217
         // 保存抓拍日志
220
         // 保存抓拍日志
218
         taSnapshotPersonService.save(taSnapshotPerson);
221
         taSnapshotPersonService.save(taSnapshotPerson);
219
-
222
+        
220
         return true;
223
         return true;
221
     }
224
     }
222
     
225
     
233
                     //推送置业顾问
236
                     //推送置业顾问
234
                     iTaCustomerService.notifyConsultant(taCustomer);
237
                     iTaCustomerService.notifyConsultant(taCustomer);
235
                     //推送置业经理
238
                     //推送置业经理
236
-                    sendMessageToConsultManager(taCustomer);
237
-                    //推送吧台
238
-                    sendMessageToBar(taCustomer,null);
239
+                    iTaCustomerService.sendMessageToConsultManager(taCustomer);
239
                 } catch (Exception e) {
240
                 } catch (Exception e) {
240
                     e.printStackTrace();
241
                     e.printStackTrace();
241
                 }
242
                 }
242
             }
243
             }
243
         }
244
         }
244
-        //推送人脸到二号岗
245
-        sendMessageToMainusher(taPerson);
246
-    }
247
-    
248
-    /**
249
-     * 推送人脸数据到二号岗
250
-     * @param taPerson
251
-     */
252
-    private void sendMessageToMainusher(TaPerson taPerson) {
253
-        try {
254
-            WebSocketServer.sendInfo(JSONObject.toJSONString(taPerson), CommConstant.WECHAT_CLIENT_MAINUSHER, null);
255
-        } catch (Exception e) {}
256
-    }
257
-    
258
-    /**
259
-     * 推送消息去吧台
260
-     * @param taCustomer
261
-     */
262
-    @Override
263
-    public void sendMessageToBar(TaCustomer taCustomer,Integer personNum) {
264
-        Map<String,Object> map = new HashMap<>();
265
-        map.put("customerId",taCustomer.getCustomerId());
266
-        map.put("customerName",taCustomer.getCustomerName());
267
-        map.put("consultantName",taCustomer.getRealtyConsultant());
268
-        map.put("avatar",taCustomer.getAvatar());
269
-        map.put("visitorNum",personNum);
270
-        map.put("visitorTime",LocalDateTime.now());
271
-        map.put("type",CommConstant.IDENTITY_BARUSHER);
272
-        try {
273
-            WebSocketServer.sendInfo(JSONObject.toJSONString(map), CommConstant.WECHAT_CLIENT_MINIAPP, null);
274
-        } catch (Exception e) {}
275
-    }
276
-    
277
-    @Override
278
-    public void sendMessageToConsultManager(TaCustomer taCustomer) {
279
-        //获取所有的置业经理信息并推送消息
280
-        List<SysUser> sysUserList = sysUserMapper.selectConsultManagerList(CommConstant.IDENTITY_CONSULTANT_MANAGER);
281
-        sysUserList.stream().forEach(e -> {
282
-            String tpl = miniApp.getTpls().getVisitor();
283
-            String page = CommConstant.PAGE_MY_ATTRIBUTION + "?id=" + taCustomer.getCustomerId();
284
-            String openid = e.getOpenid();
285
-            if (null == openid) {
286
-                return;
287
-            }
288
-            List<Object> data = new ArrayList<Object>(){{
289
-                add(taCustomer.getCustomerName());
290
-                add(taCustomer.getPhone());
291
-                add("您有客户来访, 请及时接待!");
292
-            }};
293
-    
294
-            miniApp.sendTPLMessage(tpl, openid, page, data);
295
-        });
296
     }
245
     }
297
 }
246
 }

+ 18
- 0
src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java View File

17
 
17
 
18
 import java.time.LocalDate;
18
 import java.time.LocalDate;
19
 import java.time.LocalDateTime;
19
 import java.time.LocalDateTime;
20
+import java.time.format.DateTimeFormatter;
20
 import java.util.Date;
21
 import java.util.Date;
21
 import java.util.List;
22
 import java.util.List;
22
 
23
 
200
 
201
 
201
         // 生成保安迎宾记录, 并通知小程序
202
         // 生成保安迎宾记录, 并通知小程序
202
         TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord,taCustomer);
203
         TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord,taCustomer);
204
+        if (null != taCustomer){
205
+            if (DateUtils.sameDay(taCustomer.getCreateDate(),LocalDateTime.now())){
206
+                taFirstUsherRecord.setNewCustomer(true);
207
+            }else {
208
+                taFirstUsherRecord.setNewCustomer(false);
209
+            }
210
+        }else {
211
+            taFirstUsherRecord.setNewCustomer(true);
212
+        }
203
         iTaFirstUsherRecordService.notifyCar(taFirstUsherRecord);
213
         iTaFirstUsherRecordService.notifyCar(taFirstUsherRecord);
204
 
214
 
205
         // 如果客户有固定置业, 推送消息给置业
215
         // 如果客户有固定置业, 推送消息给置业
210
                 log.error("发送消息给置业失败: {}", e.getMessage());
220
                 log.error("发送消息给置业失败: {}", e.getMessage());
211
             }
221
             }
212
         }
222
         }
223
+        
224
+        //自动关联成功
225
+        if (null != taCustomer){
226
+            iTaCustomerService.sendMessageToConsultManager(taCustomer);
227
+        }
228
+        
229
+        //推送websocket消息。统一推送。
230
+        iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
213
 
231
 
214
         return true;
232
         return true;
215
     }
233
     }

+ 120
- 6
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java View File

1
 package com.huiju.welcome.service.impl;
1
 package com.huiju.welcome.service.impl;
2
 
2
 
3
+import com.alibaba.fastjson.JSONObject;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import com.huiju.welcome.common.WebSocketServer;
8
 import com.huiju.welcome.mapper.*;
10
 import com.huiju.welcome.mapper.*;
9
 import com.huiju.welcome.model.*;
11
 import com.huiju.welcome.model.*;
10
 import com.huiju.welcome.service.*;
12
 import com.huiju.welcome.service.*;
18
 import org.springframework.stereotype.Service;
20
 import org.springframework.stereotype.Service;
19
 
21
 
20
 import java.time.LocalDateTime;
22
 import java.time.LocalDateTime;
23
+import java.time.format.DateTimeFormatter;
21
 import java.util.ArrayList;
24
 import java.util.ArrayList;
22
 import java.util.HashMap;
25
 import java.util.HashMap;
23
 import java.util.List;
26
 import java.util.List;
184
 
187
 
185
         miniApp.sendTPLMessage(tpl, openid, page, data);
188
         miniApp.sendTPLMessage(tpl, openid, page, data);
186
     }
189
     }
187
-
190
+    
191
+    /**
192
+     * 推送车辆信息给置业经理
193
+     * @param taFirstUsherRecord
194
+     * @param taCustomer
195
+     * @throws Exception
196
+     */
197
+    @Override
198
+    public void notifyFirstUsherConsultantManager(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer) {
199
+        List<SysUser> sysUserList = sysUserMapper.selectConsultManagerList(CommConstant.IDENTITY_CONSULTANT_MANAGER);
200
+        String message ="";
201
+        if (null != taCustomer){
202
+            if (null == taCustomer.getConsultantId()){
203
+                message = "请安排置业接待。";
204
+            }else{
205
+                SysUser sysUser = sysUserMapper.selectById(taCustomer.getConsultantId());
206
+                message = "置业"+sysUser.getUsername()+"客户,请安排接待";
207
+            }
208
+        }else {
209
+            message = "客户已到达, 请及时关注。";
210
+        }
211
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
212
+        
213
+        String visitData = formatter.format(taFirstUsherRecord.getVisiteDate());
214
+        List<Object> data = new ArrayList<Object>();
215
+        data.add(visitData);
216
+        data.add(taFirstUsherRecord.getPlateNumber()+" "+ taFirstUsherRecord.getColor() + " " + taFirstUsherRecord.getCarModel());
217
+        data.add(message);
218
+        sysUserList.stream().forEach(e -> {
219
+            String tpl = miniApp.getTpls().getFirstUsher();
220
+            String page = CommConstant.PAGE_MY_FIRSTUSHER + "?id=" + taFirstUsherRecord.getRecId();
221
+            String openid = e.getOpenid();
222
+            if (null == openid) {
223
+                return;
224
+            }
225
+            miniApp.sendTPLMessage(tpl, openid, page, data);
226
+        });
227
+    }
228
+    
229
+    @Override
230
+    public TaCustomer getCutomerByPhoneAndPlatenumber(String phone, String plateNumber) {
231
+        List<TaCustomer> list = taCustomerMapper.getSomeCustMayBe(plateNumber,phone);
232
+        if (list.size() > 0){
233
+            return list.get(0);
234
+        }
235
+        return null;
236
+    }
237
+    
188
     @Override
238
     @Override
189
     public boolean updateConsultant(TaCustomer taCustomer, Integer consultantId) {
239
     public boolean updateConsultant(TaCustomer taCustomer, Integer consultantId) {
190
         SysUser usr = sysUserMapper.selectById(consultantId);
240
         SysUser usr = sysUserMapper.selectById(consultantId);
248
         }
298
         }
249
     
299
     
250
         if (notify){
300
         if (notify){
251
-            //通知吧台来人了
252
-            cameraService.sendMessageToBar(cust,taMainUsherRecord.getPersonNum());
301
+            //通知前端
302
+            sendMessageAll(null,cust,taMainUsherRecord);
253
             //推送置业经理
303
             //推送置业经理
254
-            cameraService.sendMessageToConsultManager(cust);
304
+            sendMessageToConsultManager(cust);
255
         }
305
         }
256
         
306
         
257
         return cust;
307
         return cust;
289
         }
339
         }
290
         if (notify){
340
         if (notify){
291
             //通知吧台来人了
341
             //通知吧台来人了
292
-            cameraService.sendMessageToBar(cust,taFirstUsherRecord.getPersonNum());
342
+            sendMessageAll(taFirstUsherRecord,cust,null);
343
+            
344
+            //通知吧台人数等信息
345
+            sendMessageToBar(cust,taFirstUsherRecord.getPersonNum());
346
+            
293
             //推送置业经理
347
             //推送置业经理
294
-            cameraService.sendMessageToConsultManager(cust);
348
+            sendMessageToConsultManager(cust);
295
         }
349
         }
296
         
350
         
297
         return cust;
351
         return cust;
535
 
589
 
536
         return taCustomerMapper.insert(taCustomer) > 0;
590
         return taCustomerMapper.insert(taCustomer) > 0;
537
     }
591
     }
592
+    
593
+    
594
+    
595
+    /**
596
+     * 推送消息去吧台
597
+     * @param taCustomer
598
+     */
599
+    @Override
600
+    public void sendMessageToBar(TaCustomer taCustomer,Integer personNum) {
601
+        Map<String,Object> map = new HashMap<>();
602
+        map.put("customerId",taCustomer.getCustomerId());
603
+        map.put("customerName",taCustomer.getCustomerName());
604
+        map.put("consultantName",taCustomer.getRealtyConsultant());
605
+        map.put("avatar",taCustomer.getAvatar());
606
+        map.put("visitorNum",personNum);
607
+        map.put("visitorTime",LocalDateTime.now());
608
+        map.put("type",CommConstant.IDENTITY_BARUSHER);
609
+        try {
610
+            WebSocketServer.sendInfo(JSONObject.toJSONString(map), CommConstant.WECHAT_CLIENT_MINIAPP, null);
611
+        } catch (Exception e) {}
612
+    }
613
+    
614
+    @Override
615
+    public void sendMessageToConsultManager(TaCustomer taCustomer) {
616
+        //获取所有的置业经理信息并推送消息
617
+        List<SysUser> sysUserList = sysUserMapper.selectConsultManagerList(CommConstant.IDENTITY_CONSULTANT_MANAGER);
618
+        sysUserList.stream().forEach(e -> {
619
+            String tpl = miniApp.getTpls().getVisitor();
620
+            String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + taCustomer.getCustomerId();
621
+            String openid = e.getOpenid();
622
+            if (null == openid) {
623
+                return;
624
+            }
625
+            List<Object> data = new ArrayList<Object>(){{
626
+                add(taCustomer.getCustomerName());
627
+                add(taCustomer.getPhone());
628
+                add("您有客户来访, 请及时接待!");
629
+            }};
630
+            
631
+            miniApp.sendTPLMessage(tpl, openid, page, data);
632
+        });
633
+    }
634
+    
635
+    @Override
636
+    public void sendMessageAll(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer, TaMainUsherRecord taMainUsherRecord) {
637
+        Map<String,Object> map = new HashMap<>();
638
+        map.put("type",CommConstant.IDENTITY_ALL_USHER);
639
+        if (null != taFirstUsherRecord){
640
+            map.put("taFirstUsherRecord",taFirstUsherRecord);
641
+        }
642
+        if (null != taCustomer){
643
+            map.put("taCustomer",taCustomer);
644
+        }
645
+        if (null != taMainUsherRecord){
646
+            map.put("taMainUsherRecord",taMainUsherRecord);
647
+        }
648
+        try {
649
+            WebSocketServer.sendInfo(JSONObject.toJSONString(map), CommConstant.WECHAT_CLIENT_MINIAPP, null);
650
+        } catch (Exception e) {}
651
+    }
538
 
652
 
539
 }
653
 }

+ 17
- 5
src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java View File

83
         if (null != taCustomer){
83
         if (null != taCustomer){
84
             taFirstUsherRecord.setConsultantId(taCustomer.getConsultantId());
84
             taFirstUsherRecord.setConsultantId(taCustomer.getConsultantId());
85
             taFirstUsherRecord.setRealtyConsultant(taCustomer.getRealtyConsultant());
85
             taFirstUsherRecord.setRealtyConsultant(taCustomer.getRealtyConsultant());
86
+            taFirstUsherRecord.setPhone(taCustomer.getPhone());
87
+            taFirstUsherRecord.setPersonName(taCustomer.getCustomerName());
86
         }
88
         }
87
         
89
         
88
         taFirstUsherRecordMapper.insert(taFirstUsherRecord);
90
         taFirstUsherRecordMapper.insert(taFirstUsherRecord);
177
             if (StringUtils.isEmpty(taMainUsherRecord.getPlateNumber())) {
179
             if (StringUtils.isEmpty(taMainUsherRecord.getPlateNumber())) {
178
                 taMainUsherRecord.setPlateNumber(taFirstUsherRecord.getPlateNumber());
180
                 taMainUsherRecord.setPlateNumber(taFirstUsherRecord.getPlateNumber());
179
             }
181
             }
182
+            
183
+            if(null != taMainUsherRecord.getPersonNum()){
184
+                taMainUsherRecord.setPersonNum(taFirstUsherRecord.getPersonNum());
185
+            }
180
 
186
 
181
             iTaMainUsherRecordService.updateById(taMainUsherRecord);
187
             iTaMainUsherRecordService.updateById(taMainUsherRecord);
182
         }
188
         }
224
                 if (null != taCustomer.getConsultantId()){
230
                 if (null != taCustomer.getConsultantId()){
225
                     iTaCustomerService.notifyConsultant(taCustomer);
231
                     iTaCustomerService.notifyConsultant(taCustomer);
226
                 }
232
                 }
227
-                //通知吧台来人了
228
-                cameraService.sendMessageToBar(taCustomer,taFirstUsherRecord.getPersonNum());
229
-                //推送置业经理
230
-                cameraService.sendMessageToConsultManager(taCustomer);
233
+                //通知前端
234
+                iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
235
+                //通知置业经理车辆信息
236
+                iTaCustomerService.notifyConsultant(taCustomer);
231
             } catch (Exception e) {}
237
             } catch (Exception e) {}
238
+        }else if(StringUtils.isEmpty(taFirstUsherRecord.getPhone())){
239
+            //有手机号的情况下会新建customer,推送后置
240
+            //通知置业经理车辆信息
241
+            iTaCustomerService.notifyFirstUsherConsultantManager(taFirstUsherRecord,taCustomer);
242
+            //通知前端
243
+            iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
232
         }
244
         }
233
-
245
+        
234
         // 依据车牌判断是否老客户来访
246
         // 依据车牌判断是否老客户来访
235
         //if (!StringUtils.isEmpty(plateNumber)) {
247
         //if (!StringUtils.isEmpty(plateNumber)) {
236
         //    List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(plateNumber);
248
         //    List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(plateNumber);

+ 20
- 9
src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java View File

273
                 taCustomer = iTaCustomerService.getSameByPerson(personId);
273
                 taCustomer = iTaCustomerService.getSameByPerson(personId);
274
             }
274
             }
275
         }
275
         }
276
-    
277
-        //if (null == taCustomer && null == taMainUsherRecord.getCustomerId()) {
278
-        //    taCustomer = iTaCustomerService.newCustByMainUsher(taMainUsherRecord, false);
279
-        //}
280
         
276
         
281
         if (null == taCustomer){
277
         if (null == taCustomer){
282
             // 新增客户
278
             // 新增客户
325
                 if (!StringUtils.isEmpty(taMainUsherRecord.getColor())){
321
                 if (!StringUtils.isEmpty(taMainUsherRecord.getColor())){
326
                     taMainUsherRecordToday.setColor(taMainUsherRecord.getColor());
322
                     taMainUsherRecordToday.setColor(taMainUsherRecord.getColor());
327
                 }
323
                 }
324
+                if (!StringUtils.isEmpty(taMainUsherRecord.getAvatar())){
325
+                    taMainUsherRecordToday.setAvatar(taMainUsherRecord.getAvatar());
326
+                }
328
                 return updateByMiniapp(taMainUsherRecordToday);
327
                 return updateByMiniapp(taMainUsherRecordToday);
329
             }
328
             }
330
         }
329
         }
369
 
368
 
370
         // 是否需要更新客户信息
369
         // 是否需要更新客户信息
371
         // 只更新空内容
370
         // 只更新空内容
372
-        if (StringUtils.isEmpty(taCustomer.getCustomerName()) || StringUtils.isEmpty(taCustomer.getPhone())) {
371
+        if (StringUtils.isEmpty(taCustomer.getCustomerName()) || StringUtils.isEmpty(taCustomer.getPhone()) || StringUtils.isEmpty(taCustomer.getAvatar())
372
+             || StringUtils.isEmpty(taCustomer.getPlateNumber() )) {
373
             if (StringUtils.isEmpty(taCustomer.getCustomerName())) {
373
             if (StringUtils.isEmpty(taCustomer.getCustomerName())) {
374
                 taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
374
                 taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
375
             }
375
             }
442
             miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
442
             miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
443
         }
443
         }
444
     
444
     
445
-        //通知吧台来人了
446
-        cameraService.sendMessageToBar(taCustomer,taMainUsherRecord.getPersonNum());
445
+        //通知前端
446
+        iTaCustomerService.sendMessageAll(null,taCustomer,taMainUsherRecord);
447
         //推送置业经理
447
         //推送置业经理
448
-        cameraService.sendMessageToConsultManager(taCustomer);
449
-
448
+        iTaCustomerService.sendMessageToConsultManager(taCustomer);
449
+        //推送吧台
450
+        iTaCustomerService.sendMessageToBar(taCustomer,taMainUsherRecord.getPersonNum());
450
         return row > 0;
451
         return row > 0;
451
     }
452
     }
452
 
453
 
472
         taMainUsherRecord.setStatus(StatusUtils.Ready);
473
         taMainUsherRecord.setStatus(StatusUtils.Ready);
473
         taMainUsherRecord.setPersonId(taPerson.getRealId());
474
         taMainUsherRecord.setPersonId(taPerson.getRealId());
474
         int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
475
         int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
476
+        if (null != taCustomer){
477
+            if (DateUtils.sameDay(taCustomer.getCreateDate(),LocalDateTime.now())){
478
+                taMainUsherRecord.setNewCustomer(true);
479
+            }else {
480
+                taMainUsherRecord.setNewCustomer(false);
481
+            }
482
+        }else {
483
+            taMainUsherRecord.setNewCustomer(true);
484
+        }
475
 
485
 
476
         try {
486
         try {
477
             Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord, SerializerFeature.WriteMapNullValue));
487
             Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord, SerializerFeature.WriteMapNullValue));
589
         taMainUsherRecord.setChannel(taFirstUsherRecord.getChannel());
599
         taMainUsherRecord.setChannel(taFirstUsherRecord.getChannel());
590
         taMainUsherRecord.setPurpose(taFirstUsherRecord.getPurpose());
600
         taMainUsherRecord.setPurpose(taFirstUsherRecord.getPurpose());
591
         taMainUsherRecord.setCarImage(taFirstUsherRecord.getCarImage());
601
         taMainUsherRecord.setCarImage(taFirstUsherRecord.getCarImage());
602
+        taMainUsherRecord.setPersonNum(taFirstUsherRecord.getPersonNum());
592
 
603
 
593
         if (null != taCustomer) {
604
         if (null != taCustomer) {
594
             taMainUsherRecord.setPersonId(taCustomer.getCustomerId());
605
             taMainUsherRecord.setPersonId(taCustomer.getCustomerId());

+ 2
- 1
src/main/java/com.huiju.welcome/utils/CommConstant.java View File

6
     public final static String IDENTITY_MAINUSHER = "main-usher";
6
     public final static String IDENTITY_MAINUSHER = "main-usher";
7
     public final static String IDENTITY_BARUSHER = "bar-usher";
7
     public final static String IDENTITY_BARUSHER = "bar-usher";
8
     public final static String IDENTITY_CONSULTANT_MANAGER = "consultant_manager";
8
     public final static String IDENTITY_CONSULTANT_MANAGER = "consultant_manager";
9
+    public final static String IDENTITY_ALL_USHER = "all-usher";
9
 
10
 
10
     public final static String PAGE_MY_CUSTOMER = "pages/client/clientdetail/clientdetail";
11
     public final static String PAGE_MY_CUSTOMER = "pages/client/clientdetail/clientdetail";
11
-    public final static String PAGE_MY_ATTRIBUTION = "pages/client/visitorList/visitorList";
12
+    public final static String PAGE_MY_FIRSTUSHER = "pages/client/visitorDetail/visitorDetail";
12
 
13
 
13
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
14
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
14
     public final static String WECHAT_CLIENT_CAR = "car";
15
     public final static String WECHAT_CLIENT_CAR = "car";

+ 2
- 0
src/main/java/com.huiju.welcome/utils/MiniApp.java View File

101
     @Data
101
     @Data
102
     public static class Tpl {
102
     public static class Tpl {
103
         private String visitor;
103
         private String visitor;
104
+        
105
+        private String firstUsher;
104
     }
106
     }
105
 }
107
 }

+ 1
- 0
src/main/resources/application.yml View File

50
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
50
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
51
   tpls:
51
   tpls:
52
     visitor: m5fR2X1D-iWUurRe-pQQU8VgcxSSZ5eAVoquMixphFw
52
     visitor: m5fR2X1D-iWUurRe-pQQU8VgcxSSZ5eAVoquMixphFw
53
+    firstUsher: DlpqippBqmqkWWLDxsxB7iIbhlD7px4TCnP2KcK7DY8
53
 
54
 
54
 # ali-cloud
55
 # ali-cloud
55
 ali:
56
 ali: