张延森 6 years ago
parent
commit
bf373bf032
62 changed files with 1503 additions and 615 deletions
  1. 13
    0
      .idea/libraries/Maven__com_aliyun_aliyun_java_sdk_core_4_1_1.xml
  2. 13
    0
      .idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
  3. 13
    0
      .idea/libraries/Maven__com_squareup_okhttp_okhttp_2_5_0.xml
  4. 13
    0
      .idea/libraries/Maven__com_squareup_okio_okio_1_6_0.xml
  5. 13
    0
      .idea/libraries/Maven__com_sun_xml_bind_jaxb_core_2_1_14.xml
  6. 13
    0
      .idea/libraries/Maven__com_sun_xml_bind_jaxb_impl_2_1.xml
  7. 13
    0
      .idea/libraries/Maven__com_tencentcloudapi_tencentcloud_sdk_java_3_0_75.xml
  8. 13
    0
      .idea/libraries/Maven__javax_activation_activation_1_1_1.xml
  9. 13
    0
      .idea/libraries/Maven__javax_activation_javax_activation_api_1_2_0.xml
  10. 13
    0
      .idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_1.xml
  11. 10
    0
      .idea/service.iml
  12. 380
    273
      .idea/workspace.xml
  13. 11
    0
      pom.xml
  14. 0
    2
      src/main/java/com.huiju.welcome/common/WebSocketServer.java
  15. 0
    34
      src/main/java/com.huiju.welcome/config/AliOSSProperties.java
  16. 47
    0
      src/main/java/com.huiju.welcome/config/AliProperties.java
  17. 19
    0
      src/main/java/com.huiju.welcome/config/TencentProperties.java
  18. 10
    21
      src/main/java/com.huiju.welcome/controller/CameraController.java
  19. 22
    28
      src/main/java/com.huiju.welcome/controller/ImgController.java
  20. 6
    6
      src/main/java/com.huiju.welcome/controller/SysUserController.java
  21. 14
    0
      src/main/java/com.huiju.welcome/controller/TaCustomerController.java
  22. 6
    6
      src/main/java/com.huiju.welcome/controller/TaFirstpageController.java
  23. 28
    53
      src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java
  24. 0
    32
      src/main/java/com.huiju.welcome/controller/TaPersonController.java
  25. 9
    1
      src/main/java/com.huiju.welcome/controller/TaVisitorAppointmentController.java
  26. 8
    8
      src/main/java/com.huiju.welcome/controller/TaWechatUserController.java
  27. 1
    0
      src/main/java/com.huiju.welcome/interceptor/AccessInterceptor.java
  28. 1
    1
      src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java
  29. 1
    1
      src/main/java/com.huiju.welcome/model/SysUser.java
  30. 2
    0
      src/main/java/com.huiju.welcome/model/TaCarRecord.java
  31. 2
    0
      src/main/java/com.huiju.welcome/model/TaDevice.java
  32. 1
    1
      src/main/java/com.huiju.welcome/model/TaFirstpage.java
  33. 7
    0
      src/main/java/com.huiju.welcome/service/ISysParamService.java
  34. 1
    1
      src/main/java/com.huiju.welcome/service/ISysUserService.java
  35. 13
    8
      src/main/java/com.huiju.welcome/service/ITaCustomerService.java
  36. 8
    1
      src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java
  37. 1
    1
      src/main/java/com.huiju.welcome/service/ITaMessageRecordService.java
  38. 4
    0
      src/main/java/com.huiju.welcome/service/ITaPersonService.java
  39. 7
    0
      src/main/java/com.huiju.welcome/service/ITaVisitorAppointmentService.java
  40. 16
    0
      src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java
  41. 33
    0
      src/main/java/com.huiju.welcome/service/impl/SysParamServiceImpl.java
  42. 2
    2
      src/main/java/com.huiju.welcome/service/impl/SysUserServiceImpl.java
  43. 48
    5
      src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java
  44. 146
    59
      src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java
  45. 3
    1
      src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java
  46. 1
    1
      src/main/java/com.huiju.welcome/service/impl/TaFirstpageServiceImpl.java
  47. 129
    9
      src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java
  48. 10
    8
      src/main/java/com.huiju.welcome/service/impl/TaMessageRecordImpl.java
  49. 16
    2
      src/main/java/com.huiju.welcome/service/impl/TaMiniFormidsImpl.java
  50. 41
    0
      src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java
  51. 3
    31
      src/main/java/com.huiju.welcome/service/impl/TaVisitingLogServiceImpl.java
  52. 23
    1
      src/main/java/com.huiju.welcome/service/impl/TaVisitorAppointmentServiceImpl.java
  53. 121
    0
      src/main/java/com.huiju.welcome/utils/AliFaceUtils.java
  54. 5
    5
      src/main/java/com.huiju.welcome/utils/AliOSSUtils.java
  55. 1
    1
      src/main/java/com.huiju.welcome/utils/CommConstant.java
  56. 14
    3
      src/main/java/com.huiju.welcome/utils/MiniApp.java
  57. 2
    3
      src/main/java/com.huiju.welcome/utils/SAWeather.java
  58. 3
    0
      src/main/java/com.huiju.welcome/utils/StatusUtils.java
  59. 102
    0
      src/main/java/com.huiju.welcome/utils/TencentFaceUtils.java
  60. 16
    3
      src/main/resources/application.yml
  61. 3
    0
      src/main/resources/mapper/TaCustomerMapper.xml
  62. 16
    3
      target/classes/application.yml

+ 13
- 0
.idea/libraries/Maven__com_aliyun_aliyun_java_sdk_core_4_1_1.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.aliyun:aliyun-java-sdk-core:4.1.1">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/aliyun/aliyun-java-sdk-core/4.1.1/aliyun-java-sdk-core-4.1.1.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/aliyun/aliyun-java-sdk-core/4.1.1/aliyun-java-sdk-core-4.1.1-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/aliyun/aliyun-java-sdk-core/4.1.1/aliyun-java-sdk-core-4.1.1-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.google.code.gson:gson:2.8.5">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/google/code/gson/gson/2.8.5/gson-2.8.5-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/google/code/gson/gson/2.8.5/gson-2.8.5-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__com_squareup_okhttp_okhttp_2_5_0.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.squareup.okhttp:okhttp:2.5.0">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/squareup/okhttp/okhttp/2.5.0/okhttp-2.5.0.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/squareup/okhttp/okhttp/2.5.0/okhttp-2.5.0-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/squareup/okhttp/okhttp/2.5.0/okhttp-2.5.0-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__com_squareup_okio_okio_1_6_0.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.squareup.okio:okio:1.6.0">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/squareup/okio/okio/1.6.0/okio-1.6.0.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/squareup/okio/okio/1.6.0/okio-1.6.0-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/squareup/okio/okio/1.6.0/okio-1.6.0-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__com_sun_xml_bind_jaxb_core_2_1_14.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.sun.xml.bind:jaxb-core:2.1.14">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/sun/xml/bind/jaxb-core/2.1.14/jaxb-core-2.1.14.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/sun/xml/bind/jaxb-core/2.1.14/jaxb-core-2.1.14-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/sun/xml/bind/jaxb-core/2.1.14/jaxb-core-2.1.14-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__com_sun_xml_bind_jaxb_impl_2_1.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.sun.xml.bind:jaxb-impl:2.1">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/sun/xml/bind/jaxb-impl/2.1/jaxb-impl-2.1.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/sun/xml/bind/jaxb-impl/2.1/jaxb-impl-2.1-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/sun/xml/bind/jaxb-impl/2.1/jaxb-impl-2.1-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__com_tencentcloudapi_tencentcloud_sdk_java_3_0_75.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: com.tencentcloudapi:tencentcloud-sdk-java:3.0.75">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/com/tencentcloudapi/tencentcloud-sdk-java/3.0.75/tencentcloud-sdk-java-3.0.75.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/com/tencentcloudapi/tencentcloud-sdk-java/3.0.75/tencentcloud-sdk-java-3.0.75-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/com/tencentcloudapi/tencentcloud-sdk-java/3.0.75/tencentcloud-sdk-java-3.0.75-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__javax_activation_activation_1_1_1.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: javax.activation:activation:1.1.1">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/javax/activation/activation/1.1.1/activation-1.1.1-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/javax/activation/activation/1.1.1/activation-1.1.1-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__javax_activation_javax_activation_api_1_2_0.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: javax.activation:javax.activation-api:1.2.0">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_1.xml View File

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: javax.xml.bind:jaxb-api:2.3.1">
3
+    <CLASSES>
4
+      <root url="jar://D:/REPO/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://D:/REPO/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://D:/REPO/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 10
- 0
.idea/service.iml View File

@@ -125,5 +125,15 @@
125 125
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
126 126
     <orderEntry type="library" name="Maven: com.aliyun.oss:aliyun-sdk-oss:2.8.3" level="project" />
127 127
     <orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" />
128
+    <orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-core:4.1.1" level="project" />
129
+    <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
130
+    <orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
131
+    <orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
132
+    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.1.14" level="project" />
133
+    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.1" level="project" />
134
+    <orderEntry type="library" name="Maven: javax.activation:activation:1.1.1" level="project" />
135
+    <orderEntry type="library" name="Maven: com.tencentcloudapi:tencentcloud-sdk-java:3.0.75" level="project" />
136
+    <orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp:2.5.0" level="project" />
137
+    <orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" />
128 138
   </component>
129 139
 </module>

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


+ 11
- 0
pom.xml View File

@@ -97,6 +97,17 @@
97 97
 			<artifactId>aliyun-sdk-oss</artifactId>
98 98
 			<version>2.8.3</version>
99 99
 		</dependency>
100
+		<dependency>
101
+			<groupId>com.aliyun</groupId>
102
+			<artifactId>aliyun-java-sdk-core</artifactId>
103
+			<version>4.1.1</version>
104
+		</dependency>
105
+		<dependency>
106
+			<groupId>com.tencentcloudapi</groupId>
107
+			<artifactId>tencentcloud-sdk-java</artifactId>
108
+			<!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
109
+			<version>3.0.75</version>
110
+		</dependency>
100 111
 	</dependencies>
101 112
 
102 113
 	<build>

+ 0
- 2
src/main/java/com.huiju.welcome/common/WebSocketServer.java View File

@@ -131,8 +131,6 @@ public class WebSocketServer {
131 131
 				continue;
132 132
 			}
133 133
 		}
134
-
135
-		log.error("发送数据失败: [{}-{}] 不在线, 发送内容: {}", type, sid, message);
136 134
 	}
137 135
 	
138 136
 	public static synchronized int getOnlineCount() {

+ 0
- 34
src/main/java/com.huiju.welcome/config/AliOSSProperties.java View File

@@ -1,34 +0,0 @@
1
-package com.huiju.welcome.config;
2
-
3
-
4
-import lombok.Data;
5
-import org.springframework.boot.context.properties.ConfigurationProperties;
6
-
7
-@Data
8
-@ConfigurationProperties(prefix = "ali")
9
-public class AliOSSProperties {
10
-    public static String accessKeyId;
11
-    public static String accessKeySecret;
12
-    public static OSS oss = new AliOSSProperties.OSS();
13
-
14
-    public String getAccessKeyId() { return AliOSSProperties.accessKeyId; }
15
-    public String getAccessKeySecret() { return AliOSSProperties.accessKeySecret; }
16
-    public OSS getOss() { return AliOSSProperties.oss; }
17
-
18
-    // setters
19
-    public void setAccessKeyId(String accessKeyId) {
20
-        AliOSSProperties.accessKeyId = accessKeyId;
21
-    }
22
-    public void setAccessKeySecret(String accessKeySecret) { AliOSSProperties.accessKeySecret = accessKeySecret;}
23
-
24
-    public static void setOss(OSS oss) {
25
-        AliOSSProperties.oss = oss;
26
-    }
27
-
28
-    @Data
29
-    public static class OSS {
30
-        String endpoint;
31
-        String bucketName;
32
-        String bucketURL;
33
-    }
34
-}

+ 47
- 0
src/main/java/com.huiju.welcome/config/AliProperties.java View File

@@ -0,0 +1,47 @@
1
+package com.huiju.welcome.config;
2
+
3
+
4
+import lombok.Data;
5
+import org.springframework.boot.context.properties.ConfigurationProperties;
6
+
7
+@Data
8
+@ConfigurationProperties(prefix = "ali")
9
+public class AliProperties {
10
+    public static String accessKeyId;
11
+    public static String accessKeySecret;
12
+    public static OSS oss = new AliProperties.OSS();
13
+    public static Face face = new AliProperties.Face();
14
+
15
+    public String getAccessKeyId() { return AliProperties.accessKeyId; }
16
+    public String getAccessKeySecret() { return AliProperties.accessKeySecret; }
17
+    public OSS getOss() { return AliProperties.oss; }
18
+    public Face getFace() { return AliProperties.face; }
19
+
20
+    // setters
21
+    public void setAccessKeyId(String accessKeyId) {
22
+        AliProperties.accessKeyId = accessKeyId;
23
+    }
24
+    public void setAccessKeySecret(String accessKeySecret) { AliProperties.accessKeySecret = accessKeySecret;}
25
+
26
+    public static void setOss(OSS oss) {
27
+        AliProperties.oss = oss;
28
+    }
29
+    public static void setFace(Face face) {
30
+        AliProperties.face = face;
31
+    }
32
+
33
+    @Data
34
+    public static class OSS {
35
+        String endpoint;
36
+        String bucketName;
37
+        String bucketURL;
38
+    }
39
+
40
+    @Data
41
+    public static class Face {
42
+        String regionId;
43
+        String domain;
44
+        String version;
45
+        String group;
46
+    }
47
+}

+ 19
- 0
src/main/java/com.huiju.welcome/config/TencentProperties.java View File

@@ -0,0 +1,19 @@
1
+package com.huiju.welcome.config;
2
+
3
+
4
+import lombok.Data;
5
+import org.springframework.boot.context.properties.ConfigurationProperties;
6
+
7
+@Data
8
+@ConfigurationProperties(prefix = "tencent")
9
+public class TencentProperties {
10
+    String secretId;
11
+    String secretKey;
12
+    Iai iai;
13
+
14
+    @Data
15
+    public static class Iai {
16
+        String region;
17
+        String group;
18
+    }
19
+}

+ 10
- 21
src/main/java/com.huiju.welcome/controller/CameraController.java View File

@@ -114,12 +114,7 @@ public class CameraController {
114 114
 		taSnapshotPerson.setCreateDate(LocalDateTime.now());
115 115
 
116 116
 		// 人像质量最低值, 低于这个值的认为人脸抓拍失败, 取值范围 1 - 100
117
-		SysParam faceMinScoreParam = iSysParamService.getById("face-min-score");
118
-		if (null == faceMinScoreParam) {
119
-			faceMinScoreParam = new SysParam();
120
-			faceMinScoreParam.setValue("70");
121
-		}
122
-		float faceMinScore = Float.parseFloat(faceMinScoreParam.getValue());
117
+		Float faceMinScore = iSysParamService.getFaceMinScore();
123 118
 
124 119
 		Integer score = taSnapshotPerson.getScore();
125 120
 		if (null == score || score.intValue() < faceMinScore) {
@@ -128,12 +123,7 @@ public class CameraController {
128 123
 
129 124
 		// 人脸相似度阈值, 低于设定认为没有识别成功
130 125
 		// SDK 中这个值范围是 0.001 - 1, 本系统设定范围是 1 - 100
131
-		SysParam samePersonThresholdParam = iSysParamService.getById("same-person-threshold");
132
-		if (null == samePersonThresholdParam) {
133
-			samePersonThresholdParam = new SysParam();
134
-			samePersonThresholdParam.setValue("70");
135
-		}
136
-		float samePersonThreshold = Float.parseFloat(samePersonThresholdParam.getValue());
126
+		Float samePersonThreshold = iSysParamService.getSamePersonThreshold();
137 127
 		Float similarity = taSnapshotPerson.getSimilarity();
138 128
 
139 129
 		// 识别结果
@@ -151,12 +141,7 @@ public class CameraController {
151 141
 
152 142
 			if (null != lastTime && sameDevice) {
153 143
 				// 降噪设定
154
-				SysParam dispatchTimeLimitParam = iSysParamService.getById("dispatch-time-limit");
155
-				if (null == dispatchTimeLimitParam) {
156
-					dispatchTimeLimitParam = new SysParam();
157
-					dispatchTimeLimitParam.setValue("2");
158
-				}
159
-				float dispatchTimeLimit = Float.parseFloat(dispatchTimeLimitParam.getValue());
144
+				Float dispatchTimeLimit = iSysParamService.getDispatchTimeLimit();
160 145
 
161 146
 				// 默认 2 分钟内连续识别的都是垃圾数据
162 147
 				Duration duration = Duration.between(lastTime, taSnapshotPerson.getCreateDate());
@@ -200,8 +185,9 @@ public class CameraController {
200 185
 	public ResponseBean car(
201 186
 			@PathParam("deviceId") String deviceId,
202 187
 			@RequestParam("sceneImage") MultipartFile carImage,
203
-			@RequestParam("driverImage") MultipartFile driverImage,
204
-			@RequestParam("copilotImage") MultipartFile copilotImage,
188
+			@RequestParam("licenseImage") MultipartFile licenseImage,
189
+			@RequestParam(value = "driverImage", required = false) MultipartFile driverImage,
190
+			@RequestParam(value = "copilotImage", required = false) MultipartFile copilotImage,
205 191
 			@RequestParam("plateNumber") String plateNumber,
206 192
 			@RequestParam("color") String color,
207 193
 			@RequestParam("carModel") String carModel
@@ -215,6 +201,9 @@ public class CameraController {
215 201
 		if (null != carImage && !carImage.isEmpty()) {
216 202
 			taCarRecord.setCarImage(getMultipartFile(carImage));
217 203
 		}
204
+		if (null != licenseImage && !licenseImage.isEmpty()) {
205
+			taCarRecord.setLicenseImage(getMultipartFile(licenseImage));
206
+		}
218 207
 		if (null != driverImage && !driverImage.isEmpty()) {
219 208
 			taCarRecord.setDriverImage(getMultipartFile(driverImage));
220 209
 		}
@@ -224,7 +213,7 @@ public class CameraController {
224 213
 
225 214
 		iTaCarRecordService.newRecordByDevice(taCarRecord);
226 215
 
227
-		return null;
216
+		return ResponseBean.success("");
228 217
 	}
229 218
 
230 219
 	//推送给前端

+ 22
- 28
src/main/java/com.huiju.welcome/controller/ImgController.java View File

@@ -1,10 +1,13 @@
1 1
 package com.huiju.welcome.controller;
2 2
 
3 3
 import com.huiju.welcome.common.base.ResponseBean;
4
+import com.huiju.welcome.utils.AliFaceUtils;
4 5
 import com.huiju.welcome.utils.AliOSSUtils;
6
+import com.huiju.welcome.utils.TencentFaceUtils;
5 7
 import io.swagger.annotations.ApiOperation;
6 8
 import io.swagger.annotations.ApiParam;
7 9
 import org.apache.http.HttpStatus;
10
+import org.springframework.beans.factory.annotation.Autowired;
8 11
 import org.springframework.beans.factory.annotation.Value;
9 12
 import org.springframework.web.bind.annotation.PostMapping;
10 13
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,41 +27,32 @@ import java.io.IOException;
24 27
 @RestController
25 28
 @RequestMapping("/")
26 29
 public class ImgController {
27
-	
28
-	@Value("${huiju.files}")
29
-	private String huijuFiles;
30 30
 
31
-	private String subDir = "upload" + File.separator;
31
+	@Autowired
32
+	TencentFaceUtils tencentFaceUtils;
33
+
34
+	@PostMapping("/face")
35
+	public ResponseBean testUpload2Aliface() {
36
+		try {
37
+			tencentFaceUtils.searchFace("https://estateagents.oss-cn-shanghai.aliyuncs.com/1561458925754-%E6%9C%AA%E7%9F%A5%E6%96%87%E4%BB%B6.jpg");
38
+			return ResponseBean.success("");
39
+		} catch (Exception e) {
40
+			e.printStackTrace();
41
+		}
42
+		return ResponseBean.error("", 400);
43
+	}
32 44
 	
33 45
 	@ApiOperation(value = "图片/视频上传以及获取url", notes = "图片/视频上传以及获取url")
34 46
 	@PostMapping(value = "/uploadFile", consumes = "multipart/*", headers = "content-type=multipart/form-data")
35 47
 	public ResponseBean uploadFile(@ApiParam(value = "uploadFile" ,required = true) MultipartFile uploadFile){
36
-		ResponseBean responseBean = new ResponseBean();
37
-		String suffix = uploadFile.getOriginalFilename().substring(uploadFile.getOriginalFilename().lastIndexOf(".") + 1);
38
-		String fileName = System.currentTimeMillis() + "." + suffix;
39
-		String path = huijuFiles;
40
-		File tempFile = new File(path + subDir);
41
-		if (!tempFile.exists()) {
42
-			tempFile.mkdirs();
43
-		}
48
+		String defaultUploadDir = "/";
49
+
44 50
 		try {
45
-			//下载文件
46
-			FileOutputStream fos=new FileOutputStream(tempFile.getPath() + File.separator + fileName);
47
-			FileInputStream fs=(FileInputStream) uploadFile.getInputStream();
48
-			byte[] buffer=new byte[1024];
49
-			int len=0;
50
-			while((len=fs.read(buffer))!=-1){
51
-				fos.write(buffer, 0, len);
52
-			}
53
-			fos.close();
54
-			fs.close();
55
-		}catch (Exception e){
56
-			e.printStackTrace();
57
-			responseBean.addError(e.getMessage());
58
-			return responseBean;
51
+			String img = AliOSSUtils.putObject(uploadFile, defaultUploadDir);
52
+			return ResponseBean.success(img);
53
+		} catch (IOException e) {
54
+			return ResponseBean.error("上传图片失败: " + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
59 55
 		}
60
-		responseBean.addSuccess(File.separator + subDir + fileName);
61
-		return responseBean;
62 56
 	}
63 57
 
64 58
 	@PostMapping("/miniapp/upload")

+ 6
- 6
src/main/java/com.huiju.welcome/controller/SysUserController.java View File

@@ -55,7 +55,7 @@ public class SysUserController extends BaseController {
55 55
             return responseBean;
56 56
         }
57 57
 
58
-        SysUser sysUser = sysUserService.getDetailByUsername(username);
58
+        SysUser sysUser = sysUserService.getDetailByLoginname(username);
59 59
         if (null == sysUser) {
60 60
             responseBean.addError(HttpStatus.SC_BAD_REQUEST, "账户或者密码不正确");
61 61
             return responseBean;
@@ -118,7 +118,7 @@ public class SysUserController extends BaseController {
118 118
             @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "每页数量"),
119 119
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "name", value = "姓名"),
120 120
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "phone", value = "手机号"),
121
-            @ApiImplicitParam(paramType = "query", dataType = "int", name = "isSales", value = "是否销售"),
121
+            @ApiImplicitParam(paramType = "query", dataType = "String", name = "identity", value = "用户身份"),
122 122
     })
123 123
     @RequestMapping(value = "/sysuser", method = RequestMethod.GET)
124 124
     public ResponseBean list(
@@ -126,7 +126,7 @@ public class SysUserController extends BaseController {
126 126
             @RequestParam  Integer pageSize,
127 127
             String name,
128 128
             String phone,
129
-            Integer isSales,
129
+            String identity,
130 130
             HttpServletRequest request
131 131
     ) {
132 132
         ResponseBean responseBean = new ResponseBean();
@@ -139,15 +139,15 @@ public class SysUserController extends BaseController {
139 139
         queryWrapper.gt("user_id", 1); // 去掉管理员
140 140
 
141 141
         if (null != name && !"".equals(name)) {
142
-            queryWrapper.like("nickname", name);
142
+            queryWrapper.like("username", name);
143 143
         }
144 144
 
145 145
         if (null != phone && !"".equals(phone)) {
146 146
             queryWrapper.eq("phone", phone);
147 147
         }
148 148
 
149
-        if (null != isSales && isSales.intValue() > 0 ) {
150
-            queryWrapper.eq("is_sales", isSales);
149
+        if (null != identity ) {
150
+            queryWrapper.eq("user_identity", identity);
151 151
         }
152 152
 
153 153
         // 取消传递密码字段

+ 14
- 0
src/main/java/com.huiju.welcome/controller/TaCustomerController.java View File

@@ -24,7 +24,9 @@ import org.springframework.web.bind.annotation.*;
24 24
 import javax.servlet.http.HttpServletRequest;
25 25
 import java.time.LocalDateTime;
26 26
 import java.util.ArrayList;
27
+import java.util.HashMap;
27 28
 import java.util.List;
29
+import java.util.Map;
28 30
 
29 31
 /**
30 32
  * <p>
@@ -195,6 +197,9 @@ public class TaCustomerController extends BaseController {
195 197
 
196 198
             if (iTaCustomerService.updateById(taCustomer)){
197 199
 
200
+                // 反更新人员
201
+                iTaPersonService.updateByCustomer(taCustomer);
202
+
198 203
                 List<TaPerson> group = iTaCustomerService.getGroup(taCustomer.getCustomerId());
199 204
                 taCustomer.setGroup(group);
200 205
 
@@ -234,6 +239,15 @@ public class TaCustomerController extends BaseController {
234 239
         return responseBean;
235 240
     }
236 241
 
242
+    @GetMapping("/miniapp/history/customer")
243
+    public ResponseBean history(String phone) {
244
+        Map<String, Object> filters = new HashMap<String, Object>(){{
245
+            put("phone", phone);
246
+        }};
247
+
248
+        return ResponseBean.success(iTaCustomerService.getHistoryRecBy(filters));
249
+    }
250
+
237 251
     /**
238 252
      * 分页查询
239 253
      */

+ 6
- 6
src/main/java/com.huiju.welcome/controller/TaFirstpageController.java View File

@@ -223,16 +223,16 @@ public class TaFirstpageController extends BaseController {
223 223
     @ApiOperation(value = "前端获取指定首屏内容", notes = "前端获取指定首屏内容")
224 224
     @ApiImplicitParams({
225 225
             @ApiImplicitParam(paramType = "path", dataType = "String", name = "deviceId", value = "设备ID"),
226
-            @ApiImplicitParam(paramType = "Query", dataType = "String", name = "weatherName", value = "天气名称")
226
+            @ApiImplicitParam(paramType = "Query", dataType = "String", name = "city", value = "地址")
227 227
     })
228 228
     @RequestMapping(value = "/screen/fristpage/device/{deviceId}", method = RequestMethod.GET)
229 229
     public ResponseBean screenGet(@PathVariable String deviceId, HttpServletRequest request,
230
-                                  @RequestParam(value ="weatherName",required = false)String weatherName) {
231
-        return detail(0, deviceId, request,weatherName);
230
+                                  @RequestParam(value ="city",required = false)String city) {
231
+        return detail(0, deviceId, request, city);
232 232
     }
233 233
 
234 234
     // getDetail 获取首屏详情
235
-    private ResponseBean detail(int firstpageId, String deviceId, HttpServletRequest request,String weatherName) {
235
+    private ResponseBean detail(int firstpageId, String deviceId, HttpServletRequest request,String city) {
236 236
         ResponseBean responseBean = new ResponseBean();
237 237
 
238 238
         QueryWrapper<TaFirstpage> q = new QueryWrapper<>();
@@ -247,8 +247,8 @@ public class TaFirstpageController extends BaseController {
247 247
             responseBean.addError(HttpStatus.SC_NOT_FOUND, "内容不存在");
248 248
             return responseBean;
249 249
         }
250
-        //天气值weatherName
251
-        taFirstpage.setWeatherName(weatherName);
250
+        //
251
+        taFirstpage.setCity(city);
252 252
         // 获取内容
253 253
         Map<String, Object> ctt = taFirstpageService.detail(taFirstpage);
254 254
         responseBean.addSuccess(ctt);

+ 28
- 53
src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java View File

@@ -1,6 +1,8 @@
1 1
 package com.huiju.welcome.controller;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 8
 import com.huiju.welcome.common.base.BaseController;
@@ -9,12 +11,10 @@ import com.huiju.welcome.model.SysUser;
9 11
 import com.huiju.welcome.model.TaCustomer;
10 12
 import com.huiju.welcome.model.TaFollowupRecord;
11 13
 import com.huiju.welcome.model.TaMainUsherRecord;
12
-import com.huiju.welcome.service.ISysUserService;
13
-import com.huiju.welcome.service.ITaCustomerService;
14
-import com.huiju.welcome.service.ITaFollowupRecordService;
15
-import com.huiju.welcome.service.ITaMainUsherRecordService;
14
+import com.huiju.welcome.service.*;
16 15
 import com.huiju.welcome.utils.DateUtils;
17 16
 import com.huiju.welcome.utils.StatusUtils;
17
+import com.huiju.welcome.utils.StringUtils;
18 18
 import org.apache.http.HttpStatus;
19 19
 import org.slf4j.Logger;
20 20
 import org.slf4j.LoggerFactory;
@@ -44,10 +44,7 @@ public class TaMainUsherRecordController extends BaseController {
44 44
     private ITaFollowupRecordService iTaFollowupRecordService;
45 45
 
46 46
     @Autowired
47
-    private ITaCustomerService iTaCustomerService;
48
-
49
-    @Autowired
50
-    private ISysUserService iSysUserService;
47
+    private ITaPersonService iTaPersonService;
51 48
 
52 49
     /**
53 50
      * 保存对象
@@ -58,26 +55,9 @@ public class TaMainUsherRecordController extends BaseController {
58 55
     public ResponseBean save(@RequestBody TaMainUsherRecord taMainUsherRecord){
59 56
         ResponseBean responseBean = new ResponseBean();
60 57
         try {
61
-            taMainUsherRecord.setStatus(StatusUtils.Normal);
62
-
63
-            if (null == taMainUsherRecord.getConsultantId() || taMainUsherRecord.getConsultantId().intValue() == 0) {
64
-                return ResponseBean.error("请设置置业顾问", HttpStatus.SC_BAD_REQUEST);
65
-            } else {
66
-                SysUser user = iSysUserService.getById(taMainUsherRecord.getConsultantId());
67
-                taMainUsherRecord.setRealtyConsultant(user.getUsername());
68
-            }
69
-
70
-            // 先添加到置业的客户中
71
-            TaCustomer taCustomer = iTaCustomerService.newVisitRecord(taMainUsherRecord);
72
-
73
-            if (iTaMainUsherRecordService.save(taMainUsherRecord)){
58
+            iTaMainUsherRecordService.newRecordByMiniapp(taMainUsherRecord);
74 59
 
75
-                iTaMainUsherRecordService.notifyConsultant(taMainUsherRecord, taCustomer);
76
-
77
-                responseBean.addSuccess(taMainUsherRecord);
78
-            }else {
79
-                responseBean.addError("fail");
80
-            }
60
+            responseBean.addSuccess(taMainUsherRecord);
81 61
         }catch (Exception e){
82 62
             logger.error("taMainUsherRecordAdd -=- {}",e.toString());
83 63
             responseBean.addError(e.getMessage());
@@ -90,15 +70,11 @@ public class TaMainUsherRecordController extends BaseController {
90 70
      * @param id  实体ID
91 71
      */
92 72
     @ResponseBody
93
-    @RequestMapping(value="/mainUsherRecord/{id}", method= RequestMethod.DELETE)
73
+    @RequestMapping(value="/miniapp/mainUsherRecord/{id}/delete", method= RequestMethod.PUT)
94 74
     public ResponseBean delete(@PathVariable Integer id){
95 75
         ResponseBean responseBean = new ResponseBean();
96 76
         try {
97
-            if(iTaMainUsherRecordService.removeById(id)){
98
-                responseBean.addSuccess("success");
99
-            }else {
100
-                responseBean.addError("fail");
101
-            }
77
+            iTaMainUsherRecordService.deleteRecord(id);
102 78
         }catch (Exception e){
103 79
             logger.error("taMainUsherRecordDelete -=- {}",e.toString());
104 80
             responseBean.addError(e.getMessage());
@@ -115,26 +91,7 @@ public class TaMainUsherRecordController extends BaseController {
115 91
     public ResponseBean update(@RequestBody TaMainUsherRecord taMainUsherRecord, @PathVariable Integer id){
116 92
         ResponseBean responseBean = new ResponseBean();
117 93
         try {
118
-            taMainUsherRecord.setStatus(StatusUtils.Normal);
119
-
120
-            if (null == taMainUsherRecord.getConsultantId() || taMainUsherRecord.getConsultantId().intValue() == 0) {
121
-                return ResponseBean.error("请设置置业顾问", HttpStatus.SC_BAD_REQUEST);
122
-            } else {
123
-                SysUser user = iSysUserService.getById(taMainUsherRecord.getConsultantId());
124
-                taMainUsherRecord.setRealtyConsultant(user.getUsername());
125
-            }
126
-
127
-            // 先添加到置业的客户中
128
-            TaCustomer taCustomer = iTaCustomerService.newVisitRecord(taMainUsherRecord);
129
-
130
-            if (iTaMainUsherRecordService.updateById(taMainUsherRecord)){
131
-
132
-                iTaMainUsherRecordService.notifyConsultant(taMainUsherRecord, taCustomer);
133
-
134
-                responseBean.addSuccess("success");
135
-            }else {
136
-                responseBean.addError("fail");
137
-            }
94
+            iTaMainUsherRecordService.updateByMiniapp(taMainUsherRecord);
138 95
         }catch (Exception e){
139 96
             logger.error("taMainUsherRecordUpdate -=- {}",e.toString());
140 97
             responseBean.addError(e.getMessage());
@@ -166,6 +123,24 @@ public class TaMainUsherRecordController extends BaseController {
166 123
         return responseBean;
167 124
     }
168 125
 
126
+    @PutMapping("/miniapp/mainUsherRecord/{id}/whitelist")
127
+    public ResponseBean whitelist(@PathVariable Integer id, @RequestBody String paramStr) {
128
+        JSONObject params = JSONObject.parseObject(paramStr);
129
+        if (null == params) {
130
+            return ResponseBean.error("白名单信息为空或者非法", HttpStatus.SC_BAD_REQUEST);
131
+        }
132
+
133
+        Integer personId = params.getInteger("personId");
134
+        if (null == personId || personId.intValue() == 0) {
135
+            return ResponseBean.error("未找到需要设置白对单对象", HttpStatus.SC_BAD_REQUEST);
136
+        }
137
+
138
+        iTaPersonService.setPersonIntoWhitelist(personId);
139
+        iTaMainUsherRecordService.deleteRecord(id);
140
+
141
+        return ResponseBean.success("");
142
+    }
143
+
169 144
     /**
170 145
      * 分页查询
171 146
      */

+ 0
- 32
src/main/java/com.huiju.welcome/controller/TaPersonController.java View File

@@ -231,36 +231,4 @@ public class TaPersonController extends BaseController {
231 231
         responseBean.addSuccess(person);
232 232
         return responseBean;
233 233
     }
234
-
235
-    /**
236
-     * 小程序端, 添加人员到白名单。
237
-     * 实际上是把人员类型设置为工作人员
238
-     * @param paramStr
239
-     * @return
240
-     */
241
-    @PutMapping("/miniapp/whitelist")
242
-    public ResponseBean addToWhiteList(@RequestBody String paramStr) {
243
-        JSONObject params = JSONObject.parseObject(paramStr);
244
-        if (null == params) {
245
-            return ResponseBean.error("白名单信息为空或者非法", HttpStatus.SC_BAD_REQUEST);
246
-        }
247
-
248
-        Integer personId = params.getInteger("personId");
249
-        if (null == personId || personId.intValue() == 0) {
250
-            return ResponseBean.error("未找到需要设置白对单对象", HttpStatus.SC_BAD_REQUEST);
251
-        }
252
-
253
-        UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
254
-        updateWrapper.set("type_id", 3);
255
-        updateWrapper.eq("person_id", personId);
256
-
257
-        if (taPersonService.update(new TaPerson(), updateWrapper)) {
258
-            return ResponseBean.success("success");
259
-        } else {
260
-            return ResponseBean.error("设置白名单出错", HttpStatus.SC_INTERNAL_SERVER_ERROR);
261
-        }
262
-    }
263
-
264
-
265
-
266 234
 }

+ 9
- 1
src/main/java/com.huiju.welcome/controller/TaVisitorAppointmentController.java View File

@@ -10,7 +10,9 @@ import com.huiju.welcome.common.base.BaseController;
10 10
 import com.huiju.welcome.common.base.ResponseBean;
11 11
 import com.huiju.welcome.model.TaFirstUsherRecord;
12 12
 import com.huiju.welcome.model.TaVisitorAppointment;
13
+import com.huiju.welcome.model.TaWechatUser;
13 14
 import com.huiju.welcome.service.ITaVisitorAppointmentService;
15
+import com.huiju.welcome.service.ITaWechatUserService;
14 16
 import com.huiju.welcome.utils.DateUtils;
15 17
 import com.huiju.welcome.utils.JWTUtils;
16 18
 import com.huiju.welcome.utils.StatusUtils;
@@ -26,6 +28,8 @@ import org.springframework.web.bind.annotation.*;
26 28
 import javax.servlet.http.HttpServletRequest;
27 29
 import java.time.LocalDateTime;
28 30
 import java.util.Date;
31
+import java.util.HashMap;
32
+import java.util.Map;
29 33
 
30 34
 /**
31 35
  * <p>
@@ -41,6 +45,9 @@ public class TaVisitorAppointmentController extends BaseController {
41 45
     @Autowired
42 46
     ITaVisitorAppointmentService taVisitorAppointmentService;
43 47
 
48
+    @Autowired
49
+    ITaWechatUserService iTaWechatUserService;
50
+
44 51
     @GetMapping("/appointment")
45 52
     public ResponseBean list(
46 53
             @RequestParam(defaultValue = "1") Integer page,
@@ -80,7 +87,8 @@ public class TaVisitorAppointmentController extends BaseController {
80 87
             return resp;
81 88
         }
82 89
 
83
-        taVisitorAppointment.setCreateUser(Integer.valueOf(JWTUtils.getSubject(request)));
90
+        TaWechatUser user = iTaWechatUserService.getById(Integer.valueOf(JWTUtils.getSubject(request)));
91
+        taVisitorAppointment.setCreateUser(user.getPersonId());
84 92
 
85 93
         boolean success = taVisitorAppointmentService.save(taVisitorAppointment);
86 94
         if (success) {

+ 8
- 8
src/main/java/com.huiju.welcome/controller/TaWechatUserController.java View File

@@ -87,7 +87,7 @@ public class TaWechatUserController extends BaseController {
87 87
 
88 88
             boolean success = iTaWechatUserService.save(taWechatUser);
89 89
             if (!success) {
90
-                ResponseBean.error("预存用户信息失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
90
+                return ResponseBean.error("预存用户信息失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
91 91
             }
92 92
         }
93 93
 
@@ -107,41 +107,41 @@ public class TaWechatUserController extends BaseController {
107 107
         TaWechatUser taWechatUser = iTaWechatUserService.getById(Integer.valueOf(userId));
108 108
 
109 109
         if (null == taWechatUser) {
110
-            ResponseBean.error("数据异常, 请清空缓存后重新操作", HttpStatus.SC_INTERNAL_SERVER_ERROR);
110
+            return ResponseBean.error("数据异常, 请清空缓存后重新操作", HttpStatus.SC_INTERNAL_SERVER_ERROR);
111 111
         }
112 112
 
113 113
         if (null != taWechatUser.getPersonId()) {
114
-            ResponseBean.error("不支持人员重复绑定", HttpStatus.SC_BAD_REQUEST);
114
+            return ResponseBean.error("不支持人员重复绑定", HttpStatus.SC_BAD_REQUEST);
115 115
         }
116 116
 
117 117
         JSONObject params = JSONObject.parseObject(paramStr);
118 118
         if (null == params) {
119
-            ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
119
+            return ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
120 120
         }
121 121
 
122 122
         String phone = params.getString("phone");
123 123
         String captcha = params.getString("captcha");
124 124
 
125 125
         if (null == phone || "".equals(phone.trim()) || null == captcha || "".equals(captcha.trim())) {
126
-            ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
126
+            return ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
127 127
         }
128 128
 
129 129
         // todo
130 130
         // 先简单验证
131 131
         if (!"1234".equals(captcha)) {
132
-            ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
132
+            return ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
133 133
         }
134 134
 
135 135
         SysUser sysUser = iSysUserService.getByPhone(phone);
136 136
         if (null == sysUser) {
137
-            ResponseBean.error("该手机号对应人员不存在", HttpStatus.SC_BAD_REQUEST);
137
+            return ResponseBean.error("该手机号对应人员不存在", HttpStatus.SC_BAD_REQUEST);
138 138
         }
139 139
 
140 140
         taWechatUser.setPersonId(sysUser.getUserId());
141 141
         boolean success = iTaWechatUserService.updateById(taWechatUser);
142 142
 
143 143
         if (!success) {
144
-            ResponseBean.error("人员绑定失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
144
+            return ResponseBean.error("人员绑定失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
145 145
         }
146 146
 
147 147
         Map<String, Object> map = new HashMap<>();

+ 1
- 0
src/main/java/com.huiju.welcome/interceptor/AccessInterceptor.java View File

@@ -36,6 +36,7 @@ public class AccessInterceptor implements HandlerInterceptor {
36 36
         "/screen",
37 37
         "/camera",
38 38
         "/websocket",
39
+         "/face",
39 40
         "/miniapp/login"
40 41
     };
41 42
 

+ 1
- 1
src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java View File

@@ -22,5 +22,5 @@ public interface TaCustomerMapper extends BaseMapper<TaCustomer> {
22 22
     TaCustomer getCustomerOf(@Param("personId") Integer personId, @Param("realId") Integer realId);
23 23
     IPage<TaCustomer> customerPage(IPage<TaCustomer> pg, String customerName, String phone, String platNumber);
24 24
 
25
-    List<TaCustomer> getSomeCustMayBe(@Param("plateNumber") String plateNumber);
25
+    List<TaCustomer> getSomeCustMayBe(@Param("plateNumber") String plateNumber, @Param("phone") String phone);
26 26
 }

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

@@ -27,7 +27,7 @@ public class SysUser implements Serializable {
27 27
     @TableId(value = "user_id", type = IdType.AUTO)
28 28
     private Integer userId;
29 29
 
30
-    private String nickname;
30
+    private String loginname;
31 31
 
32 32
     private String password;
33 33
 

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

@@ -45,6 +45,8 @@ public class TaCarRecord implements Serializable {
45 45
 
46 46
     private String copilotImage;
47 47
 
48
+    private String licenseImage;
49
+
48 50
     private LocalDateTime createDate;
49 51
 
50 52
     /**

+ 2
- 0
src/main/java/com.huiju.welcome/model/TaDevice.java View File

@@ -39,6 +39,8 @@ public class TaDevice implements Serializable {
39 39
 
40 40
     private String api;
41 41
 
42
+    private String afr;
43
+
42 44
     private Integer status;
43 45
 
44 46
     private LocalDateTime onlineDate;

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

@@ -42,7 +42,7 @@ public class TaFirstpage implements Serializable {
42 42
      * 前端获取指定首屏内容输入动态名称
43 43
      */
44 44
     @TableField(exist = false)
45
-    private  String weatherName;
45
+    private  String city;
46 46
 
47 47
     @TableField(exist = false)
48 48
     private List<TaFirstpageContent> content;

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

@@ -13,4 +13,11 @@ import com.huiju.welcome.model.SysParam;
13 13
  */
14 14
 public interface ISysParamService extends IService<SysParam> {
15 15
 
16
+    Float getSamePersonThreshold();
17
+
18
+    String getParamOfWithDefault(String id, String def);
19
+
20
+    Float getFaceMinScore();
21
+
22
+    Float getDispatchTimeLimit();
16 23
 }

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

@@ -13,7 +13,7 @@ import com.huiju.welcome.model.SysUser;
13 13
  */
14 14
 public interface ISysUserService extends IService<SysUser> {
15 15
 
16
-    SysUser getDetailByUsername(String username);
16
+    SysUser getDetailByLoginname(String username);
17 17
 
18 18
     SysUser getByPhone(String phone);
19 19
 }

+ 13
- 8
src/main/java/com.huiju.welcome/service/ITaCustomerService.java View File

@@ -1,10 +1,8 @@
1 1
 package com.huiju.welcome.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4
-import com.huiju.welcome.model.TaCarRecord;
5
-import com.huiju.welcome.model.TaCustomer;
6
-import com.huiju.welcome.model.TaMainUsherRecord;
7
-import com.huiju.welcome.model.TaPerson;
4
+import com.huiju.welcome.common.base.ResponseBean;
5
+import com.huiju.welcome.model.*;
8 6
 
9 7
 import java.util.List;
10 8
 import java.util.Map;
@@ -17,9 +15,6 @@ import java.util.Map;
17 15
  * @since 2019-06-12
18 16
  */
19 17
 public interface ITaCustomerService extends IService<TaCustomer> {
20
-
21
-    TaCustomer newVisitRecord(TaMainUsherRecord taMainUsherRecord) throws Exception;
22
-
23 18
     List<TaPerson> getGroup(Integer customerId);
24 19
 
25 20
     Map<String, Object> getLastVisitInfo(Integer customerId);
@@ -30,7 +25,17 @@ public interface ITaCustomerService extends IService<TaCustomer> {
30 25
 
31 26
     List<TaCustomer> getSomeCustMayBe(String plateNumber);
32 27
 
33
-    TaCustomer newCustByCarDevice(TaCarRecord taCarRecord);
28
+    TaCustomer newCustByCarDevice(TaCarRecord taCarRecord, TaVisitorAppointment ...taVisitorAppointment);
34 29
 
35 30
     void notifyConsultant(TaCustomer taCustomer) throws Exception;
31
+
32
+    boolean updateConsultant(TaCustomer taCustomer, Integer consultantId);
33
+
34
+    TaCustomer newCustByMainUsher(TaMainUsherRecord taMainUsherRecord) throws Exception;
35
+
36
+    Map<String, Object> getHistoryRecBy(Map<String,Object> filters);
37
+
38
+    TaCustomer getSameByPerson(Integer personId);
39
+
40
+    boolean updataByCarRecord(TaCustomer taCustomer, TaCarRecord taCarRecord);
36 41
 }

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
5 5
 import com.huiju.welcome.common.base.ResponseBean;
6 6
 import com.huiju.welcome.model.TaCustomer;
7 7
 import com.huiju.welcome.model.TaMainUsherRecord;
8
+import com.huiju.welcome.model.TaPerson;
8 9
 
9 10
 import java.util.List;
10 11
 
@@ -22,7 +23,7 @@ public interface ITaMainUsherRecordService extends IService<TaMainUsherRecord> {
22 23
 
23 24
     void notifyConsultant(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception;
24 25
 
25
-    boolean newRecordByDevice(TaCustomer taCustomer);
26
+    boolean newRecordByDevice(TaCustomer taCustomer, TaPerson taPerson);
26 27
 
27 28
     boolean newRecordByConsultant(TaCustomer taCustomer);
28 29
     IPage<TaMainUsherRecord> taMainUsherRecordList(IPage<TaMainUsherRecord> pg,String phone,String platNumber,String personName,Integer appointment);
@@ -32,4 +33,10 @@ public interface ITaMainUsherRecordService extends IService<TaMainUsherRecord> {
32 33
      * @return
33 34
      */
34 35
     ResponseBean customerPage(int pageNum, int pageSize, String customerName, String phone, String platNumber);
36
+
37
+    boolean newRecordByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception;
38
+
39
+    boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception;
40
+
41
+    boolean deleteRecord(Integer id);
35 42
 }

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

@@ -6,5 +6,5 @@ import com.huiju.welcome.model.TaMessageRecord;
6 6
 import java.util.List;
7 7
 
8 8
 public interface ITaMessageRecordService extends IService<TaMessageRecord> {
9
-    boolean saveMessageOrNot(String toUser, String tplId, String page, List<Object> data);
9
+    boolean saveMessageOrNot(String toUser, String tplId, String page, List<Object> data, boolean save);
10 10
 }

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

@@ -52,4 +52,8 @@ public interface ITaPersonService extends IService<TaPerson> {
52 52
     TaPerson newPersonByFront(TaCustomer taCustomer);
53 53
 
54 54
     TaPerson newPersonByUsher(TaMainUsherRecord taMainUsherRecord);
55
+
56
+    boolean updateByCustomer(TaCustomer taCustomer);
57
+
58
+    boolean setPersonIntoWhitelist(Integer personId);
55 59
 }

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

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
5 5
 import com.huiju.welcome.common.base.ResponseBean;
6 6
 import com.huiju.welcome.model.TaVisitorAppointment;
7 7
 
8
+import java.util.List;
9
+import java.util.Map;
10
+
8 11
 /**
9 12
  * <p>
10 13
  *  服务类
@@ -23,4 +26,8 @@ public interface ITaVisitorAppointmentService extends IService<TaVisitorAppointm
23 26
      * @return
24 27
      */
25 28
     ResponseBean visitorAppointmentList(IPage<TaVisitorAppointment> pg, String platNumber,String personName,String phone);
29
+
30
+    List<TaVisitorAppointment> getAppointmentsBy(Map<String,Object> filters);
31
+
32
+    List<TaVisitorAppointment> getAppointmentsByPlateNumber(String plateNumber);
26 33
 }

+ 16
- 0
src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java View File

@@ -9,6 +9,9 @@ import com.huiju.welcome.service.ICameraService;
9 9
 import com.huiju.welcome.service.ITaDeviceService;
10 10
 import com.huiju.welcome.utils.Encrypt;
11 11
 import com.huiju.welcome.utils.StatusUtils;
12
+import com.huiju.welcome.utils.TencentFaceUtils;
13
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
14
+import lombok.extern.slf4j.Slf4j;
12 15
 import org.springframework.beans.factory.annotation.Autowired;
13 16
 import org.springframework.stereotype.Service;
14 17
 
@@ -19,17 +22,22 @@ import java.util.HashMap;
19 22
 import java.util.List;
20 23
 import java.util.Map;
21 24
 
25
+@Slf4j
22 26
 @Service
23 27
 public class CameraServiceImpl implements ICameraService {
24 28
     @Autowired
25 29
     private ITaDeviceService taDeviceService;
26 30
 
31
+    @Autowired
32
+    TencentFaceUtils tencentFaceUtils;
33
+
27 34
     @Override
28 35
     public String dispatchPerson(TaPerson taPerson, TaDevice... devices) {
29 36
         List<TaDevice> taDeviceList = null;
30 37
         if (null == devices || devices.length == 0) {
31 38
             QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
32 39
             queryWrapper.eq("status",StatusUtils.Normal);
40
+            queryWrapper.eq("afr",StatusUtils.BoolTrue);
33 41
             taDeviceList = taDeviceService.list(queryWrapper);
34 42
         } else {
35 43
             taDeviceList = Arrays.asList(devices);
@@ -51,6 +59,14 @@ public class CameraServiceImpl implements ICameraService {
51 59
             }
52 60
         }
53 61
 
62
+        // 下发到腾讯云人脸识别
63
+        try {
64
+            tencentFaceUtils.createFace(String.valueOf(taPerson.getRealId()), taPerson.getAvatar());
65
+        } catch (TencentCloudSDKException e) {
66
+            e.printStackTrace();
67
+            log.error("下发人脸到腾讯云失败: " + e.getMessage());
68
+        }
69
+
54 70
         return "";
55 71
     }
56 72
 }

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 4
 import com.huiju.welcome.mapper.SysParamMapper;
5 5
 import com.huiju.welcome.model.SysParam;
6 6
 import com.huiju.welcome.service.ISysParamService;
7
+import org.springframework.beans.factory.annotation.Autowired;
7 8
 import org.springframework.stereotype.Service;
8 9
 
9 10
 /**
@@ -16,5 +17,37 @@ import org.springframework.stereotype.Service;
16 17
  */
17 18
 @Service
18 19
 public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, SysParam> implements ISysParamService {
20
+    @Autowired
21
+    SysParamMapper sysParamMapper;
22
+
23
+    @Override
24
+    public Float getSamePersonThreshold() {
25
+        String val = getParamOfWithDefault("same-person-threshold", "70");
26
+        return Float.parseFloat(val);
27
+    }
28
+
29
+    @Override
30
+    public String getParamOfWithDefault(String id, String def) {
31
+        SysParam sysParam = sysParamMapper.selectById(id);
32
+        if (null == sysParam) return def;
33
+
34
+        String val = sysParam.getValue();
35
+        if (null == val || "".equals(val)) return def;
36
+
37
+        return val;
38
+    }
39
+
40
+    @Override
41
+    public Float getFaceMinScore() {
42
+        String val = getParamOfWithDefault("face-min-score", "70");
43
+        return Float.parseFloat(val);
44
+    }
45
+
46
+    @Override
47
+    public Float getDispatchTimeLimit() {
48
+        String val = getParamOfWithDefault("dispatch-time-limit", "2");
49
+        return Float.parseFloat(val);
50
+    }
51
+
19 52
 
20 53
 }

+ 2
- 2
src/main/java/com.huiju.welcome/service/impl/SysUserServiceImpl.java View File

@@ -24,9 +24,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
24 24
     private SysUserMapper sysUserMapper;
25 25
 
26 26
     @Override
27
-    public SysUser getDetailByUsername(String username) {
27
+    public SysUser getDetailByLoginname(String username) {
28 28
         QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
29
-        queryWrapper.eq("username",username);
29
+        queryWrapper.eq("loginname",username);
30 30
         return sysUserMapper.selectOne(queryWrapper);
31 31
     }
32 32
 

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

@@ -6,9 +6,11 @@ import com.huiju.welcome.mapper.TaCarRecordMapper;
6 6
 import com.huiju.welcome.model.TaCarRecord;
7 7
 import com.huiju.welcome.model.TaCustomer;
8 8
 import com.huiju.welcome.model.TaFirstUsherRecord;
9
-import com.huiju.welcome.service.ITaCarRecordService;
10
-import com.huiju.welcome.service.ITaCustomerService;
11
-import com.huiju.welcome.service.ITaFirstUsherRecordService;
9
+import com.huiju.welcome.model.TaVisitorAppointment;
10
+import com.huiju.welcome.service.*;
11
+import com.huiju.welcome.utils.TencentFaceUtils;
12
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
13
+import com.tencentcloudapi.iai.v20180301.models.Candidate;
12 14
 import org.slf4j.Logger;
13 15
 import org.slf4j.LoggerFactory;
14 16
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,6 +42,15 @@ public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCar
40 42
     @Autowired
41 43
     private ITaCustomerService iTaCustomerService;
42 44
 
45
+    @Autowired
46
+    private TencentFaceUtils tencentFaceUtils;
47
+
48
+    @Autowired
49
+    private ISysParamService iSysParamService;
50
+
51
+    @Autowired
52
+    private ITaVisitorAppointmentService iTaVisitorAppointmentService;
53
+
43 54
     @Override
44 55
     public IPage<TaCarRecord> getPageList(IPage<TaCarRecord> page, String plateNumber, Date recordDate, String customerName, String phone) {
45 56
         return taCarRecordMapper.getPageList(page, plateNumber, recordDate, customerName, phone);
@@ -56,12 +67,44 @@ public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCar
56 67
         taCarRecordMapper.insert(taCarRecord);
57 68
 
58 69
         // 到客户中查询是否有相关人员
59
-        TaCustomer taCustomer;
70
+        TaCustomer taCustomer = null;
60 71
         List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(taCarRecord.getPlateNumber());
61 72
 
62 73
         // 如果没有对应人员
63 74
         if (null == taCustomerList || taCustomerList.size() == 0) {
64
-            taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord);
75
+            // 再去人脸库比对一次
76
+            Integer personId = null;
77
+            try {
78
+                Float threshold = iSysParamService.getSamePersonThreshold();
79
+                Candidate result = tencentFaceUtils.searchFace(taCarRecord.getDriverImage());
80
+                if (result.getScore() >= threshold) {
81
+                    personId = Integer.valueOf(result.getPersonId());
82
+                }
83
+            } catch (TencentCloudSDKException e) {
84
+                e.printStackTrace();
85
+            }
86
+
87
+            // 依据人脸与预约判断
88
+            // 人脸优先级高
89
+            if (null != personId && personId > 0) {
90
+                // 找到对应人脸
91
+                taCustomer = iTaCustomerService.getSameByPerson(personId);
92
+                if (null != taCustomer) {
93
+                    // 尝试更新部分客户信息
94
+                    iTaCustomerService.updataByCarRecord(taCustomer, taCarRecord);
95
+                }
96
+            }
97
+
98
+            // 去预约记录查询一次
99
+            List<TaVisitorAppointment> appointments = iTaVisitorAppointmentService.getAppointmentsByPlateNumber(taCarRecord.getPlateNumber());
100
+
101
+            if (null == taCustomer) {
102
+                if (null != appointments && appointments.size() > 0) {
103
+                    taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord, appointments.get(0));
104
+                } else {
105
+                    taCustomer = iTaCustomerService.newCustByCarDevice(taCarRecord);
106
+                }
107
+            }
65 108
         } else {
66 109
             // 对应客户, 先随机取一条
67 110
             taCustomer = taCustomerList.get(0);

+ 146
- 59
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java View File

@@ -3,17 +3,17 @@ package com.huiju.welcome.service.impl;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5 5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
-import com.huiju.welcome.mapper.TaCustomerMapMapper;
7
-import com.huiju.welcome.mapper.TaCustomerMapper;
8
-import com.huiju.welcome.mapper.TaMainUsherRecordMapper;
9
-import com.huiju.welcome.mapper.TaWechatUserMapper;
6
+import com.huiju.welcome.common.base.ResponseBean;
7
+import com.huiju.welcome.mapper.*;
10 8
 import com.huiju.welcome.model.*;
11 9
 import com.huiju.welcome.service.ITaCustomerService;
12 10
 import com.huiju.welcome.service.ITaMainUsherRecordService;
13 11
 import com.huiju.welcome.service.ITaPersonService;
12
+import com.huiju.welcome.service.ITaVisitorAppointmentService;
14 13
 import com.huiju.welcome.utils.CommConstant;
15 14
 import com.huiju.welcome.utils.MiniApp;
16 15
 import com.huiju.welcome.utils.StatusUtils;
16
+import com.huiju.welcome.utils.StringUtils;
17 17
 import org.slf4j.Logger;
18 18
 import org.slf4j.LoggerFactory;
19 19
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
21 21
 
22 22
 import java.time.LocalDateTime;
23 23
 import java.util.ArrayList;
24
+import java.util.HashMap;
24 25
 import java.util.List;
25 26
 import java.util.Map;
26 27
 
@@ -52,46 +53,16 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
52 53
     ITaMainUsherRecordService iTaMainUsherRecordService;
53 54
 
54 55
     @Autowired
55
-    TaWechatUserMapper taWechatUserMapper;
56
+    ITaVisitorAppointmentService iTaVisitorAppointmentService;
56 57
 
57 58
     @Autowired
58
-    MiniApp miniApp;
59
-
60
-    @Override
61
-    public TaCustomer newVisitRecord(TaMainUsherRecord taMainUsherRecord) throws Exception {
62
-        Integer personId = taMainUsherRecord.getPersonId();
63
-        if (null == personId) {
64
-            TaPerson taPerson = iTaPersonService.newPersonByUsher(taMainUsherRecord);
65
-            personId = taPerson.getRealId();
66
-            taMainUsherRecord.setPersonId(personId);
67
-        }
68
-
69
-        Integer custId = taMainUsherRecord.getCustomerId();
70
-        TaCustomer cust;
71
-        if (null == custId) {
72
-            cust = newCustomerFromMainUsher(taMainUsherRecord);
73
-            if (null == cust) {
74
-                throw new Exception("生成置业客户失败");
75
-            }
76
-            taMainUsherRecord.setCustomerId(cust.getCustomerId());
77
-        } else {
78
-            cust = taCustomerMapper.selectById(custId);
79
-        }
80
-
81
-        TaCustomerMap taCustomerMap = taCustomerMapMapper.getCustomerOf(personId);
82
-        if (null == taCustomerMap) {
83
-            TaCustomerMap custMap = new TaCustomerMap();
84
-            custMap.setCustomerId(cust.getCustomerId());
85
-            custMap.setPersonId(taMainUsherRecord.getPersonId());
59
+    TaWechatUserMapper taWechatUserMapper;
86 60
 
87
-            int row = taCustomerMapMapper.insert(custMap);
88
-            if (row <= 0) {
89
-                throw new Exception("生成置业客户映射失败");
90
-            }
91
-        }
61
+    @Autowired
62
+    SysUserMapper sysUserMapper;
92 63
 
93
-        return cust;
94
-    }
64
+    @Autowired
65
+    MiniApp miniApp;
95 66
 
96 67
     @Override
97 68
     public List<TaPerson> getGroup(Integer customerId) {
@@ -107,11 +78,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
107 78
     public void judgeNewCust(TaPerson taPerson) throws Exception {
108 79
         // 首先判定这个人 2 小时内是否来访过
109 80
         LocalDateTime dt = LocalDateTime.now().minusHours(2);
110
-        List<TaMainUsherRecord> lastList = taMainUsherRecordMapper.getLastList(taPerson.getPersonId(), dt);
81
+        List<TaMainUsherRecord> lastList = taMainUsherRecordMapper.getLastList(taPerson.getRealId(), dt);
111 82
         if (null != lastList && lastList.size() > 0) return;
112 83
 
113
-        LocalDateTime now = LocalDateTime.now();
114
-
115 84
         // 查询是否有映射客户 - 如果有多个映射客户, 先随机取一条
116 85
         // 暂时没有找到好的替代方案
117 86
         TaCustomer taCustomer = taCustomerMapper.getCustomerOf(taPerson.getPersonId(), taPerson.getRealId());
@@ -122,8 +91,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
122 91
         }
123 92
 
124 93
         // 新增前台记录
125
-        iTaMainUsherRecordService.newRecordByDevice(taCustomer);
126
-
94
+        iTaMainUsherRecordService.newRecordByDevice(taCustomer, taPerson);
127 95
         return;
128 96
     }
129 97
 
@@ -144,17 +112,22 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
144 112
 
145 113
     @Override
146 114
     public List<TaCustomer> getSomeCustMayBe(String plateNumber) {
147
-        return taCustomerMapper.getSomeCustMayBe(plateNumber);
115
+        return taCustomerMapper.getSomeCustMayBe(plateNumber, null);
148 116
     }
149 117
 
150 118
     @Override
151
-    public TaCustomer newCustByCarDevice(TaCarRecord taCarRecord) {
119
+    public TaCustomer newCustByCarDevice(TaCarRecord taCarRecord, TaVisitorAppointment ...taVisitorAppointments) {
152 120
         TaCustomer taCustomer = new TaCustomer();
121
+        TaVisitorAppointment appointment = null != taVisitorAppointments && taVisitorAppointments.length > 0 ? taVisitorAppointments[0] : null;
122
+
123
+        String name = StringUtils.ifNull(taCarRecord.getCustomerName(), null != appointment ? appointment.getPersonName() : null);
124
+        String phone = null != appointment ? appointment.getPhone() : null;
153 125
 
154 126
         taCustomer.setCreateDate(LocalDateTime.now());
155 127
         taCustomer.setStatus(StatusUtils.Normal);
156
-        taCustomer.setCustomerName(taCarRecord.getCustomerName());
157
-        taCustomer.setAvatar(taCarRecord.getDriverImage());
128
+        taCustomer.setCustomerName(name);
129
+        taCustomer.setPhone(phone);
130
+        taCustomer.setAvatar(taCarRecord.getLicenseImage());
158 131
         taCustomer.setCarModel(taCarRecord.getCarModel());
159 132
         taCustomer.setPlateNumber(taCarRecord.getPlateNumber());
160 133
 
@@ -166,7 +139,8 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
166 139
         customerMap.setPersonId(taPerson.getPersonId());
167 140
 
168 141
         taCustomerMapMapper.insert(customerMap);
169
-        taCustomerMapper.insert(taCustomer);
142
+
143
+        insertCustomer(taCustomer);
170 144
 
171 145
         return taCustomer;
172 146
     }
@@ -174,7 +148,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
174 148
     @Override
175 149
     public void notifyConsultant(TaCustomer taCustomer) throws Exception {
176 150
         String tpl = miniApp.getTpls().getVisitor();
177
-        String page = "";
151
+        String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + taCustomer.getCustomerId();
178 152
         String openid = taWechatUserMapper.getOpenidOf(taCustomer.getConsultantId(), CommConstant.WECHAT_CLIENT_MINIAPP);
179 153
         if (null == openid) {
180 154
             throw new Exception("发送消息给置业失败, 当前置业[" + taCustomer.getConsultantId() + "]未绑定小程序账号");
@@ -188,6 +162,112 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
188 162
         miniApp.sendTPLMessage(tpl, openid, page, data);
189 163
     }
190 164
 
165
+    @Override
166
+    public boolean updateConsultant(TaCustomer taCustomer, Integer consultantId) {
167
+        SysUser usr = sysUserMapper.selectById(consultantId);
168
+        if (null == usr) {
169
+            log.error("更新客户置业失败, 置业ID {} 不存在", consultantId);
170
+            return false;
171
+        }
172
+
173
+        Integer originConsultant = taCustomer.getConsultantId();
174
+        taCustomer.setConsultantId(consultantId);
175
+        taCustomer.setRealtyConsultant(usr.getUsername());
176
+
177
+        // 如果变更了置业顾问
178
+        if (null == originConsultant || originConsultant.intValue() < 1 || !originConsultant.equals(consultantId)) {
179
+            try {
180
+                notifyConsultant(taCustomer);
181
+            } catch (Exception e) {}
182
+        }
183
+
184
+        int row = taCustomerMapper.updateById(taCustomer);
185
+        return row > 0;
186
+    }
187
+
188
+    @Override
189
+    public TaCustomer newCustByMainUsher(TaMainUsherRecord taMainUsherRecord) throws Exception {
190
+        Integer personId = taMainUsherRecord.getPersonId();
191
+        if (null == personId) {
192
+            TaPerson taPerson = iTaPersonService.newPersonByUsher(taMainUsherRecord);
193
+            personId = taPerson.getRealId();
194
+            taMainUsherRecord.setPersonId(personId);
195
+        }
196
+
197
+        Integer custId = taMainUsherRecord.getCustomerId();
198
+        TaCustomer cust;
199
+        if (null == custId) {
200
+            cust = copyDataFromMainUsher(taMainUsherRecord);
201
+            if (!insertCustomer(cust)) {
202
+                throw new Exception("新增客户信息失败");
203
+            }
204
+
205
+            taMainUsherRecord.setCustomerId(cust.getCustomerId());
206
+        } else {
207
+            cust = taCustomerMapper.selectById(custId);
208
+        }
209
+
210
+        TaCustomerMap taCustomerMap = taCustomerMapMapper.getCustomerOf(personId);
211
+        if (null == taCustomerMap) {
212
+            TaCustomerMap custMap = new TaCustomerMap();
213
+            custMap.setCustomerId(cust.getCustomerId());
214
+            custMap.setPersonId(taMainUsherRecord.getPersonId());
215
+
216
+            int row = taCustomerMapMapper.insert(custMap);
217
+            if (row <= 0) {
218
+                throw new Exception("生成置业客户映射失败");
219
+            }
220
+        }
221
+
222
+        return cust;
223
+    }
224
+
225
+    @Override
226
+    public Map<String, Object> getHistoryRecBy(Map<String, Object> filters) {
227
+        Map<String, Object> result = new HashMap<String, Object>(){{
228
+            put("phone", filters.get("phone").toString());
229
+        }};
230
+
231
+        List<TaVisitorAppointment> appointments = iTaVisitorAppointmentService.getAppointmentsBy(filters);
232
+        if (null != appointments && appointments.size() > 0) {
233
+            result.put("appointment", 1);
234
+            result.put("name", appointments.get(0).getPersonName());
235
+            result.put("consultantId", appointments.get(0).getCreateUser());
236
+        }
237
+
238
+        List<TaCustomer> custs = taCustomerMapper.getSomeCustMayBe(null, filters.get("phone").toString());
239
+        if (null != custs || custs.size() > 0) {
240
+            result.put("name", custs.get(0).getCustomerName());
241
+            result.put("consultantId", custs.get(0).getConsultantId());
242
+            result.put("consultantName", custs.get(0).getRealtyConsultant());
243
+            result.put("purpose", custs.get(0).getPurpose());
244
+        }
245
+
246
+        return result;
247
+    }
248
+
249
+    @Override
250
+    public TaCustomer getSameByPerson(Integer personId) {
251
+        return taCustomerMapper.getCustomerOf(personId, personId);
252
+    }
253
+
254
+    @Override
255
+    public boolean updataByCarRecord(TaCustomer taCustomer, TaCarRecord taCarRecord) {
256
+        boolean needUpate = false;
257
+
258
+        if (StringUtils.isEmpty(taCustomer.getPlateNumber())) {
259
+            needUpate = true;
260
+            taCustomer.setPlateNumber(taCarRecord.getPlateNumber());
261
+            taCustomer.setCarModel(taCarRecord.getCarModel());
262
+        }
263
+
264
+        if (needUpate) {
265
+            return taCustomerMapper.updateById(taCustomer) > 0;
266
+        }
267
+
268
+        return true;
269
+    }
270
+
191 271
     private TaCustomer newCustomerByPerson(TaPerson taPerson) throws Exception {
192 272
         TaCustomer taCustomer = new TaCustomer();
193 273
         taCustomer.setCustomerId(taPerson.getRealId());
@@ -197,10 +277,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
197 277
         taCustomer.setCustomerName(taPerson.getName());
198 278
         taCustomer.setCreateDate(LocalDateTime.now());
199 279
         taCustomer.setStatus(StatusUtils.Normal);
200
-        int row = taCustomerMapper.insert(taCustomer);
201 280
 
202
-        if (row < 1) {
203
-            throw new Exception("新增客户信息失败");
281
+        if (!insertCustomer(taCustomer)) {
282
+            throw new Exception("新增客户失败");
204 283
         }
205 284
 
206 285
         int mapsNum = taPerson.getPersonId().equals(taPerson.getRealId()) ? 1 : 2;
@@ -209,7 +288,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
209 288
             TaCustomerMap custMap = new TaCustomerMap();
210 289
             custMap.setPersonId(i == 0 ? taPerson.getRealId() : taPerson.getPersonId());
211 290
             custMap.setCustomerId(taCustomer.getCustomerId());
212
-            row = taCustomerMapMapper.insert(custMap);
291
+            int row = taCustomerMapMapper.insert(custMap);
213 292
             if (row < 1) {
214 293
                 throw new Exception("新增客户映射信息失败");
215 294
             }
@@ -218,7 +297,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
218 297
         return taCustomer;
219 298
     }
220 299
 
221
-    private TaCustomer newCustomerFromMainUsher(TaMainUsherRecord taMainUsherRecord) {
300
+    private TaCustomer copyDataFromMainUsher(TaMainUsherRecord taMainUsherRecord) {
222 301
         TaCustomer taCustomer = new TaCustomer();
223 302
         taCustomer.setCustomerId(taMainUsherRecord.getPersonId());       // 默认客户ID与人员ID一致
224 303
         taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
@@ -234,10 +313,18 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
234 313
         taCustomer.setStatus(StatusUtils.Normal);
235 314
         taCustomer.setCreateDate(LocalDateTime.now());
236 315
 
237
-        int row = taCustomerMapper.insert(taCustomer);
238
-        if (row < 1) return null;
239
-
240 316
         return taCustomer;
241 317
     }
242 318
 
319
+    private boolean insertCustomer(TaCustomer taCustomer) {
320
+        Integer consultantId = taCustomer.getConsultantId();
321
+        if (null != consultantId && consultantId.intValue() > 0) {
322
+            try {
323
+                notifyConsultant(taCustomer);
324
+            } catch (Exception e) {}
325
+        }
326
+
327
+        return taCustomerMapper.insert(taCustomer) > 0;
328
+    }
329
+
243 330
 }

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

@@ -1,5 +1,7 @@
1 1
 package com.huiju.welcome.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.alibaba.fastjson.serializer.SerializerFeature;
3 5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -72,7 +74,7 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
72 74
 
73 75
     @Override
74 76
     public void notifyMiniapp(TaFirstUsherRecord taFirstUsherRecord) {
75
-        Action act = Action.create(Action.TYPE_NEW_FIRST_USHER, taFirstUsherRecord);
77
+        Action act = Action.create(Action.TYPE_NEW_FIRST_USHER, JSONObject.toJSONString(taFirstUsherRecord, SerializerFeature.WriteMapNullValue));
76 78
         try {
77 79
             WebSocketServer.sendInfo(act.toJSON(), CommConstant.WECHAT_CLIENT_MINIAPP, null);
78 80
         } catch (Exception e) {}

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

@@ -43,7 +43,7 @@ public class TaFirstpageServiceImpl extends ServiceImpl<TaFirstpageMapper, TaFir
43 43
 
44 44
         // 获取天气
45 45
         if (taFirstpage.getWeatherShow()) {
46
-            res.put("weather",  saWeather.weather(taFirstpage));
46
+            res.put("weather",  saWeather.weather(taFirstpage.getCity()));
47 47
         }
48 48
 
49 49
         // 获取公告

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

@@ -1,6 +1,7 @@
1 1
 package com.huiju.welcome.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4
+import com.alibaba.fastjson.serializer.SerializerFeature;
4 5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,6 +17,7 @@ import com.huiju.welcome.common.base.ResponseBean;
16 17
 import com.huiju.welcome.mapper.TaCustomerMapper;
17 18
 import com.huiju.welcome.model.TaCustomer;
18 19
 import com.huiju.welcome.model.TaMainUsherRecord;
20
+import com.huiju.welcome.service.ITaCustomerService;
19 21
 import com.huiju.welcome.service.ITaMainUsherRecordService;
20 22
 import com.huiju.welcome.utils.CommConstant;
21 23
 import com.huiju.welcome.utils.MiniApp;
@@ -53,6 +55,9 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
53 55
     @Autowired
54 56
     SysUserMapper sysUserMapper;
55 57
 
58
+    @Autowired
59
+    ITaCustomerService iTaCustomerService;
60
+
56 61
     @Autowired
57 62
     MiniApp miniApp;
58 63
 
@@ -65,7 +70,7 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
65 70
             recs.add(rec.getRecId());
66 71
         }
67 72
 
68
-        UpdateWrapper<TaMainUsherRecord> wrapper = new UpdateWrapper();
73
+        UpdateWrapper<TaMainUsherRecord> wrapper = new UpdateWrapper<>();
69 74
         wrapper.set("status", StatusUtils.Normal);
70 75
         wrapper.in("rec_id", recs);
71 76
 
@@ -74,20 +79,22 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
74 79
     }
75 80
 
76 81
     @Override
77
-    public boolean newRecordByDevice(TaCustomer taCustomer) {
82
+    public boolean newRecordByDevice(TaCustomer taCustomer, TaPerson taPerson) {
78 83
         TaMainUsherRecord taMainUsherRecord = newRecordByCust(taCustomer);
84
+        taMainUsherRecord.setStatus(StatusUtils.Ready);
85
+        taMainUsherRecord.setPersonId(taPerson.getRealId());
79 86
         int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
80 87
 
81 88
         try {
82
-            Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord));
83
-            WebSocketServer.sendInfo(act.toJSON(), "miniapp", null);
84
-        } catch (Exception e) {}
89
+            Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord, SerializerFeature.WriteMapNullValue));
90
+            WebSocketServer.sendInfo(act.toJSON(), CommConstant.WECHAT_CLIENT_MINIAPP, null);
91
+        } catch (Exception e) {e.printStackTrace();}
85 92
 
86 93
         // 通知对应的置业
87 94
         if (null != taCustomer.getConsultantId()) {
88 95
             try {
89 96
                 notifyConsultant(taMainUsherRecord, taCustomer);
90
-            } catch (Exception e) {}
97
+            } catch (Exception e) {e.printStackTrace();}
91 98
         }
92 99
 
93 100
         return row > 0;
@@ -104,13 +111,22 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
104 111
     private TaMainUsherRecord newRecordByCust(TaCustomer taCustomer) {
105 112
         TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
106 113
         taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
114
+        taMainUsherRecord.setPersonName(taCustomer.getCustomerName());
115
+        taMainUsherRecord.setAvatar(taCustomer.getAvatar());
116
+        taMainUsherRecord.setPhone(taCustomer.getPhone());
107 117
         taMainUsherRecord.setAppointment(taCustomer.getApointment());
108 118
         taMainUsherRecord.setConsultantId(taCustomer.getConsultantId());
109 119
         taMainUsherRecord.setChannel(taCustomer.getChannel());
110 120
         taMainUsherRecord.setPurpose(taCustomer.getPurpose());
111 121
         taMainUsherRecord.setPlateNumber(taCustomer.getPlateNumber());
112 122
         taMainUsherRecord.setVisiteDate(LocalDateTime.now());
113
-        taMainUsherRecord.setStatus(StatusUtils.Normal);
123
+
124
+        if (StringUtils.isEmpty(taCustomer.getPhone())) {
125
+            taMainUsherRecord.setStatus(StatusUtils.Ready);
126
+        } else {
127
+            taMainUsherRecord.setStatus(StatusUtils.Normal);
128
+        }
129
+
114 130
         return taMainUsherRecord;
115 131
     }
116 132
 
@@ -129,7 +145,7 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
129 145
         String openid = taWechatUserMapper.getOpenidOf(proxyConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
130 146
         if (StringUtils.isEmpty(openid)) {
131 147
             throw new Exception("置业尚未绑定微信小程序");
132
-        };
148
+        }
133 149
 
134 150
         String visitorName = taMainUsherRecord.getPersonName();
135 151
         String phone = taMainUsherRecord.getPhone();
@@ -154,7 +170,7 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
154 170
             String rcOpenid = taWechatUserMapper.getOpenidOf(realConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
155 171
             if (StringUtils.isEmpty(openid)) {
156 172
                 throw new Exception("置业尚未绑定微信小程序");
157
-            };
173
+            }
158 174
 
159 175
             SysUser usr1 = sysUserMapper.selectById(proxyConsultant);
160 176
             List<Object> dt1 = new ArrayList<Object>(){{
@@ -183,4 +199,108 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
183 199
         response.addSuccess(result);
184 200
         return response;
185 201
     }
202
+
203
+    @Override
204
+    public boolean newRecordByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception {
205
+        Integer consultantId = taMainUsherRecord.getConsultantId();
206
+        if (null == consultantId || consultantId < 1) {
207
+            throw new Exception("置业顾问不能为空");
208
+        }
209
+
210
+        if (StringUtils.isEmpty(taMainUsherRecord.getPhone())) {
211
+            throw new Exception("客户电话不能为空");
212
+        }
213
+
214
+        taMainUsherRecord.setStatus(StatusUtils.Normal);
215
+
216
+        // 新增客户
217
+        iTaCustomerService.newCustByMainUsher(taMainUsherRecord);
218
+
219
+        return taMainUsherRecordMapper.insert(taMainUsherRecord) > 0;
220
+    }
221
+
222
+    @Override
223
+    public boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception {
224
+        Integer consultantId = taMainUsherRecord.getConsultantId();
225
+        if (null == consultantId || consultantId < 1) {
226
+            throw new Exception("置业顾问不能为空");
227
+        }
228
+
229
+        if (StringUtils.isEmpty(taMainUsherRecord.getPhone())) {
230
+            throw new Exception("客户电话不能为空");
231
+        }
232
+
233
+        taMainUsherRecord.setStatus(StatusUtils.Normal);
234
+
235
+        int row = taMainUsherRecordMapper.updateById(taMainUsherRecord);
236
+
237
+        // 是否更新了置业
238
+        TaCustomer taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
239
+        Integer originConsultant = taCustomer.getConsultantId();
240
+
241
+        // 是否需要更新客户信息
242
+        if (StringUtils.isEmpty(taCustomer.getCustomerName()) || StringUtils.isEmpty(taCustomer.getPhone())) {
243
+            if (StringUtils.isEmpty(taCustomer.getCustomerName())) {
244
+                taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
245
+            }
246
+
247
+            if (StringUtils.isEmpty(taCustomer.getPhone())) {
248
+                taCustomer.setPhone(taMainUsherRecord.getPhone());
249
+            }
250
+
251
+            iTaCustomerService.updateById(taCustomer);
252
+        }
253
+
254
+        // 如果原来置业为空
255
+        if (null == originConsultant || originConsultant < 1) {
256
+            iTaCustomerService.updateConsultant(taCustomer, consultantId);
257
+        } else if (!consultantId.equals(originConsultant)) {
258
+            // 如果临时替换跟踪置业
259
+            // 那么需要给原始置业, 以及临时置业各自发一条消息
260
+            String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + String.valueOf(taCustomer.getCustomerId());
261
+            String tplId = miniApp.getTpls().getVisitor();
262
+
263
+            // 原绑定置业
264
+            String rcOpenid = taWechatUserMapper.getOpenidOf(originConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
265
+            if (StringUtils.isEmpty(rcOpenid)) {
266
+                throw new Exception("置业尚未绑定微信小程序");
267
+            }
268
+            SysUser rcUser = sysUserMapper.selectById(originConsultant);
269
+
270
+            // 临时置业
271
+            String proxyOpenid = taWechatUserMapper.getOpenidOf(consultantId, CommConstant.WECHAT_CLIENT_MINIAPP);
272
+            if (StringUtils.isEmpty(proxyOpenid)) {
273
+                throw new Exception("置业尚未绑定微信小程序");
274
+            }
275
+            SysUser proxyUser = sysUserMapper.selectById(consultantId);
276
+
277
+            // 通知原置业, 客户被临时置业接待
278
+            List<Object> dt1 = new ArrayList<Object>(){{
279
+                add(taCustomer.getCustomerName());
280
+                add(taCustomer.getPhone());
281
+                add("您有新客户来访, 已被安排给 " + proxyUser.getUsername() + " 接待!");
282
+            }};
283
+            miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
284
+
285
+            // 通知临时置业
286
+            List<Object> dt2 = new ArrayList<Object>(){{
287
+                add(taCustomer.getCustomerName());
288
+                add(taCustomer.getPhone());
289
+                add(rcUser.getUsername() + " 有新客户来访, 请协助接待一下!");
290
+            }};
291
+            miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
292
+        }
293
+
294
+        return row > 0;
295
+    }
296
+
297
+    @Override
298
+    public boolean deleteRecord(Integer id) {
299
+        UpdateWrapper<TaMainUsherRecord> updateWrapper = new UpdateWrapper<>();
300
+        updateWrapper.set("status", StatusUtils.Delete);
301
+        updateWrapper.eq("rec_id", id);
302
+        int row = taMainUsherRecordMapper.update(new TaMainUsherRecord(), updateWrapper);
303
+
304
+        return row > 0;
305
+    }
186 306
 }

+ 10
- 8
src/main/java/com.huiju.welcome/service/impl/TaMessageRecordImpl.java View File

@@ -18,7 +18,7 @@ public class TaMessageRecordImpl extends ServiceImpl<TaMessageRecordMapper, TaMe
18 18
     TaMessageRecordMapper taMessageRecordMapper;
19 19
 
20 20
     @Override
21
-    public boolean saveMessageOrNot(String toUser, String tplId, String page, List<Object> data) {
21
+    public boolean saveMessageOrNot(String toUser, String tplId, String page, List<Object> data, boolean save) {
22 22
         String content = JSONObject.toJSONString(data);
23 23
         LocalDateTime now = LocalDateTime.now();
24 24
         LocalDateTime twoHourAgo = now.minusHours(2);
@@ -26,13 +26,15 @@ public class TaMessageRecordImpl extends ServiceImpl<TaMessageRecordMapper, TaMe
26 26
         List<TaMessageRecord> lastMessages = taMessageRecordMapper.getLastSameMessages(toUser, page, content, twoHourAgo);
27 27
         if (null != lastMessages && lastMessages.size() > 0) return false;
28 28
 
29
-        TaMessageRecord record = new TaMessageRecord();
30
-        record.setReceiver(toUser);
31
-        record.setTplId(tplId);
32
-        record.setLink(page);
33
-        record.setContent(content);
34
-        record.setCreateDate(now);
35
-        taMessageRecordMapper.insert(record);
29
+        if (save) {
30
+            TaMessageRecord record = new TaMessageRecord();
31
+            record.setReceiver(toUser);
32
+            record.setTplId(tplId);
33
+            record.setLink(page);
34
+            record.setContent(content);
35
+            record.setCreateDate(now);
36
+            taMessageRecordMapper.insert(record);
37
+        }
36 38
 
37 39
         return true;
38 40
     }

+ 16
- 2
src/main/java/com.huiju.welcome/service/impl/TaMiniFormidsImpl.java View File

@@ -8,13 +8,19 @@ import com.huiju.welcome.common.base.ResponseBean;
8 8
 import com.huiju.welcome.mapper.TaMiniFormidsMapper;
9 9
 import com.huiju.welcome.model.TaMiniFormids;
10 10
 import com.huiju.welcome.service.ITaMiniFormidsService;
11
+import lombok.extern.log4j.Log4j;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.slf4j.Logger;
14
+import org.slf4j.LoggerFactory;
11 15
 import org.springframework.beans.factory.annotation.Autowired;
12 16
 import org.springframework.stereotype.Service;
13 17
 
14 18
 import java.time.LocalDateTime;
15 19
 
16 20
 @Service
21
+@Slf4j
17 22
 public class TaMiniFormidsImpl extends ServiceImpl<TaMiniFormidsMapper, TaMiniFormids> implements ITaMiniFormidsService {
23
+//    Logger log = LoggerFactory.getLogger(TaMiniFormidsImpl.class);
18 24
 
19 25
     @Autowired
20 26
     TaMiniFormidsMapper taMiniFormidsMapper;
@@ -24,10 +30,13 @@ public class TaMiniFormidsImpl extends ServiceImpl<TaMiniFormidsMapper, TaMiniFo
24 30
         JSONObject params = JSONObject.parseObject(paramsStr);
25 31
         JSONArray formids = params.getJSONArray("formids");
26 32
 
27
-        for (Object formid: formids) {
33
+        for (Object id: formids) {
34
+            String formid = id.toString();
35
+            if ("the formId is a mock one".equals(formid)) continue;
36
+
28 37
             TaMiniFormids taMiniFormids = new TaMiniFormids();
29 38
             taMiniFormids.setOpenid(openid);
30
-            taMiniFormids.setFormid(formid.toString());
39
+            taMiniFormids.setFormid(formid);
31 40
             taMiniFormids.setCreateDate(LocalDateTime.now());
32 41
             taMiniFormidsMapper.insert(taMiniFormids);
33 42
         }
@@ -38,6 +47,11 @@ public class TaMiniFormidsImpl extends ServiceImpl<TaMiniFormidsMapper, TaMiniFo
38 47
     @Override
39 48
     public String getFormidBy(String openid, boolean... delete) {
40 49
         TaMiniFormids taMiniFormids = taMiniFormidsMapper.getFormidCanUse(openid);
50
+        if (null == taMiniFormids) {
51
+            log.error("没有找对 openid [{}] 发送消息需要的 formid", openid);
52
+            return null;
53
+        }
54
+
41 55
 
42 56
         if (null != delete && delete.length > 0 && delete[0]) {
43 57
             QueryWrapper<TaMiniFormids> wrapper = new QueryWrapper<>();

+ 41
- 0
src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java View File

@@ -10,11 +10,13 @@ import com.huiju.welcome.mapper.TaDeviceMapper;
10 10
 import com.huiju.welcome.mapper.TaPersonMapper;
11 11
 import com.huiju.welcome.mapper.TaPersonTypeMapper;
12 12
 import com.huiju.welcome.model.*;
13
+import com.huiju.welcome.service.ICameraService;
13 14
 import com.huiju.welcome.service.ITaOperationLogService;
14 15
 import com.huiju.welcome.service.ITaPersonService;
15 16
 import com.huiju.welcome.service.ITaVisitingLogService;
16 17
 import com.huiju.welcome.utils.LogBuilder;
17 18
 import com.huiju.welcome.utils.StatusUtils;
19
+import com.huiju.welcome.utils.StringUtils;
18 20
 import org.slf4j.Logger;
19 21
 import org.slf4j.LoggerFactory;
20 22
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,6 +63,9 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
61 63
 
62 64
     @Autowired
63 65
     private ITaOperationLogService taOperationLogService;
66
+
67
+    @Autowired
68
+    private ICameraService iCameraService;
64 69
     
65 70
     @Value("${huiju.files}")
66 71
     private String huijuFiles;
@@ -74,6 +79,7 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
74 79
             ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
75 80
             QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
76 81
             queryWrapper.eq("status", StatusUtils.Normal);
82
+            queryWrapper.eq("afr", StatusUtils.BoolTrue);
77 83
             taDeviceList = taDeviceMapper.selectList(queryWrapper);
78 84
         } else {
79 85
             taDeviceList = Arrays.asList(dev);
@@ -244,6 +250,7 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
244 250
     @Override
245 251
     public TaPerson newPersonByFront(TaCustomer taCustomer) {
246 252
         TaPerson taPerson = new TaPerson();
253
+        taPerson.setAvatar(taCustomer.getAvatar());
247 254
         taPerson.setPhone(taCustomer.getPhone());
248 255
         taPerson.setName(taCustomer.getCustomerName());
249 256
         taPerson.setStatus(StatusUtils.Normal);
@@ -257,6 +264,9 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
257 264
         taPerson.setRealId(taPerson.getPersonId());
258 265
         taPersonMapper.updateById(taPerson);
259 266
 
267
+        // 下发人脸到各设备
268
+        iCameraService.dispatchPerson(taPerson);
269
+
260 270
         return taPerson;
261 271
     }
262 272
 
@@ -279,6 +289,37 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
279 289
         return taPerson;
280 290
     }
281 291
 
292
+    @Override
293
+    public boolean updateByCustomer(TaCustomer taCustomer) {
294
+        if (StringUtils.isEmpty(taCustomer.getPhone())) return true;
295
+
296
+        // 默认客户与人员ID是一致的
297
+        UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
298
+        updateWrapper.set("phone", taCustomer.getPhone());
299
+        updateWrapper.set("name", taCustomer.getCustomerName());
300
+        updateWrapper.eq("real_id", taCustomer.getCustomerId()).or().eq("person_id", taCustomer.getCustomerId());
301
+
302
+        int row = taPersonMapper.update(new TaPerson(), updateWrapper);
303
+        return row > 0;
304
+    }
305
+
306
+    /**
307
+     * 加入白名单, 实际上置为工作人员
308
+     * @param personId
309
+     * @return
310
+     */
311
+    @Override
312
+    public boolean setPersonIntoWhitelist(Integer personId) {
313
+
314
+        UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
315
+        updateWrapper.set("type_id", 3);
316
+        updateWrapper.eq("person_id", personId);
317
+
318
+        int row = taPersonMapper.update(new TaPerson(), updateWrapper);
319
+
320
+        return row > 0;
321
+    }
322
+
282 323
     private String getTypeName(TaPerson taPerson) {
283 324
         TaPersonType taPersonType = taPersonTypeMapper.selectById(taPerson.getTypeId());
284 325
         return null == taPersonType ? null : taPersonType.getTypeName();

+ 3
- 31
src/main/java/com.huiju.welcome/service/impl/TaVisitingLogServiceImpl.java View File

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
12 12
 import org.springframework.stereotype.Service;
13 13
 
14 14
 import java.time.LocalDateTime;
15
+import java.util.ArrayList;
15 16
 import java.util.HashMap;
16 17
 import java.util.List;
17 18
 import java.util.Map;
@@ -51,43 +52,14 @@ public class TaVisitingLogServiceImpl extends ServiceImpl<TaVisitingLogMapper, T
51 52
     public ResponseBean getTimeline() {
52 53
         LocalDateTime now = LocalDateTime.now();
53 54
 
54
-        // 十分钟内
55
-        LocalDateTime tenMini = now.minusMinutes(10);
56
-        QueryWrapper<TaVisitingLog> query1 = new QueryWrapper<>();
57
-        query1.ge("visite_date", tenMini);
58
-        query1.orderByDesc("visite_date");
59
-        List<TaVisitingLog> tenMiniList = taVisitingLogMapper.selectList(query1);
60
-
61
-        // 半小时内
62
-        LocalDateTime halfHour = now.minusMinutes(30);
63
-        QueryWrapper<TaVisitingLog> query2 = new QueryWrapper<>();
64
-        query2.le("visite_date", tenMini);
65
-        query2.ge("visite_date", halfHour);
66
-        query2.orderByDesc("visite_date");
67
-        List<TaVisitingLog> halfHourList = taVisitingLogMapper.selectList(query2);
68
-
69
-        // 一小时内
70
-        LocalDateTime oneHour = now.minusHours(1);
71
-        QueryWrapper<TaVisitingLog> query3 = new QueryWrapper<>();
72
-        query3.le("visite_date", halfHour);
73
-        query3.ge("visite_date", oneHour);
74
-        query3.orderByDesc("visite_date");
75
-        List<TaVisitingLog> oneHourList = taVisitingLogMapper.selectList(query3);
76
-
77 55
         // 四小时内
78 56
         LocalDateTime fourHour = now.minusHours(4);
79 57
         QueryWrapper<TaVisitingLog> query4 = new QueryWrapper<>();
80
-        query4.le("visite_date", oneHour);
81 58
         query4.ge("visite_date", fourHour);
59
+        query4.groupBy("real_person");
82 60
         query4.orderByDesc("visite_date");
83 61
         List<TaVisitingLog> fourHourList = taVisitingLogMapper.selectList(query4);
84 62
 
85
-        Map<String, Object> result = new HashMap<>();
86
-        result.put("tenMini", tenMiniList);
87
-        result.put("halfHour", halfHourList);
88
-        result.put("oneHour", oneHourList);
89
-        result.put("fourHour", fourHourList);
90
-
91
-        return ResponseBean.success(result);
63
+        return ResponseBean.success(fourHourList);
92 64
     }
93 65
 }

+ 23
- 1
src/main/java/com.huiju.welcome/service/impl/TaVisitorAppointmentServiceImpl.java View File

@@ -8,6 +8,7 @@ import com.huiju.welcome.mapper.TaVisitorAppointmentMapper;
8 8
 import com.huiju.welcome.model.TaVisitorAppointment;
9 9
 import com.huiju.welcome.service.ITaVisitorAppointmentService;
10 10
 import com.huiju.welcome.utils.DateUtils;
11
+import com.huiju.welcome.utils.StatusUtils;
11 12
 import org.apache.http.HttpStatus;
12 13
 import org.springframework.beans.factory.annotation.Autowired;
13 14
 import org.springframework.stereotype.Service;
@@ -16,6 +17,7 @@ import java.time.LocalDateTime;
16 17
 import java.time.LocalDateTime;
17 18
 import java.util.Date;
18 19
 import java.util.List;
20
+import java.util.Map;
19 21
 
20 22
 /**
21 23
  * <p>
@@ -43,7 +45,27 @@ public class TaVisitorAppointmentServiceImpl extends ServiceImpl<TaVisitorAppoin
43 45
 
44 46
         return ResponseBean.success("");
45 47
     }
46
-    
48
+
49
+    @Override
50
+    public List<TaVisitorAppointment> getAppointmentsBy(Map<String, Object> filters) {
51
+        QueryWrapper<TaVisitorAppointment> queryWrapper = new QueryWrapper<>();
52
+        queryWrapper.eq("phone", filters.get("phone"));
53
+        queryWrapper.eq("status", StatusUtils.Normal);
54
+        queryWrapper.orderByDesc("create_date");
55
+
56
+        return taVisitorAppointmentMapper.selectList(queryWrapper);
57
+    }
58
+
59
+    @Override
60
+    public List<TaVisitorAppointment> getAppointmentsByPlateNumber(String plateNumber) {
61
+        QueryWrapper<TaVisitorAppointment> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.eq("plat_number", plateNumber);
63
+        queryWrapper.eq("status", StatusUtils.Normal);
64
+        queryWrapper.orderByDesc("create_date");
65
+
66
+        return taVisitorAppointmentMapper.selectList(queryWrapper);
67
+    }
68
+
47 69
     @Override
48 70
     public ResponseBean visitorAppointmentList(IPage pg, String platNumber, String personName,String phone) {
49 71
        ResponseBean responseBean= new ResponseBean();

+ 121
- 0
src/main/java/com.huiju.welcome/utils/AliFaceUtils.java View File

@@ -0,0 +1,121 @@
1
+package com.huiju.welcome.utils;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.aliyuncs.CommonRequest;
5
+import com.aliyuncs.CommonResponse;
6
+import com.aliyuncs.DefaultAcsClient;
7
+import com.aliyuncs.http.MethodType;
8
+import com.aliyuncs.profile.DefaultProfile;
9
+import com.huiju.welcome.config.AliProperties;
10
+import lombok.extern.slf4j.Slf4j;
11
+import org.apache.http.HttpStatus;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
14
+import org.springframework.context.annotation.Configuration;
15
+
16
+@Slf4j
17
+@Configuration
18
+@EnableConfigurationProperties(AliProperties.class)
19
+public class AliFaceUtils {
20
+
21
+    public final static String ACT_ADD_FACE = "AddFace";
22
+    public final static String ACT_RECOGNIZE_FACE = "RecognizeFace";
23
+
24
+    DefaultProfile profile;
25
+    DefaultAcsClient client;
26
+
27
+    @Autowired
28
+    public AliFaceUtils(AliProperties p) {
29
+        profile = DefaultProfile.getProfile(AliProperties.face.getRegionId(), AliProperties.accessKeyId, AliProperties.accessKeySecret);
30
+        client = new DefaultAcsClient(profile);
31
+    }
32
+
33
+    /**
34
+     * 添加人脸
35
+     * @param personId
36
+     * @param name
37
+     * @param url
38
+     * @param datas
39
+     * @throws Exception
40
+     */
41
+    public void addFace(Integer personId, String name, String url, String ...datas) throws Exception {
42
+        log.info("阿里人脸比对, 请求上传人脸: {}[{}] {}", name, personId, url);
43
+
44
+        if (null == url && null == datas) {
45
+            throw new Exception("图片地址 或者 Base64 数据必填一个");
46
+        }
47
+
48
+        CommonRequest request = generalRequest(ACT_ADD_FACE);
49
+        request.putBodyParameter("Person", name);
50
+        request.putBodyParameter("Image", personId);
51
+
52
+        if (null == datas || datas.length < 1) {
53
+            request.putBodyParameter("ImageUrl", url);
54
+        } else {
55
+            request.putBodyParameter("Content", datas[0]);
56
+        }
57
+
58
+        excuteRequest(request);
59
+    }
60
+
61
+    /**
62
+     * 人脸库比对
63
+     * @param url
64
+     * @param datas
65
+     * @throws Exception
66
+     */
67
+    public JSONObject recognizeFace(String url, String ...datas) throws Exception {
68
+        log.info("阿里人脸比对, 请求比对人脸: {}", url);
69
+
70
+        if (null == url && null == datas) {
71
+            throw new Exception("图片地址 或者 Base64 数据必填一个");
72
+        }
73
+
74
+        CommonRequest request = generalRequest(ACT_RECOGNIZE_FACE);
75
+
76
+        if (null == datas || datas.length < 1) {
77
+            request.putBodyParameter("ImageUrl", url);
78
+        } else {
79
+            request.putBodyParameter("Content", datas[0]);
80
+        }
81
+
82
+        return excuteRequest(request);
83
+    }
84
+
85
+    private JSONObject excuteRequest(CommonRequest request) throws Exception {
86
+        CommonResponse response = client.getCommonResponse(request);
87
+        if (response.getHttpStatus() == HttpStatus.SC_OK) {
88
+            try {
89
+                JSONObject result = JSONObject.parseObject(response.getData());
90
+
91
+                Boolean success = result.getBoolean("Success");
92
+                if (null == success || !success) {
93
+                    String error = "校验阿里人脸比对接口返回出错: " + result.getString("Message");
94
+                    log.error(error);
95
+                    throw new Exception(error);
96
+                }
97
+
98
+                return result;
99
+            } catch (Exception e) {
100
+                String error = "校验阿里人脸比对接口出错: " + e.getMessage();
101
+                log.error(error);
102
+                e.printStackTrace();
103
+                throw new Exception(error);
104
+            }
105
+        } else {
106
+            String error = "网络请求上传比对人脸失败, 错误码: {}" + response.getHttpStatus();
107
+            log.error(error);
108
+            throw new Exception(error);
109
+        }
110
+    }
111
+
112
+    private CommonRequest generalRequest(String action) {
113
+        CommonRequest request = new CommonRequest();
114
+        request.setMethod(MethodType.POST);
115
+        request.setDomain(AliProperties.face.getDomain());
116
+        request.setVersion(AliProperties.face.getVersion());
117
+        request.setAction(action);
118
+        request.putBodyParameter("Group", AliProperties.face.getGroup());
119
+        return request;
120
+    }
121
+}

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

@@ -1,7 +1,7 @@
1 1
 package com.huiju.welcome.utils;
2 2
 
3 3
 import com.aliyun.oss.OSSClient;
4
-import com.huiju.welcome.config.AliOSSProperties;
4
+import com.huiju.welcome.config.AliProperties;
5 5
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
6 6
 import org.springframework.context.annotation.Configuration;
7 7
 import org.springframework.web.multipart.MultipartFile;
@@ -9,7 +9,7 @@ import org.springframework.web.multipart.MultipartFile;
9 9
 import java.io.*;
10 10
 
11 11
 @Configuration
12
-@EnableConfigurationProperties(AliOSSProperties.class)
12
+@EnableConfigurationProperties(AliProperties.class)
13 13
 public class AliOSSUtils {
14 14
 
15 15
     /**
@@ -46,13 +46,13 @@ public class AliOSSUtils {
46 46
     }
47 47
 
48 48
     private static String putFile(String fname, InputStream input) {
49
-        OSSClient ossClient = new OSSClient(AliOSSProperties.oss.getEndpoint(), AliOSSProperties.accessKeyId, AliOSSProperties.accessKeySecret);
50
-        ossClient.putObject(AliOSSProperties.oss.getBucketName(), fname, input);
49
+        OSSClient ossClient = new OSSClient(AliProperties.oss.getEndpoint(), AliProperties.accessKeyId, AliProperties.accessKeySecret);
50
+        ossClient.putObject(AliProperties.oss.getBucketName(), fname, input);
51 51
         ossClient.shutdown();
52 52
 
53 53
         // String url = ossClient.generatePresignedUrl(AliOSSUtils.oss.getBucketName(), fname, expiration).toString();
54 54
 
55
-        String preURL = AliOSSProperties.oss.getBucketURL();
55
+        String preURL = AliProperties.oss.getBucketURL();
56 56
         if (!preURL.endsWith("/")) {
57 57
             preURL += "/";
58 58
         }

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

@@ -5,7 +5,7 @@ public class CommConstant {
5 5
     public final static String IDENTITY_FIRSTUSHER = "first-usher";
6 6
     public final static String IDENTITY_MAINUSHER = "main-usher";
7 7
 
8
-    public final static String PAGE_MY_CUSTOMER = "";
8
+    public final static String PAGE_MY_CUSTOMER = "pages/client/myclient/myclient";
9 9
 
10 10
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
11 11
 }

+ 14
- 3
src/main/java/com.huiju.welcome/utils/MiniApp.java View File

@@ -44,7 +44,7 @@ public class MiniApp {
44 44
 
45 45
 
46 46
     public ResponseBean getOpenid(String code) {
47
-        String api = url + "/" + appid + "/login?code=" + code;
47
+        String api = url + "/api/miniapp/" + appid + "/login?code=" + code;
48 48
         RestTemplate restTemplate = new RestTemplate();
49 49
         String resp = restTemplate.exchange(api,HttpMethod.resolve("GET"), new HttpEntity<String>(null, null),String.class).getBody();
50 50
 
@@ -60,10 +60,14 @@ public class MiniApp {
60 60
     }
61 61
 
62 62
     public ResponseBean sendTPLMessage(String tplId, String toUser, String page, List<Object> data) {
63
-        boolean needSend = iTaMessageRecordService.saveMessageOrNot(toUser, tplId, page, data);
63
+        boolean needSend = iTaMessageRecordService.saveMessageOrNot(toUser, tplId, page, data, false);
64 64
         if (!needSend) return ResponseBean.success("");
65 65
 
66 66
         String formId = iTaMiniFormidsService.getFormidBy(toUser, true);
67
+        if (null == formId) {
68
+            return ResponseBean.error("发送模板消息失败, 没有可用的 formid ", HttpStatus.SC_INTERNAL_SERVER_ERROR);
69
+        }
70
+
67 71
         String api = String.format("/api/%s/tpl/%s/form/%s/to/%s", appid, tplId, formId, toUser);
68 72
 
69 73
         HttpHeaders headers = new HttpHeaders();
@@ -74,7 +78,12 @@ public class MiniApp {
74 78
 
75 79
         RestTemplate restTemplate = new RestTemplate();
76 80
         HttpEntity<Map<String, Object>> request = new HttpEntity<Map<String, Object>>(sendData, headers);
77
-        String resp = restTemplate.postForEntity(url, request, String.class).getBody();
81
+        String resp ="";
82
+        try{
83
+            resp = restTemplate.postForEntity(url+api, request, String.class).getBody();
84
+        }catch (Exception e){
85
+            log.error(e.getMessage());
86
+        }
78 87
 
79 88
         JSONObject result = JSONObject.parseObject(resp);
80 89
         Integer respCode = result.getInteger("code");
@@ -84,6 +93,8 @@ public class MiniApp {
84 93
             return ResponseBean.error("调用小程序接口失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
85 94
         }
86 95
 
96
+        iTaMessageRecordService.saveMessageOrNot(toUser, tplId, page, data, true);
97
+
87 98
         return ResponseBean.success("");
88 99
     }
89 100
 

+ 2
- 3
src/main/java/com.huiju.welcome/utils/SAWeather.java View File

@@ -1,6 +1,5 @@
1 1
 package com.huiju.welcome.utils;
2 2
 
3
-import com.huiju.welcome.model.TaFirstpage;
4 3
 import org.apache.commons.lang3.StringUtils;
5 4
 import org.springframework.beans.factory.annotation.Value;
6 5
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -43,10 +42,10 @@ public class SAWeather {
43 42
     @Value("${saweather.needMoreDay}")
44 43
     private String needMoreDay;
45 44
 
46
-    public String weather(TaFirstpage taFirstpage) {
45
+    public String weather(String town) {
47 46
         List<String> params = new ArrayList<>();
48 47
         // WeatherName 为空时 显示默认
49
-        String temporaryCity = org.springframework.util.StringUtils.isEmpty(taFirstpage.getWeatherName()) ? city:taFirstpage.getWeatherName();
48
+        String temporaryCity = StringUtils.isEmpty(town) ? city: town;
50 49
         params.add("area=" + temporaryCity);
51 50
         params.add("needIndex=" + needIndex);
52 51
         params.add("need3HourForcast=" + need3HourForcast);

+ 3
- 0
src/main/java/com.huiju.welcome/utils/StatusUtils.java View File

@@ -8,4 +8,7 @@ public class StatusUtils {
8 8
 
9 9
     public static final int Offline = 0;
10 10
     public static final int Online = 1;
11
+
12
+    public static final int BoolFalse = 0;
13
+    public static final int BoolTrue = 1;
11 14
 }

+ 102
- 0
src/main/java/com.huiju.welcome/utils/TencentFaceUtils.java View File

@@ -0,0 +1,102 @@
1
+package com.huiju.welcome.utils;
2
+
3
+import com.huiju.welcome.config.TencentProperties;
4
+import com.tencentcloudapi.common.Credential;
5
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
6
+import com.tencentcloudapi.iai.v20180301.IaiClient;
7
+import com.tencentcloudapi.iai.v20180301.models.*;
8
+import lombok.extern.slf4j.Slf4j;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
11
+import org.springframework.context.annotation.Configuration;
12
+
13
+@Slf4j
14
+@Configuration
15
+@EnableConfigurationProperties(TencentProperties.class)
16
+public class TencentFaceUtils {
17
+    TencentProperties properties;
18
+    Credential cred;
19
+
20
+    @Autowired
21
+    public TencentFaceUtils(TencentProperties properties) {
22
+        this.properties = properties;
23
+        this.cred = new Credential(properties.getSecretId(), properties.getSecretKey());
24
+    }
25
+
26
+    public GetPersonBaseInfoResponse getPersonBaseInfo(String personId) throws TencentCloudSDKException {
27
+        GetPersonBaseInfoRequest request = new GetPersonBaseInfoRequest();
28
+        request.setPersonId(personId);
29
+
30
+        IaiClient client = new IaiClient(this.cred, this.properties.getIai().getRegion());
31
+        return client.GetPersonBaseInfo(request);
32
+    }
33
+
34
+    public void createPerson(String personId, String personName, String url, String ...images) throws TencentCloudSDKException {
35
+        // 已经存在的人员, 不重复创建
36
+        try {
37
+            getPersonBaseInfo(personId);
38
+            return;
39
+        } catch (TencentCloudSDKException e) {
40
+            if (e.toString().indexOf("InvalidParameterValue.PersonIdNotExist") == -1) {
41
+                throw e;
42
+            }
43
+        }
44
+
45
+        CreatePersonRequest request = new CreatePersonRequest();
46
+        request.setGroupId(this.properties.getIai().getGroup());
47
+        request.setPersonId(personId);
48
+        request.setPersonName(personName);
49
+        if (null != url && !"".equals(url)) {
50
+            request.setUrl(url);
51
+        } else if (null != images && images.length > 0) {
52
+            request.setImage(images[0]);
53
+        }
54
+
55
+        IaiClient client = new IaiClient(this.cred, this.properties.getIai().getRegion());
56
+        client.CreatePerson(request);
57
+    }
58
+
59
+    public void createFace(String personId, String url, String ...images) throws TencentCloudSDKException {
60
+        // 因为目前腾讯接口没有办法获取确切的错误码, 所以先尝试着去新增人员
61
+        // https://github.com/TencentCloud/tencentcloud-sdk-java/issues/22
62
+
63
+        try {
64
+            createPerson(personId, personId, url);
65
+        } catch (TencentCloudSDKException e) {
66
+            log.error(e.toString());
67
+        }
68
+
69
+        CreateFaceRequest request = new CreateFaceRequest();
70
+        request.setPersonId(personId);
71
+        if (null != url && !"".equals(url)) {
72
+            request.setUrls(new String[]{ url });
73
+        } else if (null != images && images.length > 0) {
74
+            request.setImages(images);
75
+        } else {
76
+            throw new TencentCloudSDKException("必须设置人脸图片");
77
+        }
78
+
79
+        IaiClient client = new IaiClient(this.cred, this.properties.getIai().getRegion());
80
+        client.CreateFace(request);
81
+    }
82
+
83
+    public Candidate searchFace(String url, String ...images) throws TencentCloudSDKException {
84
+        SearchFacesRequest request = new SearchFacesRequest();
85
+        request.setGroupIds(new String[]{ this.properties.getIai().getGroup() });
86
+        if (null != url && !"".equals(url)) {
87
+            request.setUrl(url);
88
+        } else if (null != images && images.length > 0) {
89
+            request.setImage(images[0]);
90
+        } else {
91
+            throw new TencentCloudSDKException("必须设置人脸图片");
92
+        }
93
+
94
+        IaiClient client = new IaiClient(this.cred, this.properties.getIai().getRegion());
95
+        SearchFacesResponse response = client.SearchFaces(request);
96
+        Result[] results = response.getResults();
97
+        if (null == results || results.length < 1) return null;
98
+
99
+        Candidate[] candidates = results[0].getCandidates();
100
+        return candidates[0];
101
+    }
102
+}

+ 16
- 3
src/main/resources/application.yml View File

@@ -42,7 +42,7 @@ saweather:
42 42
 
43 43
 # 小程序服务
44 44
 miniapp:
45
-  url: http://47.101.36.130:8001/api/miniapp
45
+  url: http://miniapp.ycjcjy.com
46 46
   appid: wx3f26e5f48c72d39f
47 47
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
48 48
   tpls:
@@ -50,10 +50,23 @@ miniapp:
50 50
 
51 51
 # ali-cloud
52 52
 ali:
53
-  accessKeyId: LTAIkc75dpkJw8Lb
54
-  accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
53
+  # accessKeyId: LTAIkc75dpkJw8Lb
54
+  # accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
55
+  accessKeyId: LTAIqDWVYleuHNqb
56
+  accessKeySecret: DCAtxoMKQxS3HmrHCbQUs7LaaTR6lB
55 57
   oss:
56 58
     endpoint: oss-cn-shanghai.aliyuncs.com
57 59
     bucketName: estateagents
58 60
     bucketURL: https://estateagents.oss-cn-shanghai.aliyuncs.com
61
+  face:
62
+    regionId: cn-shanghai
63
+    domain: face.cn-shanghai.aliyuncs.com
64
+    version: 2018-12-03
65
+    group: default
59 66
 
67
+tencent:
68
+  secretId: AKIDjFV4MN5aHp78sMObJ9i01lmWt2uokw6z
69
+  secretKey: oKhohKlwsSowqa5KM8drpX1FCtLfmhMq
70
+  iai:
71
+    region: ap-shanghai
72
+    group: default

+ 3
- 0
src/main/resources/mapper/TaCustomerMapper.xml View File

@@ -42,7 +42,10 @@
42 42
         FROM
43 43
             ta_customer t
44 44
         WHERE
45
+	      (
45 46
             t.plate_number = #{plateNumber}
47
+            OR t.phone = #{phone}
48
+          )
46 49
         AND IFNULL(t.customer_name, '') != ''
47 50
         AND t.`status` = 1
48 51
     </select>

+ 16
- 3
target/classes/application.yml View File

@@ -42,7 +42,7 @@ saweather:
42 42
 
43 43
 # 小程序服务
44 44
 miniapp:
45
-  url: http://47.101.36.130:8001/api/miniapp
45
+  url: http://miniapp.ycjcjy.com
46 46
   appid: wx3f26e5f48c72d39f
47 47
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
48 48
   tpls:
@@ -50,10 +50,23 @@ miniapp:
50 50
 
51 51
 # ali-cloud
52 52
 ali:
53
-  accessKeyId: LTAIkc75dpkJw8Lb
54
-  accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
53
+  # accessKeyId: LTAIkc75dpkJw8Lb
54
+  # accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
55
+  accessKeyId: LTAIqDWVYleuHNqb
56
+  accessKeySecret: DCAtxoMKQxS3HmrHCbQUs7LaaTR6lB
55 57
   oss:
56 58
     endpoint: oss-cn-shanghai.aliyuncs.com
57 59
     bucketName: estateagents
58 60
     bucketURL: https://estateagents.oss-cn-shanghai.aliyuncs.com
61
+  face:
62
+    regionId: cn-shanghai
63
+    domain: face.cn-shanghai.aliyuncs.com
64
+    version: 2018-12-03
65
+    group: default
59 66
 
67
+tencent:
68
+  secretId: AKIDjFV4MN5aHp78sMObJ9i01lmWt2uokw6z
69
+  secretKey: oKhohKlwsSowqa5KM8drpX1FCtLfmhMq
70
+  iai:
71
+    region: ap-shanghai
72
+    group: default