瀏覽代碼

Merge branch 'v4' of http://git.ycjcjy.com/welcome/service-welcome3 into v4

傅行帆 6 年之前
父節點
當前提交
effd8e58a1
共有 66 個文件被更改,包括 1755 次插入618 次删除
  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. 391
    285
      .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. 38
    20
      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. 4
    1
      src/main/java/com.huiju.welcome/controller/TaCarRecordController.java
  22. 14
    0
      src/main/java/com.huiju.welcome/controller/TaCustomerController.java
  23. 6
    2
      src/main/java/com.huiju.welcome/controller/TaFirstUsherRecordController.java
  24. 6
    6
      src/main/java/com.huiju.welcome/controller/TaFirstpageController.java
  25. 28
    53
      src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java
  26. 0
    32
      src/main/java/com.huiju.welcome/controller/TaPersonController.java
  27. 9
    1
      src/main/java/com.huiju.welcome/controller/TaVisitorAppointmentController.java
  28. 8
    8
      src/main/java/com.huiju.welcome/controller/TaWechatUserController.java
  29. 1
    0
      src/main/java/com.huiju.welcome/interceptor/AccessInterceptor.java
  30. 4
    0
      src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java
  31. 1
    1
      src/main/java/com.huiju.welcome/model/SysUser.java
  32. 4
    0
      src/main/java/com.huiju.welcome/model/TaCarRecord.java
  33. 2
    0
      src/main/java/com.huiju.welcome/model/TaDevice.java
  34. 1
    1
      src/main/java/com.huiju.welcome/model/TaFirstpage.java
  35. 7
    0
      src/main/java/com.huiju.welcome/service/ISysParamService.java
  36. 1
    1
      src/main/java/com.huiju.welcome/service/ISysUserService.java
  37. 4
    0
      src/main/java/com.huiju.welcome/service/ITaCarRecordService.java
  38. 18
    6
      src/main/java/com.huiju.welcome/service/ITaCustomerService.java
  39. 9
    0
      src/main/java/com.huiju.welcome/service/ITaFirstUsherRecordService.java
  40. 8
    1
      src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java
  41. 1
    1
      src/main/java/com.huiju.welcome/service/ITaMessageRecordService.java
  42. 4
    0
      src/main/java/com.huiju.welcome/service/ITaPersonService.java
  43. 7
    0
      src/main/java/com.huiju.welcome/service/ITaVisitorAppointmentService.java
  44. 16
    0
      src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java
  45. 33
    0
      src/main/java/com.huiju.welcome/service/impl/SysParamServiceImpl.java
  46. 2
    2
      src/main/java/com.huiju.welcome/service/impl/SysUserServiceImpl.java
  47. 102
    1
      src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java
  48. 194
    54
      src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java
  49. 70
    1
      src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java
  50. 1
    1
      src/main/java/com.huiju.welcome/service/impl/TaFirstpageServiceImpl.java
  51. 129
    10
      src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java
  52. 10
    8
      src/main/java/com.huiju.welcome/service/impl/TaMessageRecordImpl.java
  53. 16
    2
      src/main/java/com.huiju.welcome/service/impl/TaMiniFormidsImpl.java
  54. 41
    0
      src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java
  55. 3
    31
      src/main/java/com.huiju.welcome/service/impl/TaVisitingLogServiceImpl.java
  56. 23
    1
      src/main/java/com.huiju.welcome/service/impl/TaVisitorAppointmentServiceImpl.java
  57. 121
    0
      src/main/java/com.huiju.welcome/utils/AliFaceUtils.java
  58. 5
    5
      src/main/java/com.huiju.welcome/utils/AliOSSUtils.java
  59. 1
    1
      src/main/java/com.huiju.welcome/utils/CommConstant.java
  60. 14
    3
      src/main/java/com.huiju.welcome/utils/MiniApp.java
  61. 2
    3
      src/main/java/com.huiju.welcome/utils/SAWeather.java
  62. 3
    0
      src/main/java/com.huiju.welcome/utils/StatusUtils.java
  63. 102
    0
      src/main/java/com.huiju.welcome/utils/TencentFaceUtils.java
  64. 16
    3
      src/main/resources/application.yml
  65. 14
    0
      src/main/resources/mapper/TaCustomerMapper.xml
  66. 16
    3
      target/classes/application.yml

+ 13
- 0
.idea/libraries/Maven__com_aliyun_aliyun_java_sdk_core_4_1_1.xml 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

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 查看文件

125
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
125
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
126
     <orderEntry type="library" name="Maven: com.aliyun.oss:aliyun-sdk-oss:2.8.3" level="project" />
126
     <orderEntry type="library" name="Maven: com.aliyun.oss:aliyun-sdk-oss:2.8.3" level="project" />
127
     <orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" />
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
   </component>
138
   </component>
129
 </module>
139
 </module>

+ 391
- 285
.idea/workspace.xml
文件差異過大導致無法顯示
查看文件


+ 11
- 0
pom.xml 查看文件

97
 			<artifactId>aliyun-sdk-oss</artifactId>
97
 			<artifactId>aliyun-sdk-oss</artifactId>
98
 			<version>2.8.3</version>
98
 			<version>2.8.3</version>
99
 		</dependency>
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
 	</dependencies>
111
 	</dependencies>
101
 
112
 
102
 	<build>
113
 	<build>

+ 0
- 2
src/main/java/com.huiju.welcome/common/WebSocketServer.java 查看文件

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

+ 0
- 34
src/main/java/com.huiju.welcome/config/AliOSSProperties.java 查看文件

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 查看文件

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 查看文件

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
+}

+ 38
- 20
src/main/java/com.huiju.welcome/controller/CameraController.java 查看文件

74
 	@Autowired
74
 	@Autowired
75
 	private ITaCustomerService iTaCustomerService;
75
 	private ITaCustomerService iTaCustomerService;
76
 
76
 
77
+	@Autowired
78
+	private ITaCarRecordService iTaCarRecordService;
79
+
77
 	@Autowired
80
 	@Autowired
78
 	private XFYun xfYun;
81
 	private XFYun xfYun;
79
 	
82
 	
111
 		taSnapshotPerson.setCreateDate(LocalDateTime.now());
114
 		taSnapshotPerson.setCreateDate(LocalDateTime.now());
112
 
115
 
113
 		// 人像质量最低值, 低于这个值的认为人脸抓拍失败, 取值范围 1 - 100
116
 		// 人像质量最低值, 低于这个值的认为人脸抓拍失败, 取值范围 1 - 100
114
-		SysParam faceMinScoreParam = iSysParamService.getById("face-min-score");
115
-		if (null == faceMinScoreParam) {
116
-			faceMinScoreParam = new SysParam();
117
-			faceMinScoreParam.setValue("70");
118
-		}
119
-		float faceMinScore = Float.parseFloat(faceMinScoreParam.getValue());
117
+		Float faceMinScore = iSysParamService.getFaceMinScore();
120
 
118
 
121
 		Integer score = taSnapshotPerson.getScore();
119
 		Integer score = taSnapshotPerson.getScore();
122
 		if (null == score || score.intValue() < faceMinScore) {
120
 		if (null == score || score.intValue() < faceMinScore) {
125
 
123
 
126
 		// 人脸相似度阈值, 低于设定认为没有识别成功
124
 		// 人脸相似度阈值, 低于设定认为没有识别成功
127
 		// SDK 中这个值范围是 0.001 - 1, 本系统设定范围是 1 - 100
125
 		// SDK 中这个值范围是 0.001 - 1, 本系统设定范围是 1 - 100
128
-		SysParam samePersonThresholdParam = iSysParamService.getById("same-person-threshold");
129
-		if (null == samePersonThresholdParam) {
130
-			samePersonThresholdParam = new SysParam();
131
-			samePersonThresholdParam.setValue("70");
132
-		}
133
-		float samePersonThreshold = Float.parseFloat(samePersonThresholdParam.getValue());
126
+		Float samePersonThreshold = iSysParamService.getSamePersonThreshold();
134
 		Float similarity = taSnapshotPerson.getSimilarity();
127
 		Float similarity = taSnapshotPerson.getSimilarity();
135
 
128
 
136
 		// 识别结果
129
 		// 识别结果
148
 
141
 
149
 			if (null != lastTime && sameDevice) {
142
 			if (null != lastTime && sameDevice) {
150
 				// 降噪设定
143
 				// 降噪设定
151
-				SysParam dispatchTimeLimitParam = iSysParamService.getById("dispatch-time-limit");
152
-				if (null == dispatchTimeLimitParam) {
153
-					dispatchTimeLimitParam = new SysParam();
154
-					dispatchTimeLimitParam.setValue("2");
155
-				}
156
-				float dispatchTimeLimit = Float.parseFloat(dispatchTimeLimitParam.getValue());
144
+				Float dispatchTimeLimit = iSysParamService.getDispatchTimeLimit();
157
 
145
 
158
 				// 默认 2 分钟内连续识别的都是垃圾数据
146
 				// 默认 2 分钟内连续识别的都是垃圾数据
159
 				Duration duration = Duration.between(lastTime, taSnapshotPerson.getCreateDate());
147
 				Duration duration = Duration.between(lastTime, taSnapshotPerson.getCreateDate());
194
 	}
182
 	}
195
 
183
 
196
 	@PostMapping(value = "/camera/{deviceId}/car")
184
 	@PostMapping(value = "/camera/{deviceId}/car")
197
-	public ResponseBean car(@PathParam("deviceId") String deviceId, @RequestBody String paramStr) {
198
-		return null;
185
+	public ResponseBean car(
186
+			@PathParam("deviceId") String deviceId,
187
+			@RequestParam("sceneImage") MultipartFile carImage,
188
+			@RequestParam("licenseImage") MultipartFile licenseImage,
189
+			@RequestParam(value = "driverImage", required = false) MultipartFile driverImage,
190
+			@RequestParam(value = "copilotImage", required = false) MultipartFile copilotImage,
191
+			@RequestParam("plateNumber") String plateNumber,
192
+			@RequestParam("color") String color,
193
+			@RequestParam("carModel") String carModel
194
+			) {
195
+
196
+		TaCarRecord taCarRecord = new TaCarRecord();
197
+		taCarRecord.setPlateNumber(plateNumber);
198
+		taCarRecord.setColor(color);
199
+		taCarRecord.setCarModel(carModel);
200
+
201
+		if (null != carImage && !carImage.isEmpty()) {
202
+			taCarRecord.setCarImage(getMultipartFile(carImage));
203
+		}
204
+		if (null != licenseImage && !licenseImage.isEmpty()) {
205
+			taCarRecord.setLicenseImage(getMultipartFile(licenseImage));
206
+		}
207
+		if (null != driverImage && !driverImage.isEmpty()) {
208
+			taCarRecord.setDriverImage(getMultipartFile(driverImage));
209
+		}
210
+		if (null != copilotImage && !copilotImage.isEmpty()) {
211
+			taCarRecord.setCopilotImage(getMultipartFile(copilotImage));
212
+		}
213
+
214
+		iTaCarRecordService.newRecordByDevice(taCarRecord);
215
+
216
+		return ResponseBean.success("");
199
 	}
217
 	}
200
 
218
 
201
 	//推送给前端
219
 	//推送给前端

+ 22
- 28
src/main/java/com.huiju.welcome/controller/ImgController.java 查看文件

1
 package com.huiju.welcome.controller;
1
 package com.huiju.welcome.controller;
2
 
2
 
3
 import com.huiju.welcome.common.base.ResponseBean;
3
 import com.huiju.welcome.common.base.ResponseBean;
4
+import com.huiju.welcome.utils.AliFaceUtils;
4
 import com.huiju.welcome.utils.AliOSSUtils;
5
 import com.huiju.welcome.utils.AliOSSUtils;
6
+import com.huiju.welcome.utils.TencentFaceUtils;
5
 import io.swagger.annotations.ApiOperation;
7
 import io.swagger.annotations.ApiOperation;
6
 import io.swagger.annotations.ApiParam;
8
 import io.swagger.annotations.ApiParam;
7
 import org.apache.http.HttpStatus;
9
 import org.apache.http.HttpStatus;
10
+import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.beans.factory.annotation.Value;
11
 import org.springframework.beans.factory.annotation.Value;
9
 import org.springframework.web.bind.annotation.PostMapping;
12
 import org.springframework.web.bind.annotation.PostMapping;
10
 import org.springframework.web.bind.annotation.RequestMapping;
13
 import org.springframework.web.bind.annotation.RequestMapping;
24
 @RestController
27
 @RestController
25
 @RequestMapping("/")
28
 @RequestMapping("/")
26
 public class ImgController {
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
 	@ApiOperation(value = "图片/视频上传以及获取url", notes = "图片/视频上传以及获取url")
45
 	@ApiOperation(value = "图片/视频上传以及获取url", notes = "图片/视频上传以及获取url")
34
 	@PostMapping(value = "/uploadFile", consumes = "multipart/*", headers = "content-type=multipart/form-data")
46
 	@PostMapping(value = "/uploadFile", consumes = "multipart/*", headers = "content-type=multipart/form-data")
35
 	public ResponseBean uploadFile(@ApiParam(value = "uploadFile" ,required = true) MultipartFile uploadFile){
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
 		try {
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
 	@PostMapping("/miniapp/upload")
58
 	@PostMapping("/miniapp/upload")

+ 6
- 6
src/main/java/com.huiju.welcome/controller/SysUserController.java 查看文件

55
             return responseBean;
55
             return responseBean;
56
         }
56
         }
57
 
57
 
58
-        SysUser sysUser = sysUserService.getDetailByUsername(username);
58
+        SysUser sysUser = sysUserService.getDetailByLoginname(username);
59
         if (null == sysUser) {
59
         if (null == sysUser) {
60
             responseBean.addError(HttpStatus.SC_BAD_REQUEST, "账户或者密码不正确");
60
             responseBean.addError(HttpStatus.SC_BAD_REQUEST, "账户或者密码不正确");
61
             return responseBean;
61
             return responseBean;
118
             @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "每页数量"),
118
             @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "每页数量"),
119
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "name", value = "姓名"),
119
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "name", value = "姓名"),
120
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "phone", value = "手机号"),
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
     @RequestMapping(value = "/sysuser", method = RequestMethod.GET)
123
     @RequestMapping(value = "/sysuser", method = RequestMethod.GET)
124
     public ResponseBean list(
124
     public ResponseBean list(
126
             @RequestParam  Integer pageSize,
126
             @RequestParam  Integer pageSize,
127
             String name,
127
             String name,
128
             String phone,
128
             String phone,
129
-            Integer isSales,
129
+            String identity,
130
             HttpServletRequest request
130
             HttpServletRequest request
131
     ) {
131
     ) {
132
         ResponseBean responseBean = new ResponseBean();
132
         ResponseBean responseBean = new ResponseBean();
139
         queryWrapper.gt("user_id", 1); // 去掉管理员
139
         queryWrapper.gt("user_id", 1); // 去掉管理员
140
 
140
 
141
         if (null != name && !"".equals(name)) {
141
         if (null != name && !"".equals(name)) {
142
-            queryWrapper.like("nickname", name);
142
+            queryWrapper.like("username", name);
143
         }
143
         }
144
 
144
 
145
         if (null != phone && !"".equals(phone)) {
145
         if (null != phone && !"".equals(phone)) {
146
             queryWrapper.eq("phone", phone);
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
         // 取消传递密码字段

+ 4
- 1
src/main/java/com.huiju.welcome/controller/TaCarRecordController.java 查看文件

83
     public ResponseBean update(@RequestBody TaCarRecord taCarRecord, @PathVariable Integer id){
83
     public ResponseBean update(@RequestBody TaCarRecord taCarRecord, @PathVariable Integer id){
84
         ResponseBean responseBean = new ResponseBean();
84
         ResponseBean responseBean = new ResponseBean();
85
         try {
85
         try {
86
-            if (iTaCarRecordService.updateById(taCarRecord)){
86
+
87
+            boolean success = iTaCarRecordService.updateRecordByMiniapp(taCarRecord);
88
+
89
+            if (success){
87
                 responseBean.addSuccess("success");
90
                 responseBean.addSuccess("success");
88
             }else {
91
             }else {
89
                 responseBean.addError("fail");
92
                 responseBean.addError("fail");

+ 14
- 0
src/main/java/com.huiju.welcome/controller/TaCustomerController.java 查看文件

24
 import javax.servlet.http.HttpServletRequest;
24
 import javax.servlet.http.HttpServletRequest;
25
 import java.time.LocalDateTime;
25
 import java.time.LocalDateTime;
26
 import java.util.ArrayList;
26
 import java.util.ArrayList;
27
+import java.util.HashMap;
27
 import java.util.List;
28
 import java.util.List;
29
+import java.util.Map;
28
 
30
 
29
 /**
31
 /**
30
  * <p>
32
  * <p>
195
 
197
 
196
             if (iTaCustomerService.updateById(taCustomer)){
198
             if (iTaCustomerService.updateById(taCustomer)){
197
 
199
 
200
+                // 反更新人员
201
+                iTaPersonService.updateByCustomer(taCustomer);
202
+
198
                 List<TaPerson> group = iTaCustomerService.getGroup(taCustomer.getCustomerId());
203
                 List<TaPerson> group = iTaCustomerService.getGroup(taCustomer.getCustomerId());
199
                 taCustomer.setGroup(group);
204
                 taCustomer.setGroup(group);
200
 
205
 
234
         return responseBean;
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
- 2
src/main/java/com.huiju.welcome/controller/TaFirstUsherRecordController.java 查看文件

43
         ResponseBean responseBean = new ResponseBean();
43
         ResponseBean responseBean = new ResponseBean();
44
         try {
44
         try {
45
             taFirstUsherRecord.setStatus(StatusUtils.Normal);
45
             taFirstUsherRecord.setStatus(StatusUtils.Normal);
46
-            if (iTaFirstUsherRecordService.save(taFirstUsherRecord)){
46
+
47
+            boolean success = iTaFirstUsherRecordService.newRecordByMiniapp(taFirstUsherRecord);
48
+            if (success){
47
                 responseBean.addSuccess(taFirstUsherRecord);
49
                 responseBean.addSuccess(taFirstUsherRecord);
48
             }else {
50
             }else {
49
                 responseBean.addError("fail");
51
                 responseBean.addError("fail");
85
     public ResponseBean update(@RequestBody TaFirstUsherRecord taFirstUsherRecord, @PathVariable Integer id){
87
     public ResponseBean update(@RequestBody TaFirstUsherRecord taFirstUsherRecord, @PathVariable Integer id){
86
         ResponseBean responseBean = new ResponseBean();
88
         ResponseBean responseBean = new ResponseBean();
87
         try {
89
         try {
88
-            if (iTaFirstUsherRecordService.updateById(taFirstUsherRecord)){
90
+
91
+            boolean success = iTaFirstUsherRecordService.updateByMiniapp(taFirstUsherRecord);
92
+            if (success){
89
                 responseBean.addSuccess("success");
93
                 responseBean.addSuccess("success");
90
             }else {
94
             }else {
91
                 responseBean.addError("fail");
95
                 responseBean.addError("fail");

+ 6
- 6
src/main/java/com.huiju.welcome/controller/TaFirstpageController.java 查看文件

223
     @ApiOperation(value = "前端获取指定首屏内容", notes = "前端获取指定首屏内容")
223
     @ApiOperation(value = "前端获取指定首屏内容", notes = "前端获取指定首屏内容")
224
     @ApiImplicitParams({
224
     @ApiImplicitParams({
225
             @ApiImplicitParam(paramType = "path", dataType = "String", name = "deviceId", value = "设备ID"),
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
     @RequestMapping(value = "/screen/fristpage/device/{deviceId}", method = RequestMethod.GET)
228
     @RequestMapping(value = "/screen/fristpage/device/{deviceId}", method = RequestMethod.GET)
229
     public ResponseBean screenGet(@PathVariable String deviceId, HttpServletRequest request,
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
     // getDetail 获取首屏详情
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
         ResponseBean responseBean = new ResponseBean();
236
         ResponseBean responseBean = new ResponseBean();
237
 
237
 
238
         QueryWrapper<TaFirstpage> q = new QueryWrapper<>();
238
         QueryWrapper<TaFirstpage> q = new QueryWrapper<>();
247
             responseBean.addError(HttpStatus.SC_NOT_FOUND, "内容不存在");
247
             responseBean.addError(HttpStatus.SC_NOT_FOUND, "内容不存在");
248
             return responseBean;
248
             return responseBean;
249
         }
249
         }
250
-        //天气值weatherName
251
-        taFirstpage.setWeatherName(weatherName);
250
+        //
251
+        taFirstpage.setCity(city);
252
         // 获取内容
252
         // 获取内容
253
         Map<String, Object> ctt = taFirstpageService.detail(taFirstpage);
253
         Map<String, Object> ctt = taFirstpageService.detail(taFirstpage);
254
         responseBean.addSuccess(ctt);
254
         responseBean.addSuccess(ctt);

+ 28
- 53
src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java 查看文件

1
 package com.huiju.welcome.controller;
1
 package com.huiju.welcome.controller;
2
 
2
 
3
+import com.alibaba.fastjson.JSONObject;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.huiju.welcome.common.base.BaseController;
8
 import com.huiju.welcome.common.base.BaseController;
9
 import com.huiju.welcome.model.TaCustomer;
11
 import com.huiju.welcome.model.TaCustomer;
10
 import com.huiju.welcome.model.TaFollowupRecord;
12
 import com.huiju.welcome.model.TaFollowupRecord;
11
 import com.huiju.welcome.model.TaMainUsherRecord;
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
 import com.huiju.welcome.utils.DateUtils;
15
 import com.huiju.welcome.utils.DateUtils;
17
 import com.huiju.welcome.utils.StatusUtils;
16
 import com.huiju.welcome.utils.StatusUtils;
17
+import com.huiju.welcome.utils.StringUtils;
18
 import org.apache.http.HttpStatus;
18
 import org.apache.http.HttpStatus;
19
 import org.slf4j.Logger;
19
 import org.slf4j.Logger;
20
 import org.slf4j.LoggerFactory;
20
 import org.slf4j.LoggerFactory;
44
     private ITaFollowupRecordService iTaFollowupRecordService;
44
     private ITaFollowupRecordService iTaFollowupRecordService;
45
 
45
 
46
     @Autowired
46
     @Autowired
47
-    private ITaCustomerService iTaCustomerService;
48
-
49
-    @Autowired
50
-    private ISysUserService iSysUserService;
47
+    private ITaPersonService iTaPersonService;
51
 
48
 
52
     /**
49
     /**
53
      * 保存对象
50
      * 保存对象
58
     public ResponseBean save(@RequestBody TaMainUsherRecord taMainUsherRecord){
55
     public ResponseBean save(@RequestBody TaMainUsherRecord taMainUsherRecord){
59
         ResponseBean responseBean = new ResponseBean();
56
         ResponseBean responseBean = new ResponseBean();
60
         try {
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
         }catch (Exception e){
61
         }catch (Exception e){
82
             logger.error("taMainUsherRecordAdd -=- {}",e.toString());
62
             logger.error("taMainUsherRecordAdd -=- {}",e.toString());
83
             responseBean.addError(e.getMessage());
63
             responseBean.addError(e.getMessage());
90
      * @param id  实体ID
70
      * @param id  实体ID
91
      */
71
      */
92
     @ResponseBody
72
     @ResponseBody
93
-    @RequestMapping(value="/mainUsherRecord/{id}", method= RequestMethod.DELETE)
73
+    @RequestMapping(value="/miniapp/mainUsherRecord/{id}/delete", method= RequestMethod.PUT)
94
     public ResponseBean delete(@PathVariable Integer id){
74
     public ResponseBean delete(@PathVariable Integer id){
95
         ResponseBean responseBean = new ResponseBean();
75
         ResponseBean responseBean = new ResponseBean();
96
         try {
76
         try {
97
-            if(iTaMainUsherRecordService.removeById(id)){
98
-                responseBean.addSuccess("success");
99
-            }else {
100
-                responseBean.addError("fail");
101
-            }
77
+            iTaMainUsherRecordService.deleteRecord(id);
102
         }catch (Exception e){
78
         }catch (Exception e){
103
             logger.error("taMainUsherRecordDelete -=- {}",e.toString());
79
             logger.error("taMainUsherRecordDelete -=- {}",e.toString());
104
             responseBean.addError(e.getMessage());
80
             responseBean.addError(e.getMessage());
115
     public ResponseBean update(@RequestBody TaMainUsherRecord taMainUsherRecord, @PathVariable Integer id){
91
     public ResponseBean update(@RequestBody TaMainUsherRecord taMainUsherRecord, @PathVariable Integer id){
116
         ResponseBean responseBean = new ResponseBean();
92
         ResponseBean responseBean = new ResponseBean();
117
         try {
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
         }catch (Exception e){
95
         }catch (Exception e){
139
             logger.error("taMainUsherRecordUpdate -=- {}",e.toString());
96
             logger.error("taMainUsherRecordUpdate -=- {}",e.toString());
140
             responseBean.addError(e.getMessage());
97
             responseBean.addError(e.getMessage());
166
         return responseBean;
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 查看文件

231
         responseBean.addSuccess(person);
231
         responseBean.addSuccess(person);
232
         return responseBean;
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 查看文件

10
 import com.huiju.welcome.common.base.ResponseBean;
10
 import com.huiju.welcome.common.base.ResponseBean;
11
 import com.huiju.welcome.model.TaFirstUsherRecord;
11
 import com.huiju.welcome.model.TaFirstUsherRecord;
12
 import com.huiju.welcome.model.TaVisitorAppointment;
12
 import com.huiju.welcome.model.TaVisitorAppointment;
13
+import com.huiju.welcome.model.TaWechatUser;
13
 import com.huiju.welcome.service.ITaVisitorAppointmentService;
14
 import com.huiju.welcome.service.ITaVisitorAppointmentService;
15
+import com.huiju.welcome.service.ITaWechatUserService;
14
 import com.huiju.welcome.utils.DateUtils;
16
 import com.huiju.welcome.utils.DateUtils;
15
 import com.huiju.welcome.utils.JWTUtils;
17
 import com.huiju.welcome.utils.JWTUtils;
16
 import com.huiju.welcome.utils.StatusUtils;
18
 import com.huiju.welcome.utils.StatusUtils;
26
 import javax.servlet.http.HttpServletRequest;
28
 import javax.servlet.http.HttpServletRequest;
27
 import java.time.LocalDateTime;
29
 import java.time.LocalDateTime;
28
 import java.util.Date;
30
 import java.util.Date;
31
+import java.util.HashMap;
32
+import java.util.Map;
29
 
33
 
30
 /**
34
 /**
31
  * <p>
35
  * <p>
41
     @Autowired
45
     @Autowired
42
     ITaVisitorAppointmentService taVisitorAppointmentService;
46
     ITaVisitorAppointmentService taVisitorAppointmentService;
43
 
47
 
48
+    @Autowired
49
+    ITaWechatUserService iTaWechatUserService;
50
+
44
     @GetMapping("/appointment")
51
     @GetMapping("/appointment")
45
     public ResponseBean list(
52
     public ResponseBean list(
46
             @RequestParam(defaultValue = "1") Integer page,
53
             @RequestParam(defaultValue = "1") Integer page,
80
             return resp;
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
         boolean success = taVisitorAppointmentService.save(taVisitorAppointment);
93
         boolean success = taVisitorAppointmentService.save(taVisitorAppointment);
86
         if (success) {
94
         if (success) {

+ 8
- 8
src/main/java/com.huiju.welcome/controller/TaWechatUserController.java 查看文件

87
 
87
 
88
             boolean success = iTaWechatUserService.save(taWechatUser);
88
             boolean success = iTaWechatUserService.save(taWechatUser);
89
             if (!success) {
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
         TaWechatUser taWechatUser = iTaWechatUserService.getById(Integer.valueOf(userId));
107
         TaWechatUser taWechatUser = iTaWechatUserService.getById(Integer.valueOf(userId));
108
 
108
 
109
         if (null == taWechatUser) {
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
         if (null != taWechatUser.getPersonId()) {
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
         JSONObject params = JSONObject.parseObject(paramStr);
117
         JSONObject params = JSONObject.parseObject(paramStr);
118
         if (null == params) {
118
         if (null == params) {
119
-            ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
119
+            return ResponseBean.error("绑定参数为空或者非法", HttpStatus.SC_BAD_REQUEST);
120
         }
120
         }
121
 
121
 
122
         String phone = params.getString("phone");
122
         String phone = params.getString("phone");
123
         String captcha = params.getString("captcha");
123
         String captcha = params.getString("captcha");
124
 
124
 
125
         if (null == phone || "".equals(phone.trim()) || null == captcha || "".equals(captcha.trim())) {
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
         // todo
129
         // todo
130
         // 先简单验证
130
         // 先简单验证
131
         if (!"1234".equals(captcha)) {
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
         SysUser sysUser = iSysUserService.getByPhone(phone);
135
         SysUser sysUser = iSysUserService.getByPhone(phone);
136
         if (null == sysUser) {
136
         if (null == sysUser) {
137
-            ResponseBean.error("该手机号对应人员不存在", HttpStatus.SC_BAD_REQUEST);
137
+            return ResponseBean.error("该手机号对应人员不存在", HttpStatus.SC_BAD_REQUEST);
138
         }
138
         }
139
 
139
 
140
         taWechatUser.setPersonId(sysUser.getUserId());
140
         taWechatUser.setPersonId(sysUser.getUserId());
141
         boolean success = iTaWechatUserService.updateById(taWechatUser);
141
         boolean success = iTaWechatUserService.updateById(taWechatUser);
142
 
142
 
143
         if (!success) {
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
         Map<String, Object> map = new HashMap<>();
147
         Map<String, Object> map = new HashMap<>();

+ 1
- 0
src/main/java/com.huiju.welcome/interceptor/AccessInterceptor.java 查看文件

36
         "/screen",
36
         "/screen",
37
         "/camera",
37
         "/camera",
38
         "/websocket",
38
         "/websocket",
39
+         "/face",
39
         "/miniapp/login"
40
         "/miniapp/login"
40
     };
41
     };
41
 
42
 

+ 4
- 0
src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java 查看文件

6
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Param;
7
 import org.apache.ibatis.annotations.Param;
8
 
8
 
9
+import java.util.List;
10
+
9
 /**
11
 /**
10
  * <p>
12
  * <p>
11
  *  Mapper 接口
13
  *  Mapper 接口
19
 
21
 
20
     TaCustomer getCustomerOf(@Param("personId") Integer personId, @Param("realId") Integer realId);
22
     TaCustomer getCustomerOf(@Param("personId") Integer personId, @Param("realId") Integer realId);
21
     IPage<TaCustomer> customerPage(IPage<TaCustomer> pg, String customerName, String phone, String platNumber);
23
     IPage<TaCustomer> customerPage(IPage<TaCustomer> pg, String customerName, String phone, String platNumber);
24
+
25
+    List<TaCustomer> getSomeCustMayBe(@Param("plateNumber") String plateNumber, @Param("phone") String phone);
22
 }
26
 }

+ 1
- 1
src/main/java/com.huiju.welcome/model/SysUser.java 查看文件

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

+ 4
- 0
src/main/java/com.huiju.welcome/model/TaCarRecord.java 查看文件

43
 
43
 
44
     private String driverImage;
44
     private String driverImage;
45
 
45
 
46
+    private String copilotImage;
47
+
48
+    private String licenseImage;
49
+
46
     private LocalDateTime createDate;
50
     private LocalDateTime createDate;
47
 
51
 
48
     /**
52
     /**

+ 2
- 0
src/main/java/com.huiju.welcome/model/TaDevice.java 查看文件

39
 
39
 
40
     private String api;
40
     private String api;
41
 
41
 
42
+    private String afr;
43
+
42
     private Integer status;
44
     private Integer status;
43
 
45
 
44
     private LocalDateTime onlineDate;
46
     private LocalDateTime onlineDate;

+ 1
- 1
src/main/java/com.huiju.welcome/model/TaFirstpage.java 查看文件

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

+ 7
- 0
src/main/java/com.huiju.welcome/service/ISysParamService.java 查看文件

13
  */
13
  */
14
 public interface ISysParamService extends IService<SysParam> {
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 查看文件

13
  */
13
  */
14
 public interface ISysUserService extends IService<SysUser> {
14
 public interface ISysUserService extends IService<SysUser> {
15
 
15
 
16
-    SysUser getDetailByUsername(String username);
16
+    SysUser getDetailByLoginname(String username);
17
 
17
 
18
     SysUser getByPhone(String phone);
18
     SysUser getByPhone(String phone);
19
 }
19
 }

+ 4
- 0
src/main/java/com.huiju.welcome/service/ITaCarRecordService.java 查看文件

28
      * @return
28
      * @return
29
      */
29
      */
30
     IPage<TaCarRecord> getPageList(IPage<TaCarRecord> page, String plateNumber, Date recordDate, String customerName, String phone);
30
     IPage<TaCarRecord> getPageList(IPage<TaCarRecord> page, String plateNumber, Date recordDate, String customerName, String phone);
31
+
32
+    boolean newRecordByDevice(TaCarRecord taCarRecord);
33
+
34
+    boolean updateRecordByMiniapp(TaCarRecord taCarRecord);
31
 }
35
 }

+ 18
- 6
src/main/java/com.huiju.welcome/service/ITaCustomerService.java 查看文件

1
 package com.huiju.welcome.service;
1
 package com.huiju.welcome.service;
2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
-import com.huiju.welcome.model.TaCustomer;
5
-import com.huiju.welcome.model.TaMainUsherRecord;
6
-import com.huiju.welcome.model.TaPerson;
4
+import com.huiju.welcome.common.base.ResponseBean;
5
+import com.huiju.welcome.model.*;
7
 
6
 
8
 import java.util.List;
7
 import java.util.List;
9
 import java.util.Map;
8
 import java.util.Map;
16
  * @since 2019-06-12
15
  * @since 2019-06-12
17
  */
16
  */
18
 public interface ITaCustomerService extends IService<TaCustomer> {
17
 public interface ITaCustomerService extends IService<TaCustomer> {
19
-
20
-    TaCustomer newVisitRecord(TaMainUsherRecord taMainUsherRecord) throws Exception;
21
-
22
     List<TaPerson> getGroup(Integer customerId);
18
     List<TaPerson> getGroup(Integer customerId);
23
 
19
 
24
     Map<String, Object> getLastVisitInfo(Integer customerId);
20
     Map<String, Object> getLastVisitInfo(Integer customerId);
26
     void judgeNewCust(TaPerson taPerson) throws Exception;
22
     void judgeNewCust(TaPerson taPerson) throws Exception;
27
 
23
 
28
     void deleteCustOfPerson(Integer personId, Integer realId);
24
     void deleteCustOfPerson(Integer personId, Integer realId);
25
+
26
+    List<TaCustomer> getSomeCustMayBe(String plateNumber);
27
+
28
+    TaCustomer newCustByCarDevice(TaCarRecord taCarRecord, TaVisitorAppointment ...taVisitorAppointment);
29
+
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);
29
 }
41
 }

+ 9
- 0
src/main/java/com.huiju.welcome/service/ITaFirstUsherRecordService.java 查看文件

2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.huiju.welcome.model.TaCarRecord;
5
 import com.huiju.welcome.model.TaFirstUsherRecord;
6
 import com.huiju.welcome.model.TaFirstUsherRecord;
6
 
7
 
7
 import java.util.List;
8
 import java.util.List;
23
     IPage<TaFirstUsherRecord> taFirstUsherRecordlist(IPage<TaFirstUsherRecord> pg,String plateNumber, String visiteDate);
24
     IPage<TaFirstUsherRecord> taFirstUsherRecordlist(IPage<TaFirstUsherRecord> pg,String plateNumber, String visiteDate);
24
 
25
 
25
     boolean updateNormal(List<TaFirstUsherRecord> records);
26
     boolean updateNormal(List<TaFirstUsherRecord> records);
27
+
28
+    TaFirstUsherRecord newRecordByDevice(TaCarRecord taCarRecord);
29
+
30
+    void notifyMiniapp(TaFirstUsherRecord taFirstUsherRecord);
31
+
32
+    boolean newRecordByMiniapp(TaFirstUsherRecord taFirstUsherRecord);
33
+
34
+    boolean updateByMiniapp(TaFirstUsherRecord taFirstUsherRecord);
26
 }
35
 }

+ 8
- 1
src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java 查看文件

5
 import com.huiju.welcome.common.base.ResponseBean;
5
 import com.huiju.welcome.common.base.ResponseBean;
6
 import com.huiju.welcome.model.TaCustomer;
6
 import com.huiju.welcome.model.TaCustomer;
7
 import com.huiju.welcome.model.TaMainUsherRecord;
7
 import com.huiju.welcome.model.TaMainUsherRecord;
8
+import com.huiju.welcome.model.TaPerson;
8
 
9
 
9
 import java.util.List;
10
 import java.util.List;
10
 
11
 
22
 
23
 
23
     void notifyConsultant(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception;
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
     boolean newRecordByConsultant(TaCustomer taCustomer);
28
     boolean newRecordByConsultant(TaCustomer taCustomer);
28
     IPage<TaMainUsherRecord> taMainUsherRecordList(IPage<TaMainUsherRecord> pg,String phone,String platNumber,String personName,Integer appointment);
29
     IPage<TaMainUsherRecord> taMainUsherRecordList(IPage<TaMainUsherRecord> pg,String phone,String platNumber,String personName,Integer appointment);
32
      * @return
33
      * @return
33
      */
34
      */
34
     ResponseBean customerPage(int pageNum, int pageSize, String customerName, String phone, String platNumber);
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 查看文件

6
 import java.util.List;
6
 import java.util.List;
7
 
7
 
8
 public interface ITaMessageRecordService extends IService<TaMessageRecord> {
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 查看文件

52
     TaPerson newPersonByFront(TaCustomer taCustomer);
52
     TaPerson newPersonByFront(TaCustomer taCustomer);
53
 
53
 
54
     TaPerson newPersonByUsher(TaMainUsherRecord taMainUsherRecord);
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 查看文件

5
 import com.huiju.welcome.common.base.ResponseBean;
5
 import com.huiju.welcome.common.base.ResponseBean;
6
 import com.huiju.welcome.model.TaVisitorAppointment;
6
 import com.huiju.welcome.model.TaVisitorAppointment;
7
 
7
 
8
+import java.util.List;
9
+import java.util.Map;
10
+
8
 /**
11
 /**
9
  * <p>
12
  * <p>
10
  *  服务类
13
  *  服务类
23
      * @return
26
      * @return
24
      */
27
      */
25
     ResponseBean visitorAppointmentList(IPage<TaVisitorAppointment> pg, String platNumber,String personName,String phone);
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 查看文件

9
 import com.huiju.welcome.service.ITaDeviceService;
9
 import com.huiju.welcome.service.ITaDeviceService;
10
 import com.huiju.welcome.utils.Encrypt;
10
 import com.huiju.welcome.utils.Encrypt;
11
 import com.huiju.welcome.utils.StatusUtils;
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
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.stereotype.Service;
16
 import org.springframework.stereotype.Service;
14
 
17
 
19
 import java.util.List;
22
 import java.util.List;
20
 import java.util.Map;
23
 import java.util.Map;
21
 
24
 
25
+@Slf4j
22
 @Service
26
 @Service
23
 public class CameraServiceImpl implements ICameraService {
27
 public class CameraServiceImpl implements ICameraService {
24
     @Autowired
28
     @Autowired
25
     private ITaDeviceService taDeviceService;
29
     private ITaDeviceService taDeviceService;
26
 
30
 
31
+    @Autowired
32
+    TencentFaceUtils tencentFaceUtils;
33
+
27
     @Override
34
     @Override
28
     public String dispatchPerson(TaPerson taPerson, TaDevice... devices) {
35
     public String dispatchPerson(TaPerson taPerson, TaDevice... devices) {
29
         List<TaDevice> taDeviceList = null;
36
         List<TaDevice> taDeviceList = null;
30
         if (null == devices || devices.length == 0) {
37
         if (null == devices || devices.length == 0) {
31
             QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
38
             QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
32
             queryWrapper.eq("status",StatusUtils.Normal);
39
             queryWrapper.eq("status",StatusUtils.Normal);
40
+            queryWrapper.eq("afr",StatusUtils.BoolTrue);
33
             taDeviceList = taDeviceService.list(queryWrapper);
41
             taDeviceList = taDeviceService.list(queryWrapper);
34
         } else {
42
         } else {
35
             taDeviceList = Arrays.asList(devices);
43
             taDeviceList = Arrays.asList(devices);
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
         return "";
70
         return "";
55
     }
71
     }
56
 }
72
 }

+ 33
- 0
src/main/java/com.huiju.welcome/service/impl/SysParamServiceImpl.java 查看文件

4
 import com.huiju.welcome.mapper.SysParamMapper;
4
 import com.huiju.welcome.mapper.SysParamMapper;
5
 import com.huiju.welcome.model.SysParam;
5
 import com.huiju.welcome.model.SysParam;
6
 import com.huiju.welcome.service.ISysParamService;
6
 import com.huiju.welcome.service.ISysParamService;
7
+import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.stereotype.Service;
8
 import org.springframework.stereotype.Service;
8
 
9
 
9
 /**
10
 /**
16
  */
17
  */
17
 @Service
18
 @Service
18
 public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, SysParam> implements ISysParamService {
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 查看文件

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

+ 102
- 1
src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java 查看文件

4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
 import com.huiju.welcome.mapper.TaCarRecordMapper;
5
 import com.huiju.welcome.mapper.TaCarRecordMapper;
6
 import com.huiju.welcome.model.TaCarRecord;
6
 import com.huiju.welcome.model.TaCarRecord;
7
-import com.huiju.welcome.service.ITaCarRecordService;
7
+import com.huiju.welcome.model.TaCustomer;
8
+import com.huiju.welcome.model.TaFirstUsherRecord;
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;
14
+import org.slf4j.Logger;
15
+import org.slf4j.LoggerFactory;
8
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
9
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
10
 
18
 
11
 import java.time.LocalDate;
19
 import java.time.LocalDate;
12
 import java.time.LocalDateTime;
20
 import java.time.LocalDateTime;
13
 import java.util.Date;
21
 import java.util.Date;
22
+import java.util.List;
14
 
23
 
15
 /**
24
 /**
16
  * <p>
25
  * <p>
22
  */
31
  */
23
 @Service
32
 @Service
24
 public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCarRecord> implements ITaCarRecordService {
33
 public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCarRecord> implements ITaCarRecordService {
34
+    Logger log = LoggerFactory.getLogger(TaCarRecordServiceImpl.class);
25
 
35
 
26
     @Autowired
36
     @Autowired
27
     private TaCarRecordMapper taCarRecordMapper;
37
     private TaCarRecordMapper taCarRecordMapper;
28
 
38
 
39
+    @Autowired
40
+    private ITaFirstUsherRecordService iTaFirstUsherRecordService;
41
+
42
+    @Autowired
43
+    private ITaCustomerService iTaCustomerService;
44
+
45
+    @Autowired
46
+    private TencentFaceUtils tencentFaceUtils;
47
+
48
+    @Autowired
49
+    private ISysParamService iSysParamService;
50
+
51
+    @Autowired
52
+    private ITaVisitorAppointmentService iTaVisitorAppointmentService;
53
+
29
     @Override
54
     @Override
30
     public IPage<TaCarRecord> getPageList(IPage<TaCarRecord> page, String plateNumber, Date recordDate, String customerName, String phone) {
55
     public IPage<TaCarRecord> getPageList(IPage<TaCarRecord> page, String plateNumber, Date recordDate, String customerName, String phone) {
31
         return taCarRecordMapper.getPageList(page, plateNumber, recordDate, customerName, phone);
56
         return taCarRecordMapper.getPageList(page, plateNumber, recordDate, customerName, phone);
32
     }
57
     }
58
+
59
+    /**
60
+     * 车辆抓拍之后
61
+     * @param taCarRecord
62
+     * @return
63
+     */
64
+    @Override
65
+    public boolean newRecordByDevice(TaCarRecord taCarRecord) {
66
+        // 先入库
67
+        taCarRecordMapper.insert(taCarRecord);
68
+
69
+        // 到客户中查询是否有相关人员
70
+        TaCustomer taCustomer = null;
71
+        List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(taCarRecord.getPlateNumber());
72
+
73
+        // 如果没有对应人员
74
+        if (null == taCustomerList || taCustomerList.size() == 0) {
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
+            }
108
+        } else {
109
+            // 对应客户, 先随机取一条
110
+            taCustomer = taCustomerList.get(0);
111
+        }
112
+
113
+        // 生成保安迎宾记录, 并通知小程序
114
+        TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord);
115
+        iTaFirstUsherRecordService.notifyMiniapp(taFirstUsherRecord);
116
+
117
+        // 如果客户有固定置业, 推送消息给置业
118
+        if (null != taCustomer.getConsultantId()) {
119
+            try {
120
+                iTaCustomerService.notifyConsultant(taCustomer);
121
+            } catch (Exception e) {
122
+                log.error("发送消息给置业失败: {}", e.getMessage());
123
+            }
124
+        }
125
+
126
+        return false;
127
+    }
128
+
129
+    @Override
130
+    public boolean updateRecordByMiniapp(TaCarRecord taCarRecord) {
131
+        // 先暂时只做更新动作
132
+        return taCarRecordMapper.updateById(taCarRecord) > 0;
133
+    }
33
 }
134
 }

+ 194
- 54
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java 查看文件

3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.model.TaCustomer;
10
-import com.huiju.welcome.model.TaCustomerMap;
11
-import com.huiju.welcome.model.TaMainUsherRecord;
12
-import com.huiju.welcome.model.TaPerson;
6
+import com.huiju.welcome.common.base.ResponseBean;
7
+import com.huiju.welcome.mapper.*;
8
+import com.huiju.welcome.model.*;
13
 import com.huiju.welcome.service.ITaCustomerService;
9
 import com.huiju.welcome.service.ITaCustomerService;
14
 import com.huiju.welcome.service.ITaMainUsherRecordService;
10
 import com.huiju.welcome.service.ITaMainUsherRecordService;
15
 import com.huiju.welcome.service.ITaPersonService;
11
 import com.huiju.welcome.service.ITaPersonService;
12
+import com.huiju.welcome.service.ITaVisitorAppointmentService;
13
+import com.huiju.welcome.utils.CommConstant;
16
 import com.huiju.welcome.utils.MiniApp;
14
 import com.huiju.welcome.utils.MiniApp;
17
 import com.huiju.welcome.utils.StatusUtils;
15
 import com.huiju.welcome.utils.StatusUtils;
16
+import com.huiju.welcome.utils.StringUtils;
17
+import org.slf4j.Logger;
18
+import org.slf4j.LoggerFactory;
18
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.stereotype.Service;
20
 import org.springframework.stereotype.Service;
20
 
21
 
21
 import java.time.LocalDateTime;
22
 import java.time.LocalDateTime;
23
+import java.util.ArrayList;
24
+import java.util.HashMap;
22
 import java.util.List;
25
 import java.util.List;
23
 import java.util.Map;
26
 import java.util.Map;
24
 
27
 
32
  */
35
  */
33
 @Service
36
 @Service
34
 public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCustomer> implements ITaCustomerService {
37
 public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCustomer> implements ITaCustomerService {
38
+    Logger log = LoggerFactory.getLogger(TaCustomerServiceImpl.class);
39
+
35
     @Autowired
40
     @Autowired
36
     TaCustomerMapper taCustomerMapper;
41
     TaCustomerMapper taCustomerMapper;
37
 
42
 
48
     ITaMainUsherRecordService iTaMainUsherRecordService;
53
     ITaMainUsherRecordService iTaMainUsherRecordService;
49
 
54
 
50
     @Autowired
55
     @Autowired
51
-    MiniApp miniApp;
52
-
53
-    @Override
54
-    public TaCustomer newVisitRecord(TaMainUsherRecord taMainUsherRecord) throws Exception {
55
-        Integer personId = taMainUsherRecord.getPersonId();
56
-        if (null == personId) {
57
-            TaPerson taPerson = iTaPersonService.newPersonByUsher(taMainUsherRecord);
58
-            personId = taPerson.getRealId();
59
-            taMainUsherRecord.setPersonId(personId);
60
-        }
61
-
62
-        Integer custId = taMainUsherRecord.getCustomerId();
63
-        TaCustomer cust;
64
-        if (null == custId) {
65
-            cust = newCustomerFromMainUsher(taMainUsherRecord);
66
-            if (null == cust) {
67
-                throw new Exception("生成置业客户失败");
68
-            }
69
-            taMainUsherRecord.setCustomerId(cust.getCustomerId());
70
-        } else {
71
-            cust = taCustomerMapper.selectById(custId);
72
-        }
56
+    ITaVisitorAppointmentService iTaVisitorAppointmentService;
73
 
57
 
74
-        TaCustomerMap taCustomerMap = taCustomerMapMapper.getCustomerOf(personId);
75
-        if (null == taCustomerMap) {
76
-            TaCustomerMap custMap = new TaCustomerMap();
77
-            custMap.setCustomerId(cust.getCustomerId());
78
-            custMap.setPersonId(taMainUsherRecord.getPersonId());
58
+    @Autowired
59
+    TaWechatUserMapper taWechatUserMapper;
79
 
60
 
80
-            int row = taCustomerMapMapper.insert(custMap);
81
-            if (row <= 0) {
82
-                throw new Exception("生成置业客户映射失败");
83
-            }
84
-        }
61
+    @Autowired
62
+    SysUserMapper sysUserMapper;
85
 
63
 
86
-        return cust;
87
-    }
64
+    @Autowired
65
+    MiniApp miniApp;
88
 
66
 
89
     @Override
67
     @Override
90
     public List<TaPerson> getGroup(Integer customerId) {
68
     public List<TaPerson> getGroup(Integer customerId) {
100
     public void judgeNewCust(TaPerson taPerson) throws Exception {
78
     public void judgeNewCust(TaPerson taPerson) throws Exception {
101
         // 首先判定这个人 2 小时内是否来访过
79
         // 首先判定这个人 2 小时内是否来访过
102
         LocalDateTime dt = LocalDateTime.now().minusHours(2);
80
         LocalDateTime dt = LocalDateTime.now().minusHours(2);
103
-        List<TaMainUsherRecord> lastList = taMainUsherRecordMapper.getLastList(taPerson.getPersonId(), dt);
81
+        List<TaMainUsherRecord> lastList = taMainUsherRecordMapper.getLastList(taPerson.getRealId(), dt);
104
         if (null != lastList && lastList.size() > 0) return;
82
         if (null != lastList && lastList.size() > 0) return;
105
 
83
 
106
-        LocalDateTime now = LocalDateTime.now();
107
-
108
         // 查询是否有映射客户 - 如果有多个映射客户, 先随机取一条
84
         // 查询是否有映射客户 - 如果有多个映射客户, 先随机取一条
109
         // 暂时没有找到好的替代方案
85
         // 暂时没有找到好的替代方案
110
         TaCustomer taCustomer = taCustomerMapper.getCustomerOf(taPerson.getPersonId(), taPerson.getRealId());
86
         TaCustomer taCustomer = taCustomerMapper.getCustomerOf(taPerson.getPersonId(), taPerson.getRealId());
115
         }
91
         }
116
 
92
 
117
         // 新增前台记录
93
         // 新增前台记录
118
-        iTaMainUsherRecordService.newRecordByDevice(taCustomer);
119
-
94
+        iTaMainUsherRecordService.newRecordByDevice(taCustomer, taPerson);
120
         return;
95
         return;
121
     }
96
     }
122
 
97
 
135
         taCustomerMapper.update(new TaCustomer(), updateWrapper);
110
         taCustomerMapper.update(new TaCustomer(), updateWrapper);
136
     }
111
     }
137
 
112
 
113
+    @Override
114
+    public List<TaCustomer> getSomeCustMayBe(String plateNumber) {
115
+        return taCustomerMapper.getSomeCustMayBe(plateNumber, null);
116
+    }
117
+
118
+    @Override
119
+    public TaCustomer newCustByCarDevice(TaCarRecord taCarRecord, TaVisitorAppointment ...taVisitorAppointments) {
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;
125
+
126
+        taCustomer.setCreateDate(LocalDateTime.now());
127
+        taCustomer.setStatus(StatusUtils.Normal);
128
+        taCustomer.setCustomerName(name);
129
+        taCustomer.setPhone(phone);
130
+        taCustomer.setAvatar(taCarRecord.getLicenseImage());
131
+        taCustomer.setCarModel(taCarRecord.getCarModel());
132
+        taCustomer.setPlateNumber(taCarRecord.getPlateNumber());
133
+
134
+        TaPerson taPerson = iTaPersonService.newPersonByFront(taCustomer);
135
+        taCustomer.setCustomerId(taPerson.getRealId());
136
+
137
+        TaCustomerMap customerMap = new TaCustomerMap();
138
+        customerMap.setCustomerId(taCustomer.getCustomerId());
139
+        customerMap.setPersonId(taPerson.getPersonId());
140
+
141
+        taCustomerMapMapper.insert(customerMap);
142
+
143
+        insertCustomer(taCustomer);
144
+
145
+        return taCustomer;
146
+    }
147
+
148
+    @Override
149
+    public void notifyConsultant(TaCustomer taCustomer) throws Exception {
150
+        String tpl = miniApp.getTpls().getVisitor();
151
+        String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + taCustomer.getCustomerId();
152
+        String openid = taWechatUserMapper.getOpenidOf(taCustomer.getConsultantId(), CommConstant.WECHAT_CLIENT_MINIAPP);
153
+        if (null == openid) {
154
+            throw new Exception("发送消息给置业失败, 当前置业[" + taCustomer.getConsultantId() + "]未绑定小程序账号");
155
+        }
156
+        List<Object> data = new ArrayList<Object>(){{
157
+            add(taCustomer.getCustomerName());
158
+            add(taCustomer.getPhone());
159
+            add("您有客户来访, 请及时接待!");
160
+        }};
161
+
162
+        miniApp.sendTPLMessage(tpl, openid, page, data);
163
+    }
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
+
138
     private TaCustomer newCustomerByPerson(TaPerson taPerson) throws Exception {
271
     private TaCustomer newCustomerByPerson(TaPerson taPerson) throws Exception {
139
         TaCustomer taCustomer = new TaCustomer();
272
         TaCustomer taCustomer = new TaCustomer();
140
         taCustomer.setCustomerId(taPerson.getRealId());
273
         taCustomer.setCustomerId(taPerson.getRealId());
144
         taCustomer.setCustomerName(taPerson.getName());
277
         taCustomer.setCustomerName(taPerson.getName());
145
         taCustomer.setCreateDate(LocalDateTime.now());
278
         taCustomer.setCreateDate(LocalDateTime.now());
146
         taCustomer.setStatus(StatusUtils.Normal);
279
         taCustomer.setStatus(StatusUtils.Normal);
147
-        int row = taCustomerMapper.insert(taCustomer);
148
 
280
 
149
-        if (row < 1) {
150
-            throw new Exception("新增客户信息失败");
281
+        if (!insertCustomer(taCustomer)) {
282
+            throw new Exception("新增客户失败");
151
         }
283
         }
152
 
284
 
153
         int mapsNum = taPerson.getPersonId().equals(taPerson.getRealId()) ? 1 : 2;
285
         int mapsNum = taPerson.getPersonId().equals(taPerson.getRealId()) ? 1 : 2;
156
             TaCustomerMap custMap = new TaCustomerMap();
288
             TaCustomerMap custMap = new TaCustomerMap();
157
             custMap.setPersonId(i == 0 ? taPerson.getRealId() : taPerson.getPersonId());
289
             custMap.setPersonId(i == 0 ? taPerson.getRealId() : taPerson.getPersonId());
158
             custMap.setCustomerId(taCustomer.getCustomerId());
290
             custMap.setCustomerId(taCustomer.getCustomerId());
159
-            row = taCustomerMapMapper.insert(custMap);
291
+            int row = taCustomerMapMapper.insert(custMap);
160
             if (row < 1) {
292
             if (row < 1) {
161
                 throw new Exception("新增客户映射信息失败");
293
                 throw new Exception("新增客户映射信息失败");
162
             }
294
             }
165
         return taCustomer;
297
         return taCustomer;
166
     }
298
     }
167
 
299
 
168
-    private TaCustomer newCustomerFromMainUsher(TaMainUsherRecord taMainUsherRecord) {
300
+    private TaCustomer copyDataFromMainUsher(TaMainUsherRecord taMainUsherRecord) {
169
         TaCustomer taCustomer = new TaCustomer();
301
         TaCustomer taCustomer = new TaCustomer();
170
         taCustomer.setCustomerId(taMainUsherRecord.getPersonId());       // 默认客户ID与人员ID一致
302
         taCustomer.setCustomerId(taMainUsherRecord.getPersonId());       // 默认客户ID与人员ID一致
171
         taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
303
         taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
181
         taCustomer.setStatus(StatusUtils.Normal);
313
         taCustomer.setStatus(StatusUtils.Normal);
182
         taCustomer.setCreateDate(LocalDateTime.now());
314
         taCustomer.setCreateDate(LocalDateTime.now());
183
 
315
 
184
-        int row = taCustomerMapper.insert(taCustomer);
185
-        if (row < 1) return null;
186
-
187
         return taCustomer;
316
         return taCustomer;
188
     }
317
     }
189
 
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
+
190
 }
330
 }

+ 70
- 1
src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java 查看文件

1
 package com.huiju.welcome.service.impl;
1
 package com.huiju.welcome.service.impl;
2
 
2
 
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.alibaba.fastjson.serializer.SerializerFeature;
3
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.huiju.welcome.common.Action;
9
+import com.huiju.welcome.common.WebSocketServer;
6
 import com.huiju.welcome.mapper.TaFirstUsherRecordMapper;
10
 import com.huiju.welcome.mapper.TaFirstUsherRecordMapper;
11
+import com.huiju.welcome.model.TaCarRecord;
12
+import com.huiju.welcome.model.TaCustomer;
7
 import com.huiju.welcome.model.TaFirstUsherRecord;
13
 import com.huiju.welcome.model.TaFirstUsherRecord;
14
+import com.huiju.welcome.service.ITaCustomerService;
8
 import com.huiju.welcome.service.ITaFirstUsherRecordService;
15
 import com.huiju.welcome.service.ITaFirstUsherRecordService;
16
+import com.huiju.welcome.utils.CommConstant;
9
 import com.huiju.welcome.utils.StatusUtils;
17
 import com.huiju.welcome.utils.StatusUtils;
18
+import com.huiju.welcome.utils.StringUtils;
10
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.stereotype.Service;
20
 import org.springframework.stereotype.Service;
12
 
21
 
22
+import java.time.LocalDateTime;
13
 import java.util.ArrayList;
23
 import java.util.ArrayList;
14
 import java.util.List;
24
 import java.util.List;
15
 
25
 
26
     @Autowired
36
     @Autowired
27
     TaFirstUsherRecordMapper taFirstUsherRecordMapper;
37
     TaFirstUsherRecordMapper taFirstUsherRecordMapper;
28
 
38
 
39
+    @Autowired
40
+    ITaCustomerService iTaCustomerService;
41
+
29
     @Override
42
     @Override
30
     public boolean updateNormal(List<TaFirstUsherRecord> records) {
43
     public boolean updateNormal(List<TaFirstUsherRecord> records) {
31
         if (records == null || records.size() == 0) return true;
44
         if (records == null || records.size() == 0) return true;
42
         int row = taFirstUsherRecordMapper.update(new TaFirstUsherRecord(), wrapper);
55
         int row = taFirstUsherRecordMapper.update(new TaFirstUsherRecord(), wrapper);
43
         return row >= 0;
56
         return row >= 0;
44
     }
57
     }
45
-    
58
+
59
+    @Override
60
+    public TaFirstUsherRecord newRecordByDevice(TaCarRecord taCarRecord) {
61
+        TaFirstUsherRecord taFirstUsherRecord = new TaFirstUsherRecord();
62
+        taFirstUsherRecord.setStatus(StatusUtils.Ready);
63
+        taFirstUsherRecord.setCarImage(taCarRecord.getCarImage());
64
+        taFirstUsherRecord.setCarModel(taCarRecord.getCarModel());
65
+        taFirstUsherRecord.setColor(taCarRecord.getColor());
66
+        taFirstUsherRecord.setCarRecord(taCarRecord.getSerialNo());
67
+        taFirstUsherRecord.setPlateNumber(taCarRecord.getPlateNumber());
68
+        taFirstUsherRecord.setVisiteDate(LocalDateTime.now());
69
+
70
+        taFirstUsherRecordMapper.insert(taFirstUsherRecord);
71
+
72
+        return taFirstUsherRecord;
73
+    }
74
+
75
+    @Override
76
+    public void notifyMiniapp(TaFirstUsherRecord taFirstUsherRecord) {
77
+        Action act = Action.create(Action.TYPE_NEW_FIRST_USHER, JSONObject.toJSONString(taFirstUsherRecord, SerializerFeature.WriteMapNullValue));
78
+        try {
79
+            WebSocketServer.sendInfo(act.toJSON(), CommConstant.WECHAT_CLIENT_MINIAPP, null);
80
+        } catch (Exception e) {}
81
+    }
82
+
83
+    @Override
84
+    public boolean newRecordByMiniapp(TaFirstUsherRecord taFirstUsherRecord) {
85
+        notifyConsultant(taFirstUsherRecord);
86
+        int row = taFirstUsherRecordMapper.insert(taFirstUsherRecord);
87
+
88
+        return row > 0;
89
+    }
90
+
91
+    @Override
92
+    public boolean updateByMiniapp(TaFirstUsherRecord taFirstUsherRecord) {
93
+        notifyConsultant(taFirstUsherRecord);
94
+        int row = taFirstUsherRecordMapper.updateById(taFirstUsherRecord);
95
+        return row > 0;
96
+    }
97
+
98
+    private void notifyConsultant(TaFirstUsherRecord taFirstUsherRecord) {
99
+        String plateNumber = taFirstUsherRecord.getPlateNumber();
100
+
101
+        // 依据车牌判断是否老客户来访
102
+        if (!StringUtils.isEmpty(plateNumber)) {
103
+            List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(plateNumber);
104
+
105
+            // 一个车牌对应多个客户, 先随机找一条数据
106
+            if (null != taCustomerList && taCustomerList.size() > 0) {
107
+                TaCustomer taCustomer = taCustomerList.get(0);
108
+                try {
109
+                    iTaCustomerService.notifyConsultant(taCustomer);
110
+                } catch (Exception e) {}
111
+            }
112
+        }
113
+    }
114
+
46
     @Override
115
     @Override
47
     public IPage<TaFirstUsherRecord> taFirstUsherRecordlist(IPage pg,String plateNumber, String visiteDate) {
116
     public IPage<TaFirstUsherRecord> taFirstUsherRecordlist(IPage pg,String plateNumber, String visiteDate) {
48
         IPage<TaFirstUsherRecord> pageTaFirstUsherRecord= taFirstUsherRecordMapper.taFirstUsherRecordlist(pg,plateNumber,visiteDate);
117
         IPage<TaFirstUsherRecord> pageTaFirstUsherRecord= taFirstUsherRecordMapper.taFirstUsherRecordlist(pg,plateNumber,visiteDate);

+ 1
- 1
src/main/java/com.huiju.welcome/service/impl/TaFirstpageServiceImpl.java 查看文件

43
 
43
 
44
         // 获取天气
44
         // 获取天气
45
         if (taFirstpage.getWeatherShow()) {
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
- 10
src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java 查看文件

1
 package com.huiju.welcome.service.impl;
1
 package com.huiju.welcome.service.impl;
2
 
2
 
3
 import com.alibaba.fastjson.JSONObject;
3
 import com.alibaba.fastjson.JSONObject;
4
+import com.alibaba.fastjson.serializer.SerializerFeature;
4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
14
 import com.huiju.welcome.model.*;
15
 import com.huiju.welcome.model.*;
15
 import com.huiju.welcome.common.base.ResponseBean;
16
 import com.huiju.welcome.common.base.ResponseBean;
16
 import com.huiju.welcome.mapper.TaCustomerMapper;
17
 import com.huiju.welcome.mapper.TaCustomerMapper;
17
-import com.huiju.welcome.mapper.TaMainUsherRecordMapper;
18
 import com.huiju.welcome.model.TaCustomer;
18
 import com.huiju.welcome.model.TaCustomer;
19
 import com.huiju.welcome.model.TaMainUsherRecord;
19
 import com.huiju.welcome.model.TaMainUsherRecord;
20
+import com.huiju.welcome.service.ITaCustomerService;
20
 import com.huiju.welcome.service.ITaMainUsherRecordService;
21
 import com.huiju.welcome.service.ITaMainUsherRecordService;
21
 import com.huiju.welcome.utils.CommConstant;
22
 import com.huiju.welcome.utils.CommConstant;
22
 import com.huiju.welcome.utils.MiniApp;
23
 import com.huiju.welcome.utils.MiniApp;
54
     @Autowired
55
     @Autowired
55
     SysUserMapper sysUserMapper;
56
     SysUserMapper sysUserMapper;
56
 
57
 
58
+    @Autowired
59
+    ITaCustomerService iTaCustomerService;
60
+
57
     @Autowired
61
     @Autowired
58
     MiniApp miniApp;
62
     MiniApp miniApp;
59
 
63
 
66
             recs.add(rec.getRecId());
70
             recs.add(rec.getRecId());
67
         }
71
         }
68
 
72
 
69
-        UpdateWrapper<TaMainUsherRecord> wrapper = new UpdateWrapper();
73
+        UpdateWrapper<TaMainUsherRecord> wrapper = new UpdateWrapper<>();
70
         wrapper.set("status", StatusUtils.Normal);
74
         wrapper.set("status", StatusUtils.Normal);
71
         wrapper.in("rec_id", recs);
75
         wrapper.in("rec_id", recs);
72
 
76
 
75
     }
79
     }
76
 
80
 
77
     @Override
81
     @Override
78
-    public boolean newRecordByDevice(TaCustomer taCustomer) {
82
+    public boolean newRecordByDevice(TaCustomer taCustomer, TaPerson taPerson) {
79
         TaMainUsherRecord taMainUsherRecord = newRecordByCust(taCustomer);
83
         TaMainUsherRecord taMainUsherRecord = newRecordByCust(taCustomer);
84
+        taMainUsherRecord.setStatus(StatusUtils.Ready);
85
+        taMainUsherRecord.setPersonId(taPerson.getRealId());
80
         int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
86
         int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
81
 
87
 
82
         try {
88
         try {
83
-            Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord));
84
-            WebSocketServer.sendInfo(act.toJSON(), "miniapp", null);
85
-        } 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();}
86
 
92
 
87
         // 通知对应的置业
93
         // 通知对应的置业
88
         if (null != taCustomer.getConsultantId()) {
94
         if (null != taCustomer.getConsultantId()) {
89
             try {
95
             try {
90
                 notifyConsultant(taMainUsherRecord, taCustomer);
96
                 notifyConsultant(taMainUsherRecord, taCustomer);
91
-            } catch (Exception e) {}
97
+            } catch (Exception e) {e.printStackTrace();}
92
         }
98
         }
93
 
99
 
94
         return row > 0;
100
         return row > 0;
105
     private TaMainUsherRecord newRecordByCust(TaCustomer taCustomer) {
111
     private TaMainUsherRecord newRecordByCust(TaCustomer taCustomer) {
106
         TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
112
         TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
107
         taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
113
         taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
114
+        taMainUsherRecord.setPersonName(taCustomer.getCustomerName());
115
+        taMainUsherRecord.setAvatar(taCustomer.getAvatar());
116
+        taMainUsherRecord.setPhone(taCustomer.getPhone());
108
         taMainUsherRecord.setAppointment(taCustomer.getApointment());
117
         taMainUsherRecord.setAppointment(taCustomer.getApointment());
109
         taMainUsherRecord.setConsultantId(taCustomer.getConsultantId());
118
         taMainUsherRecord.setConsultantId(taCustomer.getConsultantId());
110
         taMainUsherRecord.setChannel(taCustomer.getChannel());
119
         taMainUsherRecord.setChannel(taCustomer.getChannel());
111
         taMainUsherRecord.setPurpose(taCustomer.getPurpose());
120
         taMainUsherRecord.setPurpose(taCustomer.getPurpose());
112
         taMainUsherRecord.setPlateNumber(taCustomer.getPlateNumber());
121
         taMainUsherRecord.setPlateNumber(taCustomer.getPlateNumber());
113
         taMainUsherRecord.setVisiteDate(LocalDateTime.now());
122
         taMainUsherRecord.setVisiteDate(LocalDateTime.now());
114
-        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
+
115
         return taMainUsherRecord;
130
         return taMainUsherRecord;
116
     }
131
     }
117
 
132
 
130
         String openid = taWechatUserMapper.getOpenidOf(proxyConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
145
         String openid = taWechatUserMapper.getOpenidOf(proxyConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
131
         if (StringUtils.isEmpty(openid)) {
146
         if (StringUtils.isEmpty(openid)) {
132
             throw new Exception("置业尚未绑定微信小程序");
147
             throw new Exception("置业尚未绑定微信小程序");
133
-        };
148
+        }
134
 
149
 
135
         String visitorName = taMainUsherRecord.getPersonName();
150
         String visitorName = taMainUsherRecord.getPersonName();
136
         String phone = taMainUsherRecord.getPhone();
151
         String phone = taMainUsherRecord.getPhone();
155
             String rcOpenid = taWechatUserMapper.getOpenidOf(realConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
170
             String rcOpenid = taWechatUserMapper.getOpenidOf(realConsultant, CommConstant.WECHAT_CLIENT_MINIAPP);
156
             if (StringUtils.isEmpty(openid)) {
171
             if (StringUtils.isEmpty(openid)) {
157
                 throw new Exception("置业尚未绑定微信小程序");
172
                 throw new Exception("置业尚未绑定微信小程序");
158
-            };
173
+            }
159
 
174
 
160
             SysUser usr1 = sysUserMapper.selectById(proxyConsultant);
175
             SysUser usr1 = sysUserMapper.selectById(proxyConsultant);
161
             List<Object> dt1 = new ArrayList<Object>(){{
176
             List<Object> dt1 = new ArrayList<Object>(){{
184
         response.addSuccess(result);
199
         response.addSuccess(result);
185
         return response;
200
         return response;
186
     }
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
+    }
187
 }
306
 }

+ 10
- 8
src/main/java/com.huiju.welcome/service/impl/TaMessageRecordImpl.java 查看文件

18
     TaMessageRecordMapper taMessageRecordMapper;
18
     TaMessageRecordMapper taMessageRecordMapper;
19
 
19
 
20
     @Override
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
         String content = JSONObject.toJSONString(data);
22
         String content = JSONObject.toJSONString(data);
23
         LocalDateTime now = LocalDateTime.now();
23
         LocalDateTime now = LocalDateTime.now();
24
         LocalDateTime twoHourAgo = now.minusHours(2);
24
         LocalDateTime twoHourAgo = now.minusHours(2);
26
         List<TaMessageRecord> lastMessages = taMessageRecordMapper.getLastSameMessages(toUser, page, content, twoHourAgo);
26
         List<TaMessageRecord> lastMessages = taMessageRecordMapper.getLastSameMessages(toUser, page, content, twoHourAgo);
27
         if (null != lastMessages && lastMessages.size() > 0) return false;
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
         return true;
39
         return true;
38
     }
40
     }

+ 16
- 2
src/main/java/com.huiju.welcome/service/impl/TaMiniFormidsImpl.java 查看文件

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

+ 41
- 0
src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java 查看文件

10
 import com.huiju.welcome.mapper.TaPersonMapper;
10
 import com.huiju.welcome.mapper.TaPersonMapper;
11
 import com.huiju.welcome.mapper.TaPersonTypeMapper;
11
 import com.huiju.welcome.mapper.TaPersonTypeMapper;
12
 import com.huiju.welcome.model.*;
12
 import com.huiju.welcome.model.*;
13
+import com.huiju.welcome.service.ICameraService;
13
 import com.huiju.welcome.service.ITaOperationLogService;
14
 import com.huiju.welcome.service.ITaOperationLogService;
14
 import com.huiju.welcome.service.ITaPersonService;
15
 import com.huiju.welcome.service.ITaPersonService;
15
 import com.huiju.welcome.service.ITaVisitingLogService;
16
 import com.huiju.welcome.service.ITaVisitingLogService;
16
 import com.huiju.welcome.utils.LogBuilder;
17
 import com.huiju.welcome.utils.LogBuilder;
17
 import com.huiju.welcome.utils.StatusUtils;
18
 import com.huiju.welcome.utils.StatusUtils;
19
+import com.huiju.welcome.utils.StringUtils;
18
 import org.slf4j.Logger;
20
 import org.slf4j.Logger;
19
 import org.slf4j.LoggerFactory;
21
 import org.slf4j.LoggerFactory;
20
 import org.springframework.beans.factory.annotation.Autowired;
22
 import org.springframework.beans.factory.annotation.Autowired;
61
 
63
 
62
     @Autowired
64
     @Autowired
63
     private ITaOperationLogService taOperationLogService;
65
     private ITaOperationLogService taOperationLogService;
66
+
67
+    @Autowired
68
+    private ICameraService iCameraService;
64
     
69
     
65
     @Value("${huiju.files}")
70
     @Value("${huiju.files}")
66
     private String huijuFiles;
71
     private String huijuFiles;
74
             ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
79
             ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
75
             QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
80
             QueryWrapper<TaDevice> queryWrapper = new QueryWrapper<>();
76
             queryWrapper.eq("status", StatusUtils.Normal);
81
             queryWrapper.eq("status", StatusUtils.Normal);
82
+            queryWrapper.eq("afr", StatusUtils.BoolTrue);
77
             taDeviceList = taDeviceMapper.selectList(queryWrapper);
83
             taDeviceList = taDeviceMapper.selectList(queryWrapper);
78
         } else {
84
         } else {
79
             taDeviceList = Arrays.asList(dev);
85
             taDeviceList = Arrays.asList(dev);
244
     @Override
250
     @Override
245
     public TaPerson newPersonByFront(TaCustomer taCustomer) {
251
     public TaPerson newPersonByFront(TaCustomer taCustomer) {
246
         TaPerson taPerson = new TaPerson();
252
         TaPerson taPerson = new TaPerson();
253
+        taPerson.setAvatar(taCustomer.getAvatar());
247
         taPerson.setPhone(taCustomer.getPhone());
254
         taPerson.setPhone(taCustomer.getPhone());
248
         taPerson.setName(taCustomer.getCustomerName());
255
         taPerson.setName(taCustomer.getCustomerName());
249
         taPerson.setStatus(StatusUtils.Normal);
256
         taPerson.setStatus(StatusUtils.Normal);
257
         taPerson.setRealId(taPerson.getPersonId());
264
         taPerson.setRealId(taPerson.getPersonId());
258
         taPersonMapper.updateById(taPerson);
265
         taPersonMapper.updateById(taPerson);
259
 
266
 
267
+        // 下发人脸到各设备
268
+        iCameraService.dispatchPerson(taPerson);
269
+
260
         return taPerson;
270
         return taPerson;
261
     }
271
     }
262
 
272
 
279
         return taPerson;
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
     private String getTypeName(TaPerson taPerson) {
323
     private String getTypeName(TaPerson taPerson) {
283
         TaPersonType taPersonType = taPersonTypeMapper.selectById(taPerson.getTypeId());
324
         TaPersonType taPersonType = taPersonTypeMapper.selectById(taPerson.getTypeId());
284
         return null == taPersonType ? null : taPersonType.getTypeName();
325
         return null == taPersonType ? null : taPersonType.getTypeName();

+ 3
- 31
src/main/java/com.huiju.welcome/service/impl/TaVisitingLogServiceImpl.java 查看文件

12
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
13
 
13
 
14
 import java.time.LocalDateTime;
14
 import java.time.LocalDateTime;
15
+import java.util.ArrayList;
15
 import java.util.HashMap;
16
 import java.util.HashMap;
16
 import java.util.List;
17
 import java.util.List;
17
 import java.util.Map;
18
 import java.util.Map;
51
     public ResponseBean getTimeline() {
52
     public ResponseBean getTimeline() {
52
         LocalDateTime now = LocalDateTime.now();
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
         LocalDateTime fourHour = now.minusHours(4);
56
         LocalDateTime fourHour = now.minusHours(4);
79
         QueryWrapper<TaVisitingLog> query4 = new QueryWrapper<>();
57
         QueryWrapper<TaVisitingLog> query4 = new QueryWrapper<>();
80
-        query4.le("visite_date", oneHour);
81
         query4.ge("visite_date", fourHour);
58
         query4.ge("visite_date", fourHour);
59
+        query4.groupBy("real_person");
82
         query4.orderByDesc("visite_date");
60
         query4.orderByDesc("visite_date");
83
         List<TaVisitingLog> fourHourList = taVisitingLogMapper.selectList(query4);
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 查看文件

8
 import com.huiju.welcome.model.TaVisitorAppointment;
8
 import com.huiju.welcome.model.TaVisitorAppointment;
9
 import com.huiju.welcome.service.ITaVisitorAppointmentService;
9
 import com.huiju.welcome.service.ITaVisitorAppointmentService;
10
 import com.huiju.welcome.utils.DateUtils;
10
 import com.huiju.welcome.utils.DateUtils;
11
+import com.huiju.welcome.utils.StatusUtils;
11
 import org.apache.http.HttpStatus;
12
 import org.apache.http.HttpStatus;
12
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
16
 import java.time.LocalDateTime;
17
 import java.time.LocalDateTime;
17
 import java.util.Date;
18
 import java.util.Date;
18
 import java.util.List;
19
 import java.util.List;
20
+import java.util.Map;
19
 
21
 
20
 /**
22
 /**
21
  * <p>
23
  * <p>
43
 
45
 
44
         return ResponseBean.success("");
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
     @Override
69
     @Override
48
     public ResponseBean visitorAppointmentList(IPage pg, String platNumber, String personName,String phone) {
70
     public ResponseBean visitorAppointmentList(IPage pg, String platNumber, String personName,String phone) {
49
        ResponseBean responseBean= new ResponseBean();
71
        ResponseBean responseBean= new ResponseBean();

+ 121
- 0
src/main/java/com.huiju.welcome/utils/AliFaceUtils.java 查看文件

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 查看文件

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

+ 1
- 1
src/main/java/com.huiju.welcome/utils/CommConstant.java 查看文件

5
     public final static String IDENTITY_FIRSTUSHER = "first-usher";
5
     public final static String IDENTITY_FIRSTUSHER = "first-usher";
6
     public final static String IDENTITY_MAINUSHER = "main-usher";
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
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
10
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
11
 }
11
 }

+ 14
- 3
src/main/java/com.huiju.welcome/utils/MiniApp.java 查看文件

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

+ 2
- 3
src/main/java/com.huiju.welcome/utils/SAWeather.java 查看文件

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

+ 3
- 0
src/main/java/com.huiju.welcome/utils/StatusUtils.java 查看文件

8
 
8
 
9
     public static final int Offline = 0;
9
     public static final int Offline = 0;
10
     public static final int Online = 1;
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 查看文件

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 查看文件

42
 
42
 
43
 # 小程序服务
43
 # 小程序服务
44
 miniapp:
44
 miniapp:
45
-  url: http://47.101.36.130:8001/api/miniapp
45
+  url: http://miniapp.ycjcjy.com
46
   appid: wx3f26e5f48c72d39f
46
   appid: wx3f26e5f48c72d39f
47
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
47
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
48
   tpls:
48
   tpls:
50
 
50
 
51
 # ali-cloud
51
 # ali-cloud
52
 ali:
52
 ali:
53
-  accessKeyId: LTAIkc75dpkJw8Lb
54
-  accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
53
+  # accessKeyId: LTAIkc75dpkJw8Lb
54
+  # accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
55
+  accessKeyId: LTAIqDWVYleuHNqb
56
+  accessKeySecret: DCAtxoMKQxS3HmrHCbQUs7LaaTR6lB
55
   oss:
57
   oss:
56
     endpoint: oss-cn-shanghai.aliyuncs.com
58
     endpoint: oss-cn-shanghai.aliyuncs.com
57
     bucketName: estateagents
59
     bucketName: estateagents
58
     bucketURL: https://estateagents.oss-cn-shanghai.aliyuncs.com
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

+ 14
- 0
src/main/resources/mapper/TaCustomerMapper.xml 查看文件

35
         </where>
35
         </where>
36
         order by create_date desc
36
         order by create_date desc
37
     </select>
37
     </select>
38
+
39
+    <select id="getSomeCustMayBe" resultType="com.huiju.welcome.model.TaCustomer">
40
+        SELECT
41
+            *
42
+        FROM
43
+            ta_customer t
44
+        WHERE
45
+	      (
46
+            t.plate_number = #{plateNumber}
47
+            OR t.phone = #{phone}
48
+          )
49
+        AND IFNULL(t.customer_name, '') != ''
50
+        AND t.`status` = 1
51
+    </select>
38
 </mapper>
52
 </mapper>

+ 16
- 3
target/classes/application.yml 查看文件

42
 
42
 
43
 # 小程序服务
43
 # 小程序服务
44
 miniapp:
44
 miniapp:
45
-  url: http://47.101.36.130:8001/api/miniapp
45
+  url: http://miniapp.ycjcjy.com
46
   appid: wx3f26e5f48c72d39f
46
   appid: wx3f26e5f48c72d39f
47
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
47
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
48
   tpls:
48
   tpls:
50
 
50
 
51
 # ali-cloud
51
 # ali-cloud
52
 ali:
52
 ali:
53
-  accessKeyId: LTAIkc75dpkJw8Lb
54
-  accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
53
+  # accessKeyId: LTAIkc75dpkJw8Lb
54
+  # accessKeySecret: v4bvXCaix6vSDTCFfwSAdqV53iFEQw
55
+  accessKeyId: LTAIqDWVYleuHNqb
56
+  accessKeySecret: DCAtxoMKQxS3HmrHCbQUs7LaaTR6lB
55
   oss:
57
   oss:
56
     endpoint: oss-cn-shanghai.aliyuncs.com
58
     endpoint: oss-cn-shanghai.aliyuncs.com
57
     bucketName: estateagents
59
     bucketName: estateagents
58
     bucketURL: https://estateagents.oss-cn-shanghai.aliyuncs.com
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