Преглед на файлове

修改 单元门和文案

魏熙美 преди 6 години
родител
ревизия
27fc90f343

+ 6
- 5
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/HkController.java Целия файл

@@ -59,15 +59,16 @@ public class HkController extends BaseController {
59 59
 		return responseBean;
60 60
 	}
61 61
 
62
-	@ApiOperation(value = "门口机开门", notes = "门口机开门")
62
+	@ApiOperation(value = "门口机(可视对讲)开门", notes = "门口机(可是对讲)开门")
63 63
 	@ApiImplicitParams({
64
-			@ApiImplicitParam(dataTypeClass = Integer.class, paramType = "header", name = "X-Auth-Token", value = "Token")
64
+			@ApiImplicitParam(dataTypeClass = Integer.class, paramType = "header", name = "X-Auth-Token", value = "Token"),
65
+			@ApiImplicitParam(dataTypeClass = Integer.class, paramType = "path", name = "id", value = "设备id"),
65 66
 	})
66
-	@RequestMapping(value = "/visual/syncControl", method = RequestMethod.POST)
67
-	public ResponseBean syncControl( HttpServletRequest request, HttpSession session){
67
+	@RequestMapping(value = "/visual/syncControl/{id}", method = RequestMethod.POST)
68
+	public ResponseBean syncControl(HttpServletRequest request, HttpSession session, @PathVariable("id") Integer equipmentId){
68 69
 		ResponseBean responseBean = new ResponseBean();
69 70
 		UserElement userElement = getUserElement(session);
70
-		responseBean = ihkService.syncControl(userElement.getUserVerifyId());
71
+		responseBean = ihkService.syncControl(userElement, equipmentId);
71 72
 		return responseBean;
72 73
 	}
73 74
 

+ 1
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/VistorController.java Целия файл

@@ -66,8 +66,7 @@ public class VistorController extends BaseController {
66 66
         }
67 67
 
68 68
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
69
-        Integer userId = userElement.getId();
70
-        responseBean = vistorServiceI.invateHis(communityId, userId);
69
+        responseBean = vistorServiceI.invateHis(userElement);
71 70
         return  responseBean;
72 71
     }
73 72
 

+ 11
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpEquipmentMapper.java Целия файл

@@ -99,4 +99,15 @@ public interface TpEquipmentMapper {
99 99
     List<TpEquipment> selectByCommunityIdAndUnitIdAndFace(@Param("communityId") Integer communityId, @Param("unitId") Integer unitId, @Param("equipmentType") Integer equipmentType);
100 100
 
101 101
 
102
+    /**
103
+     * 根据小区更新 萤石云 token 和 token的有效期
104
+     *
105
+     * equipment_type 值为 5 表示门口机视频流
106
+     * @param communityId
107
+     * @param accessToken
108
+     * @param expireTime
109
+     * @return
110
+     */
111
+    @Select("update tp_equipment set op_user_uuid = #{accessToken} and unit_uuids = #{expireTime} where community_id = #{communityId} and equipment_type=5")
112
+    Integer updateYinShiYunByCommunityId(@Param("communityId") Integer communityId,@Param("accessToken") String accessToken, @Param("expireTime") String expireTime);
102 113
 }

+ 13
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TaVisitor.java Целия файл

@@ -2,6 +2,7 @@ package com.community.huiju.model;
2 2
 
3 3
 import java.util.Date;
4 4
 import java.util.List;
5
+import java.util.Map;
5 6
 
6 7
 public class TaVisitor {
7 8
     private Integer id;
@@ -36,6 +37,11 @@ public class TaVisitor {
36 37
 
37 38
     private List<String> carLicense;
38 39
 
40
+    /**
41
+     * 单元门集合
42
+     */
43
+    private List<Map<String, Object>> unitList;
44
+
39 45
     public Integer getId() {
40 46
         return id;
41 47
     }
@@ -164,4 +170,11 @@ public class TaVisitor {
164 170
         this.carLicense = carLicense;
165 171
     }
166 172
 
173
+    public List<Map<String, Object>> getUnitList() {
174
+        return unitList;
175
+    }
176
+
177
+    public void setUnitList(List<Map<String, Object>> unitList) {
178
+        this.unitList = unitList;
179
+    }
167 180
 }

+ 13
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpConfiguration.java Целия файл

@@ -27,6 +27,11 @@ public class TpConfiguration {
27 27
 
28 28
     private String deviceuuid;
29 29
 
30
+    /**
31
+     * 单元门展示名字
32
+     */
33
+    private String displayName;
34
+
30 35
     public Integer getId() {
31 36
         return id;
32 37
     }
@@ -122,4 +127,12 @@ public class TpConfiguration {
122 127
     public void setDeviceuuid(String deviceuuid) {
123 128
         this.deviceuuid = deviceuuid == null ? null : deviceuuid.trim();
124 129
     }
130
+
131
+    public String getDisplayName() {
132
+        return displayName;
133
+    }
134
+
135
+    public void setDisplayName(String displayName) {
136
+        this.displayName = displayName;
137
+    }
125 138
 }

+ 4
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/IHKService.java Целия файл

@@ -1,6 +1,7 @@
1 1
 package com.community.huiju.service;
2 2
 
3 3
 import com.community.commom.mode.ResponseBean;
4
+import com.community.commom.session.UserElement;
4 5
 
5 6
 /**
6 7
  * 海康 业务
@@ -22,11 +23,11 @@ public interface IHKService {
22 23
     ResponseBean downloadAuthorityByDeviceUuids();
23 24
 
24 25
     /**
25
-     * 异步反控开门 (远程开门)
26
+     * 异步反控开门 (远程开门(可视对讲,门口机))
26 27
      *
27
-     * @param userVerifyId 审核ID
28
+     * @param equipmentId 可视对讲设备id
28 29
      * @return
29 30
      */
30
-    ResponseBean syncControl(Integer userVerifyId);
31
+    ResponseBean syncControl(UserElement userElement, Integer equipmentId);
31 32
 
32 33
 }

+ 2
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/TaVistorServiceI.java Целия файл

@@ -23,11 +23,10 @@ public interface TaVistorServiceI {
23 23
 
24 24
     /**
25 25
      * 访客邀请记录
26
-     * @param communityId
27
-     * @param userId
26
+     * @param userElement
28 27
      * @return
29 28
      */
30
-    ResponseBean invateHis(Integer communityId, Integer userId);
29
+    ResponseBean invateHis(UserElement userElement);
31 30
 
32 31
     /**
33 32
      * 查询 邀请访客车辆 是否开启

+ 16
- 13
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/HKServiceImpl.java Целия файл

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
4 4
 import com.alibaba.fastjson.JSONObject;
5 5
 import com.community.commom.constant.Constant;
6 6
 import com.community.commom.mode.ResponseBean;
7
+import com.community.commom.session.UserElement;
7 8
 import com.community.commom.uuid.IdGen;
8 9
 import com.community.commom.hk.HKOpenApi;
9 10
 import com.community.huiju.dao.*;
@@ -209,7 +210,7 @@ public class HKServiceImpl implements IHKService {
209 210
         parUser.put("appkey", tpEquipmentTree.getAppkey());
210 211
         parUser.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
211 212
         Map<String, Object> resultMap = JSONObject.parseObject(HKOpenApi.addUser(parUser), HashMap.class);
212
-        int errorCode = (int) resultMap.get("errorCode");
213
+        Integer errorCode = (Integer) resultMap.get("errorCode");
213 214
         if (errorCode == 0) {
214 215
             Map<String, Object> resultDataMap = (Map<String, Object>) resultMap.get("data");
215 216
 
@@ -369,33 +370,35 @@ public class HKServiceImpl implements IHKService {
369 370
     }
370 371
 
371 372
     @Override
372
-    public ResponseBean syncControl(Integer userVerifyId) {
373
+    public ResponseBean syncControl(UserElement userElement, Integer equipmentId) {
373 374
         // TODO 暂时只支持开单元门
374 375
 
375 376
         ResponseBean responseBean = new ResponseBean();
376 377
 
377
-        // 查询当前的房产
378
-        TaUserVerify userVerify = taUserVerifyMapper.selectByPrimaryKey(userVerifyId);
379
-        TpEquipmentTree tpEquipmentTree = tpEquipmentTreeMapper.selectByCommunityId(userVerify.getCommunityId());
380 378
         // 单元门口机
381
-        List<TpEquipment> tpEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(userVerify.getCommunityId(), userVerify.getUnitId(), 3);
379
+        TpEquipment tpEquipment = tpEquipmentMapper.selectByPrimaryKey(equipmentId);
380
+        TpEquipmentTree tpEquipmentTree = tpEquipmentTreeMapper.selectByCommunityId(userElement.getCommunityId());
381
+        TaUserVerify userVerify = taUserVerifyMapper.selectByPrimaryKey(userElement.getId());
382 382
 
383
-         if (CollectionUtils.isEmpty(tpEquipments)) {
383
+        if (null == tpEquipment) {
384 384
              responseBean.addError("无设备信息!");
385 385
              return responseBean;
386 386
          }
387 387
 
388
-         String str = "";
389
-         for (TpEquipment e : tpEquipments) {
390
-             TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(e.getUuidId());
391
-             str += tpConfiguration.getConfigurationValue();
392
-             str += ",";
388
+         if ("3".equals(tpEquipment.getEquipmentType())) {
389
+             responseBean.addError("不是单元门设备!");
390
+             return responseBean;
393 391
          }
394 392
 
393
+         String str = "";
394
+
395
+         // uuid_id 是可是对讲设备
396
+         TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(tpEquipment.getUuidId());
397
+
395 398
         // 查询设备编号
396 399
 
397 400
         Map<String,Object> parMap = com.beust.jcommander.internal.Maps.newHashMap();
398
-        parMap.put("longNums", str);
401
+        parMap.put("longNums", tpConfiguration.getConfigurationValue());
399 402
         parMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
400 403
         parMap.put("secret", tpEquipmentTree.getSecret());
401 404
         parMap.put("appkey", tpEquipmentTree.getAppkey());

+ 39
- 27
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/MonitoringServiceImpl.java Целия файл

@@ -250,6 +250,8 @@ public class MonitoringServiceImpl implements IMonitoringService {
250 250
 
251 251
         /**
252 252
          * tp_equipment 表
253
+         *      url_id 是可视对讲视频流id配置
254
+         *      uuid_id 是可视对讲视设备
253 255
          *      op_user_uuid 是监控的Token,
254 256
          *      unit_uuids 是token的有效时间
255 257
          *      appkey 是视频流的appKey
@@ -261,42 +263,52 @@ public class MonitoringServiceImpl implements IMonitoringService {
261 263
          *
262 264
          */
263 265
 
264
-        List<TpEquipment> tpEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(userElement.getCommunityId(), userElement.getUnitId(), 5);
266
+        List<TpEquipment> tpEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(userElement.getCommunityId(), userElement.getUnitId(), 3);
265 267
         if (CollectionUtils.isEmpty(tpEquipments)) {
266 268
             String address = toCommunities.getCommunityName() + tpUnit.getPhaseName() + tpUnit.getBuildingName() + tpUnit.getName();
267 269
             responseBean.addError("系统未配置单元门口机设备!", address, null);
268 270
             return responseBean;
269 271
         }
270
-        TpEquipment tpEquipment = tpEquipments.get(0);
271
-        TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(tpEquipment.getUuidId());
272
-
273
-        // 判断视频流地址,是否过期
274
-        if (StringUtils.isBlank(tpEquipment.getOpUserUuid()) || System.currentTimeMillis() >= Long.valueOf(tpEquipment.getUnitUuids())) {
275
-            // 开始更新视频Token
276
-            Map<String,Object> queryMap = new HashMap<>();
277
-            queryMap.put("appKey", tpEquipment.getAppkey());
278
-            queryMap.put("appSecret", tpEquipment.getSecret());
279
-            try {
280
-                String result = OkHttpRequestUtils.doPost(yinShiProperties.getVideoTokenUrl(), queryMap);
281
-                JSONObject jsonObject = JSONObject.parseObject(result).getJSONObject("data");
282
-                tpEquipment.setOpUserUuid(jsonObject.getString("accessToken"));
283
-                tpEquipment.setUnitUuids(String.valueOf(jsonObject.getLong("expireTime")));
284
-                tpEquipmentMapper.updateByPrimaryKeySelective(tpEquipment);
285
-            } catch (Exception e) {
286
-                throw new WisdomException("获取视频Token失败!");
272
+
273
+        List<Map<String,Object>> resultMap = tpEquipments.stream().map(e -> {
274
+            // 获取视频地址
275
+            TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(e.getUrlId());
276
+            // 判断视频流地址,是否过期
277
+            if (StringUtils.isBlank(e.getOpUserUuid()) || System.currentTimeMillis() >= Long.valueOf(e.getUnitUuids())) {
278
+                // 开始更新视频Token
279
+                Map<String,Object> queryMap = new HashMap<>();
280
+                queryMap.put("appKey", e.getAppkey());
281
+                queryMap.put("appSecret", e.getSecret());
282
+                try {
283
+                    String result = OkHttpRequestUtils.doPost(yinShiProperties.getVideoTokenUrl(), queryMap);
284
+                    JSONObject jsonObject = JSONObject.parseObject(result).getJSONObject("data");
285
+                    String accessToken = jsonObject.getString("accessToken");
286
+                    String expireTime = String.valueOf(jsonObject.getLong("expireTime"));
287
+                    // 根据小区更新所有的门口机的萤石云 token, token有效期
288
+                    tpEquipmentMapper.updateYinShiYunByCommunityId(userElement.getCommunityId(), accessToken, expireTime);
289
+                } catch (Exception exception) {
290
+                    throw new WisdomException("获取视频Token失败!");
291
+                }
292
+
287 293
             }
288 294
 
289
-        }
295
+            Map<String,Object> map = new HashMap<>();
296
+            map.put("equipmentsId", e.getId());
297
+            // 流程视频流地址
298
+            map.put("url", tpConfiguration.getConfigurationValue());
299
+            // 高清视频流地址
300
+            map.put("url_high", tpConfiguration.getKey());
301
+            map.put("address", toCommunities.getCommunityName() + tpUnit.getPhaseName() + tpUnit.getBuildingName() + tpUnit.getName());
302
+            // 门口机位置(可视对讲) ,例如:东门
303
+            map.put("displayName", tpConfiguration.getDisplayName());
304
+            map.put("token", e.getOpUserUuid());
305
+
306
+            return map;
307
+
308
+        }).collect(Collectors.toList());
290 309
 
291 310
 
292
-        Map<String,Object> map = new HashMap<>();
293
-        // 流程视频流地址
294
-        map.put("url", tpConfiguration.getConfigurationValue());
295
-        // 高清视频流地址
296
-        map.put("url_high", tpConfiguration.getKey());
297
-        map.put("address", toCommunities.getCommunityName() + tpUnit.getPhaseName() + tpUnit.getBuildingName() + tpUnit.getName());
298
-        map.put("token", tpEquipment.getOpUserUuid());
299
-        responseBean.addSuccess(map);
311
+        responseBean.addSuccess(resultMap);
300 312
 
301 313
         // 记录 单元门监控查看
302 314
         TaRemotelyMonitor taRemotelyMonitor = new TaRemotelyMonitor();

+ 31
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaVistorServiceImpl.java Целия файл

@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
17 17
 import java.util.Date;
18 18
 import java.util.List;
19 19
 import java.util.Map;
20
+import java.util.stream.Collectors;
20 21
 
21 22
 /**
22 23
  * @author weichaochao
@@ -43,6 +44,10 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
43 44
     @Autowired
44 45
     private TaVisitorLicenseSettingMapper taVisitorLicenseSettingMapper;
45 46
 
47
+    @Autowired
48
+    private TpUnitMapper tpUnitMapper;
49
+
50
+
46 51
     @Override
47 52
     @Transactional(rollbackFor = Exception.class)
48 53
     public ResponseBean insertTaVistor(TaVisitor taVisitor, UserElement userElement) {
@@ -79,20 +84,31 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
79 84
         }
80 85
 
81 86
         // 推送海康
82
-        temporaryRegister(userElement.getId(),taVisitor, userElement.getCommunityId(), response);
87
+        temporaryRegister(userElement.getId(),taVisitor, userElement.getCommunityId(), response, userElement);
83 88
 
84 89
         return response;
85 90
     }
86 91
 
87 92
     @Override
88
-    public ResponseBean invateHis(Integer communityId, Integer userId) {
93
+    public ResponseBean invateHis(UserElement userElement) {
89 94
         ResponseBean responseBean = new ResponseBean();
90
-        List<TaVisitor> taVisitors = taVisitorMapper.findAllVistors(communityId, userId);
95
+        List<TaVisitor> taVisitors = taVisitorMapper.findAllVistors(userElement.getCommunityId(), userElement.getId());
96
+
97
+        // 查询出所有的单元门
98
+        List<TpUnit> unitList = tpUnitMapper.selectByAddress(userElement.getCommunityId(), userElement.getPhaseId(), userElement.getBuildingId());
99
+        List<Map<String, Object>> unitMapList = unitList.stream().map(e -> {
100
+            Map<String, Object> unitMap = Maps.newHashMap();
101
+            unitMap.put("id", e.getId());
102
+            unitMap.put("unit", e.getPhaseName() + e.getBuildingName() + e.getName());
103
+
104
+            return unitMap;
105
+        }).collect(Collectors.toList());
91 106
 
92 107
         for (TaVisitor taVisitor : taVisitors){
93 108
             if (Constant.EFFECTIVE.equals(taVisitor.getDrivingStatus())){
94 109
                 List<String> taVisitorLicenses = taVisitorLicenseMapper.findTaVistorLicenseById(taVisitor.getId());
95 110
                 taVisitor.setCarLicense(taVisitorLicenses);
111
+                taVisitor.setUnitList(unitMapList);
96 112
             }
97 113
         }
98 114
         responseBean.addSuccess(taVisitors);
@@ -106,7 +122,17 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
106 122
      * @param userId 被访人ID
107 123
      * @param visitor
108 124
      */
109
-    private void temporaryRegister(Integer userId,TaVisitor visitor, Integer communityId ,ResponseBean response){
125
+    private void temporaryRegister(Integer userId,TaVisitor visitor, Integer communityId ,ResponseBean response, UserElement userElement){
126
+        // 查询出所有的单元门
127
+        List<TpUnit> unitList = tpUnitMapper.selectByAddress(communityId, userElement.getPhaseId(), userElement.getBuildingId());
128
+        List<Map<String, Object>> unitMapList = unitList.stream().map(e -> {
129
+            Map<String, Object> unitMap = Maps.newHashMap();
130
+            unitMap.put("id", e.getId());
131
+            unitMap.put("unit", e.getPhaseName() + e.getBuildingName() + e.getName());
132
+
133
+            return unitMap;
134
+        }).collect(Collectors.toList());
135
+
110 136
 
111 137
         // 获取设备树,里面有 opUserId
112 138
         TpEquipmentTree tpEquipmentTree = tpEquipmentTreeMapper.selectByCommunityId(communityId);
@@ -127,6 +153,7 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
127 153
             map.put("visitorEndTime",visitor.getVisitorEndTime());
128 154
             map.put("drivingStatus",visitor.getDrivingStatus());
129 155
             map.put("payEntity",visitor.getPayEntity());
156
+            map.put("unitMapList", unitMapList);
130 157
 
131 158
             // 把访问码存入
132 159
             visitor.setVisitorCode(visitorCode);

+ 2
- 1
CODE/smart-community/app-api/src/main/resources/mapper/TpConfigurationMapper.xml Целия файл

@@ -14,10 +14,11 @@
14 14
     <result column="community_id" property="communityId" jdbcType="INTEGER" />
15 15
     <result column="doorUuid" property="dooruuid" jdbcType="VARCHAR" />
16 16
     <result column="deviceUuid" property="deviceuuid" jdbcType="VARCHAR" />
17
+    <result column="display_name" property="displayName"/>
17 18
   </resultMap>
18 19
   <sql id="Base_Column_List" >
19 20
     id, `key`, configuration_name, configuration_type, configuration_value, create_tiem,
20
-    create_user, update_time, update_user, community_id, doorUuid, deviceUuid
21
+    create_user, update_time, update_user, community_id, doorUuid, deviceUuid, display_name
21 22
   </sql>
22 23
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
23 24
     select