Kaynağa Gözat

Merge branch '2.0.0' of http://git.ycjcjy.com/fuxingfan/smartCommunity into 2.0.0

魏熙美 6 yıl önce
ebeveyn
işleme
d120dce2d4

+ 1
- 2
CODE/smart-community/app-api/src/main/resources/mapper/TaUserVerifyMapper.xml Dosyayı Görüntüle

@@ -267,7 +267,7 @@
267 267
     from ta_user_verify tuv
268 268
     where tuv.user_id = #{userId,jdbcType=INTEGER}
269 269
   </select>
270
-  <select id="selectCommunityAndAddress" resultMap="BaseResultMap">
270
+  <select id="selectCommunityAndAddress" resultType="com.community.huiju.model.TaUserVerify">
271 271
     select
272 272
     <include refid="Base_Column_List"/>
273 273
     from ta_user_verify
@@ -281,6 +281,5 @@
281 281
     <if test="verifyStatus != null and verifyStatus != ''">
282 282
       and verify_status = #{verifyStatus}
283 283
     </if>
284
-
285 284
   </select>
286 285
 </mapper>

+ 237
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/common/welcome/OkHttpRequestUtils.java Dosyayı Görüntüle

@@ -0,0 +1,237 @@
1
+package com.community.huiju.common.welcome;
2
+
3
+import com.beust.jcommander.internal.Maps;
4
+import okhttp3.*;
5
+
6
+import java.io.ByteArrayOutputStream;
7
+import java.io.File;
8
+import java.io.FileInputStream;
9
+import java.util.Iterator;
10
+import java.util.Map;
11
+
12
+/**
13
+ * 封装请求
14
+ * @author weiximei
15
+ */
16
+public class OkHttpRequestUtils {
17
+
18
+    // 定义请求客户端
19
+    private static OkHttpClient client = new OkHttpClient();
20
+
21
+    /**
22
+     * get 请求
23
+     * @param url 请求URL
24
+     * @return
25
+     * @throws Exception
26
+     */
27
+    public static String doGet(String url) throws Exception {
28
+       return doGet(url, Maps.newHashMap());
29
+    }
30
+
31
+
32
+    /**
33
+     * get 请求
34
+     * @param url 请求URL
35
+     * @param query 携带参数参数
36
+     * @return
37
+     * @throws Exception
38
+     */
39
+    public static String doGet(String url, Map<String, Object> query) throws Exception {
40
+
41
+        return doGet(url, Maps.newHashMap(), query);
42
+    }
43
+
44
+    /**
45
+     * get 请求
46
+     * @param url url
47
+     * @param header 请求头参数
48
+     * @param query 参数
49
+     * @return
50
+     */
51
+    public static String doGet(String url, Map<String, Object> header, Map<String, Object> query) throws Exception {
52
+
53
+        // 创建一个请求 Builder
54
+        Request.Builder builder = new Request.Builder();
55
+        // 创建一个 request
56
+        Request request = builder.url(url).build();
57
+
58
+        // 创建一个 HttpUrl.Builder
59
+        HttpUrl.Builder urlBuilder = request.url().newBuilder();
60
+        // 创建一个 Headers.Builder
61
+        Headers.Builder headerBuilder = request.headers().newBuilder();
62
+
63
+        // 装载请求头参数
64
+        Iterator<Map.Entry<String, Object>> headerIterator = header.entrySet().iterator();
65
+        headerIterator.forEachRemaining(e -> {
66
+            headerBuilder.add(e.getKey(), (String) e.getValue());
67
+        });
68
+
69
+        // 装载请求的参数
70
+        Iterator<Map.Entry<String, Object>> queryIterator = query.entrySet().iterator();
71
+        queryIterator.forEachRemaining(e -> {
72
+            urlBuilder.addQueryParameter(e.getKey(), (String) e.getValue());
73
+        });
74
+
75
+        // 设置自定义的 builder
76
+        builder.url(urlBuilder.build()).headers(headerBuilder.build());
77
+
78
+        try (Response execute = client.newCall(builder.build()).execute()) {
79
+            return execute.body().string();
80
+        }
81
+    }
82
+
83
+    /**
84
+     * post 请求, 请求参数 并且 携带文件上传
85
+     * @param url
86
+     * @param header
87
+     * @param parameter
88
+     * @param file
89
+     * @return
90
+     * @throws Exception
91
+     */
92
+    public static String doPost(String url, Map<String, Object> header, Map<String, Object> parameter, File file) throws Exception {
93
+
94
+        // 创建一个请求 Builder
95
+        Request.Builder builder = new Request.Builder();
96
+        // 创建一个 request
97
+        Request request = builder.url(url).build();
98
+
99
+        // 创建一个 Headers.Builder
100
+        Headers.Builder headerBuilder = request.headers().newBuilder();
101
+
102
+        // 装载请求头参数
103
+        Iterator<Map.Entry<String, Object>> headerIterator = header.entrySet().iterator();
104
+        headerIterator.forEachRemaining(e -> {
105
+            headerBuilder.add(e.getKey(), (String) e.getValue());
106
+        });
107
+
108
+        MultipartBody.Builder requestBuilder = new MultipartBody.Builder();
109
+
110
+        // 状态请求参数
111
+        Iterator<Map.Entry<String, Object>> queryIterator = parameter.entrySet().iterator();
112
+        queryIterator.forEachRemaining(e -> {
113
+            requestBuilder.addFormDataPart(e.getKey(), (String) e.getValue());
114
+        });
115
+
116
+        if (null != file) {
117
+            // application/octet-stream
118
+            requestBuilder.addFormDataPart("uploadFiles", file.getName(), RequestBody.create(MediaType.parse("application/octet-stream"), file));
119
+        }
120
+
121
+        // 设置自定义的 builder
122
+        builder.headers(headerBuilder.build()).post(requestBuilder.build());
123
+
124
+        // 然后再 build 一下
125
+        try (Response execute = client.newCall(builder.build()).execute()) {
126
+            return execute.body().string();
127
+        }
128
+    }
129
+
130
+    /**
131
+     * post 请求, 请求参数 并且 携带文件上传二进制流
132
+     * @param url
133
+     * @param header
134
+     * @param parameter
135
+     * @param fileName 文件名
136
+     * @param fileByte 文件的二进制流
137
+     * @return
138
+     * @throws Exception
139
+     */
140
+    public static String doPost(String url, Map<String, Object> header, Map<String, Object> parameter, String fileName, byte [] fileByte) throws Exception {
141
+// 创建一个请求 Builder
142
+        Request.Builder builder = new Request.Builder();
143
+        // 创建一个 request
144
+        Request request = builder.url(url).build();
145
+
146
+        // 创建一个 Headers.Builder
147
+        Headers.Builder headerBuilder = request.headers().newBuilder();
148
+
149
+        // 装载请求头参数
150
+        Iterator<Map.Entry<String, Object>> headerIterator = header.entrySet().iterator();
151
+        headerIterator.forEachRemaining(e -> {
152
+            headerBuilder.add(e.getKey(), (String) e.getValue());
153
+        });
154
+
155
+        MultipartBody.Builder requestBuilder = new MultipartBody.Builder();
156
+
157
+        // 状态请求参数
158
+        Iterator<Map.Entry<String, Object>> queryIterator = parameter.entrySet().iterator();
159
+        queryIterator.forEachRemaining(e -> {
160
+            requestBuilder.addFormDataPart(e.getKey(), (String) e.getValue());
161
+        });
162
+
163
+        if (fileByte.length > 0) {
164
+            // application/octet-stream
165
+            requestBuilder.addFormDataPart("uploadFiles", fileName, RequestBody.create(MediaType.parse("application/octet-stream"), fileByte));
166
+        }
167
+
168
+        // 设置自定义的 builder
169
+        builder.headers(headerBuilder.build()).post(requestBuilder.build());
170
+
171
+        try (Response execute = client.newCall(builder.build()).execute()) {
172
+            return execute.body().string();
173
+        }
174
+    }
175
+
176
+
177
+    /**
178
+     * post 请求  携带文件上传
179
+     * @param url
180
+     * @param file
181
+     * @return
182
+     * @throws Exception
183
+     */
184
+    public static String doPost(String url, File file) throws Exception {
185
+        return doPost(url, Maps.newHashMap(), Maps.newHashMap(), file);
186
+    }
187
+
188
+    /**
189
+     * post 请求
190
+     * @param url
191
+     * @param header 请求头
192
+     * @param parameter 参数
193
+     * @return
194
+     * @throws Exception
195
+     */
196
+    public static String doPost(String url, Map<String, Object> header, Map<String, Object> parameter) throws Exception {
197
+        return doPost(url, header, parameter, null);
198
+    }
199
+
200
+    /**
201
+     * post 请求
202
+     * @param url
203
+     * @param parameter 参数
204
+     * @return
205
+     * @throws Exception
206
+     */
207
+    public static String doPost(String url, Map<String, Object> parameter) throws Exception {
208
+        return doPost(url, Maps.newHashMap(), parameter, null);
209
+    }
210
+
211
+    public static void main(String[] args) throws Exception {
212
+
213
+        byte [] fileByte = null;
214
+
215
+        File file = new File("C:\\Users\\szc\\Pictures\\file-read-4182.jpg");
216
+        FileInputStream fileInputStream = new FileInputStream(file);
217
+
218
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
219
+        byte[] b = new byte[1024];
220
+        int n;
221
+        while ((n = fileInputStream.read(b)) != -1)
222
+        {
223
+            bos.write(b, 0, n);
224
+        }
225
+        fileInputStream.close();
226
+        bos.close();
227
+        fileByte = bos.toByteArray();
228
+
229
+
230
+        Map<String, Object> queryMap = Maps.newHashMap();
231
+        queryMap.put("pageNum","2");
232
+        queryMap.put("pageSize","50");
233
+        System.out.println(OkHttpRequestUtils.doPost("http://localhost:8566/uploadImage" , Maps.newHashMap(), Maps.newHashMap(),file.getName(), fileByte));
234
+
235
+    }
236
+
237
+}

+ 26
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/common/welcome/WelcomeProperties.java Dosyayı Görüntüle

@@ -0,0 +1,26 @@
1
+package com.community.huiju.common.welcome;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Data;
5
+import lombok.NoArgsConstructor;
6
+import org.springframework.boot.context.properties.ConfigurationProperties;
7
+import org.springframework.stereotype.Component;
8
+
9
+/**
10
+ * 迎宾系统配置
11
+ * @author weiximei
12
+ */
13
+@ConfigurationProperties(prefix = "welcome")
14
+@Component
15
+@Data
16
+@AllArgsConstructor
17
+@NoArgsConstructor
18
+public class WelcomeProperties {
19
+
20
+    /** 小区 **/
21
+    private Integer communityId;
22
+
23
+    /** 请求url **/
24
+    private String url;
25
+
26
+}

+ 4
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BuildingTreeController.java Dosyayı Görüntüle

@@ -47,6 +47,10 @@ public class BuildingTreeController extends BaseController {
47 47
 	
48 48
 	@ApiOperation(value = "获取树形数据", notes = "获取树形数据")
49 49
 	@GetMapping(value = "/trees")
50
+	@ApiImplicitParams({
51
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token"),
52
+			@ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "id", value = "当前节点id(查期时ID为空)")
53
+	})
50 54
 	public ResponseBean getTreeList(@RequestParam(value = "id", required = false) Integer id,@RequestParam("treeType") String treeType,HttpSession session){
51 55
 		ResponseBean responseBean = new ResponseBean();UserElement userElement = getUserElement(session);
52 56
 

+ 122
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/FaceController.java Dosyayı Görüntüle

@@ -0,0 +1,122 @@
1
+package com.community.huiju.controller;
2
+
3
+import com.community.commom.mode.ResponseBean;
4
+import com.community.commom.session.UserElement;
5
+import com.community.huiju.common.base.BaseController;
6
+import com.community.huiju.service.FaceServiceI;
7
+import io.swagger.annotations.*;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.cloud.context.config.annotation.RefreshScope;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestMethod;
12
+import org.springframework.web.bind.annotation.RequestParam;
13
+import org.springframework.web.bind.annotation.RestController;
14
+import org.springframework.web.multipart.MultipartFile;
15
+
16
+import javax.servlet.http.HttpSession;
17
+
18
+@RestController
19
+@RefreshScope
20
+@RequestMapping("/")
21
+@Api(value = "人脸相关API", description = "人脸相关API")
22
+public class FaceController extends BaseController {
23
+    @Autowired
24
+    private FaceServiceI faceServicel;
25
+
26
+    @ApiOperation(value = "添加人脸图片", notes = "添加人脸图片")
27
+    @ApiImplicitParams({
28
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
29
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "phaseName",value = "期名称"),
30
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "buildingName",value = "楼栋名称"),
31
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "unitName",value = "单元名称"),
32
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "levelName",value = "楼层名称"),
33
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "roomNoName",value = "户号"),
34
+            @ApiImplicitParam(paramType = "query",dataType = "Integer",name = "otherUserId",value = "otherUserId")
35
+    })
36
+    
37
+    @RequestMapping(value = "/addFace",method = RequestMethod.POST)
38
+    public Object getTaFace(HttpSession session,
39
+                            @ApiParam(value = "file" ,required = true) MultipartFile uploadFile,
40
+                            @RequestParam(required = false) Integer otherUserId,
41
+                            @RequestParam(required = false) String phaseName,
42
+                            @RequestParam(required = false) String buildingName,
43
+                            @RequestParam(required = false) String unitName,
44
+                            @RequestParam(required = false) String levelName,
45
+                            @RequestParam(required = false) String roomNoName){
46
+        ResponseBean responseBean = new ResponseBean();
47
+        UserElement userElement = getUserElement(session);
48
+        responseBean = faceServicel.addFace(userElement ,uploadFile,otherUserId,phaseName,buildingName,unitName,levelName,roomNoName);
49
+        return responseBean;
50
+    }
51
+
52
+    @ApiOperation(value = "修改人脸图片", notes = "修改人脸图片")
53
+    @ApiImplicitParams({
54
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
55
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "phaseName",value = "期名称"),
56
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "buildingName",value = "楼栋名称"),
57
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "unitName",value = "单元名称"),
58
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "levelName",value = "楼层名称"),
59
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "roomNoName",value = "户号"),
60
+            @ApiImplicitParam(paramType = "query",dataType = "Integer",name = "otherUserId",value = "otherUserId")
61
+    })
62
+    @RequestMapping(value = "/upDateFace",method = RequestMethod.POST)
63
+    public Object upDateTaFace(HttpSession session,
64
+                               @ApiParam(value = "file" ,required = true) MultipartFile uploadFile,
65
+                               @RequestParam(required = false) Integer otherUserId,
66
+                               @RequestParam(required = false) String phaseName,
67
+                               @RequestParam(required = false) String buildingName,
68
+                               @RequestParam(required = false) String unitName,
69
+                               @RequestParam(required = false) String levelName,
70
+                               @RequestParam(required = false) String roomNoName){
71
+        ResponseBean responseBean = new ResponseBean();
72
+        UserElement userElement = getUserElement(session);
73
+         responseBean = faceServicel.upDateFace(userElement,uploadFile,otherUserId,phaseName,buildingName,unitName,levelName,roomNoName);
74
+        return responseBean;
75
+    }
76
+
77
+    @ApiOperation(value = "获取当前已录入人脸信息", notes = "获取当前已录入人脸信息")
78
+    @ApiImplicitParams({
79
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
80
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "phaseName",value = "期名称"),
81
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "buildingName",value = "楼栋名称"),
82
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "unitName",value = "单元名称"),
83
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "levelName",value = "楼层名称"),
84
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "roomNoName",value = "户号"),
85
+            @ApiImplicitParam(paramType = "query",dataType = "Integer",name = "otherUserId",value = "家属或租户ID,不填为本人")
86
+    })
87
+    @RequestMapping(value = "/getUserIdFace",method = RequestMethod.GET)
88
+    public Object getTaFaceByUserId(HttpSession session, @RequestParam(required = false) Integer otherUserId,
89
+                                    @RequestParam(required = false) String phaseName,
90
+                                    @RequestParam(required = false) String buildingName,
91
+                                    @RequestParam(required = false) String unitName,
92
+                                    @RequestParam(required = false) String levelName,
93
+                                    @RequestParam(required = false) String roomNoName){
94
+        UserElement userElement = getUserElement(session);
95
+        ResponseBean responseBean = faceServicel.getTaFaceByUserId(userElement,otherUserId,phaseName,buildingName,unitName,levelName,roomNoName);
96
+        return responseBean;
97
+    }
98
+
99
+    @ApiOperation(value = "删除当前人脸信息", notes = "删除当前人脸信息")
100
+    @ApiImplicitParams({
101
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
102
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "phaseName",value = "期名称"),
103
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "buildingName",value = "楼栋名称"),
104
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "unitName",value = "单元名称"),
105
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "levelName",value = "楼层名称"),
106
+            @ApiImplicitParam(paramType = "query",dataType = "String",name = "roomNoName",value = "户号"),
107
+            @ApiImplicitParam(paramType = "query",dataType = "Integer",name = "otherUserId",value = "家属或租户ID,不填为本人")
108
+    })
109
+    @RequestMapping(value = "/getUserIdFace",method = RequestMethod.GET)
110
+    public Object deleteFace(HttpSession session, @RequestParam(required = false) Integer otherUserId,
111
+                                    @RequestParam(required = false) String phaseName,
112
+                                    @RequestParam(required = false) String buildingName,
113
+                                    @RequestParam(required = false) String unitName,
114
+                                    @RequestParam(required = false) String levelName,
115
+                                    @RequestParam(required = false) String roomNoName){
116
+        ResponseBean responseBean = faceServicel.deleteFace(otherUserId,phaseName,buildingName,unitName,levelName,roomNoName);
117
+        return responseBean;
118
+    }
119
+
120
+}
121
+
122
+}

+ 7
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/TaFaceMapper.java Dosyayı Görüntüle

@@ -2,6 +2,7 @@ package com.community.huiju.dao;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.community.huiju.model.TaFace;
5
+import org.apache.ibatis.annotations.Mapper;
5 6
 
6 7
 /**
7 8
  * <p>
@@ -11,6 +12,12 @@ import com.community.huiju.model.TaFace;
11 12
  * @author jobob
12 13
  * @since 2019-04-11
13 14
  */
15
+@Mapper
14 16
 public interface TaFaceMapper extends BaseMapper<TaFace> {
15 17
 
18
+    TaFace getByUserVerifyId(Integer userVerifyId);
19
+
20
+    void insertSelective(TaFace taFace);
21
+
22
+    void updateByPrimaryKeySelective(TaFace taFace);
16 23
 }

+ 9
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/TaUserVerifyMapper.java Dosyayı Görüntüle

@@ -79,4 +79,13 @@ public interface TaUserVerifyMapper extends BaseMapper<TaUserVerify> {
79 79
             "and role_id = 1")
80 80
     TaUserVerify selectCommunityAndAddressName(@Param("communityId") Integer communityId, @Param("phaseName") String phaseName, @Param("buildingName") String buildingName, @Param("unitName") String unitName, @Param("levelName") String levelName, @Param("roomNoName") String roomNoName);
81 81
 
82
+
83
+    List<TaUserVerify> selectUserVerifyCommunityAndAddress(@Param("userId") Integer userId,
84
+                                                 @Param("communityId") Integer communityId,
85
+                                                 @Param("phaseId") Integer phaseId,
86
+                                                 @Param("buildingId") Integer buildingId,
87
+                                                 @Param("unitId") Integer unitId,
88
+                                                 @Param("levelId") Integer levelId,
89
+                                                 @Param("roomNoId") Integer roomNoId,
90
+                                                 @Param("verifyStatus") Integer verifyStatus);
82 91
 }

+ 4
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TaFace.java Dosyayı Görüntüle

@@ -23,6 +23,10 @@ import java.time.LocalDateTime;
23 23
 public class TaFace implements Serializable {
24 24
 
25 25
     private static final long serialVersionUID = 1L;
26
+    /**
27
+     * id
28
+     */
29
+    private  Integer id;
26 30
 
27 31
     /**
28 32
      * 小区id

+ 47
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/FaceServiceI.java Dosyayı Görüntüle

@@ -0,0 +1,47 @@
1
+package com.community.huiju.service;
2
+
3
+
4
+import com.community.commom.mode.ResponseBean;
5
+import com.community.commom.session.UserElement;
6
+import com.community.huiju.model.TaUser;
7
+import org.springframework.web.multipart.MultipartFile;
8
+
9
+public interface FaceServiceI {
10
+    /**
11
+     * 添加人脸
12
+     * @param userElement 登入人ID
13
+     *  @param  uploadFile
14
+     *  @param otherUserId 关联家属或者租客ID
15
+     * @return
16
+     */
17
+    ResponseBean addFace(UserElement userElement, MultipartFile uploadFile, Integer otherUserId,String phaseName,String buildingName,String unitName,String levelName,String roomNoName);
18
+
19
+    /**
20
+     * 更新当前人脸
21
+     * @param userElement 登入人ID
22
+     *  @param  uploadFile
23
+     *  @param otherUserId 关联家属或者租客ID
24
+     * @return
25
+     */
26
+    ResponseBean upDateFace(UserElement userElement, MultipartFile uploadFile, Integer otherUserId,String phaseName,String buildingName,String unitName,String levelName,String roomNoName);
27
+
28
+    /**
29
+     * 当前登入人是否有人脸信息
30
+     * @param userElement
31
+     * @param otherUserId
32
+     * @return
33
+     */
34
+    ResponseBean getTaFaceByUserId(UserElement userElement, Integer otherUserId,String phaseName,String buildingName,String unitName,String levelName,String roomNoName);
35
+
36
+    /**
37
+     * 删除当前人脸信息
38
+     * @param otherUserId
39
+     * @param phaseName
40
+     * @param buildingName
41
+     * @param unitName
42
+     * @param levelName
43
+     * @param roomNoName
44
+     * @return
45
+     */
46
+    ResponseBean deleteFace(Integer otherUserId, String phaseName, String buildingName, String unitName, String levelName, String roomNoName);
47
+}

+ 248
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/FaceServicelimpl.java Dosyayı Görüntüle

@@ -0,0 +1,248 @@
1
+package com.community.huiju.service.impl;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.community.commom.ailiyun.AESDecode;
6
+import com.community.commom.constant.Constant;
7
+import com.community.commom.hk.HKOpenApi;
8
+import com.community.commom.mode.ResponseBean;
9
+import com.community.commom.session.UserElement;
10
+import com.community.huiju.common.welcome.WelcomeProperties;
11
+import com.community.huiju.dao.TaFaceMapper;
12
+import com.community.huiju.dao.TaSysRoleMapper;
13
+import com.community.huiju.dao.TaUserMapper;
14
+import com.community.huiju.dao.TaUserVerifyMapper;
15
+import com.community.huiju.exception.WisdomException;
16
+import com.community.huiju.model.TaFace;
17
+import com.community.huiju.model.TaUser;
18
+import com.community.huiju.model.TaUserVerify;
19
+import com.community.huiju.service.FaceServiceI;
20
+import com.community.huiju.service.ImageServiceI;
21
+import lombok.extern.slf4j.Slf4j;
22
+import org.springframework.beans.factory.annotation.Autowired;
23
+import org.springframework.http.HttpEntity;
24
+import org.springframework.http.HttpHeaders;
25
+import org.springframework.http.HttpMethod;
26
+import org.springframework.http.MediaType;
27
+import org.springframework.stereotype.Service;
28
+import org.springframework.transaction.annotation.Transactional;
29
+import org.springframework.web.client.RestTemplate;
30
+import org.springframework.web.multipart.MultipartFile;
31
+
32
+import java.io.IOException;
33
+import java.time.LocalDateTime;
34
+import java.util.ArrayList;
35
+import java.util.Date;
36
+import java.util.List;
37
+
38
+@Service("faceServicel")
39
+@Transactional
40
+@Slf4j
41
+public class FaceServicelimpl implements FaceServiceI {
42
+
43
+
44
+    @Autowired
45
+    private TaFaceMapper taFaceMapper;
46
+
47
+    @Autowired
48
+    private TaUserMapper taUserMapper;
49
+
50
+    @Autowired
51
+    private TaSysRoleMapper taSysRoleMapper;
52
+
53
+    @Autowired
54
+    private ImageServiceI imageServiceI;
55
+
56
+    @Autowired
57
+    private WelcomeProperties welcomeProperties;
58
+
59
+    @Autowired
60
+    private TaUserVerifyMapper taUserVerifyMapper;
61
+
62
+    @Override
63
+    @Transactional(rollbackFor = Exception.class)
64
+    public ResponseBean addFace(UserElement userElement, MultipartFile uploadFile, Integer otherUserId,String phaseName,String buildingName,String unitName,String levelName,String roomNoName) {
65
+        ResponseBean responseBean = new ResponseBean();
66
+        // 当前人脸图片url
67
+        String faceImg = img(uploadFile);
68
+        //查看当前期/栋/单元/楼层/户是否存在
69
+        TaUserVerify taUserVerify= infoExist(phaseName,buildingName,unitName,levelName, roomNoName,otherUserId);
70
+        if (null==taUserVerify){
71
+            responseBean.addError("请查看期/栋/单元/楼层/户号是否正确");
72
+            return responseBean;
73
+        }
74
+        // 是否审核通过
75
+        if (null!=taUserVerify && !taUserVerify.getVerifyStatus().equals("1")){
76
+            responseBean.addSuccess("当前房产未通过审核");
77
+            return responseBean;
78
+        }
79
+        TaFace taFace = new TaFace();
80
+        taFace.setFaceImg(faceImg);
81
+        taFace.setCommunityId(taUserVerify.getCommunityId());
82
+        taFace.setTaUserVerifyId(taUserVerify.getId());
83
+        taFace.setCreateUser(userElement.getId());
84
+        taFace.setCreateDate(LocalDateTime.now());
85
+        /*推送海康 */
86
+        boolean isA =true;
87
+         responseBean = checKout(faceImg, taFace, isA, uploadFile, otherUserId);
88
+        return responseBean;
89
+    }
90
+
91
+    /**
92
+     * 修改人脸信息
93
+     *
94
+     * @param userElement 登入人ID
95
+     * @param uploadFile
96
+     * @param otherUserId 关联家属或者租客ID
97
+     * @return
98
+     */
99
+    @Override
100
+    @Transactional(rollbackFor = Exception.class)
101
+    public ResponseBean upDateFace(UserElement userElement, MultipartFile uploadFile, Integer otherUserId,String phaseName,String buildingName,String unitName,String levelName,String roomNoName) {
102
+        ResponseBean responseBean = new ResponseBean();
103
+        // 人脸图片地址url
104
+        String faceImg = img(uploadFile);
105
+
106
+        //查看当前期/栋/单元/楼层/户是否存在
107
+        TaUserVerify taUserVerify= infoExist(phaseName,buildingName,unitName,levelName, roomNoName,otherUserId);
108
+        if (null==taUserVerify){
109
+            responseBean.addError("请查看期/栋/单元/楼层/户号是否正确");
110
+            return responseBean;
111
+        }
112
+
113
+        TaFace face = taFaceMapper.getByUserVerifyId(taUserVerify.getId());
114
+        if (null==face){
115
+            responseBean.addError("当前信息暂无人脸,请录入");
116
+            return responseBean;
117
+        }
118
+        face.setTaUserVerifyId(taUserVerify.getId());
119
+        face.setFaceImg(faceImg);
120
+        face.setUpdateUser(userElement.getId());
121
+        face.setUpdateDate(LocalDateTime.now());
122
+        boolean isA=false;
123
+        ResponseBean resps = checKout(faceImg, face, isA, uploadFile, otherUserId);
124
+        return resps;
125
+    }
126
+
127
+    /**
128
+     * 验证图片是否为人脸,推送海康
129
+     */
130
+    public ResponseBean checKout(String faceImg, TaFace taFace, boolean isA, MultipartFile uploadFile, Integer userId) {
131
+        ResponseBean responseBean = new ResponseBean();
132
+        TaUser user = taUserMapper.selectById(userId);
133
+        if (user.getHkUserId() == null) {
134
+            responseBean.addError("海康人员ID不存在,无法录入");
135
+            log.error("本地库人员ID:{}  的海康人员ID不存在", userId);
136
+            return responseBean;
137
+        }
138
+        AESDecode aesd = new AESDecode();
139
+        String body = "{\"type\": \"0\", \"image_url\":\"" + faceImg + "\"}";
140
+        try {
141
+            responseBean = aesd.send(body);
142
+            JSONObject jsonObject = JSONObject.parseObject(responseBean.getMessage());
143
+            Integer type = (Integer) jsonObject.get("errno");
144
+            Integer faceNum = (Integer) jsonObject.get("face_num");
145
+
146
+            /*推送海康*/
147
+            String data = HKOpenApi.HKpersonGroupId(uploadFile, user.getHkUserId(), user.getHkPersonNo(), user.getUserName(), user.getHkCardNo());
148
+            /*boolean isA为true进行添加,为false进行修改*/
149
+            if (0 == type && 1 == faceNum) {
150
+                if (null == data) {
151
+                    throw new RuntimeException("海康人脸推送失敗!");
152
+                }
153
+                if (isA) {
154
+                    taFaceMapper.insertSelective(taFace);
155
+                } else {
156
+                    taFaceMapper.updateByPrimaryKeySelective(taFace);
157
+                }
158
+                responseBean.addSuccess("操作成功");
159
+                HKOpenApi.downloadFaceAndFingerInfos(String.valueOf(user.getHkUserId()));
160
+//                //可视对讲时 指定人员人脸权限下载
161
+//                List<Integer> userIdList = new ArrayList<>();
162
+//                userIdList.add(user.getHkUserId());
163
+//                //临时设备编号
164
+//                // TODO 根据期楼栋号,来查询出门口机
165
+//                List<String> visualList = new ArrayList<>();
166
+//                visualList.add("10010100000");
167
+//                HKOpenApi.visualIntercom(null, 1, userIdList, visualList);
168
+            } else {
169
+                responseBean.addError("请录入正确图片");
170
+            }
171
+        } catch (Exception e) {
172
+            e.printStackTrace();
173
+            log.error("海康人脸推送失敗! {}", e);
174
+            throw new RuntimeException("海康人脸推送失敗!");
175
+        }
176
+        return responseBean;
177
+    }
178
+
179
+    /**
180
+     * 当前登入人是否有人脸信息
181
+     */
182
+    @Override
183
+    public ResponseBean getTaFaceByUserId(UserElement userElement, Integer otherUserId,String phaseName,String buildingName,String unitName,String levelName,String roomNoName) {
184
+        ResponseBean responseBean = new ResponseBean();
185
+        //查看当前期/栋/单元/楼层/户是否存在
186
+        TaUserVerify taUserVerify= infoExist(phaseName,buildingName,unitName,levelName, roomNoName,otherUserId);
187
+        if (null==taUserVerify){
188
+            responseBean.addError("请查看期/栋/单元/楼层/户号是否正确");
189
+            return responseBean;
190
+        }
191
+
192
+        TaFace face = taFaceMapper.getByUserVerifyId(taUserVerify.getId());
193
+        if (null==face){
194
+            responseBean.addError("当前用户暂无人脸图片");
195
+            return responseBean;
196
+        }
197
+        responseBean.addSuccess(face);
198
+        return responseBean;
199
+
200
+    }
201
+
202
+    @Override
203
+    public ResponseBean deleteFace(Integer otherUserId, String phaseName, String buildingName, String unitName, String levelName, String roomNoName) {
204
+        TaUserVerify taUserVerify= infoExist(phaseName,buildingName,unitName,levelName, roomNoName,otherUserId);
205
+        taUserVerify.setVerifyStatus()
206
+        return null;
207
+    }
208
+
209
+    /**
210
+     * 得到当前图片
211
+     */
212
+    private String img(MultipartFile uploadFile) {
213
+        String faceImg = null;
214
+        try {
215
+            faceImg = imageServiceI.getImageUrl(uploadFile);
216
+        } catch (IOException e) {
217
+            e.printStackTrace();
218
+        }
219
+        return faceImg;
220
+    }
221
+
222
+    /*查询当前期/栋/单元/房间号结果是否存在*/
223
+    public TaUserVerify infoExist(String phaseName,String buildingName,String unitName,String levelName,String roomNoName,Integer otherUserId){
224
+        if (null==phaseName){
225
+            return null;
226
+        }else if (null==buildingName){
227
+            return null;
228
+        }else if (null==unitName){
229
+            return null;
230
+        }else if (null==levelName){
231
+            return null;
232
+        }else if (null==roomNoName){
233
+            return null;
234
+        }
235
+        /*查询当前的房产ID*/
236
+        QueryWrapper<TaUserVerify>  queryTaUserVerify= new QueryWrapper<>();
237
+        queryTaUserVerify.eq("phase_name",phaseName);
238
+        queryTaUserVerify.eq("building_name",buildingName);
239
+        queryTaUserVerify.eq("unit_name",unitName);
240
+        queryTaUserVerify.eq("level_name",levelName);
241
+        queryTaUserVerify.eq("room_no_name",roomNoName);
242
+        queryTaUserVerify.eq("user_id",otherUserId);
243
+        TaUserVerify taUserVerify= taUserVerifyMapper.selectOne(queryTaUserVerify);
244
+        return taUserVerify;
245
+    }
246
+}
247
+
248
+

+ 121
- 0
CODE/smart-community/property-api/src/main/resources/mapper/TaFaceMapper.xml Dosyayı Görüntüle

@@ -0,0 +1,121 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.community.huiju.dao.TaFaceMapper" >
4
+
5
+    <select id="selectByPrimaryKey" resultType="com.community.huiju.model.TaFace">
6
+        select
7
+        id, community_id,ta_user_verify_id,face_img,create_user, create_date, update_user,
8
+        update_date
9
+        from ta_face
10
+        where id = #{id,jdbcType=INTEGER}
11
+    </select>
12
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
13
+        delete from ta_face
14
+        where id = #{id,jdbcType=INTEGER}
15
+    </delete>
16
+    <insert id="insert" parameterType="com.community.huiju.model.TaFace" >
17
+        insert into ta_face (id, community_id, ta_user_verify_id,face_img, create_user, create_date,
18
+        update_user, update_date)
19
+        values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER},#{taUserVerifyId,jdbcType=INTEGER},#{faceImg,jdbcType=VARCHAR},#{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP},
20
+        #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP})
21
+    </insert>
22
+    <insert id="insertSelective"  parameterType="com.community.huiju.model.TaFace" >
23
+        insert into ta_face
24
+        <trim prefix="(" suffix=")" suffixOverrides="," >
25
+            <if test="id != null" >
26
+                id,
27
+            </if>
28
+            <if test="communityId != null" >
29
+                community_id,
30
+            </if>
31
+            <if test="taUserVerifyId != null" >
32
+                ta_user_verify_id,
33
+            </if>
34
+            <if test="faceImg != null" >
35
+                face_img,
36
+            </if>
37
+            <if test="createUser != null" >
38
+                create_user,
39
+            </if>
40
+            <if test="createDate != null" >
41
+                create_date,
42
+            </if>
43
+            <if test="updateUser != null" >
44
+                update_user,
45
+            </if>
46
+            <if test="updateDate != null" >
47
+                update_date,
48
+            </if>
49
+        </trim>
50
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
51
+            <if test="id != null" >
52
+                #{id,jdbcType=INTEGER},
53
+            </if>
54
+            <if test="communityId != null" >
55
+                #{communityId,jdbcType=INTEGER},
56
+            </if>
57
+            <if test="taUserVerifyId != null" >
58
+                #{taUserVerifyId,jdbcType=INTEGER},
59
+            </if>
60
+            <if test="faceImg != null" >
61
+                #{faceImg,jdbcType=VARCHAR},
62
+            </if>
63
+            <if test="createUser != null" >
64
+                #{createUser,jdbcType=INTEGER},
65
+            </if>
66
+            <if test="createDate != null" >
67
+                #{createDate,jdbcType=TIMESTAMP},
68
+            </if>
69
+            <if test="updateUser != null" >
70
+                #{updateUser,jdbcType=INTEGER},
71
+            </if>
72
+            <if test="updateDate != null" >
73
+                #{updateDate,jdbcType=TIMESTAMP},
74
+            </if>
75
+        </trim>
76
+    </insert>
77
+    <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TaFace">
78
+        update ta_face
79
+        <set >
80
+            <if test="communityId != null" >
81
+                community_id = #{communityId,jdbcType=INTEGER},
82
+            </if>
83
+            <if test="taUserVerifyId != null" >
84
+                ta_user_verify_id = #{taUserVerifyId,jdbcType=INTEGER},
85
+            </if>
86
+            <if test="faceImg != null" >
87
+                face_img = #{faceImg,jdbcType=VARCHAR},
88
+            </if>
89
+            <if test="createUser != null" >
90
+                create_user = #{createUser,jdbcType=INTEGER},
91
+            </if>
92
+            <if test="createDate != null" >
93
+                create_date = #{createDate,jdbcType=TIMESTAMP},
94
+            </if>
95
+            <if test="updateUser != null" >
96
+                update_user = #{updateUser,jdbcType=INTEGER},
97
+            </if>
98
+            <if test="updateDate != null" >
99
+                update_date = #{updateDate,jdbcType=TIMESTAMP},
100
+            </if>
101
+        </set>
102
+        where id = #{id,jdbcType=INTEGER}
103
+    </update>
104
+
105
+    <select id="getByUserVerifyId" resultType="com.community.huiju.model.TaFace" parameterType="java.lang.Integer">
106
+        select
107
+        id, community_id,ta_user_verify_id,face_img,create_user, create_date, update_user,
108
+        update_date
109
+        from ta_face
110
+        where ta_user_verify_id = #{userVerifyId,jdbcType=INTEGER}
111
+    </select>
112
+
113
+    <select id="getById" resultType="com.community.huiju.model.TaFace"  parameterType="java.lang.Integer" >
114
+        select
115
+        id, community_id,ta_user_verify_id,face_img,create_user, create_date, update_user,
116
+        update_date
117
+        from ta_face
118
+        where id = #{id,jdbcType=INTEGER}
119
+    </select>
120
+
121
+</mapper>

+ 16
- 0
CODE/smart-community/property-api/src/main/resources/mapper/TaUserVerifyMapper.xml Dosyayı Görüntüle

@@ -59,4 +59,20 @@
59 59
         and user_id = #{userId}
60 60
         and role_id = #{roleId}
61 61
     </select>
62
+
63
+    <select id="selectUserVerifyCommunityAndAddress" resultType="com.community.huiju.model.TaUserVerify">
64
+        select
65
+          *
66
+        from ta_user_verify
67
+        where community_id = #{communityId,jdbcType=INTEGER}
68
+        and user_id = #{userId,jdbcType=INTEGER}
69
+        and phase_id = #{phaseId,jdbcType=INTEGER}
70
+        and building_id = #{buildingId,jdbcType=INTEGER}
71
+        and unit_id = #{unitId,jdbcType=INTEGER}
72
+        and level_id = #{levelId,jdbcType=INTEGER}
73
+        and room_no_id = #{roomNoId,jdbcType=INTEGER}
74
+        <if test="verifyStatus != null and verifyStatus != ''">
75
+            and verify_status = #{verifyStatus}
76
+        </if>
77
+    </select>
62 78
 </mapper>