From f695f18aaa68f5ca3776f1e3b86c89145ba36958 Mon Sep 17 00:00:00 2001 From: xins Date: Tue, 10 Oct 2023 16:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=E5=BE=AE=E6=9C=8D=E5=8A=A11.?= =?UTF-8?q?5.0=20dataprocess=EF=BC=9A=201=E3=80=81=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=95=B0=E6=8D=AE=E7=9A=84=E8=80=97=E8=B4=B9?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=97=A5=E5=BF=97=202=E3=80=81devicecode?= =?UTF-8?q?=E8=BD=AC=E5=B0=8F=E5=86=99=E5=A4=84=E7=90=86=20system=EF=BC=9A?= =?UTF-8?q?=201=E3=80=81=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E5=AE=8C?= =?UTF-8?q?=E5=96=84=EF=BC=881=EF=BC=89=E3=80=81=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E8=BF=87=E6=BB=A4=E5=AE=8C=E5=96=84=EF=BC=9B?= =?UTF-8?q?2=EF=BC=89=E3=80=81=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=89=202=E3=80=81=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=AE=8C=E5=96=84=203=E3=80=81=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E7=AE=A1=E7=90=86admin=E5=8F=AF=E4=BB=A5=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=A7=9F=E6=88=B7=E7=9A=84=EF=BC=8C=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E4=B9=9F=E6=9C=89=E6=9D=83=E9=99=90=E5=A2=9E=E5=88=A0=E6=94=B9?= =?UTF-8?q?=E6=9F=A5=204=E3=80=81=E5=B2=97=E4=BD=8D=E7=AE=A1=E7=90=86admin?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=88=9B=E5=BB=BA=E7=A7=9F=E6=88=B7=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E7=A7=9F=E6=88=B7=E4=B9=9F=E6=9C=89=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=20business=EF=BC=9A=201?= =?UTF-8?q?=E3=80=81=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86=E5=AE=8C=E5=96=84?= =?UTF-8?q?=EF=BC=881=EF=BC=89=E3=80=81=E5=A2=9E=E5=8A=A0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=EF=BC=9B2=EF=BC=89=E3=80=81=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E8=BF=87=E6=BB=A4=E9=80=BB=E8=BE=91=E5=AE=8C?= =?UTF-8?q?=E5=96=84=EF=BC=9B3=EF=BC=89=E3=80=81=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8F=AF=E4=BB=A5=E5=B0=8F=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=AF=8D=E3=80=81=E6=95=B0=E5=AD=97=E5=92=8C=E4=B8=8B=E5=88=92?= =?UTF-8?q?=E7=BA=BF=EF=BC=8C=E6=9C=80=E5=89=8D=E9=9D=A2=E4=B8=8D=E9=99=90?= =?UTF-8?q?=E5=88=B6=E6=98=AF=E5=AD=97=E6=AF=8D=EF=BC=9B=EF=BC=89=202?= =?UTF-8?q?=E3=80=81=E8=AE=BE=E5=A4=87=E6=A8=A1=E5=9E=8B=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=881)=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=A0=87=E8=AF=86=E7=AC=A6=E4=B8=BAvalue?= =?UTF-8?q?=E6=97=B6=E5=9C=A8tdengine=E5=88=9B=E5=BB=BA=E8=A1=A8=E6=97=B6?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=88=90value1=EF=BC=9B2=EF=BC=89=E3=80=81va?= =?UTF-8?q?lue1=E4=B8=8D=E5=85=81=E8=AE=B8=E5=81=9A=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E7=AC=A6=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AF=BC=E5=87=BA=EF=BC=89?= =?UTF-8?q?=203=E3=80=81=E7=9B=91=E6=8E=A7=E5=8D=95=E5=85=83=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=AE=8C=E5=96=84=204=E3=80=81=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=8D=95=E5=85=83=E5=AE=8C=E5=96=84=EF=BC=881=EF=BC=89?= =?UTF-8?q?=E3=80=81=E6=A0=B9=E6=8D=AE=E7=A7=9F=E6=88=B7=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=AE=8C=E5=96=84=EF=BC=9B=EF=BC=89=205?= =?UTF-8?q?=E3=80=81=E5=9C=BA=E6=99=AF=E5=AE=8C=E5=96=84=206=E3=80=81?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/system/api/domain/SysDept.java | 20 ++ .../com/ruoyi/system/api/domain/SysRole.java | 20 ++ .../com/ruoyi/system/api/domain/SysUser.java | 254 +++++++++--------- .../core/constant/TdEngineConstants.java | 8 +- .../ruoyi/common/log/enums/BusinessType.java | 10 + .../resources/mapper/basic/HwTenantMapper.xml | 1 + .../controller/HwDeviceController.java | 17 +- .../controller/HwDeviceModeController.java | 18 +- .../HwDeviceModeFunctionController.java | 1 + .../HwMonitorPlatformController.java | 4 + .../controller/HwSceneController.java | 30 +-- .../controller/HwTenantController.java | 1 + .../com/ruoyi/business/domain/HwDevice.java | 55 ++-- .../ruoyi/business/domain/HwDeviceMode.java | 19 +- .../business/domain/HwDeviceModeFunction.java | 35 +-- .../business/domain/HwMonitorUnitType.java | 10 +- .../com/ruoyi/business/domain/HwScene.java | 23 +- .../com/ruoyi/business/domain/HwTenant.java | 201 +++++++------- .../business/mapper/HwMonitorUnitMapper.java | 8 - .../service/IHwDeviceModeService.java | 9 + .../service/impl/HwDeviceModeServiceImpl.java | 30 ++- .../service/impl/HwDeviceServiceImpl.java | 8 +- .../service/impl/HwSceneServiceImpl.java | 11 +- .../mapper/business/HwDeviceMapper.xml | 5 +- .../mapper/business/HwDeviceModeMapper.xml | 3 +- .../mapper/business/HwMonitorUnitMapper.xml | 31 +-- .../business/HwMonitorUnitTypeMapper.xml | 4 +- .../mqtt/client/config/MqttConfiguration.java | 23 +- .../service/IDataProcessService.java | 2 +- .../service/impl/DataProcessServiceImpl.java | 6 +- .../service/impl/DeviceStatusServiceImpl.java | 2 +- .../system/controller/SysDeptController.java | 88 +++--- .../system/controller/SysPostController.java | 27 ++ .../system/controller/SysRoleController.java | 11 + .../system/controller/SysUserController.java | 11 +- .../java/com/ruoyi/system/domain/SysPost.java | 9 + .../service/impl/SysDeptServiceImpl.java | 158 +++++------ .../service/impl/SysPostServiceImpl.java | 1 + .../service/impl/SysUserServiceImpl.java | 2 +- .../resources/mapper/system/SysDeptMapper.xml | 20 +- .../resources/mapper/system/SysPostMapper.xml | 22 +- .../resources/mapper/system/SysRoleMapper.xml | 8 +- .../resources/mapper/system/SysUserMapper.xml | 6 +- ruoyi-ui/src/api/system/dept.js | 14 +- ruoyi-ui/src/api/system/post.js | 8 + ruoyi-ui/src/api/system/user.js | 2 +- ruoyi-ui/src/assets/logo/logo1.png | Bin 0 -> 5561 bytes ruoyi-ui/src/views/business/device/index.vue | 69 ++++- .../business/deviceMode/deviceModeEvent.vue | 2 +- .../business/deviceMode/deviceModeService.vue | 3 +- .../business/deviceMode/editDeviceMode.vue | 10 +- .../src/views/business/deviceMode/index.vue | 13 +- .../views/business/electronicFence/index.vue | 4 +- .../src/views/business/monitorUnit/index.vue | 10 +- .../views/business/monitorUnitType/index.vue | 5 +- ruoyi-ui/src/views/business/scene/index.vue | 110 ++++---- ruoyi-ui/src/views/business/tenant/index.vue | 110 +++++--- ruoyi-ui/src/views/register.vue | 2 +- ruoyi-ui/src/views/system/dept/index.vue | 67 ++++- ruoyi-ui/src/views/system/post/index.vue | 61 ++++- ruoyi-ui/src/views/system/role/index.vue | 166 +++++++----- ruoyi-ui/src/views/system/user/index.vue | 82 ++++-- 62 files changed, 1189 insertions(+), 781 deletions(-) create mode 100644 ruoyi-ui/src/assets/logo/logo1.png diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java index fe96667..30cd844 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java @@ -57,6 +57,10 @@ public class SysDept extends BaseEntity private Long tenantId; + private String tenantName; + + private String notEditable;//是否不可编辑,1:是,0:否 + public Long getDeptId() { return deptId; @@ -191,6 +195,22 @@ public class SysDept extends BaseEntity this.tenantId = tenantId; } + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public String getNotEditable() { + return notEditable; + } + + public void setNotEditable(String notEditable) { + this.notEditable = notEditable; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java index f6a564b..dc533fd 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java @@ -66,6 +66,10 @@ public class SysRole extends BaseEntity private Long tenantId; + private String tenantName; + + private String notEditable;//是否不可编辑,1:是,0:否 + public SysRole() { @@ -229,6 +233,22 @@ public class SysRole extends BaseEntity this.tenantId = tenantId; } + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public String getNotEditable() { + return notEditable; + } + + public void setNotEditable(String notEditable) { + this.notEditable = notEditable; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java index 7945d6f..b2fa235 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java @@ -3,6 +3,7 @@ package com.ruoyi.system.api.domain; import java.util.Date; import java.util.List; import javax.validation.constraints.*; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; @@ -14,289 +15,288 @@ import com.ruoyi.common.core.xss.Xss; /** * 用户对象 sys_user - * + * * @author ruoyi */ -public class SysUser extends BaseEntity -{ +public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; - /** 用户ID */ - @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") + /** + * 用户ID + */ + @Excel(name = "用户编号", cellType = ColumnType.NUMERIC, prompt = "用户编号") private Long userId; - /** 部门ID */ + /** + * 部门ID + */ @Excel(name = "部门编号", type = Type.IMPORT) private Long deptId; - /** 用户账号 */ - @Excel(name = "登录名称") + /** + * 用户账号 + */ + @Excel(name = "用户名称") private String userName; - /** 用户昵称 */ - @Excel(name = "用户名称") + /** + * 用户昵称 + */ + @Excel(name = "用户昵称") private String nickName; - /** 用户邮箱 */ + /** + * 用户邮箱 + */ @Excel(name = "用户邮箱") private String email; - /** 手机号码 */ + /** + * 手机号码 + */ @Excel(name = "手机号码") private String phonenumber; - /** 用户性别 */ + /** + * 用户性别 + */ @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") private String sex; - /** 用户头像 */ + /** + * 用户头像 + */ private String avatar; - /** 密码 */ + /** + * 密码 + */ private String password; - /** 帐号状态(0正常 1停用) */ + /** + * 帐号状态(0正常 1停用) + */ @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - /** 最后登录IP */ + /** + * 最后登录IP + */ @Excel(name = "最后登录IP", type = Type.EXPORT) private String loginIp; - /** 最后登录时间 */ + /** + * 最后登录时间 + */ @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) private Date loginDate; - /** 部门对象 */ + /** + * 部门对象 + */ @Excels({ - @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), - @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) + @Excel(name = "部门编号", targetAttr = "deptId", type = Type.EXPORT), + @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), + @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) }) private SysDept dept; - /** 角色对象 */ + /** + * 角色对象 + */ private List roles; - /** 角色组 */ + /** + * 角色组 + */ private Long[] roleIds; - /** 岗位组 */ + /** + * 岗位组 + */ private Long[] postIds; - /** 角色ID */ + /** + * 角色ID + */ private Long roleId; + @Excel(name = "租户Id") private Long tenantId;//租户ID + @Excel(name = "租户名称") private String tenantName;//租户名称 - public SysUser() - { + + public SysUser() { } - public SysUser(Long userId) - { + public SysUser(Long userId) { this.userId = userId; } - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setUserId(Long userId) - { + public void setUserId(Long userId) { this.userId = userId; } - public boolean isAdmin() - { + public boolean isAdmin() { return isAdmin(this.userId); } - public static boolean isAdmin(Long userId) - { + public static boolean isAdmin(Long userId) { return userId != null && 1L == userId; } - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } @Xss(message = "用户昵称不能包含脚本字符") @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") - public String getNickName() - { + public String getNickName() { return nickName; } - public void setNickName(String nickName) - { + public void setNickName(String nickName) { this.nickName = nickName; } @Xss(message = "用户账号不能包含脚本字符") @NotBlank(message = "用户账号不能为空") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") - public String getUserName() - { + public String getUserName() { return userName; } - public void setUserName(String userName) - { + public void setUserName(String userName) { this.userName = userName; } @Email(message = "邮箱格式不正确") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { + public String getEmail() { return email; } - public void setEmail(String email) - { + public void setEmail(String email) { this.email = email; } @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") - public String getPhonenumber() - { + public String getPhonenumber() { return phonenumber; } - public void setPhonenumber(String phonenumber) - { + public void setPhonenumber(String phonenumber) { this.phonenumber = phonenumber; } - public String getSex() - { + public String getSex() { return sex; } - public void setSex(String sex) - { + public void setSex(String sex) { this.sex = sex; } - public String getAvatar() - { + public String getAvatar() { return avatar; } - public void setAvatar(String avatar) - { + public void setAvatar(String avatar) { this.avatar = avatar; } - public String getPassword() - { + public String getPassword() { return password; } - public void setPassword(String password) - { + public void setPassword(String password) { this.password = password; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public String getLoginIp() - { + public String getLoginIp() { return loginIp; } - public void setLoginIp(String loginIp) - { + public void setLoginIp(String loginIp) { this.loginIp = loginIp; } - public Date getLoginDate() - { + public Date getLoginDate() { return loginDate; } - public void setLoginDate(Date loginDate) - { + public void setLoginDate(Date loginDate) { this.loginDate = loginDate; } - public SysDept getDept() - { + public SysDept getDept() { return dept; } - public void setDept(SysDept dept) - { + public void setDept(SysDept dept) { this.dept = dept; } - public List getRoles() - { + public List getRoles() { return roles; } - public void setRoles(List roles) - { + public void setRoles(List roles) { this.roles = roles; } - public Long[] getRoleIds() - { + public Long[] getRoleIds() { return roleIds; } - public void setRoleIds(Long[] roleIds) - { + public void setRoleIds(Long[] roleIds) { this.roleIds = roleIds; } - public Long[] getPostIds() - { + public Long[] getPostIds() { return postIds; } - public void setPostIds(Long[] postIds) - { + public void setPostIds(Long[] postIds) { this.postIds = postIds; } - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } @@ -318,26 +318,26 @@ public class SysUser extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("deptId", getDeptId()) - .append("userName", getUserName()) - .append("nickName", getNickName()) - .append("email", getEmail()) - .append("phonenumber", getPhonenumber()) - .append("sex", getSex()) - .append("avatar", getAvatar()) - .append("password", getPassword()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("loginIp", getLoginIp()) - .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .append("dept", getDept()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("deptId", getDeptId()) + .append("userName", getUserName()) + .append("nickName", getNickName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("loginIp", getLoginIp()) + .append("loginDate", getLoginDate()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("dept", getDept()) + .toString(); } } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java index c3ad950..ee94018 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java @@ -1,7 +1,6 @@ package com.ruoyi.common.core.constant; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * @Description: TdEngine服务常量 @@ -66,6 +65,11 @@ public class TdEngineConstants { TDENGINE_KEY_TRANSFER_MAP.put("value", "value1"); } + /** + * 禁止的功能标识符 + */ + public static final List ABNDON_FUNCTION_IDENTIFIERS = Arrays.asList("ts","value1"); + public static final Map DEVICE_DATA_COLUMN_MAP = new HashMap(); static { diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/enums/BusinessType.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/enums/BusinessType.java index 0b18de8..12fc1d4 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/enums/BusinessType.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/enums/BusinessType.java @@ -56,4 +56,14 @@ public enum BusinessType * 清空数据 */ CLEAN, + + /** + * 发布 + */ + PUBLISH, + + /** + * 下发控制指令 + */ + CONTROL } diff --git a/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/HwTenantMapper.xml b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/HwTenantMapper.xml index b834d94..1f3e3c1 100644 --- a/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/HwTenantMapper.xml +++ b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/HwTenantMapper.xml @@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and tenant_grade = #{tenantGrade} and tenant_field = #{tenantField} + order by tenant_id desc select hd.device_id,hd.device_code,hd.device_name,hd.device_type, hd.tenant_id,hd.scene_id,hd.monitor_unit_id,hd.device_mode_id,hd.active_status, - hd.active_time,hd.device_status,hd.online_status, + hd.active_time,hd.device_status,hd.online_status,hd.releated_device_id,hd.device_pic, + hd.publish_time,hd.access_gw_protocol,hd.access_protocol,hd.data_format,hd.networking_mode, hs.scene_name,hmu.monitor_unit_name,hdmf.device_mode_name,ht.tenant_name from hw_device hd left join hw_scene hs on hd.scene_id = hs.scene_id diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml index 3c0780e..e10c1ab 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml @@ -295,7 +295,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml index a8c3d04..fa38987 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml @@ -22,6 +22,7 @@ + @@ -64,13 +65,6 @@ select monitor_unit_id, monitor_unit_name, scene_id, parent_id, monitor_unit_type_id, area_id, monitor_address, monitor_pic, preserve_time, remark, monitor_unit_status, create_by, create_time, update_by, update_time, monitor_unit_field from hw_monitor_unit hmu - - select hmu.monitor_unit_id, hmu.monitor_unit_name, hmu.scene_id, hmu.parent_id, - hmu.monitor_unit_type_id, hmu.area_id, hmu.monitor_address, hmu.monitor_pic, - hmu.preserve_time, hmu.monitor_unit_status, hc.scene_name - from hw_monitor_unit hmu left join hw_scene hc on hmu.scene_id = hc.scene_id - - - - - hmu.monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null) - and monitor_unit_name like concat('%', #{monitorUnitName}, '%') - and scene_id = #{sceneId} - and parent_id = #{parentId} - and monitor_unit_type_id = #{monitorUnitTypeId} - and area_id = #{areaId} - and monitor_address = #{monitorAddress} - and monitor_pic = #{monitorPic} - and preserve_time = #{preserveTime} - and monitor_unit_status = #{monitorUnitStatus} - and monitor_unit_field = #{monitorUnitField} - - - diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml index d3fad2d..b299da3 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml @@ -20,11 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select monitor_unit_type_id, monitor_unit_type_name, vitual_flag, monitor_unit_type_status, language_code, common_flag, scene_id, remark, create_by, create_time, update_by, update_time, unit_type_icon, unit_type_field from hw_monitor_unit_type + select monitor_unit_type_id, monitor_unit_type_name, vitual_flag, monitor_unit_type_status, language_code, common_flag, scene_id, remark, create_by, create_time, update_by, update_time, unit_type_icon, unit_type_field,tenant_id from hw_monitor_unit_type diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java index 9a2ff20..244143f 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java @@ -129,21 +129,22 @@ public class MqttConfiguration { @Override public void onMessage(ChannelContext channelContext, String topic, MqttPublishMessage mqttPublishMessage, ByteBuffer payload) { String payloadString = new String(payload.array(), StandardCharsets.UTF_8); - System.out.println("paa:" + topic); - logger.info("topic:{} payload:{}", topic, payloadString); - try{ - if (topic.startsWith(dataTopicFilter.replace("#","")) && topic.endsWith(TOPIC_TYPE_DATA_POSTFIX)) { - dataProcessService.processBusinessData(payloadString, imagePath, imagePatterns,imageDomain,imagePrefix); + Long start = System.currentTimeMillis(); + logger.info("topic:{},start:{}ms", topic, start); + try { + if (topic.startsWith(dataTopicFilter.replace("#", "")) && topic.endsWith(TOPIC_TYPE_DATA_POSTFIX)) { + int processDataCount = dataProcessService.processBusinessData(payloadString, imagePath, imagePatterns, imageDomain, imagePrefix); + Long end = System.currentTimeMillis(); + logger.info("Process Data start:{}ms,end:{}ms,Spend Time:{}ms,Data Count:{}", start, end, end - start, processDataCount); } else if (topic.equals(deviceStatusTopic)) { - deviceStatusService.handleDeviceStatus(payloadString,clientId); - }else { - dataProcessService.testBase64(payloadString,imagePath,imagePatterns,imageDomain,imagePrefix); + deviceStatusService.handleDeviceStatus(payloadString, clientId); + } else { + dataProcessService.testBase64(payloadString, imagePath, imagePatterns, imageDomain, imagePrefix); } - }catch(Exception e){ + } catch (Exception e) { e.printStackTrace(); - logger.error("Error processing business data:"+e.getMessage()); + logger.error("Error processing business data:" + e.getMessage()); } - } }); diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDataProcessService.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDataProcessService.java index 023b3d5..6a67c02 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDataProcessService.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDataProcessService.java @@ -12,7 +12,7 @@ public interface IDataProcessService { * @author xins * @date 2023-08-31 16:16 */ - public void processBusinessData(String jsonData, String imagePath, + public int processBusinessData(String jsonData, String imagePath, String imagePatterns,String imageDomain,String imagePrefix); diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java index 1283556..025bcec 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java @@ -76,7 +76,7 @@ public class DataProcessServiceImpl implements IDataProcessService { * @date 2023-08-31 16:16 */ @Override - public void processBusinessData(String jsonData, String imagePath, + public int processBusinessData(String jsonData, String imagePath, String imagePatterns,String imageDomain,String imagePrefix) { JSONObject json = JSON.parseObject(jsonData); Long ts = json.getLong(TdEngineConstants.PAYLOAD_TS); @@ -90,7 +90,7 @@ public class DataProcessServiceImpl implements IDataProcessService { for (int i = 0; i < paramArr.size(); i++) { JSONObject paramJson = paramArr.getJSONObject(i); JSONObject dataValueJson = paramJson.getJSONObject(TdEngineConstants.PAYLOAD_DATAVALUE); - String deviceCode = dataValueJson.getString(TdEngineConstants.PAYLOAD_DEVICE_CODE); + String deviceCode = dataValueJson.getString(TdEngineConstants.PAYLOAD_DEVICE_CODE).toLowerCase(); HwDevice hwDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(deviceCode); Long sceneId = hwDevice.getSceneId(); Long deviceId = hwDevice.getDeviceId(); @@ -182,6 +182,8 @@ public class DataProcessServiceImpl implements IDataProcessService { checkElectronicFence(deviceId, tenantId, monitorUnitId, sceneId, longitude, latitude, ts); } } + + return paramArr.size(); } /** diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java index 462f849..7a5910e 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java @@ -39,7 +39,7 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService { // ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1, // "statusTime":1694506127199,"deviceCode":"hw-data-process-1"} JSONObject json = JSON.parseObject(payloadString); - String deviceCode = json.getString("deviceCode"); + String deviceCode = json.getString("deviceCode").toLowerCase(); if (clientId.equals(deviceCode)) { //校验是不是自己,如果是自己则不记录状态,返回即可。 return; } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java index cf43c68..731f292 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java @@ -1,6 +1,11 @@ package com.ruoyi.system.controller; import java.util.List; + +import com.ruoyi.basic.api.RemoteBasicService; +import com.ruoyi.common.core.constant.HwDictConstants; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -23,26 +28,37 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.SysDept; import com.ruoyi.system.service.ISysDeptService; +import javax.annotation.Resource; + /** * 部门信息 - * + * * @author ruoyi */ @RestController @RequestMapping("/dept") -public class SysDeptController extends BaseController -{ +public class SysDeptController extends BaseController { @Autowired private ISysDeptService deptService; + @Resource + private RemoteBasicService remoteBasicService; + /** * 获取部门列表 */ @RequiresPermissions("system:dept:list") @GetMapping("/list") - public AjaxResult list(SysDept dept) - { + public AjaxResult list(SysDept dept) { List depts = deptService.selectDeptList(dept); + Long tenantId = SecurityUtils.getTenantId(); + if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { + depts.forEach(d -> { + if (!d.getTenantId().equals(tenantId)) { + d.setNotEditable("1"); + } + }); + } return success(depts); } @@ -50,10 +66,12 @@ public class SysDeptController extends BaseController * 查询部门列表(排除节点) */ @RequiresPermissions("system:dept:list") - @GetMapping("/list/exclude/{deptId}") - public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) - { - List depts = deptService.selectDeptList(new SysDept()); + @GetMapping("/list/exclude/{deptId}/{tenantId}") + public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId, + @PathVariable(value = "tenantId", required = false) Long tenantId) { + SysDept dept = new SysDept(); + dept.setTenantId(tenantId); + List depts = deptService.selectDeptList(dept); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); return success(depts); } @@ -63,8 +81,7 @@ public class SysDeptController extends BaseController */ @RequiresPermissions("system:dept:query") @GetMapping(value = "/{deptId}") - public AjaxResult getInfo(@PathVariable Long deptId) - { + public AjaxResult getInfo(@PathVariable Long deptId) { deptService.checkDeptDataScope(deptId); return success(deptService.selectDeptById(deptId)); } @@ -75,12 +92,14 @@ public class SysDeptController extends BaseController @RequiresPermissions("system:dept:add") @Log(title = "部门管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@Validated @RequestBody SysDept dept) - { - if (!deptService.checkDeptNameUnique(dept)) - { + public AjaxResult add(@Validated @RequestBody SysDept dept) { + if (!deptService.checkDeptNameUnique(dept)) { return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } + //如果不是admin的租户,则就保存为登录用户的租户id,如果是admin,则需要保存admin在创建时选择的租户ID + if (!SecurityUtils.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { + dept.setTenantId(SecurityUtils.getTenantId()); + } dept.setCreateBy(SecurityUtils.getUsername()); return toAjax(deptService.insertDept(dept)); } @@ -91,20 +110,14 @@ public class SysDeptController extends BaseController @RequiresPermissions("system:dept:edit") @Log(title = "部门管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@Validated @RequestBody SysDept dept) - { + public AjaxResult edit(@Validated @RequestBody SysDept dept) { Long deptId = dept.getDeptId(); deptService.checkDeptDataScope(deptId); - if (!deptService.checkDeptNameUnique(dept)) - { + if (!deptService.checkDeptNameUnique(dept)) { return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); - } - else if (dept.getParentId().equals(deptId)) - { + } else if (dept.getParentId().equals(deptId)) { return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); - } - else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) - { + } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) { return error("该部门包含未停用的子部门!"); } dept.setUpdateBy(SecurityUtils.getUsername()); @@ -117,17 +130,30 @@ public class SysDeptController extends BaseController @RequiresPermissions("system:dept:remove") @Log(title = "部门管理", businessType = BusinessType.DELETE) @DeleteMapping("/{deptId}") - public AjaxResult remove(@PathVariable Long deptId) - { - if (deptService.hasChildByDeptId(deptId)) - { + public AjaxResult remove(@PathVariable Long deptId) { + if (deptService.hasChildByDeptId(deptId)) { return warn("存在下级部门,不允许删除"); } - if (deptService.checkDeptExistUser(deptId)) - { + if (deptService.checkDeptExistUser(deptId)) { return warn("部门存在用户,不允许删除"); } deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); } + + + /** + * 获取租户信息列表 + */ + @RequiresPermissions("system:dept:list") + @GetMapping("/getTenants") + public AjaxResult getTenants() { + Long tenantId = SecurityUtils.getTenantId(); + if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { + return success(remoteBasicService.getTenants().getData()); + } else { + return success(); + } + } + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java index 36ac90c..68095ba 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java @@ -1,7 +1,13 @@ package com.ruoyi.system.controller; import java.util.List; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.basic.api.RemoteBasicService; +import com.ruoyi.common.core.constant.HwDictConstants; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; @@ -35,6 +41,9 @@ public class SysPostController extends BaseController @Autowired private ISysPostService postService; + @Resource + private RemoteBasicService remoteBasicService; + /** * 获取岗位列表 */ @@ -83,6 +92,10 @@ public class SysPostController extends BaseController { return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } + //如果不是admin的租户,则就保存为登录用户的租户id,如果是admin,则需要保存admin在创建时选择的租户ID + if (!SecurityUtils.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { + post.setTenantId(SecurityUtils.getTenantId()); + } post.setCreateBy(SecurityUtils.getUsername()); return toAjax(postService.insertPost(post)); } @@ -127,4 +140,18 @@ public class SysPostController extends BaseController List posts = postService.selectPostAll(); return success(posts); } + + /** + * 获取租户信息列表 + */ + @RequiresPermissions("system:post:list") + @GetMapping("/getTenants") + public AjaxResult getTenants() { + Long tenantId = SecurityUtils.getTenantId(); + if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { + return success(remoteBasicService.getTenants().getData()); + } else { + return success(); + } + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java index 6c95f45..db2cc0b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java @@ -2,6 +2,8 @@ package com.ruoyi.system.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.constant.HwDictConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; @@ -52,6 +54,14 @@ public class SysRoleController extends BaseController { startPage(); List list = roleService.selectRoleList(role); + Long tenantId = SecurityUtils.getTenantId(); + if(tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)){ + list.forEach(r->{ + if(!r.getTenantId().equals(tenantId)){ + r.setNotEditable("1"); + } + }); + } return getDataTable(list); } @@ -188,6 +198,7 @@ public class SysRoleController extends BaseController public TableDataInfo unallocatedList(SysUser user) { startPage(); + user.setTenantId(SecurityUtils.getTenantId()); List list = userService.selectUnallocatedList(user); return getDataTable(list); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index cc0d60f..e7f6319 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -211,11 +211,9 @@ public class SysUserController extends BaseController { } user.setCreateBy(SecurityUtils.getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser loginSysUser = loginUser.getSysUser(); //如果不是admin的租户,则就保存为登录用户的租户id,如果是adimin,则需要保存admin在创建时选择的租户ID - if (!loginSysUser.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { - user.setTenantId(loginSysUser.getTenantId()); + if (!SecurityUtils.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { + user.setTenantId(SecurityUtils.getTenantId()); } return toAjax(userService.insertUser(user)); @@ -314,7 +312,6 @@ public class SysUserController extends BaseController { @GetMapping("/deptTree") public AjaxResult deptTree(SysDept dept) { - System.out.println("ddddd:" + dept.getTenantId()); return success(deptService.selectDeptTreeList(dept)); } @@ -324,9 +321,7 @@ public class SysUserController extends BaseController { @RequiresPermissions("system:user:list") @GetMapping("/getTenants") public AjaxResult getTenants() { - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser user = loginUser.getSysUser(); - Long tenantId = user.getTenantId(); + Long tenantId = SecurityUtils.getTenantId(); if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { return success(remoteBasicService.getTenants().getData()); } else { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java index cda41f9..ed227d3 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java @@ -40,6 +40,7 @@ public class SysPost extends BaseEntity private Long tenantId; + private String tenantName; /** 用户是否存在此岗位标识 默认不存在 */ private boolean flag = false; @@ -108,6 +109,14 @@ public class SysPost extends BaseEntity this.tenantId = tenantId; } + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + public boolean isFlag() { return flag; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 987626e..1d33a75 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.UserConstants; @@ -23,12 +24,11 @@ import com.ruoyi.system.service.ISysDeptService; /** * 部门管理 服务实现 - * + * * @author ruoyi */ @Service -public class SysDeptServiceImpl implements ISysDeptService -{ +public class SysDeptServiceImpl implements ISysDeptService { @Autowired private SysDeptMapper deptMapper; @@ -37,52 +37,46 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @Override - @DataScope(deptAlias = "d",tenantAlias = "d") - public List selectDeptList(SysDept dept) - { + @DataScope(deptAlias = "d", tenantAlias = "d") + public List selectDeptList(SysDept dept) { return deptMapper.selectDeptList(dept); } /** * 查询部门树结构信息 - * + * * @param dept 部门信息 * @return 部门树信息集合 */ @Override - public List selectDeptTreeList(SysDept dept) - { + public List selectDeptTreeList(SysDept dept) { List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); return buildDeptTreeSelect(depts); } /** * 构建前端所需要树结构 - * + * * @param depts 部门列表 * @return 树结构列表 */ @Override - public List buildDeptTree(List depts) - { + public List buildDeptTree(List depts) { List returnList = new ArrayList(); List tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()); - for (SysDept dept : depts) - { + for (SysDept dept : depts) { // 如果是顶级节点, 遍历该父节点的所有子节点 - if (!tempList.contains(dept.getParentId())) - { + if (!tempList.contains(dept.getParentId())) { recursionFn(depts, dept); returnList.add(dept); } } - if (returnList.isEmpty()) - { + if (returnList.isEmpty()) { returnList = depts; } return returnList; @@ -90,93 +84,85 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 构建前端所需要下拉树结构 - * + * * @param depts 部门列表 * @return 下拉树结构列表 */ @Override - public List buildDeptTreeSelect(List depts) - { + public List buildDeptTreeSelect(List depts) { List deptTrees = buildDeptTree(depts); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); } /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @return 选中部门列表 */ @Override - public List selectDeptListByRoleId(Long roleId) - { + public List selectDeptListByRoleId(Long roleId) { SysRole role = roleMapper.selectRoleById(roleId); return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); } /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @Override - public SysDept selectDeptById(Long deptId) - { + public SysDept selectDeptById(Long deptId) { return deptMapper.selectDeptById(deptId); } /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @Override - public int selectNormalChildrenDeptById(Long deptId) - { + public int selectNormalChildrenDeptById(Long deptId) { return deptMapper.selectNormalChildrenDeptById(deptId); } /** * 是否存在子节点 - * + * * @param deptId 部门ID * @return 结果 */ @Override - public boolean hasChildByDeptId(Long deptId) - { + public boolean hasChildByDeptId(Long deptId) { int result = deptMapper.hasChildByDeptId(deptId); return result > 0; } /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 true 存在 false 不存在 */ @Override - public boolean checkDeptExistUser(Long deptId) - { + public boolean checkDeptExistUser(Long deptId) { int result = deptMapper.checkDeptExistUser(deptId); return result > 0; } /** * 校验部门名称是否唯一 - * + * * @param dept 部门信息 * @return 结果 */ @Override - public boolean checkDeptNameUnique(SysDept dept) - { + public boolean checkDeptNameUnique(SysDept dept) { Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); - if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -184,19 +170,16 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 校验部门是否有数据权限 - * + * * @param deptId 部门id */ @Override - public void checkDeptDataScope(Long deptId) - { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) - { + public void checkDeptDataScope(Long deptId) { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) { SysDept dept = new SysDept(); dept.setDeptId(deptId); List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); - if (StringUtils.isEmpty(depts)) - { + if (StringUtils.isEmpty(depts)) { throw new ServiceException("没有权限访问部门数据!"); } } @@ -204,36 +187,38 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 新增保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @Override - public int insertDept(SysDept dept) - { - SysDept info = deptMapper.selectDeptById(dept.getParentId()); - // 如果父节点不为正常状态,则不允许新增子节点 - if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) - { - throw new ServiceException("部门停用,不允许新增"); + public int insertDept(SysDept dept) { + if (dept.getParentId() == null) { + dept.setParentId(0L); + dept.setAncestors("0"); + } else { + SysDept info = deptMapper.selectDeptById(dept.getParentId()); + // 如果父节点不为正常状态,则不允许新增子节点 + if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { + throw new ServiceException("部门停用,不允许新增"); + } + dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); } - dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + return deptMapper.insertDept(dept); } /** * 修改保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @Override - public int updateDept(SysDept dept) - { + public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); - if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) - { + if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); @@ -241,8 +226,7 @@ public class SysDeptServiceImpl implements ISysDeptService } int result = deptMapper.updateDept(dept); if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) - && !StringUtils.equals("0", dept.getAncestors())) - { + && !StringUtils.equals("0", dept.getAncestors())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatusNormal(dept); } @@ -251,11 +235,10 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改该部门的父级部门状态 - * + * * @param dept 当前部门 */ - private void updateParentDeptStatusNormal(SysDept dept) - { + private void updateParentDeptStatusNormal(SysDept dept) { String ancestors = dept.getAncestors(); Long[] deptIds = Convert.toLongArray(ancestors); deptMapper.updateDeptStatusNormal(deptIds); @@ -263,48 +246,41 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改子元素关系 - * - * @param deptId 被修改的部门ID + * + * @param deptId 被修改的部门ID * @param newAncestors 新的父ID集合 * @param oldAncestors 旧的父ID集合 */ - public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) - { + public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { List children = deptMapper.selectChildrenDeptById(deptId); - for (SysDept child : children) - { + for (SysDept child : children) { child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); } - if (children.size() > 0) - { + if (children.size() > 0) { deptMapper.updateDeptChildren(children); } } /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ @Override - public int deleteDeptById(Long deptId) - { + public int deleteDeptById(Long deptId) { return deptMapper.deleteDeptById(deptId); } /** * 递归列表 */ - private void recursionFn(List list, SysDept t) - { + private void recursionFn(List list, SysDept t) { // 得到子节点列表 List childList = getChildList(list, t); t.setChildren(childList); - for (SysDept tChild : childList) - { - if (hasChild(list, tChild)) - { + for (SysDept tChild : childList) { + if (hasChild(list, tChild)) { recursionFn(list, tChild); } } @@ -313,15 +289,12 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 得到子节点列表 */ - private List getChildList(List list, SysDept t) - { + private List getChildList(List list, SysDept t) { List tlist = new ArrayList(); Iterator it = list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SysDept n = (SysDept) it.next(); - if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) - { + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { tlist.add(n); } } @@ -331,8 +304,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 判断是否有子节点 */ - private boolean hasChild(List list, SysDept t) - { + private boolean hasChild(List list, SysDept t) { return getChildList(list, t).size() > 0 ? true : false; } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 5558bff..e5ae7b0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -34,6 +34,7 @@ public class SysPostServiceImpl implements ISysPostService * @return 岗位信息集合 */ @Override + @DataScope(tenantAlias = "p") public List selectPostList(SysPost post) { return postMapper.selectPostList(post); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 1816213..5660356 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -92,7 +92,7 @@ public class SysUserServiceImpl implements ISysUserService { * @return 用户信息集合信息 */ @Override - @DataScope(deptAlias = "d", userAlias = "u") + @DataScope(deptAlias = "d", userAlias = "u",tenantAlias = "u") public List selectUnallocatedList(SysUser user) { return userMapper.selectUnallocatedList(user); } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 52fcc3e..e9f0bf6 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -20,30 +20,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time - from sys_dept d + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.tenant_id,ht.tenant_name + from sys_dept d left join hw_tenant ht on d.tenant_id=ht.tenant_id - AND post_code like concat('%', #{postCode}, '%') + AND p.post_code like concat('%', #{postCode}, '%') - AND status = #{status} + AND p.status = #{status} - AND post_name like concat('%', #{postName}, '%') + AND p.post_name like concat('%', #{postName}, '%') - - AND tenant_id = #{tenantId} + + AND p.tenant_id = #{tenantId} ${params.tenantDataScope} - + order by p.tenant_id,p.post_sort @@ -59,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${params.dataScope} ${params.tenantDataScope} - order by r.role_sort + order by r.tenant_id,r.role_sort