张延森 6 years ago
parent
commit
867684a316
27 changed files with 883 additions and 567 deletions
  1. 365
    490
      .idea/workspace.xml
  2. 33
    4
      src/main/java/com.huiju.welcome/controller/CameraController.java
  3. 41
    0
      src/main/java/com.huiju.welcome/controller/TaCarController.java
  4. 7
    0
      src/main/java/com.huiju.welcome/controller/TaCarRecordController.java
  5. 10
    0
      src/main/java/com.huiju.welcome/controller/TaVisitorAppointmentController.java
  6. 17
    0
      src/main/java/com.huiju.welcome/mapper/TaCarMapper.java
  7. 45
    0
      src/main/java/com.huiju.welcome/model/TaCar.java
  8. 5
    0
      src/main/java/com.huiju.welcome/model/TaCarRecord.java
  9. 4
    0
      src/main/java/com.huiju.welcome/service/ISysParamService.java
  10. 3
    0
      src/main/java/com.huiju.welcome/service/ITaCarRecordService.java
  11. 19
    0
      src/main/java/com.huiju.welcome/service/ITaCarService.java
  12. 3
    1
      src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java
  13. 4
    0
      src/main/java/com.huiju.welcome/service/ITaPersonService.java
  14. 2
    0
      src/main/java/com.huiju.welcome/service/ITaVisitorAppointmentService.java
  15. 52
    33
      src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java
  16. 12
    0
      src/main/java/com.huiju.welcome/service/impl/SysParamServiceImpl.java
  17. 39
    5
      src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java
  18. 68
    0
      src/main/java/com.huiju.welcome/service/impl/TaCarServiceImpl.java
  19. 18
    9
      src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java
  20. 1
    0
      src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java
  21. 64
    14
      src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java
  22. 6
    1
      src/main/java/com.huiju.welcome/service/impl/TaMessageRecordImpl.java
  23. 26
    1
      src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java
  24. 12
    0
      src/main/java/com.huiju.welcome/service/impl/TaVisitorAppointmentServiceImpl.java
  25. 18
    9
      src/main/java/com.huiju.welcome/utils/AliFaceUtils.java
  26. 5
    0
      src/main/java/com.huiju.welcome/utils/CommConstant.java
  27. 4
    0
      src/main/resources/mapper/TaCarMapper.xml

+ 365
- 490
.idea/workspace.xml
File diff suppressed because it is too large
View File


+ 33
- 4
src/main/java/com.huiju.welcome/controller/CameraController.java View File

8
 import com.huiju.welcome.common.base.ResponseBean;
8
 import com.huiju.welcome.common.base.ResponseBean;
9
 import com.huiju.welcome.model.*;
9
 import com.huiju.welcome.model.*;
10
 import com.huiju.welcome.service.*;
10
 import com.huiju.welcome.service.*;
11
+import com.huiju.welcome.utils.AliFaceUtils;
11
 import com.huiju.welcome.utils.AliOSSUtils;
12
 import com.huiju.welcome.utils.AliOSSUtils;
12
 import com.huiju.welcome.utils.StatusUtils;
13
 import com.huiju.welcome.utils.StatusUtils;
13
 import com.huiju.welcome.utils.XFYun;
14
 import com.huiju.welcome.utils.XFYun;
58
 	@Autowired
59
 	@Autowired
59
 	private ICameraService cameraService;
60
 	private ICameraService cameraService;
60
 
61
 
62
+	@Autowired
63
+	private AliFaceUtils aliFaceUtils;
64
+
61
 	@GetMapping("/ping")
65
 	@GetMapping("/ping")
62
 	public String ping() {
66
 	public String ping() {
63
 		return "pong";
67
 		return "pong";
93
 
97
 
94
 	@PostMapping("/camera/{deviceId}/face")
98
 	@PostMapping("/camera/{deviceId}/face")
95
 	public ResponseBean face(
99
 	public ResponseBean face(
96
-			@PathParam("deviceId") String deviceId,
100
+			@PathVariable("deviceId") String deviceId,
97
 			@RequestParam(value = "avatar", required = false) MultipartFile avatar,
101
 			@RequestParam(value = "avatar", required = false) MultipartFile avatar,
98
 			@RequestParam(value = "score", defaultValue = "0") Integer score
102
 			@RequestParam(value = "score", defaultValue = "0") Integer score
99
 	) {
103
 	) {
111
 			return ResponseBean.success("");
115
 			return ResponseBean.success("");
112
 		}
116
 		}
113
 
117
 
118
+		TaSnapshotPerson taSnapshotPerson = new TaSnapshotPerson();
119
+
114
 		// 人脸比对检索
120
 		// 人脸比对检索
115
-		// todo
121
+		JSONObject result = null;
122
+		try {
123
+			result = aliFaceUtils.searchFace(avatarURL);
124
+		} catch (Exception e) {
125
+			log.error("比对人脸失败: {}", e.getMessage());
126
+			e.printStackTrace();
127
+			return ResponseBean.error("比对人脸失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
128
+		}
129
+
130
+		if (null != result) {
131
+			Float rate = result.getFloat("rate");
132
+			if (null == rate) {
133
+				log.error("比对人脸异常, 比对阈值结果为空");
134
+				rate = 0.0f;
135
+			} else {
136
+				rate *= 100;
137
+			}
138
+			Integer matchPerson = result.getInteger("personId");
139
+
140
+			taSnapshotPerson.setSimilarity(rate);
141
+			taSnapshotPerson.setMatchPerson(matchPerson);
142
+		} else {
143
+			taSnapshotPerson.setSimilarity(0f);
144
+		}
116
 
145
 
117
-		TaSnapshotPerson taSnapshotPerson = new TaSnapshotPerson();
118
 		taSnapshotPerson.setCreateDate(LocalDateTime.now());
146
 		taSnapshotPerson.setCreateDate(LocalDateTime.now());
119
 		taSnapshotPerson.setStatus(StatusUtils.Normal);
147
 		taSnapshotPerson.setStatus(StatusUtils.Normal);
120
 		taSnapshotPerson.setAvatar(avatarURL);
148
 		taSnapshotPerson.setAvatar(avatarURL);
127
 
155
 
128
 	@PostMapping(value = "/camera/{deviceId}/car")
156
 	@PostMapping(value = "/camera/{deviceId}/car")
129
 	public ResponseBean car(
157
 	public ResponseBean car(
130
-			@PathParam("deviceId") String deviceId,
158
+			@PathVariable("deviceId") String deviceId,
131
 			@RequestParam("sceneImage") MultipartFile carImage,
159
 			@RequestParam("sceneImage") MultipartFile carImage,
132
 			@RequestParam("licenseImage") MultipartFile licenseImage,
160
 			@RequestParam("licenseImage") MultipartFile licenseImage,
133
 			@RequestParam(value = "driverImage", required = false) MultipartFile driverImage,
161
 			@RequestParam(value = "driverImage", required = false) MultipartFile driverImage,
141
 		taCarRecord.setPlateNumber(plateNumber);
169
 		taCarRecord.setPlateNumber(plateNumber);
142
 		taCarRecord.setColor(color);
170
 		taCarRecord.setColor(color);
143
 		taCarRecord.setCarModel(carModel);
171
 		taCarRecord.setCarModel(carModel);
172
+		taCarRecord.setCreateDate(LocalDateTime.now());
144
 
173
 
145
 		if (null != carImage && !carImage.isEmpty()) {
174
 		if (null != carImage && !carImage.isEmpty()) {
146
 			taCarRecord.setCarImage(getMultipartFile(carImage));
175
 			taCarRecord.setCarImage(getMultipartFile(carImage));

+ 41
- 0
src/main/java/com.huiju.welcome/controller/TaCarController.java View File

1
+package com.huiju.welcome.controller;
2
+
3
+import com.huiju.welcome.common.base.BaseController;
4
+import com.huiju.welcome.common.base.ResponseBean;
5
+import com.huiju.welcome.service.ITaCarService;
6
+import com.huiju.welcome.utils.CommConstant;
7
+import org.slf4j.Logger;
8
+import org.slf4j.LoggerFactory;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.web.bind.annotation.*;
11
+
12
+/**
13
+ * <p>
14
+    *  前端控制器
15
+    * </p>
16
+ *
17
+ * @author jobob
18
+ * @since 2019-06-11
19
+ */
20
+@RestController
21
+@RequestMapping("/")
22
+public class TaCarController extends BaseController {
23
+
24
+    private final Logger logger = LoggerFactory.getLogger(TaCarController.class);
25
+
26
+    @Autowired
27
+    public ITaCarService iTaCarService;
28
+
29
+    @PutMapping("/car/whitelist/{id}")
30
+    public ResponseBean addWhiteList(@PathVariable String id) {
31
+        iTaCarService.setCarType(id, CommConstant.TYPE_CAR_INNER);
32
+        return ResponseBean.success("");
33
+    }
34
+
35
+    @DeleteMapping("/car/whitelist/{id}")
36
+    public ResponseBean deleteWhiteList(@PathVariable String id) {
37
+        iTaCarService.setCarType(id, CommConstant.TYPE_CAR_NORMAL);
38
+        return ResponseBean.success("");
39
+    }
40
+
41
+}

+ 7
- 0
src/main/java/com.huiju.welcome/controller/TaCarRecordController.java View File

13
 import org.springframework.web.bind.annotation.*;
13
 import org.springframework.web.bind.annotation.*;
14
 
14
 
15
 import java.util.Date;
15
 import java.util.Date;
16
+import java.util.List;
16
 
17
 
17
 /**
18
 /**
18
  * <p>
19
  * <p>
135
         responseBean.addSuccess(pageList);
136
         responseBean.addSuccess(pageList);
136
         return responseBean;
137
         return responseBean;
137
     }
138
     }
139
+
140
+    @RequestMapping("/miniapp/carRecord/timeline")
141
+    public ResponseBean timeline() {
142
+        List<TaCarRecord> result = iTaCarRecordService.getTimeline();
143
+        return ResponseBean.success(result);
144
+    }
138
 }
145
 }

+ 10
- 0
src/main/java/com.huiju.welcome/controller/TaVisitorAppointmentController.java View File

145
         return result;
145
         return result;
146
     }
146
     }
147
 
147
 
148
+    @ApiOperation(value = "访客预约信息",notes = "访客预约信息")
149
+    @RequestMapping(value="/miniapp/appointment",method= RequestMethod.GET)
150
+    public ResponseBean myAppointmentList(@RequestParam(defaultValue = "1") int pageNum,
151
+                                          @RequestParam(defaultValue = "10") int pageSize,
152
+                                          HttpServletRequest request) {
153
+        TaWechatUser user = iTaWechatUserService.getById(Integer.valueOf(JWTUtils.getSubject(request)));
154
+        IPage<TaVisitorAppointment> result = taVisitorAppointmentService.getMyAppointmentList(pageNum, pageSize, user.getPersonId());
155
+        return ResponseBean.success(result);
156
+    }
157
+
148
 }
158
 }

+ 17
- 0
src/main/java/com.huiju.welcome/mapper/TaCarMapper.java View File

1
+package com.huiju.welcome.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.huiju.welcome.model.TaCar;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ *  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-06-18
14
+ */
15
+@Mapper
16
+public interface TaCarMapper extends BaseMapper<TaCar> {
17
+}

+ 45
- 0
src/main/java/com.huiju.welcome/model/TaCar.java View File

1
+package com.huiju.welcome.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import lombok.Data;
8
+import lombok.EqualsAndHashCode;
9
+import lombok.experimental.Accessors;
10
+
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
14
+/**
15
+ * <p>
16
+ * 
17
+ * </p>
18
+ *
19
+ * @author jobob
20
+ * @since 2019-06-18
21
+ */
22
+@Data
23
+@EqualsAndHashCode(callSuper = false)
24
+@Accessors(chain = true)
25
+@TableName("ta_car")
26
+public class TaCar implements Serializable {
27
+
28
+    private static final long serialVersionUID = 1L;
29
+
30
+    @TableId(value = "plate_number", type = IdType.INPUT)
31
+    private String plateNumber;
32
+
33
+    private String color;
34
+
35
+    private String carModel;
36
+
37
+    private String carImage;
38
+
39
+    private String typeId;
40
+
41
+    @TableField("`status`")
42
+    private Integer status;
43
+
44
+    private LocalDateTime createDate;
45
+}

+ 5
- 0
src/main/java/com.huiju.welcome/model/TaCarRecord.java View File

61
     @TableField(exist = false)
61
     @TableField(exist = false)
62
     private String phone;
62
     private String phone;
63
 
63
 
64
+    /**
65
+     * 预约人数
66
+     */
67
+    @TableField(exist = false)
68
+    private Integer personNum;
64
 }
69
 }

+ 4
- 0
src/main/java/com.huiju.welcome/service/ISysParamService.java View File

20
     Float getFaceMinScore();
20
     Float getFaceMinScore();
21
 
21
 
22
     Float getDispatchTimeLimit();
22
     Float getDispatchTimeLimit();
23
+
24
+    Float getTplMessageInterval();
25
+
26
+    Float getCustomerVisitInterval();
23
 }
27
 }

+ 3
- 0
src/main/java/com.huiju.welcome/service/ITaCarRecordService.java View File

7
 import java.time.LocalDate;
7
 import java.time.LocalDate;
8
 import java.time.LocalDateTime;
8
 import java.time.LocalDateTime;
9
 import java.util.Date;
9
 import java.util.Date;
10
+import java.util.List;
10
 
11
 
11
 /**
12
 /**
12
  * <p>
13
  * <p>
32
     boolean newRecordByDevice(TaCarRecord taCarRecord);
33
     boolean newRecordByDevice(TaCarRecord taCarRecord);
33
 
34
 
34
     boolean updateRecordByMiniapp(TaCarRecord taCarRecord);
35
     boolean updateRecordByMiniapp(TaCarRecord taCarRecord);
36
+
37
+    List<TaCarRecord> getTimeline();
35
 }
38
 }

+ 19
- 0
src/main/java/com.huiju.welcome/service/ITaCarService.java View File

1
+package com.huiju.welcome.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.huiju.welcome.model.TaCar;
5
+import com.huiju.welcome.model.TaCarRecord;
6
+
7
+/**
8
+ * <p>
9
+ *  服务类
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-06-18
14
+ */
15
+public interface ITaCarService extends IService<TaCar> {
16
+    TaCar newCarByDevice(TaCarRecord taCarRecord);
17
+
18
+    boolean setCarType(String id, String typeId);
19
+}

+ 3
- 1
src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java View File

23
 
23
 
24
     void notifyConsultant(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception;
24
     void notifyConsultant(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception;
25
 
25
 
26
-    boolean newRecordByDevice(TaCustomer taCustomer, TaPerson taPerson);
26
+    boolean newRecordByDeviceDeprecated(TaCustomer taCustomer, TaPerson taPerson);
27
 
27
 
28
     boolean newRecordByConsultant(TaCustomer taCustomer);
28
     boolean newRecordByConsultant(TaCustomer taCustomer);
29
     IPage<TaMainUsherRecord> taMainUsherRecordList(IPage<TaMainUsherRecord> pg,String phone,String platNumber,String personName,Integer appointment);
29
     IPage<TaMainUsherRecord> taMainUsherRecordList(IPage<TaMainUsherRecord> pg,String phone,String platNumber,String personName,Integer appointment);
39
     boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception;
39
     boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception;
40
 
40
 
41
     boolean deleteRecord(Integer id);
41
     boolean deleteRecord(Integer id);
42
+
43
+    boolean newRecordByDevice(TaPerson taPerson, TaCustomer taCustomer);
42
 }
44
 }

+ 4
- 0
src/main/java/com.huiju.welcome/service/ITaPersonService.java View File

57
     TaPerson newPersonByDevice(TaSnapshotPerson taSnapshotPerson);
57
     TaPerson newPersonByDevice(TaSnapshotPerson taSnapshotPerson);
58
 
58
 
59
     boolean send2Front(TaPerson taPerson);
59
     boolean send2Front(TaPerson taPerson);
60
+
61
+    boolean updateByMainUsher(TaMainUsherRecord taMainUsherRecord);
62
+
63
+    TaPerson getByIdOrReal(Integer personId);
60
 }
64
 }

+ 2
- 0
src/main/java/com.huiju.welcome/service/ITaVisitorAppointmentService.java View File

30
     List<TaVisitorAppointment> getAppointmentsBy(Map<String,Object> filters);
30
     List<TaVisitorAppointment> getAppointmentsBy(Map<String,Object> filters);
31
 
31
 
32
     List<TaVisitorAppointment> getAppointmentsByPlateNumber(String plateNumber);
32
     List<TaVisitorAppointment> getAppointmentsByPlateNumber(String plateNumber);
33
+
34
+    IPage<TaVisitorAppointment> getMyAppointmentList(int pageNum, int pageSize, Integer personId);
33
 }
35
 }

+ 52
- 33
src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java View File

7
 import com.huiju.welcome.model.TaPerson;
7
 import com.huiju.welcome.model.TaPerson;
8
 import com.huiju.welcome.model.TaSnapshotPerson;
8
 import com.huiju.welcome.model.TaSnapshotPerson;
9
 import com.huiju.welcome.service.*;
9
 import com.huiju.welcome.service.*;
10
-import com.huiju.welcome.utils.Encrypt;
11
-import com.huiju.welcome.utils.StatusUtils;
12
-import com.huiju.welcome.utils.TencentFaceUtils;
10
+import com.huiju.welcome.utils.*;
13
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
11
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
14
 import lombok.extern.slf4j.Slf4j;
12
 import lombok.extern.slf4j.Slf4j;
15
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.beans.factory.annotation.Autowired;
33
     @Autowired
31
     @Autowired
34
     TencentFaceUtils tencentFaceUtils;
32
     TencentFaceUtils tencentFaceUtils;
35
 
33
 
34
+    @Autowired
35
+    AliFaceUtils aliFaceUtils;
36
+
36
     @Autowired
37
     @Autowired
37
     ISysParamService iSysParamService;
38
     ISysParamService iSysParamService;
38
 
39
 
50
 
51
 
51
     @Override
52
     @Override
52
     public String dispatchPerson(TaPerson taPerson, TaDevice... devices) {
53
     public String dispatchPerson(TaPerson taPerson, TaDevice... devices) {
53
-        List<TaDevice> taDeviceList = null;
54
-        if (null == devices || devices.length == 0) {
55
-            QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.eq("status",StatusUtils.Normal);
57
-            queryWrapper.eq("afr",StatusUtils.BoolTrue);
58
-            taDeviceList = taDeviceService.list(queryWrapper);
59
-        } else {
60
-            taDeviceList = Arrays.asList(devices);
61
-        }
62
-
63
-        //分发人脸到各个相机
64
-        for(TaDevice device: taDeviceList) {
65
-            try {
66
-                Map<String, Object> payload = new HashMap<>();
67
-                payload.put("personId", taPerson.getPersonId());
68
-                payload.put("image", taPerson.getAvatar());
69
-
70
-                Action act = Action.create(Action.TYPE_DISPATCH_FACE, payload);
71
-
72
-                WebSocketServer.sendInfo(act.toJSON(), "device", device.getDeviceId());
73
-            } catch (Exception e){
74
-                e.printStackTrace();
75
-                return "连接设备(" + device.getDeviceId() + ")人脸下发服务 失败: "+ e.getMessage();
76
-            }
77
-        }
54
+//        List<TaDevice> taDeviceList = null;
55
+//        if (null == devices || devices.length == 0) {
56
+//            QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
57
+//            queryWrapper.eq("status",StatusUtils.Normal);
58
+//            queryWrapper.eq("afr",StatusUtils.BoolTrue);
59
+//            taDeviceList = taDeviceService.list(queryWrapper);
60
+//        } else {
61
+//            taDeviceList = Arrays.asList(devices);
62
+//        }
63
+//
64
+//        //分发人脸到各个相机
65
+//        for(TaDevice device: taDeviceList) {
66
+//            try {
67
+//                Map<String, Object> payload = new HashMap<>();
68
+//                payload.put("personId", taPerson.getPersonId());
69
+//                payload.put("image", taPerson.getAvatar());
70
+//
71
+//                Action act = Action.create(Action.TYPE_DISPATCH_FACE, payload);
72
+//
73
+//                WebSocketServer.sendInfo(act.toJSON(), "device", device.getDeviceId());
74
+//            } catch (Exception e){
75
+//                e.printStackTrace();
76
+//                return "连接设备(" + device.getDeviceId() + ")人脸下发服务 失败: "+ e.getMessage();
77
+//            }
78
+//        }
79
+//
80
+//        // 下发到腾讯云人脸识别
81
+//        try {
82
+//            tencentFaceUtils.createFace(String.valueOf(taPerson.getRealId()), taPerson.getAvatar());
83
+//        } catch (TencentCloudSDKException e) {
84
+//            e.printStackTrace();
85
+//            log.error("下发人脸到腾讯云失败: " + e.getMessage());
86
+//        }
78
 
87
 
79
-        // 下发到腾讯云人脸识别
80
         try {
88
         try {
81
-            tencentFaceUtils.createFace(String.valueOf(taPerson.getRealId()), taPerson.getAvatar());
82
-        } catch (TencentCloudSDKException e) {
89
+            aliFaceUtils.createFace(String.valueOf(taPerson.getRealId()), taPerson.getAvatar());
90
+        } catch (Exception e) {
83
             e.printStackTrace();
91
             e.printStackTrace();
84
-            log.error("下发人脸到腾讯云失败: " + e.getMessage());
92
+            log.error("下发人脸到阿里云失败: " + e.getMessage());
85
         }
93
         }
86
 
94
 
87
         return "";
95
         return "";
104
 
112
 
105
         // 识别结果
113
         // 识别结果
106
         boolean newGuy = null == similarity || similarity < (samePersonThreshold / 100);
114
         boolean newGuy = null == similarity || similarity < (samePersonThreshold / 100);
107
-
108
         TaPerson taPerson = null;
115
         TaPerson taPerson = null;
116
+
109
         if (!newGuy) {
117
         if (!newGuy) {
110
             taPerson = taPersonService.getById(taSnapshotPerson.getMatchPerson());
118
             taPerson = taPersonService.getById(taSnapshotPerson.getMatchPerson());
119
+            if (null == taPerson) {
120
+                // 出现这种情况, 说明阿里云的人脸库与本地不一致。
121
+                newGuy = true;
122
+            }
111
 
123
 
124
+            // 如果是工作人员则忽略
125
+            if (null != taPerson && null != taPerson.getTypeId() && taPerson.getTypeId() == CommConstant.TYPE_INNER_PERSON) {
126
+                return true;
127
+            }
128
+        }
129
+
130
+        if (!newGuy) {
112
             // 抓拍人与比对人是同一个人
131
             // 抓拍人与比对人是同一个人
113
             taSnapshotPerson.setPersonId(taSnapshotPerson.getMatchPerson());
132
             taSnapshotPerson.setPersonId(taSnapshotPerson.getMatchPerson());
114
 
133
 

+ 12
- 0
src/main/java/com.huiju.welcome/service/impl/SysParamServiceImpl.java View File

49
         return Float.parseFloat(val);
49
         return Float.parseFloat(val);
50
     }
50
     }
51
 
51
 
52
+    @Override
53
+    public Float getTplMessageInterval() {
54
+        String val = getParamOfWithDefault("tpl-message-interval", "120");
55
+        return Float.parseFloat(val);
56
+    }
57
+
58
+    @Override
59
+    public Float getCustomerVisitInterval() {
60
+        String val = getParamOfWithDefault("customer-visit-interval", "120");
61
+        return Float.parseFloat(val);
62
+    }
63
+
52
 
64
 
53
 }
65
 }

+ 39
- 5
src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java View File

1
 package com.huiju.welcome.service.impl;
1
 package com.huiju.welcome.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
 import com.huiju.welcome.mapper.TaCarRecordMapper;
6
 import com.huiju.welcome.mapper.TaCarRecordMapper;
6
-import com.huiju.welcome.model.TaCarRecord;
7
-import com.huiju.welcome.model.TaCustomer;
8
-import com.huiju.welcome.model.TaFirstUsherRecord;
9
-import com.huiju.welcome.model.TaVisitorAppointment;
7
+import com.huiju.welcome.model.*;
10
 import com.huiju.welcome.service.*;
8
 import com.huiju.welcome.service.*;
9
+import com.huiju.welcome.utils.CommConstant;
11
 import com.huiju.welcome.utils.TencentFaceUtils;
10
 import com.huiju.welcome.utils.TencentFaceUtils;
12
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
11
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
13
 import com.tencentcloudapi.iai.v20180301.models.Candidate;
12
 import com.tencentcloudapi.iai.v20180301.models.Candidate;
36
     @Autowired
35
     @Autowired
37
     private TaCarRecordMapper taCarRecordMapper;
36
     private TaCarRecordMapper taCarRecordMapper;
38
 
37
 
38
+    @Autowired
39
+    private ITaCarService iTaCarService;
40
+
41
+    @Autowired
42
+    private ITaPersonService iTaPersonService;
43
+
39
     @Autowired
44
     @Autowired
40
     private ITaFirstUsherRecordService iTaFirstUsherRecordService;
45
     private ITaFirstUsherRecordService iTaFirstUsherRecordService;
41
 
46
 
63
      */
68
      */
64
     @Override
69
     @Override
65
     public boolean newRecordByDevice(TaCarRecord taCarRecord) {
70
     public boolean newRecordByDevice(TaCarRecord taCarRecord) {
71
+        // 是否内部车辆
72
+        TaCar taCar = iTaCarService.getById(taCarRecord.getPlateNumber());
73
+        if (null != taCar && taCar.getTypeId().equals(CommConstant.TYPE_CAR_INNER)) {
74
+            return true;
75
+        }
76
+
66
         // 到客户中查询是否有相关人员
77
         // 到客户中查询是否有相关人员
67
         TaCustomer taCustomer = null;
78
         TaCustomer taCustomer = null;
68
         List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(taCarRecord.getPlateNumber());
79
         List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(taCarRecord.getPlateNumber());
84
             // 依据人脸与预约判断
95
             // 依据人脸与预约判断
85
             // 人脸优先级高
96
             // 人脸优先级高
86
             if (null != personId && personId > 0) {
97
             if (null != personId && personId > 0) {
98
+                // 是否内部人员
99
+                TaPerson taPerson = iTaPersonService.getByIdOrReal(personId);
100
+                if (null != taPerson.getTypeId() && taPerson.getTypeId() == CommConstant.TYPE_INNER_PERSON) {
101
+                    return true;
102
+                }
103
+
87
                 // 找到对应人脸
104
                 // 找到对应人脸
88
                 taCustomer = iTaCustomerService.getSameByPerson(personId);
105
                 taCustomer = iTaCustomerService.getSameByPerson(personId);
89
                 if (null != taCustomer) {
106
                 if (null != taCustomer) {
100
                     taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord, appointments.get(0));
117
                     taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord, appointments.get(0));
101
                     taCarRecord.setPhone(appointments.get(0).getPhone());
118
                     taCarRecord.setPhone(appointments.get(0).getPhone());
102
                     taCarRecord.setCustomerName(appointments.get(0).getPersonName());
119
                     taCarRecord.setCustomerName(appointments.get(0).getPersonName());
120
+                    taCarRecord.setPersonNum(appointments.get(0).getPersonNum());
103
                 } else {
121
                 } else {
104
                     taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord);
122
                     taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord);
105
                 }
123
                 }
111
 
129
 
112
         // 先入库
130
         // 先入库
113
         taCarRecordMapper.insert(taCarRecord);
131
         taCarRecordMapper.insert(taCarRecord);
132
+        iTaCarService.newCarByDevice(taCarRecord);
114
 
133
 
115
         // 生成保安迎宾记录, 并通知小程序
134
         // 生成保安迎宾记录, 并通知小程序
116
         TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord);
135
         TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord);
125
             }
144
             }
126
         }
145
         }
127
 
146
 
128
-        return false;
147
+        return true;
129
     }
148
     }
130
 
149
 
131
     @Override
150
     @Override
133
         // 先暂时只做更新动作
152
         // 先暂时只做更新动作
134
         return taCarRecordMapper.updateById(taCarRecord) > 0;
153
         return taCarRecordMapper.updateById(taCarRecord) > 0;
135
     }
154
     }
155
+
156
+    @Override
157
+    public List<TaCarRecord> getTimeline() {
158
+        LocalDateTime now = LocalDateTime.now();
159
+
160
+        // 四小时内
161
+        LocalDateTime fourHour = now.minusHours(4);
162
+        QueryWrapper<TaCarRecord> query = new QueryWrapper<>();
163
+        query.ge("create_date", fourHour);
164
+        query.groupBy("plate_number");
165
+        query.orderByDesc("create_date");
166
+        List<TaCarRecord> result = taCarRecordMapper.selectList(query);
167
+
168
+        return result;
169
+    }
136
 }
170
 }

+ 68
- 0
src/main/java/com.huiju.welcome/service/impl/TaCarServiceImpl.java View File

1
+package com.huiju.welcome.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.huiju.welcome.mapper.TaCarMapper;
6
+import com.huiju.welcome.model.*;
7
+import com.huiju.welcome.service.*;
8
+import com.huiju.welcome.utils.CommConstant;
9
+import com.huiju.welcome.utils.StatusUtils;
10
+import org.slf4j.Logger;
11
+import org.slf4j.LoggerFactory;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.stereotype.Service;
14
+
15
+import java.time.LocalDateTime;
16
+
17
+/**
18
+ * <p>
19
+ *  服务实现类
20
+ * </p>
21
+ *
22
+ * @author jobob
23
+ * @since 2019-06-18
24
+ */
25
+@Service
26
+public class TaCarServiceImpl extends ServiceImpl<TaCarMapper, TaCar> implements ITaCarService {
27
+    Logger log = LoggerFactory.getLogger(TaCarServiceImpl.class);
28
+
29
+    @Autowired
30
+    private TaCarMapper taCarMapper;
31
+
32
+    @Override
33
+    public TaCar newCarByDevice(TaCarRecord taCarRecord) {
34
+        String plateNumber = taCarRecord.getPlateNumber();
35
+        if (null == plateNumber || "".equals(plateNumber)) {
36
+            return null;
37
+        }
38
+
39
+        TaCar taCar = taCarMapper.selectById(plateNumber);
40
+        if (null != taCar) return taCar;
41
+
42
+        taCar = new TaCar();
43
+        taCar.setPlateNumber(taCarRecord.getPlateNumber());
44
+        taCar.setCarImage(taCarRecord.getCarImage());
45
+        taCar.setCarModel(taCarRecord.getCarModel());
46
+        taCar.setColor(taCarRecord.getColor());
47
+        taCar.setTypeId(CommConstant.TYPE_CAR_NORMAL);
48
+        taCar.setStatus(StatusUtils.Normal);
49
+        taCar.setCreateDate(LocalDateTime.now());
50
+
51
+        int row = taCarMapper.insert(taCar);
52
+        if (row < 1) {
53
+            log.error("插入车辆信息出错!");
54
+            return null;
55
+        }
56
+
57
+        return taCar;
58
+    }
59
+
60
+    @Override
61
+    public boolean setCarType(String id, String typeId) {
62
+        UpdateWrapper<TaCar> updateWrapper = new UpdateWrapper<>();
63
+        updateWrapper.set("type_id", typeId);
64
+        updateWrapper.eq("plate_number", id);
65
+
66
+        return taCarMapper.update(new TaCar(), updateWrapper) > 0;
67
+    }
68
+}

+ 18
- 9
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java View File

6
 import com.huiju.welcome.common.base.ResponseBean;
6
 import com.huiju.welcome.common.base.ResponseBean;
7
 import com.huiju.welcome.mapper.*;
7
 import com.huiju.welcome.mapper.*;
8
 import com.huiju.welcome.model.*;
8
 import com.huiju.welcome.model.*;
9
-import com.huiju.welcome.service.ITaCustomerService;
10
-import com.huiju.welcome.service.ITaMainUsherRecordService;
11
-import com.huiju.welcome.service.ITaPersonService;
12
-import com.huiju.welcome.service.ITaVisitorAppointmentService;
9
+import com.huiju.welcome.service.*;
13
 import com.huiju.welcome.utils.CommConstant;
10
 import com.huiju.welcome.utils.CommConstant;
14
 import com.huiju.welcome.utils.MiniApp;
11
 import com.huiju.welcome.utils.MiniApp;
15
 import com.huiju.welcome.utils.StatusUtils;
12
 import com.huiju.welcome.utils.StatusUtils;
61
     @Autowired
58
     @Autowired
62
     SysUserMapper sysUserMapper;
59
     SysUserMapper sysUserMapper;
63
 
60
 
61
+    @Autowired
62
+    ISysParamService iSysParamService;
63
+
64
     @Autowired
64
     @Autowired
65
     MiniApp miniApp;
65
     MiniApp miniApp;
66
 
66
 
77
     @Override
77
     @Override
78
     public void judgeNewCust(TaPerson taPerson) throws Exception {
78
     public void judgeNewCust(TaPerson taPerson) throws Exception {
79
         // 首先判定这个人 2 小时内是否来访过
79
         // 首先判定这个人 2 小时内是否来访过
80
-        LocalDateTime dt = LocalDateTime.now().minusHours(2);
80
+        Float interval = iSysParamService.getCustomerVisitInterval();
81
+        LocalDateTime dt = LocalDateTime.now().minusMinutes(interval.intValue());
81
         List<TaMainUsherRecord> lastList = taMainUsherRecordMapper.getLastList(taPerson.getRealId(), dt);
82
         List<TaMainUsherRecord> lastList = taMainUsherRecordMapper.getLastList(taPerson.getRealId(), dt);
82
         if (null != lastList && lastList.size() > 0) return;
83
         if (null != lastList && lastList.size() > 0) return;
83
 
84
 
87
 
88
 
88
         // 如果是新人过来
89
         // 如果是新人过来
89
         if (null == taCustomer) {
90
         if (null == taCustomer) {
90
-            taCustomer = newCustomerByPerson(taPerson);
91
+//            taCustomer = newCustomerByPerson(taPerson);
91
         }
92
         }
92
 
93
 
93
         // 新增前台记录
94
         // 新增前台记录
94
-        iTaMainUsherRecordService.newRecordByDevice(taCustomer, taPerson);
95
+//        iTaMainUsherRecordService.newRecordByDeviceDeprecated(taCustomer, taPerson);
96
+        iTaMainUsherRecordService.newRecordByDevice(taPerson, taCustomer);
95
         return;
97
         return;
96
     }
98
     }
97
 
99
 
122
 
124
 
123
         String name = StringUtils.ifNull(taCarRecord.getCustomerName(), null != appointment ? appointment.getPersonName() : null);
125
         String name = StringUtils.ifNull(taCarRecord.getCustomerName(), null != appointment ? appointment.getPersonName() : null);
124
         String phone = null != appointment ? appointment.getPhone() : null;
126
         String phone = null != appointment ? appointment.getPhone() : null;
127
+        Integer consultantId = null != appointment ? appointment.getCreateUser() : null;
125
 
128
 
126
         taCustomer.setCreateDate(LocalDateTime.now());
129
         taCustomer.setCreateDate(LocalDateTime.now());
127
         taCustomer.setStatus(StatusUtils.Normal);
130
         taCustomer.setStatus(StatusUtils.Normal);
128
         taCustomer.setCustomerName(name);
131
         taCustomer.setCustomerName(name);
129
         taCustomer.setPhone(phone);
132
         taCustomer.setPhone(phone);
130
-        taCustomer.setAvatar(taCarRecord.getLicenseImage());
133
+        taCustomer.setAvatar(taCarRecord.getDriverImage());
131
         taCustomer.setCarModel(taCarRecord.getCarModel());
134
         taCustomer.setCarModel(taCarRecord.getCarModel());
132
         taCustomer.setPlateNumber(taCarRecord.getPlateNumber());
135
         taCustomer.setPlateNumber(taCarRecord.getPlateNumber());
136
+        taCustomer.setConsultantId(consultantId);
133
 
137
 
134
         TaPerson taPerson = iTaPersonService.newPersonByFront(taCustomer);
138
         TaPerson taPerson = iTaPersonService.newPersonByFront(taCustomer);
135
         taCustomer.setCustomerId(taPerson.getRealId());
139
         taCustomer.setCustomerId(taPerson.getRealId());
230
 
234
 
231
         List<TaVisitorAppointment> appointments = iTaVisitorAppointmentService.getAppointmentsBy(filters);
235
         List<TaVisitorAppointment> appointments = iTaVisitorAppointmentService.getAppointmentsBy(filters);
232
         if (null != appointments && appointments.size() > 0) {
236
         if (null != appointments && appointments.size() > 0) {
237
+            result.put("source", "appointment");
233
             result.put("appointment", 1);
238
             result.put("appointment", 1);
234
             result.put("name", appointments.get(0).getPersonName());
239
             result.put("name", appointments.get(0).getPersonName());
235
             result.put("consultantId", appointments.get(0).getCreateUser());
240
             result.put("consultantId", appointments.get(0).getCreateUser());
241
+            result.put("sex", appointments.get(0).getSex());
242
+            result.put("plateNumber", appointments.get(0).getPlatNumber());
236
         }
243
         }
237
 
244
 
238
         List<TaCustomer> custs = taCustomerMapper.getSomeCustMayBe(null, filters.get("phone").toString());
245
         List<TaCustomer> custs = taCustomerMapper.getSomeCustMayBe(null, filters.get("phone").toString());
239
-        if (null != custs || custs.size() > 0) {
246
+        if (null != custs && custs.size() > 0) {
247
+            result.put("source", "customer");
240
             result.put("name", custs.get(0).getCustomerName());
248
             result.put("name", custs.get(0).getCustomerName());
241
             result.put("consultantId", custs.get(0).getConsultantId());
249
             result.put("consultantId", custs.get(0).getConsultantId());
242
             result.put("consultantName", custs.get(0).getRealtyConsultant());
250
             result.put("consultantName", custs.get(0).getRealtyConsultant());
243
             result.put("purpose", custs.get(0).getPurpose());
251
             result.put("purpose", custs.get(0).getPurpose());
252
+            result.put("plateNumber", custs.get(0).getPlateNumber());
244
         }
253
         }
245
 
254
 
246
         return result;
255
         return result;

+ 1
- 0
src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java View File

67
         taFirstUsherRecord.setPlateNumber(taCarRecord.getPlateNumber());
67
         taFirstUsherRecord.setPlateNumber(taCarRecord.getPlateNumber());
68
         taFirstUsherRecord.setVisiteDate(LocalDateTime.now());
68
         taFirstUsherRecord.setVisiteDate(LocalDateTime.now());
69
         taFirstUsherRecord.setPersonName(taCarRecord.getCustomerName());
69
         taFirstUsherRecord.setPersonName(taCarRecord.getCustomerName());
70
+        taFirstUsherRecord.setPersonNum(taCarRecord.getPersonNum());
70
 
71
 
71
         taFirstUsherRecordMapper.insert(taFirstUsherRecord);
72
         taFirstUsherRecordMapper.insert(taFirstUsherRecord);
72
 
73
 

+ 64
- 14
src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java View File

19
 import com.huiju.welcome.model.TaMainUsherRecord;
19
 import com.huiju.welcome.model.TaMainUsherRecord;
20
 import com.huiju.welcome.service.ITaCustomerService;
20
 import com.huiju.welcome.service.ITaCustomerService;
21
 import com.huiju.welcome.service.ITaMainUsherRecordService;
21
 import com.huiju.welcome.service.ITaMainUsherRecordService;
22
+import com.huiju.welcome.service.ITaPersonService;
22
 import com.huiju.welcome.utils.CommConstant;
23
 import com.huiju.welcome.utils.CommConstant;
23
 import com.huiju.welcome.utils.MiniApp;
24
 import com.huiju.welcome.utils.MiniApp;
24
 import com.huiju.welcome.utils.StatusUtils;
25
 import com.huiju.welcome.utils.StatusUtils;
58
     @Autowired
59
     @Autowired
59
     ITaCustomerService iTaCustomerService;
60
     ITaCustomerService iTaCustomerService;
60
 
61
 
62
+    @Autowired
63
+    ITaPersonService iTaPersonService;
64
+
61
     @Autowired
65
     @Autowired
62
     MiniApp miniApp;
66
     MiniApp miniApp;
63
 
67
 
79
     }
83
     }
80
 
84
 
81
     @Override
85
     @Override
82
-    public boolean newRecordByDevice(TaCustomer taCustomer, TaPerson taPerson) {
86
+    public boolean newRecordByDeviceDeprecated(TaCustomer taCustomer, TaPerson taPerson) {
83
         TaMainUsherRecord taMainUsherRecord = newRecordByCust(taCustomer);
87
         TaMainUsherRecord taMainUsherRecord = newRecordByCust(taCustomer);
84
         taMainUsherRecord.setStatus(StatusUtils.Ready);
88
         taMainUsherRecord.setStatus(StatusUtils.Ready);
85
         taMainUsherRecord.setPersonId(taPerson.getRealId());
89
         taMainUsherRecord.setPersonId(taPerson.getRealId());
232
 
236
 
233
         taMainUsherRecord.setStatus(StatusUtils.Normal);
237
         taMainUsherRecord.setStatus(StatusUtils.Normal);
234
 
238
 
235
-        int row = taMainUsherRecordMapper.updateById(taMainUsherRecord);
236
-
237
         // 是否更新了置业
239
         // 是否更新了置业
238
-        TaCustomer taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
240
+        TaCustomer taCustomer = null;
241
+        if (null == taMainUsherRecord.getCustomerId()) {
242
+            taCustomer = iTaCustomerService.newCustByMainUsher(taMainUsherRecord);
243
+        } else {
244
+            taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
245
+        }
246
+
239
         Integer originConsultant = taCustomer.getConsultantId();
247
         Integer originConsultant = taCustomer.getConsultantId();
240
 
248
 
241
         // 是否需要更新客户信息
249
         // 是否需要更新客户信息
251
             iTaCustomerService.updateById(taCustomer);
259
             iTaCustomerService.updateById(taCustomer);
252
         }
260
         }
253
 
261
 
262
+        int row = taMainUsherRecordMapper.updateById(taMainUsherRecord);
263
+
264
+        // 更新人员信息
265
+        iTaPersonService.updateByMainUsher(taMainUsherRecord);
266
+
254
         // 如果原来置业为空
267
         // 如果原来置业为空
255
         if (null == originConsultant || originConsultant < 1) {
268
         if (null == originConsultant || originConsultant < 1) {
256
             iTaCustomerService.updateConsultant(taCustomer, consultantId);
269
             iTaCustomerService.updateConsultant(taCustomer, consultantId);
275
             SysUser proxyUser = sysUserMapper.selectById(consultantId);
288
             SysUser proxyUser = sysUserMapper.selectById(consultantId);
276
 
289
 
277
             // 通知原置业, 客户被临时置业接待
290
             // 通知原置业, 客户被临时置业接待
278
-            List<Object> dt1 = new ArrayList<Object>(){{
279
-                add(taCustomer.getCustomerName());
280
-                add(taCustomer.getPhone());
281
-                add("您有新客户来访, 已被安排给 " + proxyUser.getUsername() + " 接待!");
282
-            }};
291
+            List<Object> dt1 = new ArrayList<Object>();
292
+            dt1.add(taCustomer.getCustomerName());
293
+            dt1.add(taCustomer.getPhone());
294
+            dt1.add("您有新客户来访, 已被安排给 " + proxyUser.getUsername() + " 接待!");
295
+
283
             miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
296
             miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
284
 
297
 
285
             // 通知临时置业
298
             // 通知临时置业
286
-            List<Object> dt2 = new ArrayList<Object>(){{
287
-                add(taCustomer.getCustomerName());
288
-                add(taCustomer.getPhone());
289
-                add(rcUser.getUsername() + " 有新客户来访, 请协助接待一下!");
290
-            }};
299
+            List<Object> dt2 = new ArrayList<Object>();
300
+            dt2.add(taCustomer.getCustomerName());
301
+            dt2.add(taCustomer.getPhone());
302
+            dt2.add(rcUser.getUsername() + " 有新客户来访, 请协助接待一下!");
303
+
291
             miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
304
             miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
292
         }
305
         }
293
 
306
 
303
 
316
 
304
         return row > 0;
317
         return row > 0;
305
     }
318
     }
319
+
320
+    @Override
321
+    public boolean newRecordByDevice(TaPerson taPerson, TaCustomer taCustomer) {
322
+        TaMainUsherRecord taMainUsherRecord = null;
323
+        if (null != taCustomer) {
324
+            taMainUsherRecord = newRecordByCust(taCustomer);
325
+        } else {
326
+            taMainUsherRecord = newRecordByPerson(taPerson);
327
+        }
328
+
329
+        taMainUsherRecord.setStatus(StatusUtils.Ready);
330
+        taMainUsherRecord.setPersonId(taPerson.getRealId());
331
+        int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
332
+
333
+        try {
334
+            Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord, SerializerFeature.WriteMapNullValue));
335
+            WebSocketServer.sendInfo(act.toJSON(), CommConstant.WECHAT_CLIENT_MINIAPP, null);
336
+        } catch (Exception e) {e.printStackTrace();}
337
+
338
+        return row > 0;
339
+    }
340
+
341
+    private TaMainUsherRecord newRecordByPerson(TaPerson taPerson) {
342
+        TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
343
+        taMainUsherRecord.setPersonName(taPerson.getName());
344
+        taMainUsherRecord.setAvatar(taPerson.getAvatar());
345
+        taMainUsherRecord.setPhone(taPerson.getPhone());
346
+        taMainUsherRecord.setVisiteDate(LocalDateTime.now());
347
+
348
+        if (StringUtils.isEmpty(taPerson.getPhone())) {
349
+            taMainUsherRecord.setStatus(StatusUtils.Ready);
350
+        } else {
351
+            taMainUsherRecord.setStatus(StatusUtils.Normal);
352
+        }
353
+
354
+        return taMainUsherRecord;
355
+    }
306
 }
356
 }

+ 6
- 1
src/main/java/com.huiju.welcome/service/impl/TaMessageRecordImpl.java View File

4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
 import com.huiju.welcome.mapper.TaMessageRecordMapper;
5
 import com.huiju.welcome.mapper.TaMessageRecordMapper;
6
 import com.huiju.welcome.model.TaMessageRecord;
6
 import com.huiju.welcome.model.TaMessageRecord;
7
+import com.huiju.welcome.service.ISysParamService;
7
 import com.huiju.welcome.service.ITaMessageRecordService;
8
 import com.huiju.welcome.service.ITaMessageRecordService;
8
 import org.springframework.beans.factory.annotation.Autowired;
9
 import org.springframework.beans.factory.annotation.Autowired;
9
 import org.springframework.stereotype.Service;
10
 import org.springframework.stereotype.Service;
17
     @Autowired
18
     @Autowired
18
     TaMessageRecordMapper taMessageRecordMapper;
19
     TaMessageRecordMapper taMessageRecordMapper;
19
 
20
 
21
+    @Autowired
22
+    ISysParamService iSysParamService;
23
+
20
     @Override
24
     @Override
21
     public boolean saveMessageOrNot(String toUser, String tplId, String page, List<Object> data, boolean save) {
25
     public boolean saveMessageOrNot(String toUser, String tplId, String page, List<Object> data, boolean save) {
22
         String content = JSONObject.toJSONString(data);
26
         String content = JSONObject.toJSONString(data);
27
+        Float interval = iSysParamService.getTplMessageInterval();
23
         LocalDateTime now = LocalDateTime.now();
28
         LocalDateTime now = LocalDateTime.now();
24
-        LocalDateTime twoHourAgo = now.minusHours(2);
29
+        LocalDateTime twoHourAgo = now.minusMinutes(interval.intValue());
25
 
30
 
26
         List<TaMessageRecord> lastMessages = taMessageRecordMapper.getLastSameMessages(toUser, page, content, twoHourAgo);
31
         List<TaMessageRecord> lastMessages = taMessageRecordMapper.getLastSameMessages(toUser, page, content, twoHourAgo);
27
         if (null != lastMessages && lastMessages.size() > 0) return false;
32
         if (null != lastMessages && lastMessages.size() > 0) return false;

+ 26
- 1
src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java View File

303
         UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
303
         UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
304
         updateWrapper.set("phone", taCustomer.getPhone());
304
         updateWrapper.set("phone", taCustomer.getPhone());
305
         updateWrapper.set("name", taCustomer.getCustomerName());
305
         updateWrapper.set("name", taCustomer.getCustomerName());
306
+        updateWrapper.set("type_id", CommConstant.TYPE_VIP_PERSON);
306
         updateWrapper.eq("real_id", taCustomer.getCustomerId()).or().eq("person_id", taCustomer.getCustomerId());
307
         updateWrapper.eq("real_id", taCustomer.getCustomerId()).or().eq("person_id", taCustomer.getCustomerId());
307
 
308
 
308
         int row = taPersonMapper.update(new TaPerson(), updateWrapper);
309
         int row = taPersonMapper.update(new TaPerson(), updateWrapper);
334
         person.setStatus(StatusUtils.Normal);
335
         person.setStatus(StatusUtils.Normal);
335
         person.setLastVisiteDate(taSnapshotPerson.getCreateDate());
336
         person.setLastVisiteDate(taSnapshotPerson.getCreateDate());
336
         person.setLastVisiteDevice(taSnapshotPerson.getDeviceId());
337
         person.setLastVisiteDevice(taSnapshotPerson.getDeviceId());
337
-        person.setSex(taSnapshotPerson.getSex().toString());
338
+
339
+        Integer sex = taSnapshotPerson.getSex();
340
+        person.setSex(null == sex || sex == 0 ? null : String.valueOf(sex));
338
 
341
 
339
         int row = taPersonMapper.insert(person);
342
         int row = taPersonMapper.insert(person);
340
         if (row < 1) {
343
         if (row < 1) {
409
         return true;
412
         return true;
410
     }
413
     }
411
 
414
 
415
+    @Override
416
+    public boolean updateByMainUsher(TaMainUsherRecord taMainUsherRecord) {
417
+        // 默认客户与人员ID是一致的
418
+        UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
419
+        updateWrapper.set("phone", taMainUsherRecord.getPhone());
420
+        updateWrapper.set("name", taMainUsherRecord.getPersonName());
421
+        updateWrapper.set("type_id", CommConstant.TYPE_VIP_PERSON);
422
+        updateWrapper.eq("real_id", taMainUsherRecord.getPersonId()).or().eq("person_id", taMainUsherRecord.getPersonId());
423
+
424
+        int row = taPersonMapper.update(new TaPerson(), updateWrapper);
425
+        return row > 0;
426
+    }
427
+
428
+    @Override
429
+    public TaPerson getByIdOrReal(Integer personId) {
430
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
431
+        queryWrapper.eq("person_id", personId).or().eq("real_id", personId);
432
+        queryWrapper.last("limit 1");
433
+
434
+        return taPersonMapper.selectOne(queryWrapper);
435
+    }
436
+
412
     private String getTypeName(TaPerson taPerson) {
437
     private String getTypeName(TaPerson taPerson) {
413
         TaPersonType taPersonType = taPersonTypeMapper.selectById(taPerson.getTypeId());
438
         TaPersonType taPersonType = taPersonTypeMapper.selectById(taPerson.getTypeId());
414
         return null == taPersonType ? null : taPersonType.getTypeName();
439
         return null == taPersonType ? null : taPersonType.getTypeName();

+ 12
- 0
src/main/java/com.huiju.welcome/service/impl/TaVisitorAppointmentServiceImpl.java View File

2
 
2
 
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
 import com.huiju.welcome.common.base.ResponseBean;
7
 import com.huiju.welcome.common.base.ResponseBean;
7
 import com.huiju.welcome.mapper.TaVisitorAppointmentMapper;
8
 import com.huiju.welcome.mapper.TaVisitorAppointmentMapper;
66
         return taVisitorAppointmentMapper.selectList(queryWrapper);
67
         return taVisitorAppointmentMapper.selectList(queryWrapper);
67
     }
68
     }
68
 
69
 
70
+    @Override
71
+    public IPage<TaVisitorAppointment> getMyAppointmentList(int pageNum, int pageSize, Integer personId) {
72
+        IPage<TaVisitorAppointment> page = new Page<>(pageNum, pageSize);
73
+        QueryWrapper<TaVisitorAppointment> queryWrapper = new QueryWrapper<>();
74
+        queryWrapper.eq("create_user", personId);
75
+        queryWrapper.gt("status", StatusUtils.Delete);
76
+        queryWrapper.orderByDesc("create_date");
77
+
78
+        return taVisitorAppointmentMapper.selectPage(page, queryWrapper);
79
+    }
80
+
69
     @Override
81
     @Override
70
     public ResponseBean visitorAppointmentList(IPage pg, String platNumber, String personName,String phone) {
82
     public ResponseBean visitorAppointmentList(IPage pg, String platNumber, String personName,String phone) {
71
        ResponseBean responseBean= new ResponseBean();
83
        ResponseBean responseBean= new ResponseBean();

+ 18
- 9
src/main/java/com.huiju.welcome/utils/AliFaceUtils.java View File

18
 import com.aliyuncs.http.MethodType;
18
 import com.aliyuncs.http.MethodType;
19
 import com.aliyuncs.profile.DefaultProfile;
19
 import com.aliyuncs.profile.DefaultProfile;
20
 import com.aliyuncs.profile.IClientProfile;
20
 import com.aliyuncs.profile.IClientProfile;
21
-import com.google.gson.JsonObject;
22
 import com.huiju.welcome.config.AliProperties;
21
 import com.huiju.welcome.config.AliProperties;
23
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
22
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
24
-import com.tencentcloudapi.iai.v20180301.models.GetPersonBaseInfoResponse;
25
 import lombok.extern.slf4j.Slf4j;
23
 import lombok.extern.slf4j.Slf4j;
26
 import org.apache.http.HttpStatus;
24
 import org.apache.http.HttpStatus;
27
 import org.springframework.beans.factory.annotation.Autowired;
25
 import org.springframework.beans.factory.annotation.Autowired;
49
     DefaultProfile profile;
47
     DefaultProfile profile;
50
     DefaultAcsClient client;
48
     DefaultAcsClient client;
51
     IAcsClient recognitionClient;
49
     IAcsClient recognitionClient;
52
-    
53
-    
50
+
54
     @Autowired
51
     @Autowired
55
     public AliFaceUtils(AliProperties p) throws ClientException {
52
     public AliFaceUtils(AliProperties p) throws ClientException {
56
         profile = DefaultProfile.getProfile(AliProperties.face.getRegionId(), AliProperties.accessKeyId, AliProperties.accessKeySecret);
53
         profile = DefaultProfile.getProfile(AliProperties.face.getRegionId(), AliProperties.accessKeyId, AliProperties.accessKeySecret);
66
      * @throws UnsupportedEncodingException
63
      * @throws UnsupportedEncodingException
67
      */
64
      */
68
     public JSONObject getPersonBaseInfo(String personId) throws Exception {
65
     public JSONObject getPersonBaseInfo(String personId) throws Exception {
69
-        JSONObject result = new JSONObject();
70
         GetPersonRequest getPersonRequest = new GetPersonRequest();
66
         GetPersonRequest getPersonRequest = new GetPersonRequest();
71
         getPersonRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
67
         getPersonRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
72
         getPersonRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
68
         getPersonRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
112
     }
108
     }
113
     
109
     
114
     /**
110
     /**
115
-     * 穿件人员
111
+     * 创建人员
116
      * @param personId
112
      * @param personId
117
      * @param personName
113
      * @param personName
118
      * @throws TencentCloudSDKException
114
      * @throws TencentCloudSDKException
119
      * @throws UnsupportedEncodingException
115
      * @throws UnsupportedEncodingException
120
      */
116
      */
121
     public JSONObject createPerson(String personId, String personName) throws Exception {
117
     public JSONObject createPerson(String personId, String personName) throws Exception {
122
-        JSONObject result = new JSONObject();
123
         // 已经存在的人员, 不重复创建
118
         // 已经存在的人员, 不重复创建
124
         try {
119
         try {
125
             if (null != getPersonBaseInfo(personId)){
120
             if (null != getPersonBaseInfo(personId)){
128
         } catch (Exception e) {
123
         } catch (Exception e) {
129
            throw e;
124
            throw e;
130
         }
125
         }
126
+
131
         AddPersonRequest addPersonRequest = new AddPersonRequest();
127
         AddPersonRequest addPersonRequest = new AddPersonRequest();
132
         // 指定api返回格式
128
         // 指定api返回格式
133
         addPersonRequest.setAcceptFormat(FormatType.JSON);
129
         addPersonRequest.setAcceptFormat(FormatType.JSON);
177
             throw e;
173
             throw e;
178
         }
174
         }
179
     }
175
     }
180
-    
176
+
177
+    /**
178
+     * 创建人员
179
+     * @param personId
180
+     * @param url
181
+     * @return
182
+     * @throws Exception
183
+     */
181
     public JSONObject createFace(String personId, String url) throws Exception {
184
     public JSONObject createFace(String personId, String url) throws Exception {
182
         JSONObject result = new JSONObject();
185
         JSONObject result = new JSONObject();
183
         try {
186
         try {
235
         }
238
         }
236
         return result;
239
         return result;
237
     }
240
     }
238
-    
241
+
242
+    /**
243
+     * 人脸查询
244
+     * @param url
245
+     * @return
246
+     * @throws Exception
247
+     */
239
     public JSONObject searchFace(String url) throws Exception {
248
     public JSONObject searchFace(String url) throws Exception {
240
         ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest();
249
         ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest();
241
         imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
250
         imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式

+ 5
- 0
src/main/java/com.huiju.welcome/utils/CommConstant.java View File

10
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
10
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
11
 
11
 
12
     public final static Integer TYPE_NEW_PERSON = 1;
12
     public final static Integer TYPE_NEW_PERSON = 1;
13
+    public final static Integer TYPE_VIP_PERSON = 2;
14
+    public final static Integer TYPE_INNER_PERSON = 3;
15
+
16
+    public final static String TYPE_CAR_NORMAL = "normal";
17
+    public final static String TYPE_CAR_INNER = "inner";
13
 }
18
 }

+ 4
- 0
src/main/resources/mapper/TaCarMapper.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.welcome.mapper.TaCarMapper">
4
+</mapper>