浏览代码

完善 访客

weiximei 6 年前
父节点
当前提交
951e073645

+ 6
- 6
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/HKOpenApi.java 查看文件

@@ -440,12 +440,12 @@ public class HKOpenApi {
440 440
     
441 441
     /**
442 442
      * 未预约登记
443
-     * @param visitorName
444
-     * @param phoneNo
445
-     * @param personNum
446
-     * @param startTime
447
-     * @param endTime
448
-     * @param personId
443
+     * @param visitorName 访客姓名
444
+     * @param phoneNo 联系电话
445
+     * @param personNum 来访人数
446
+     * @param startTime 来访时间
447
+     * @param endTime 离开时间
448
+     * @param personId 被访人ID
449 449
      * @return
450 450
      */
451 451
     public static String temporaryRegister(String visitorName, String phoneNo,Integer personNum,Long startTime,Long endTime,Integer personId){

+ 1
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/VistorController.java 查看文件

@@ -46,7 +46,7 @@ public class VistorController extends BaseController {
46 46
 
47 47
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
48 48
         Integer userId = userElement.getId();
49
-        vistorServiceI.insertTaVistor(taVisitor, communityId, userId);
49
+        responseBean = vistorServiceI.insertTaVistor(taVisitor, communityId, userId);
50 50
         return  responseBean;
51 51
     }
52 52
 

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TaVisitor.java 查看文件

@@ -16,7 +16,7 @@ public class TaVisitor {
16 16
 
17 17
     private Date visitorStatrtTime;
18 18
 
19
-    private Integer visitorEndTime;
19
+    private Date visitorEndTime;
20 20
 
21 21
     private String drivingStatus;
22 22
 
@@ -84,11 +84,11 @@ public class TaVisitor {
84 84
         this.visitorStatrtTime = visitorStatrtTime;
85 85
     }
86 86
 
87
-    public Integer getVisitorEndTime() {
87
+    public Date getVisitorEndTime() {
88 88
         return visitorEndTime;
89 89
     }
90 90
 
91
-    public void setVisitorEndTime(Integer visitorEndTime) {
91
+    public void setVisitorEndTime(Date visitorEndTime) {
92 92
         this.visitorEndTime = visitorEndTime;
93 93
     }
94 94
 

+ 9
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/TaVistorServiceI.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.community.huiju.service;
2 2
 
3
+import com.community.commom.mode.ResponseBean;
3 4
 import com.community.huiju.model.TaVisitor;
4 5
 
5 6
 import java.util.List;
@@ -11,6 +12,13 @@ import java.util.List;
11 12
  * @date 2018/11/1
12 13
  */
13 14
 public interface TaVistorServiceI {
14
-    void insertTaVistor(TaVisitor taVisitor, Integer communityId, Integer userId);
15
+    /**
16
+     * 创建访客
17
+     * @param taVisitor
18
+     * @param communityId
19
+     * @param userId
20
+     * @return
21
+     */
22
+    ResponseBean insertTaVistor(TaVisitor taVisitor, Integer communityId, Integer userId);
15 23
     List<TaVisitor> invateHis(Integer communityId, Integer userId);
16 24
 }

+ 57
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaVistorServiceImpl.java 查看文件

@@ -1,16 +1,25 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.community.commom.constant.Constant;
5
+import com.community.commom.mode.ResponseBean;
6
+import com.community.huiju.common.hk.HKOpenApi;
7
+import com.community.huiju.dao.TaUserMapper;
4 8
 import com.community.huiju.dao.TaVisitorLicenseMapper;
5 9
 import com.community.huiju.dao.TaVisitorMapper;
10
+import com.community.huiju.model.TaUser;
6 11
 import com.community.huiju.model.TaVisitor;
7 12
 import com.community.huiju.model.TaVisitorLicense;
8 13
 import com.community.huiju.service.TaVistorServiceI;
14
+import com.google.common.collect.Maps;
15
+import lombok.extern.slf4j.Slf4j;
9 16
 import org.springframework.beans.factory.annotation.Autowired;
10 17
 import org.springframework.stereotype.Service;
18
+import org.springframework.transaction.annotation.Transactional;
11 19
 
12 20
 import java.util.Date;
13 21
 import java.util.List;
22
+import java.util.Map;
14 23
 
15 24
 /**
16 25
  * @author weichaochao
@@ -19,6 +28,7 @@ import java.util.List;
19 28
  * @date 2018/11/1
20 29
  */
21 30
 @Service("TaVistorServiceImpl")
31
+@Slf4j
22 32
 public class TaVistorServiceImpl implements TaVistorServiceI {
23 33
 
24 34
     @Autowired
@@ -27,8 +37,13 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
27 37
     @Autowired
28 38
     private TaVisitorLicenseMapper taVisitorLicenseMapper;
29 39
 
40
+    @Autowired
41
+    private TaUserMapper taUserMapper;
42
+
30 43
     @Override
31
-    public void insertTaVistor(TaVisitor taVisitor, Integer communityId, Integer userId) {
44
+    @Transactional(rollbackFor = Exception.class)
45
+    public ResponseBean insertTaVistor(TaVisitor taVisitor, Integer communityId, Integer userId) {
46
+        ResponseBean response = new ResponseBean();
32 47
 
33 48
         //todo 推送到海康然后返回给我们一个vistor_code,暂未提供
34 49
 
@@ -37,6 +52,7 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
37 52
         taVisitor.setCreateUser(userId);
38 53
         taVisitor.setCreateDate(new Date());
39 54
         taVisitor.setUpdateDate(new Date());
55
+        taVisitor.setCommunityId(communityId);
40 56
 
41 57
         if (Constant.EFFECTIVE.equals(taVisitor.getDrivingStatus())){
42 58
             taVisitorMapper.insertSelective(taVisitor);
@@ -56,6 +72,10 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
56 72
             taVisitorMapper.insertSelective(taVisitor);
57 73
         }
58 74
 
75
+        // 推送海康
76
+        temporaryRegister(userId,taVisitor,response);
77
+
78
+        return response;
59 79
     }
60 80
 
61 81
     @Override
@@ -70,4 +90,40 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
70 90
         }
71 91
         return taVisitors;
72 92
     }
93
+
94
+    /**
95
+     * 推送海康
96
+     *
97
+     * 未预约登记(临时登记)【V2.8.2】
98
+     * @param userId 被访人ID
99
+     * @param visitor
100
+     */
101
+    private void temporaryRegister(Integer userId,TaVisitor visitor,ResponseBean response){
102
+        TaUser taUser = taUserMapper.selectByPrimaryKey(userId);
103
+        String result = HKOpenApi.temporaryRegister(visitor.getVisitorName(),visitor.getVisitorTel(),
104
+                Integer.valueOf(visitor.getVisitorNum()),visitor.getVisitorStatrtTime().getTime(),
105
+                visitor.getVisitorEndTime().getTime(),taUser.getHkUserId());
106
+
107
+        JSONObject resultJSON = JSONObject.parseObject(result);
108
+        int errorCode = resultJSON.getInteger("errorCode");
109
+        if (errorCode == 0) {
110
+            String visitorCode = resultJSON.getJSONObject("data").getString("QRCode");
111
+            Map<String,Object> map = Maps.newHashMap();
112
+            map.put("message","创建访问登记成功!");
113
+            map.put("visitorCode",resultJSON.getJSONObject("data").getString("QRCode"));
114
+
115
+            // 把访问码存入
116
+            visitor.setVisitorCode(visitorCode);
117
+            taVisitorMapper.updateByPrimaryKeySelective(visitor);
118
+
119
+            response.addSuccess(map);
120
+            return;
121
+        }
122
+
123
+        String errorMessage = resultJSON.getString("errorMessage");
124
+        response.addError("创建访问登记失败!");
125
+        log.error("创建访问登记失败! 错误信息: {}",errorMessage);
126
+        throw new RuntimeException("创建访问登记失败!" + errorMessage);
127
+
128
+    }
73 129
 }

+ 2
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TicketServiceImpl.java 查看文件

@@ -149,8 +149,8 @@ public class TicketServiceImpl implements ITicketService {
149 149
         List<TpTicketVO> tpTicketVOList = Lists.newArrayList();
150 150
         tpTicketVOConvert(tpTicketList, tpTicketVOList);
151 151
         Map<String, Object> map = Maps.newHashMap();
152
-        map.put("pagelist",pagelist.getTotal());
153
-        map.put("total",tpTicketVOList);
152
+        map.put("pagelist",tpTicketVOList);
153
+        map.put("total",pagelist.getTotal());
154 154
 
155 155
         response.addSuccess(map);
156 156
 

+ 6
- 6
CODE/smart-community/app-api/src/main/resources/mapper/TaVisitorMapper.xml 查看文件

@@ -8,7 +8,7 @@
8 8
     <result column="visitor_tel" property="visitorTel" jdbcType="VARCHAR" />
9 9
     <result column="visitor_num" property="visitorNum" jdbcType="VARCHAR" />
10 10
     <result column="visitor_statrt_time" property="visitorStatrtTime" jdbcType="TIMESTAMP" />
11
-    <result column="visitor_end_time" property="visitorEndTime" jdbcType="INTEGER" />
11
+    <result column="visitor_end_time" property="visitorEndTime" jdbcType="TIMESTAMP" />
12 12
     <result column="driving_status" property="drivingStatus" jdbcType="CHAR" />
13 13
     <result column="pay_entity" property="payEntity" jdbcType="VARCHAR" />
14 14
     <result column="visitor_code" property="visitorCode" jdbcType="VARCHAR" />
@@ -42,7 +42,7 @@
42 42
       )
43 43
     values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{visitorName,jdbcType=VARCHAR}, 
44 44
       #{visitorTel,jdbcType=VARCHAR}, #{visitorNum,jdbcType=VARCHAR}, #{visitorStatrtTime,jdbcType=TIMESTAMP}, 
45
-      #{visitorEndTime,jdbcType=INTEGER}, #{drivingStatus,jdbcType=CHAR}, #{payEntity,jdbcType=VARCHAR}, 
45
+      #{visitorEndTime,jdbcType=TIMESTAMP}, #{drivingStatus,jdbcType=CHAR}, #{payEntity,jdbcType=VARCHAR},
46 46
       #{visitorCode,jdbcType=VARCHAR}, #{taUserId,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, 
47 47
       #{createDate,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP}
48 48
       )
@@ -116,7 +116,7 @@
116 116
         #{visitorStatrtTime,jdbcType=TIMESTAMP},
117 117
       </if>
118 118
       <if test="visitorEndTime != null" >
119
-        #{visitorEndTime,jdbcType=INTEGER},
119
+        #{visitorEndTime,jdbcType=TIMESTAMP},
120 120
       </if>
121 121
       <if test="drivingStatus != null" >
122 122
         #{drivingStatus,jdbcType=CHAR},
@@ -163,7 +163,7 @@
163 163
         visitor_statrt_time = #{visitorStatrtTime,jdbcType=TIMESTAMP},
164 164
       </if>
165 165
       <if test="visitorEndTime != null" >
166
-        visitor_end_time = #{visitorEndTime,jdbcType=INTEGER},
166
+        visitor_end_time = #{visitorEndTime,jdbcType=TIMESTAMP},
167 167
       </if>
168 168
       <if test="drivingStatus != null" >
169 169
         driving_status = #{drivingStatus,jdbcType=CHAR},
@@ -199,7 +199,7 @@
199 199
       visitor_tel = #{visitorTel,jdbcType=VARCHAR},
200 200
       visitor_num = #{visitorNum,jdbcType=VARCHAR},
201 201
       visitor_statrt_time = #{visitorStatrtTime,jdbcType=TIMESTAMP},
202
-      visitor_end_time = #{visitorEndTime,jdbcType=INTEGER},
202
+      visitor_end_time = #{visitorEndTime,jdbcType=TIMESTAMP},
203 203
       driving_status = #{drivingStatus,jdbcType=CHAR},
204 204
       pay_entity = #{payEntity,jdbcType=VARCHAR},
205 205
       visitor_code = #{visitorCode,jdbcType=VARCHAR},
@@ -280,7 +280,7 @@
280 280
         #{visitorStatrtTime,jdbcType=TIMESTAMP},
281 281
       </if>
282 282
       <if test="visitorEndTime != null" >
283
-        #{visitorEndTime,jdbcType=INTEGER},
283
+        #{visitorEndTime,jdbcType=TIMESTAMP},
284 284
       </if>
285 285
       <if test="drivingStatus != null" >
286 286
         #{drivingStatus,jdbcType=CHAR},