From 2058f9a0686d1b2d5543d369fb768c9bd40e0e63 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期三, 30 八月 2023 16:52:29 +0800
Subject: [PATCH] 增加电子围栏关联用户
---
ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWallUser.java | 24 ++++++++
ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml | 30 ++++++++++
ard-work/src/main/java/com/ruoyi/dispatch/service/impl/ArdDispatchPoliceServiceImpl.java | 8 --
ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWall.java | 16 +++++
ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/service/impl/ArdWallServiceImpl.java | 45 +++++++++++++-
ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/mapper/ArdWallMapper.java | 27 +++++++++
6 files changed, 137 insertions(+), 13 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWall.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWall.java
index 1aa5914..81cefa4 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWall.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWall.java
@@ -1,9 +1,12 @@
package com.ruoyi.alarmpoints.elecwall.domain;
+import com.ruoyi.common.core.domain.entity.SysUser;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
+
+import java.util.List;
/**
* 鐢靛瓙鍥存爮绠$悊瀵硅薄 ard_wall
@@ -41,8 +44,19 @@
/** 鎵�灞炵敤鎴� */
@Excel(name = "鎵�灞炵敤鎴�")
private String userId;
+ /** 鍏宠仈鐢ㄦ埛鍒楄〃 */
+ @Excel(name = "鍏宠仈鐢ㄦ埛鍒楄〃")
+ List<SysUser> sysUserList;
- public void setId(String id)
+ public List<SysUser> getSysUserList() {
+ return sysUserList;
+ }
+
+ public void setSysUserList(List<SysUser> sysUserList) {
+ this.sysUserList = sysUserList;
+ }
+
+ public void setId(String id)
{
this.id = id;
}
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWallUser.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWallUser.java
new file mode 100644
index 0000000..eae4f4a
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/domain/ArdWallUser.java
@@ -0,0 +1,24 @@
+package com.ruoyi.alarmpoints.elecwall.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 娲捐鍏宠仈鐢ㄦ埛瀵硅薄 ard_dispatch_police_user
+ *
+ * @author ard
+ * @date 2023-08-21
+ */
+@Data
+public class ArdWallUser
+{
+ private static final long serialVersionUID = 1L;
+
+ /** 鍥存爮ID */
+ @Excel(name = "鍥存爮ID")
+ private String wallId;
+
+ /** 鍏宠仈鐢ㄦ埛ID */
+ @Excel(name = "鍏宠仈鐢ㄦ埛ID")
+ private String userId;
+}
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/mapper/ArdWallMapper.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/mapper/ArdWallMapper.java
index 1ac201a..4ff3dd4 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/mapper/ArdWallMapper.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/mapper/ArdWallMapper.java
@@ -2,6 +2,8 @@
import java.util.List;
import com.ruoyi.alarmpoints.elecwall.domain.ArdWall;
+import com.ruoyi.alarmpoints.elecwall.domain.ArdWallUser;
+import com.ruoyi.dispatch.domain.ArdDispatchPoliceUser;
/**
* 鐢靛瓙鍥存爮绠$悊Mapper鎺ュ彛
@@ -58,4 +60,29 @@
* @return 缁撴灉
*/
public int deleteArdWallByIds(String[] ids);
+
+ /**
+ * 鎵归噺鏂板鍥存爮鍏宠仈鐢ㄦ埛
+ *
+ * @param ardWallUserList 鍥存爮鍏宠仈鐢ㄦ埛鍒楄〃
+ * @return 缁撴灉
+ */
+ public int batchArdWallUser(List<ArdWallUser> ardWallUserList);
+
+
+ /**
+ * 閫氳繃鍥存爮绠$悊涓婚敭鍒犻櫎娲捐鍏宠仈鐢ㄦ埛淇℃伅
+ *
+ * @param id 鍥存爮绠$悊ID
+ * @return 缁撴灉
+ */
+ public int deleteArdWallUserByWallId(String id);
+
+ /**
+ * 鎵归噺鍒犻櫎鍥存爮鍏宠仈鐢ㄦ埛
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎
+ * @return 缁撴灉
+ */
+ public int deleteArdWallUserByWallIds(String[] ids);
}
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/service/impl/ArdWallServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/service/impl/ArdWallServiceImpl.java
index 124fea2..4840e3c 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/service/impl/ArdWallServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/elecwall/service/impl/ArdWallServiceImpl.java
@@ -1,9 +1,16 @@
package com.ruoyi.alarmpoints.elecwall.service.impl;
+import java.util.ArrayList;
import java.util.List;
+
+import com.ruoyi.alarmpoints.elecwall.domain.ArdWallUser;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.dispatch.domain.ArdDispatchPolice;
+import com.ruoyi.dispatch.domain.ArdDispatchPoliceUser;
import org.springframework.stereotype.Service;
import com.ruoyi.alarmpoints.elecwall.mapper.ArdWallMapper;
import com.ruoyi.alarmpoints.elecwall.domain.ArdWall;
@@ -53,9 +60,11 @@
@Override
public int insertArdWall(ArdWall ardWall) {
ardWall.setId(IdUtils.simpleUUID());
- ardWall.setCreateBy(SecurityUtils.getUsername());
- ardWall.setCreateTime(DateUtils.getNowDate());
- return ardWallMapper.insertArdWall(ardWall);
+ ardWall.setCreateBy(SecurityUtils.getUsername());
+ ardWall.setCreateTime(DateUtils.getNowDate());
+ int i = ardWallMapper.insertArdWall(ardWall);
+ insertArdWallUser(ardWall);
+ return i;
}
/**
@@ -66,8 +75,10 @@
*/
@Override
public int updateArdWall(ArdWall ardWall) {
- ardWall.setUpdateBy(SecurityUtils.getUsername());
- ardWall.setUpdateTime(DateUtils.getNowDate());
+ ardWall.setUpdateBy(SecurityUtils.getUsername());
+ ardWall.setUpdateTime(DateUtils.getNowDate());
+ ardWallMapper.deleteArdWallUserByWallId(ardWall.getId());
+ insertArdWallUser(ardWall);
return ardWallMapper.updateArdWall(ardWall);
}
@@ -79,6 +90,7 @@
*/
@Override
public int deleteArdWallByIds(String[] ids) {
+ ardWallMapper.deleteArdWallUserByWallIds(ids);
return ardWallMapper.deleteArdWallByIds(ids);
}
@@ -90,6 +102,29 @@
*/
@Override
public int deleteArdWallById(String id) {
+ ardWallMapper.deleteArdWallUserByWallId(id);
return ardWallMapper.deleteArdWallById(id);
}
+
+ /**
+ * 鏂板鐢靛瓙鍥存爮鍏宠仈鐢ㄦ埛淇℃伅
+ *
+ * @param ardWall 鐢靛瓙鍥存爮绠$悊瀵硅薄
+ */
+ public void insertArdWallUser(ArdWall ardWall) {
+ List<SysUser> sysUserList = ardWall.getSysUserList();
+ String id = ardWall.getId();
+ if (StringUtils.isNotNull(sysUserList)) {
+ List<ArdWallUser> list = new ArrayList<ArdWallUser>();
+ for (SysUser user : sysUserList) {
+ ArdWallUser ardWallUser = new ArdWallUser();
+ ardWallUser.setWallId(id);
+ ardWallUser.setUserId(user.getUserId());
+ list.add(ardWallUser);
+ }
+ if (list.size() > 0) {
+ ardWallMapper.batchArdWallUser(list);
+ }
+ }
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/dispatch/service/impl/ArdDispatchPoliceServiceImpl.java b/ard-work/src/main/java/com/ruoyi/dispatch/service/impl/ArdDispatchPoliceServiceImpl.java
index b6df112..18dd7b0 100644
--- a/ard-work/src/main/java/com/ruoyi/dispatch/service/impl/ArdDispatchPoliceServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/dispatch/service/impl/ArdDispatchPoliceServiceImpl.java
@@ -83,8 +83,7 @@
public int updateArdDispatchPolice(ArdDispatchPolice ardDispatchPolice) {
ardDispatchPolice.setUpdateBy(SecurityUtils.getUsername());
ardDispatchPolice.setUpdateTime(DateUtils.getNowDate());
- ardDispatchPoliceMapper.deleteArdDispatchPoliceUserByDispatchId(ardDispatchPolice.getId())
- ;
+ ardDispatchPoliceMapper.deleteArdDispatchPoliceUserByDispatchId(ardDispatchPolice.getId());
insertArdDispatchPoliceUser(ardDispatchPolice);
return ardDispatchPoliceMapper.updateArdDispatchPolice(ardDispatchPolice);
}
@@ -115,11 +114,6 @@
return ardDispatchPoliceMapper.deleteArdDispatchPoliceById(id);
}
- /**
- * 鏂板娲捐鍏宠仈鐢ㄦ埛淇℃伅
- *
- * @param ardDispatchPolice 娲捐绠$悊瀵硅薄
- */
/**
* 鏂板娲捐鍏宠仈鐢ㄦ埛淇℃伅
*
diff --git a/ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml b/ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml
index 68933d9..53d55fe 100644
--- a/ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml
+++ b/ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml
@@ -16,6 +16,19 @@
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
+ <!-- 瀛愭煡璇紝鍏宠仈 ard_dispatch_police_user 琛� -->
+ <collection property="sysUserList" ofType="java.util.List" select="getSysUserListByMainTableId" column="id"/>
+ </resultMap>
+ <select id="getSysUserListByMainTableId" resultType="SysUser">
+ SELECT u.*
+ FROM ard_wall_user b
+ left join sys_user u on b.user_id = u.user_id
+ WHERE wall_id = #{id}
+ </select>
+ <resultMap type="SysUser" id="SysUserListResult">
+ <result property="userId" column="sub_user_id"/>
+ <result property="nickName" column="sub_nick_name"/>
+ <result property="deptId" column="sub_dept_id"/>
</resultMap>
<sql id="selectArdWallVo">
@@ -96,4 +109,21 @@
#{id}
</foreach>
</delete>
+ <insert id="batchArdWallUser">
+ insert into ard_wall_user( wall_id, user_id) values
+ <foreach item="item" index="index" collection="list" separator=",">
+ ( #{item.wallId}, #{item.userId})
+ </foreach>
+ </insert>
+ <delete id="deleteArdWallUserByWallId" parameterType="String">
+ delete
+ from ard_wall_user
+ where wall_id = #{wallId}
+ </delete>
+ <delete id="deleteArdWallUserByWallIds" parameterType="String">
+ delete from ard_wall_user where wall_id in
+ <foreach item="wallId" collection="array" open="(" separator="," close=")">
+ #{wallId}
+ </foreach>
+ </delete>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3