dingxin 6 년 전
부모
커밋
b63004faf2

+ 1
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java 파일 보기

@@ -841,7 +841,7 @@ public class TaUserServiceImpl implements ITaUserService {
841 841
         }
842 842
 
843 843
 
844
-        if (null != user.getUserVerifyId()) {
844
+        if (null != user.getUserVerifyId() && null != user.getCommunityId()) {
845 845
             TaUserVO userVO = new TaUserVO();
846 846
             // 根据用户id, 获取 用户的住址, 人脸是否认证, 角色
847 847
             userSetUp(user, userVO);

+ 19
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/TpEquipmentTreeMapper.java 파일 보기

@@ -0,0 +1,19 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.TpEquipmentTree;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface TpEquipmentTreeMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(TpEquipmentTree record);
11
+
12
+    int insertSelective(TpEquipmentTree record);
13
+
14
+    TpEquipmentTree selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(TpEquipmentTree record);
17
+
18
+    int updateByPrimaryKey(TpEquipmentTree record);
19
+}

+ 95
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/model/TpEquipmentTree.java 파일 보기

@@ -0,0 +1,95 @@
1
+package com.community.huiju.model;
2
+
3
+import java.util.Date;
4
+
5
+public class TpEquipmentTree {
6
+    private Integer id;
7
+
8
+    private Integer communityId;
9
+
10
+    private String equipmentName;
11
+
12
+    private Integer pid;
13
+
14
+    private Integer sort;
15
+
16
+    private Date createTime;
17
+
18
+    private Integer createUser;
19
+
20
+    private Date updateTime;
21
+
22
+    private Integer updateUser;
23
+
24
+    public Integer getId() {
25
+        return id;
26
+    }
27
+
28
+    public void setId(Integer id) {
29
+        this.id = id;
30
+    }
31
+
32
+    public Integer getCommunityId() {
33
+        return communityId;
34
+    }
35
+
36
+    public void setCommunityId(Integer communityId) {
37
+        this.communityId = communityId;
38
+    }
39
+
40
+    public String getEquipmentName() {
41
+        return equipmentName;
42
+    }
43
+
44
+    public void setEquipmentName(String equipmentName) {
45
+        this.equipmentName = equipmentName == null ? null : equipmentName.trim();
46
+    }
47
+
48
+    public Integer getPid() {
49
+        return pid;
50
+    }
51
+
52
+    public void setPid(Integer pid) {
53
+        this.pid = pid;
54
+    }
55
+
56
+    public Integer getSort() {
57
+        return sort;
58
+    }
59
+
60
+    public void setSort(Integer sort) {
61
+        this.sort = sort;
62
+    }
63
+
64
+    public Date getCreateTime() {
65
+        return createTime;
66
+    }
67
+
68
+    public void setCreateTime(Date createTime) {
69
+        this.createTime = createTime;
70
+    }
71
+
72
+    public Integer getCreateUser() {
73
+        return createUser;
74
+    }
75
+
76
+    public void setCreateUser(Integer createUser) {
77
+        this.createUser = createUser;
78
+    }
79
+
80
+    public Date getUpdateTime() {
81
+        return updateTime;
82
+    }
83
+
84
+    public void setUpdateTime(Date updateTime) {
85
+        this.updateTime = updateTime;
86
+    }
87
+
88
+    public Integer getUpdateUser() {
89
+        return updateUser;
90
+    }
91
+
92
+    public void setUpdateUser(Integer updateUser) {
93
+        this.updateUser = updateUser;
94
+    }
95
+}

+ 22
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/CommunityServiceImpl.java 파일 보기

@@ -38,6 +38,9 @@ public class CommunityServiceImpl implements CommunityServiceI {
38 38
 
39 39
 	@Autowired
40 40
 	private TpCarouselSettingMapper tpCarouselSettingMapper;
41
+
42
+	@Autowired
43
+	private TpEquipmentTreeMapper tpEquipmentTreeMapper;
41 44
 	
42 45
 	/**
43 46
 	 * 分页获取小区列表
@@ -82,9 +85,28 @@ public class CommunityServiceImpl implements CommunityServiceI {
82 85
 		addAppMenu(toCommunities.getId());
83 86
 		// 默认创建 banner轮播数  3
84 87
 		addBannerNum(toCommunities.getId(), 3);
88
+		// 创建默认的设备树
89
+		addEquipmentTree(toCommunities.getId(), toCommunities.getCommunityName(), tpUser.getId());
85 90
 		return size;
86 91
 	}
87 92
 
93
+	/**
94
+	 * 创建默认的设备树
95
+	 * @param communityId
96
+	 * @param communityName
97
+	 */
98
+	private void addEquipmentTree(Integer communityId, String communityName, Integer userId) {
99
+		TpEquipmentTree tpEquipmentTree = new TpEquipmentTree();
100
+		tpEquipmentTree.setCommunityId(communityId);
101
+		tpEquipmentTree.setEquipmentName(communityName);
102
+		tpEquipmentTree.setPid(0);
103
+		tpEquipmentTree.setSort(0);
104
+		tpEquipmentTree.setCreateTime(new Date());
105
+		tpEquipmentTree.setCreateUser(userId);
106
+
107
+		tpEquipmentTreeMapper.insertSelective(tpEquipmentTree);
108
+	}
109
+
88 110
 	/**
89 111
 	 * 创建 banner轮播数
90 112
 	 * @param communityId

+ 142
- 0
CODE/smart-community/operate-api/src/main/resources/mapper/TpEquipmentTreeMapper.xml 파일 보기

@@ -0,0 +1,142 @@
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.TpEquipmentTreeMapper" >
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpEquipmentTree" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="community_id" property="communityId" jdbcType="INTEGER" />
7
+    <result column="equipment_name" property="equipmentName" jdbcType="VARCHAR" />
8
+    <result column="pid" property="pid" jdbcType="INTEGER" />
9
+    <result column="sort" property="sort" jdbcType="INTEGER" />
10
+    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
11
+    <result column="create_user" property="createUser" jdbcType="INTEGER" />
12
+    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
13
+    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
14
+  </resultMap>
15
+  <sql id="Base_Column_List" >
16
+    id, community_id, equipment_name, pid, sort, create_time, create_user, update_time, 
17
+    update_user
18
+  </sql>
19
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
20
+    select 
21
+    <include refid="Base_Column_List" />
22
+    from tp_equipment_tree
23
+    where id = #{id,jdbcType=INTEGER}
24
+  </select>
25
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
26
+    delete from tp_equipment_tree
27
+    where id = #{id,jdbcType=INTEGER}
28
+  </delete>
29
+  <insert id="insert" parameterType="com.community.huiju.model.TpEquipmentTree" >
30
+    insert into tp_equipment_tree (id, community_id, equipment_name, 
31
+      pid, sort, create_time, 
32
+      create_user, update_time, update_user
33
+      )
34
+    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{equipmentName,jdbcType=VARCHAR}, 
35
+      #{pid,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
36
+      #{createUser,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER}
37
+      )
38
+  </insert>
39
+  <insert id="insertSelective" parameterType="com.community.huiju.model.TpEquipmentTree" >
40
+    insert into tp_equipment_tree
41
+    <trim prefix="(" suffix=")" suffixOverrides="," >
42
+      <if test="id != null" >
43
+        id,
44
+      </if>
45
+      <if test="communityId != null" >
46
+        community_id,
47
+      </if>
48
+      <if test="equipmentName != null" >
49
+        equipment_name,
50
+      </if>
51
+      <if test="pid != null" >
52
+        pid,
53
+      </if>
54
+      <if test="sort != null" >
55
+        sort,
56
+      </if>
57
+      <if test="createTime != null" >
58
+        create_time,
59
+      </if>
60
+      <if test="createUser != null" >
61
+        create_user,
62
+      </if>
63
+      <if test="updateTime != null" >
64
+        update_time,
65
+      </if>
66
+      <if test="updateUser != null" >
67
+        update_user,
68
+      </if>
69
+    </trim>
70
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
71
+      <if test="id != null" >
72
+        #{id,jdbcType=INTEGER},
73
+      </if>
74
+      <if test="communityId != null" >
75
+        #{communityId,jdbcType=INTEGER},
76
+      </if>
77
+      <if test="equipmentName != null" >
78
+        #{equipmentName,jdbcType=VARCHAR},
79
+      </if>
80
+      <if test="pid != null" >
81
+        #{pid,jdbcType=INTEGER},
82
+      </if>
83
+      <if test="sort != null" >
84
+        #{sort,jdbcType=INTEGER},
85
+      </if>
86
+      <if test="createTime != null" >
87
+        #{createTime,jdbcType=TIMESTAMP},
88
+      </if>
89
+      <if test="createUser != null" >
90
+        #{createUser,jdbcType=INTEGER},
91
+      </if>
92
+      <if test="updateTime != null" >
93
+        #{updateTime,jdbcType=TIMESTAMP},
94
+      </if>
95
+      <if test="updateUser != null" >
96
+        #{updateUser,jdbcType=INTEGER},
97
+      </if>
98
+    </trim>
99
+  </insert>
100
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpEquipmentTree" >
101
+    update tp_equipment_tree
102
+    <set >
103
+      <if test="communityId != null" >
104
+        community_id = #{communityId,jdbcType=INTEGER},
105
+      </if>
106
+      <if test="equipmentName != null" >
107
+        equipment_name = #{equipmentName,jdbcType=VARCHAR},
108
+      </if>
109
+      <if test="pid != null" >
110
+        pid = #{pid,jdbcType=INTEGER},
111
+      </if>
112
+      <if test="sort != null" >
113
+        sort = #{sort,jdbcType=INTEGER},
114
+      </if>
115
+      <if test="createTime != null" >
116
+        create_time = #{createTime,jdbcType=TIMESTAMP},
117
+      </if>
118
+      <if test="createUser != null" >
119
+        create_user = #{createUser,jdbcType=INTEGER},
120
+      </if>
121
+      <if test="updateTime != null" >
122
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
123
+      </if>
124
+      <if test="updateUser != null" >
125
+        update_user = #{updateUser,jdbcType=INTEGER},
126
+      </if>
127
+    </set>
128
+    where id = #{id,jdbcType=INTEGER}
129
+  </update>
130
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpEquipmentTree" >
131
+    update tp_equipment_tree
132
+    set community_id = #{communityId,jdbcType=INTEGER},
133
+      equipment_name = #{equipmentName,jdbcType=VARCHAR},
134
+      pid = #{pid,jdbcType=INTEGER},
135
+      sort = #{sort,jdbcType=INTEGER},
136
+      create_time = #{createTime,jdbcType=TIMESTAMP},
137
+      create_user = #{createUser,jdbcType=INTEGER},
138
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
139
+      update_user = #{updateUser,jdbcType=INTEGER}
140
+    where id = #{id,jdbcType=INTEGER}
141
+  </update>
142
+</mapper>

+ 2
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TpConfiguration.java 파일 보기

@@ -1,6 +1,7 @@
1 1
 package com.community.huiju.model;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import com.baomidou.mybatisplus.annotation.TableName;
6 7
 import lombok.Data;
@@ -32,6 +33,7 @@ public class TpConfiguration implements Serializable {
32 33
     /**
33 34
      * 配置key
34 35
      */
36
+    @TableField(value = "`key`")
35 37
     private String key;
36 38
 
37 39
     /**

+ 24
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TpEquipmentServiceImpl.java 파일 보기

@@ -14,6 +14,7 @@ import com.community.huiju.model.TpEquipmentTree;
14 14
 import com.community.huiju.service.ITpEquipmentService;
15 15
 import org.springframework.beans.factory.annotation.Autowired;
16 16
 import org.springframework.stereotype.Service;
17
+import org.springframework.transaction.annotation.Transactional;
17 18
 
18 19
 import java.time.LocalDateTime;
19 20
 import java.util.List;
@@ -47,6 +48,7 @@ public class TpEquipmentServiceImpl extends ServiceImpl<TpEquipmentMapper, TpEqu
47 48
     }
48 49
 
49 50
     @Override
51
+    @Transactional(rollbackFor = Exception.class)
50 52
     public ResponseBean saveOrUpdateMonitoring(String parameter, UserElement userElement) {
51 53
         ResponseBean responseBean = new ResponseBean();
52 54
 
@@ -57,7 +59,7 @@ public class TpEquipmentServiceImpl extends ServiceImpl<TpEquipmentMapper, TpEqu
57 59
 
58 60
         List<TpEquipment> tpEquipments = JSONObject.parseArray(parameter, TpEquipment.class);
59 61
         for (int i = 0; i < tpEquipments.size(); i++){
60
-            TpEquipment equipment = tpEquipments.get(0);
62
+            TpEquipment equipment = tpEquipments.get(i);
61 63
             Integer id = equipment.getId();
62 64
             if (null == id) {
63 65
                 // 监控地址
@@ -85,13 +87,21 @@ public class TpEquipmentServiceImpl extends ServiceImpl<TpEquipmentMapper, TpEqu
85 87
                 equipment.setSecurityRoomTelId(tpConfigurationSecurityRoomTel.getId());
86 88
                 equipment.setEquipmentType("1");
87 89
                 equipment.setEquipmentTreeId(tpEquipmentTree.getId());
90
+                equipment.setCreateTime(LocalDateTime.now());
91
+                equipment.setCreateUser(userElement.getId());
92
+                equipment.setCommunityId(userElement.getCommunityId());
88 93
 
89 94
                 tpEquipmentMapper.insert(equipment);
90 95
             } else {
96
+                updateConfiguration(equipment.getAddress(), equipment.getAddressId());
97
+                updateConfiguration(equipment.getUrl(), equipment.getUrlId());
98
+                updateConfiguration(equipment.getSecurityGuardTel(), equipment.getSecurityGuardTelId());
99
+                updateConfiguration(equipment.getSecurityRoomTel(), equipment.getSecurityGuardTelId());
91 100
                 tpEquipmentMapper.updateById(equipment);
92 101
             }
93 102
         }
94 103
 
104
+        responseBean.addSuccess("操作成功!");
95 105
         return responseBean;
96 106
     }
97 107
 
@@ -116,4 +126,17 @@ public class TpEquipmentServiceImpl extends ServiceImpl<TpEquipmentMapper, TpEqu
116 126
 
117 127
         return tpConfiguration;
118 128
     }
129
+
130
+    /**
131
+     * 根据id更新 设备配置表的值
132
+     * @param value
133
+     * @param configurationId
134
+     */
135
+    public void updateConfiguration(String value, Integer configurationId) {
136
+        QueryWrapper<TpConfiguration> configurationQueryWrapper = new QueryWrapper<>();
137
+        configurationQueryWrapper.eq("id", configurationId);
138
+        TpConfiguration tpConfiguration = tpConfigurationMapper.selectOne(configurationQueryWrapper);
139
+        tpConfiguration.setConfigurationValue(value);
140
+        tpConfigurationMapper.updateById(tpConfiguration);
141
+    }
119 142
 }

+ 10
- 0
VUECODE/smart-property-manage/src/api/equipment.js 파일 보기

@@ -1,5 +1,6 @@
1 1
 import request from '@/utils/request'
2 2
 
3
+// 查询设备列表
3 4
 export function getAll(data) {
4 5
   return request({
5 6
     url: '/equipment',
@@ -10,3 +11,12 @@ export function getAll(data) {
10 11
   })
11 12
 }
12 13
 
14
+// 提交设备数据,进行保存
15
+export function equipmentMonitoring(data) {
16
+  return request({
17
+    url: '/equipment/monitoring',
18
+    method: 'post',
19
+    data
20
+  })
21
+}
22
+

+ 10
- 1
VUECODE/smart-property-manage/src/store/modules/equipment.js 파일 보기

@@ -1,4 +1,4 @@
1
-import { getAll } from '@/api/equipment'
1
+import { getAll, equipmentMonitoring } from '@/api/equipment'
2 2
 
3 3
 const equipment = {
4 4
   state: {
@@ -16,6 +16,15 @@ const equipment = {
16 16
           reject(error)
17 17
         })
18 18
       })
19
+    },
20
+    EquipmentMonitoring({ commit }, data) { // 提交设备数据
21
+      return new Promise((resolve, reject) => {
22
+        equipmentMonitoring(data).then(response => {
23
+          resolve(response)
24
+        }).catch(error => {
25
+          reject(error)
26
+        })
27
+      })
19 28
     }
20 29
   }
21 30
 }

+ 9
- 0
VUECODE/smart-property-manage/src/views/systemResources/app/index.vue 파일 보기

@@ -212,6 +212,15 @@ export default {
212 212
     },
213 213
     monitoringSubmit() { // 监控提交
214 214
       console.log('monitoringForm : ', this.equipmentList)
215
+      this.$store.dispatch('EquipmentMonitoring', this.equipmentList).then((res) => {
216
+        if (res.code === '0') {
217
+          this.$message.success(res.message)
218
+          // 监控
219
+          this.equipmentGetAll()
220
+        }
221
+      }).catch(() => {
222
+        console.log('EquipmentMonitoring error')
223
+      })
215 224
     },
216 225
     monitoringRemover(id, equipmentIndex) { // 监控删除
217 226
       // console.log('monitoringForm : ', this.equipmentList, '  下坐标:', index)