Browse Source

完善 访客

weiximei 6 years ago
parent
commit
951e073645

+ 6
- 6
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/HKOpenApi.java View File

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
      * @return
449
      * @return
450
      */
450
      */
451
     public static String temporaryRegister(String visitorName, String phoneNo,Integer personNum,Long startTime,Long endTime,Integer personId){
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 View File

46
 
46
 
47
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
47
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
48
         Integer userId = userElement.getId();
48
         Integer userId = userElement.getId();
49
-        vistorServiceI.insertTaVistor(taVisitor, communityId, userId);
49
+        responseBean = vistorServiceI.insertTaVistor(taVisitor, communityId, userId);
50
         return  responseBean;
50
         return  responseBean;
51
     }
51
     }
52
 
52
 

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TaVisitor.java View File

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

+ 9
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/TaVistorServiceI.java View File

1
 package com.community.huiju.service;
1
 package com.community.huiju.service;
2
 
2
 
3
+import com.community.commom.mode.ResponseBean;
3
 import com.community.huiju.model.TaVisitor;
4
 import com.community.huiju.model.TaVisitor;
4
 
5
 
5
 import java.util.List;
6
 import java.util.List;
11
  * @date 2018/11/1
12
  * @date 2018/11/1
12
  */
13
  */
13
 public interface TaVistorServiceI {
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
     List<TaVisitor> invateHis(Integer communityId, Integer userId);
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 View File

1
 package com.community.huiju.service.impl;
1
 package com.community.huiju.service.impl;
2
 
2
 
3
+import com.alibaba.fastjson.JSONObject;
3
 import com.community.commom.constant.Constant;
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
 import com.community.huiju.dao.TaVisitorLicenseMapper;
8
 import com.community.huiju.dao.TaVisitorLicenseMapper;
5
 import com.community.huiju.dao.TaVisitorMapper;
9
 import com.community.huiju.dao.TaVisitorMapper;
10
+import com.community.huiju.model.TaUser;
6
 import com.community.huiju.model.TaVisitor;
11
 import com.community.huiju.model.TaVisitor;
7
 import com.community.huiju.model.TaVisitorLicense;
12
 import com.community.huiju.model.TaVisitorLicense;
8
 import com.community.huiju.service.TaVistorServiceI;
13
 import com.community.huiju.service.TaVistorServiceI;
14
+import com.google.common.collect.Maps;
15
+import lombok.extern.slf4j.Slf4j;
9
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
18
+import org.springframework.transaction.annotation.Transactional;
11
 
19
 
12
 import java.util.Date;
20
 import java.util.Date;
13
 import java.util.List;
21
 import java.util.List;
22
+import java.util.Map;
14
 
23
 
15
 /**
24
 /**
16
  * @author weichaochao
25
  * @author weichaochao
19
  * @date 2018/11/1
28
  * @date 2018/11/1
20
  */
29
  */
21
 @Service("TaVistorServiceImpl")
30
 @Service("TaVistorServiceImpl")
31
+@Slf4j
22
 public class TaVistorServiceImpl implements TaVistorServiceI {
32
 public class TaVistorServiceImpl implements TaVistorServiceI {
23
 
33
 
24
     @Autowired
34
     @Autowired
27
     @Autowired
37
     @Autowired
28
     private TaVisitorLicenseMapper taVisitorLicenseMapper;
38
     private TaVisitorLicenseMapper taVisitorLicenseMapper;
29
 
39
 
40
+    @Autowired
41
+    private TaUserMapper taUserMapper;
42
+
30
     @Override
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
         //todo 推送到海康然后返回给我们一个vistor_code,暂未提供
48
         //todo 推送到海康然后返回给我们一个vistor_code,暂未提供
34
 
49
 
37
         taVisitor.setCreateUser(userId);
52
         taVisitor.setCreateUser(userId);
38
         taVisitor.setCreateDate(new Date());
53
         taVisitor.setCreateDate(new Date());
39
         taVisitor.setUpdateDate(new Date());
54
         taVisitor.setUpdateDate(new Date());
55
+        taVisitor.setCommunityId(communityId);
40
 
56
 
41
         if (Constant.EFFECTIVE.equals(taVisitor.getDrivingStatus())){
57
         if (Constant.EFFECTIVE.equals(taVisitor.getDrivingStatus())){
42
             taVisitorMapper.insertSelective(taVisitor);
58
             taVisitorMapper.insertSelective(taVisitor);
56
             taVisitorMapper.insertSelective(taVisitor);
72
             taVisitorMapper.insertSelective(taVisitor);
57
         }
73
         }
58
 
74
 
75
+        // 推送海康
76
+        temporaryRegister(userId,taVisitor,response);
77
+
78
+        return response;
59
     }
79
     }
60
 
80
 
61
     @Override
81
     @Override
70
         }
90
         }
71
         return taVisitors;
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 View File

149
         List<TpTicketVO> tpTicketVOList = Lists.newArrayList();
149
         List<TpTicketVO> tpTicketVOList = Lists.newArrayList();
150
         tpTicketVOConvert(tpTicketList, tpTicketVOList);
150
         tpTicketVOConvert(tpTicketList, tpTicketVOList);
151
         Map<String, Object> map = Maps.newHashMap();
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
         response.addSuccess(map);
155
         response.addSuccess(map);
156
 
156
 

+ 6
- 6
CODE/smart-community/app-api/src/main/resources/mapper/TaVisitorMapper.xml View File

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