ソースを参照

修改迎宾推送接口

魏熙美 6 年 前
コミット
6e33d54444

+ 3
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/UserController.java ファイルの表示

@@ -255,16 +255,15 @@ public class UserController extends BaseController {
255 255
     @ApiOperation(value = "迎宾系统添加人员", notes = "迎宾系统添加人员")
256 256
     @ApiImplicitParams({
257 257
             @ApiImplicitParam(paramType = "form", dataTypeClass = String.class, value = "userName人员名称"),
258
-            @ApiImplicitParam(paramType = "form", dataTypeClass = MultipartFile.class, name = "file", value = "图片"),
259
-            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
258
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
260 259
     })
261 260
     @RequestMapping(value = "/user/welcome/add", method = RequestMethod.POST)
262
-    public ResponseBean welcomeAddUser(@RequestParam("userName") String userName, @RequestParam("file") MultipartFile file, HttpSession session) {
261
+    public ResponseBean welcomeAddUser(@RequestParam("userName") String userName, HttpSession session) {
263 262
         ResponseBean responseBean = new ResponseBean();
264 263
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
265 264
         TaUser user = new TaUser();
266 265
         user.setUserName(userName);
267
-        responseBean = iTaUserService.welcomeFace(userElement, file, user);
266
+        responseBean = iTaUserService.addWelcomeUser(userElement, user);
268 267
         return responseBean;
269 268
     }
270 269
 }

+ 8
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/FaceServiceI.java ファイルの表示

@@ -32,4 +32,12 @@ public interface FaceServiceI {
32 32
      */
33 33
     ResponseBean getTaFaceByUserId(Integer userId,Integer otherUserId);
34 34
 
35
+    /**
36
+     * 迎宾人员 添加人脸
37
+     * @param uploadFile
38
+     * @param user
39
+     * @return
40
+     */
41
+    ResponseBean addWelcomeFace(MultipartFile uploadFile, TaUser user);
42
+
35 43
 }

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/ITaUserService.java ファイルの表示

@@ -116,12 +116,12 @@ public interface ITaUserService {
116 116
     ResponseBean temporaryLogin(Integer communityId);
117 117
 
118 118
     /**
119
-     * 迎宾专用 接口
119
+     * 迎宾专用 接口  添加人员
120 120
      * @param userElement
121
-     * @param uploadFile
121
+     * @param user
122 122
      * @param user
123 123
      * @return
124 124
      */
125
-    ResponseBean welcomeFace(UserElement userElement, MultipartFile uploadFile, TaUser user);
125
+    ResponseBean addWelcomeUser(UserElement userElement,TaUser user);
126 126
 
127 127
 }

+ 72
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/FaceServicelimpl.java ファイルの表示

@@ -5,9 +5,11 @@ import com.community.commom.constant.Constant;
5 5
 import com.community.commom.mode.ResponseBean;
6 6
 import com.community.commom.session.UserElement;
7 7
 import com.community.huiju.common.hk.HKOpenApi;
8
+import com.community.huiju.common.welcome.WelcomeProperties;
8 9
 import com.community.huiju.dao.TaFaceMapper;
9 10
 import com.community.huiju.dao.TaSysRoleMapper;
10 11
 import com.community.huiju.dao.TaUserMapper;
12
+import com.community.huiju.exception.WisdomException;
11 13
 import com.community.huiju.model.TaFace;
12 14
 import com.community.huiju.model.TaSysRole;
13 15
 import com.community.huiju.model.TaUser;
@@ -15,8 +17,13 @@ import com.community.huiju.service.FaceServiceI;
15 17
 import com.community.huiju.service.ImageServiceI;
16 18
 import lombok.extern.slf4j.Slf4j;
17 19
 import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.http.HttpEntity;
21
+import org.springframework.http.HttpHeaders;
22
+import org.springframework.http.HttpMethod;
23
+import org.springframework.http.MediaType;
18 24
 import org.springframework.stereotype.Service;
19 25
 import org.springframework.transaction.annotation.Transactional;
26
+import org.springframework.web.client.RestTemplate;
20 27
 import org.springframework.web.multipart.MultipartFile;
21 28
 import java.io.IOException;
22 29
 import java.util.ArrayList;
@@ -41,11 +48,23 @@ public class FaceServicelimpl implements FaceServiceI {
41 48
     @Autowired
42 49
     private ImageServiceI imageServiceI;
43 50
 
51
+    @Autowired
52
+    private WelcomeProperties welcomeProperties;
53
+
44 54
     @Override
45 55
     @Transactional(rollbackFor = Exception.class)
46 56
     public ResponseBean addFace(Integer userid, MultipartFile uploadFile,Integer otherUserId) {
47 57
         ResponseBean responseBean= new ResponseBean();
48 58
 
59
+        // 判断是否是迎宾系统人员
60
+        TaUser welcomeUser = taUserMapper.selectByPrimaryKey(otherUserId);
61
+        if (null != welcomeUser && null != welcomeProperties.getCommunityId() && welcomeUser.getCommunityId().intValue() == welcomeProperties.getCommunityId()) {
62
+            // 开始推送迎宾
63
+            responseBean = addWelcomeFace(uploadFile, welcomeUser);
64
+            return responseBean;
65
+        }
66
+
67
+
49 68
          String faceImg =img(uploadFile);
50 69
         /**当otherUserId不为空时判断它是否是业主下的租客或者家属*/
51 70
         if (null!= otherUserId) {
@@ -267,6 +286,59 @@ public class FaceServicelimpl implements FaceServiceI {
267 286
         response.addError("您的信息已存在");
268 287
         return response;
269 288
     }
289
+
290
+    @Override
291
+    @Transactional(rollbackFor = Exception.class)
292
+    public ResponseBean addWelcomeFace(MultipartFile uploadFile, TaUser user) {
293
+        ResponseBean responseBean = new ResponseBean();
294
+
295
+        // 开始推送 迎宾系统
296
+        String result = "";
297
+        try {
298
+//            Map<String, Object> parameterMap = Maps.newHashMap();
299
+//            parameterMap.put("userName", user.getUserName());
300
+//            String welcomeUrl = welcomeProperties.getUrl() + "/" + user.getId();
301
+//            OkHttpRequestUtils.doPost(welcomeUrl, Maps.newHashMap(), parameterMap, uploadFile.getOriginalFilename(), uploadFile.getBytes());
302
+
303
+            RestTemplate restTemplate = new RestTemplate();
304
+            String faceUrl = welcomeProperties.getUrl() + "/" + user.getId() + "?userName=" + user.getUserName();
305
+            HttpHeaders headers = new HttpHeaders();
306
+            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
307
+            HttpEntity httpEntity = new HttpEntity(uploadFile.getBytes());
308
+            result = restTemplate.exchange(faceUrl, HttpMethod.POST, httpEntity, String.class).getBody();
309
+        } catch (Exception e) {
310
+            e.printStackTrace();
311
+            log.error("推送 迎宾系统失败!", e);
312
+            throw new WisdomException("推送 迎宾系统失败!");
313
+        }
314
+
315
+        JSONObject jsonObject = JSONObject.parseObject(result);
316
+        if (!jsonObject.get("code").equals(200)){
317
+            String message = jsonObject.get("message").toString();
318
+            log.error(" 推送 迎宾系统失败! {}",message);
319
+            throw new WisdomException(message);
320
+        }
321
+
322
+        // 开始存储人脸的图片到本地库
323
+        TaFace taFace = new TaFace();
324
+        taFace.setCommunityId(user.getCommunityId());
325
+        taFace.setCreateDate(new Date());
326
+        taFace.setCreateUser(user.getId());
327
+        taFace.setTaUserId(user.getId());
328
+        taFace.setUpdateDate(new Date());
329
+        taFace.setUpdateUser(user.getId());
330
+        try {
331
+            taFace.setFaceImg(imageServiceI.getImageUrl(uploadFile));
332
+        } catch (IOException e) {
333
+            e.printStackTrace();
334
+            log.error("迎宾系统 人脸图片上传阿里云失败!", e);
335
+        }
336
+
337
+        taFaceMapper.insertSelective(taFace);
338
+
339
+        responseBean.addSuccess("操作成功!");
340
+        return responseBean;
341
+    }
270 342
 }
271 343
 
272 344
 

+ 6
- 49
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java ファイルの表示

@@ -999,10 +999,12 @@ public class TaUserServiceImpl implements ITaUserService {
999 999
     }
1000 1000
 
1001 1001
     @Override
1002
-    @Transactional(rollbackFor = Exception.class)
1003
-    public ResponseBean welcomeFace(UserElement userElement, MultipartFile uploadFile, TaUser user) {
1002
+    public ResponseBean addWelcomeUser(UserElement userElement, TaUser user) {
1004 1003
         ResponseBean responseBean = new ResponseBean();
1005 1004
 
1005
+        TaUser currentUser = taUserMapper.selectByPrimaryKey(userElement.getId());
1006
+
1007
+        user.setBuildingOwnerInfoId(currentUser.getBuildingOwnerInfoId());
1006 1008
         user.setCommunityId(userElement.getCommunityId());
1007 1009
         user.setParentId(userElement.getId());
1008 1010
         user.setCreateDate(new Date());
@@ -1010,6 +1012,7 @@ public class TaUserServiceImpl implements ITaUserService {
1010 1012
         user.setCommunityId(userElement.getCommunityId());
1011 1013
         user.setVerifyStatus("1");
1012 1014
         user.setAcceptAgreementStatus("1");
1015
+        user.setFaceStatus("0");
1013 1016
         user.setStatus("1");
1014 1017
 
1015 1018
         int rows = taUserMapper.insertSelective(user);
@@ -1020,53 +1023,7 @@ public class TaUserServiceImpl implements ITaUserService {
1020 1023
 
1021 1024
         // 角色  2 表示租客
1022 1025
         addOrUpdateUserRole(2,responseBean,user,true);
1023
-
1024
-        // 开始推送 迎宾系统
1025
-
1026
-        String result = "";
1027
-
1028
-        try {
1029
-//            Map<String, Object> parameterMap = Maps.newHashMap();
1030
-//            parameterMap.put("userName", user.getUserName());
1031
-//            String welcomeUrl = welcomeProperties.getUrl() + "/" + user.getId();
1032
-//            OkHttpRequestUtils.doPost(welcomeUrl, Maps.newHashMap(), parameterMap, uploadFile.getOriginalFilename(), uploadFile.getBytes());
1033
-
1034
-            RestTemplate restTemplate = new RestTemplate();
1035
-            String faceUrl = welcomeProperties.getUrl() + "/" + user.getId() + "?userName=" + user.getUserName();
1036
-            HttpHeaders headers = new HttpHeaders();
1037
-            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
1038
-            HttpEntity httpEntity = new HttpEntity(uploadFile.getBytes());
1039
-            result = restTemplate.exchange(faceUrl, HttpMethod.POST, httpEntity, String.class).getBody();
1040
-        } catch (Exception e) {
1041
-            e.printStackTrace();
1042
-            log.error("推送 迎宾系统失败!", e);
1043
-        }
1044
-
1045
-        JSONObject jsonObject = JSONObject.parseObject(result);
1046
-        if (!jsonObject.get("code").equals(200)){
1047
-            String message = jsonObject.get("message").toString();
1048
-            log.error(" 推送 迎宾系统失败! {}",message);
1049
-            throw new WisdomException(message);
1050
-        }
1051
-
1052
-        // 开始存储人脸的图片到本地库
1053
-        TaFace taFace = new TaFace();
1054
-        taFace.setCommunityId(user.getCommunityId());
1055
-        taFace.setCreateDate(new Date());
1056
-        taFace.setCreateUser(user.getId());
1057
-        taFace.setTaUserId(user.getId());
1058
-        taFace.setUpdateDate(new Date());
1059
-        taFace.setUpdateUser(user.getId());
1060
-        try {
1061
-            taFace.setFaceImg(imageService.getImageUrl(uploadFile));
1062
-        } catch (IOException e) {
1063
-            e.printStackTrace();
1064
-            log.error("迎宾系统 人脸图片上传阿里云失败!", e);
1065
-        }
1066
-
1067
-        taFaceMapper.insertSelective(taFace);
1068
-
1069
-        responseBean.addSuccess("操作成功!");
1026
+        responseBean.addSuccess(user);
1070 1027
         return responseBean;
1071 1028
     }
1072 1029
 }