若依微服务1.5.0

dataprocess:
1、增加处理数据的耗费时间日志
2、devicecode转小写处理
system:
1、用户管理完善(1)、根据租户过滤完善;2)、导出功能完善)
2、角色管理完善
3、部门管理admin可以创建租户的,租户也有权限增删改查
4、岗位管理admin可以创建租户的,租户也有权限增删改查
business:
1、设备管理完善(1)、增加导出;2)、根据租户过滤逻辑完善;3)、设备代码可以小写字母、数字和下划线,最前面不限制是字母;)
2、设备模型管理完善(1)、修复功能标识符为value时在tdengine创建表时转换成value1;2)、value1不允许做标识符,增加导出)
3、监控单元类型完善
4、监控单元完善(1)、根据租户过滤逻辑完善;)
5、场景完善
6、租户完善
master
xins 2 years ago
parent 900932e87f
commit f695f18aaa

@ -57,6 +57,10 @@ public class SysDept extends BaseEntity
private Long tenantId; private Long tenantId;
private String tenantName;
private String notEditable;//是否不可编辑10
public Long getDeptId() public Long getDeptId()
{ {
return deptId; return deptId;
@ -191,6 +195,22 @@ public class SysDept extends BaseEntity
this.tenantId = tenantId; 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 @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -66,6 +66,10 @@ public class SysRole extends BaseEntity
private Long tenantId; private Long tenantId;
private String tenantName;
private String notEditable;//是否不可编辑10
public SysRole() public SysRole()
{ {
@ -229,6 +233,22 @@ public class SysRole extends BaseEntity
this.tenantId = tenantId; 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 @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -3,6 +3,7 @@ package com.ruoyi.system.api.domain;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel;
@ -14,289 +15,288 @@ import com.ruoyi.common.core.xss.Xss;
/** /**
* sys_user * sys_user
* *
* @author ruoyi * @author ruoyi
*/ */
public class SysUser extends BaseEntity public class SysUser extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 用户ID */ /**
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") * ID
*/
@Excel(name = "用户编号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
private Long userId; private Long userId;
/** 部门ID */ /**
* ID
*/
@Excel(name = "部门编号", type = Type.IMPORT) @Excel(name = "部门编号", type = Type.IMPORT)
private Long deptId; private Long deptId;
/** 用户账号 */ /**
@Excel(name = "登录名称") *
*/
@Excel(name = "用户名称")
private String userName; private String userName;
/** 用户昵称 */ /**
@Excel(name = "用户名称") *
*/
@Excel(name = "用户昵称")
private String nickName; private String nickName;
/** 用户邮箱 */ /**
*
*/
@Excel(name = "用户邮箱") @Excel(name = "用户邮箱")
private String email; private String email;
/** 手机号码 */ /**
*
*/
@Excel(name = "手机号码") @Excel(name = "手机号码")
private String phonenumber; private String phonenumber;
/** 用户性别 */ /**
*
*/
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String sex; private String sex;
/** 用户头像 */ /**
*
*/
private String avatar; private String avatar;
/** 密码 */ /**
*
*/
private String password; private String password;
/** 帐号状态0正常 1停用 */ /**
* 0 1
*/
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
/** 删除标志0代表存在 2代表删除 */ /**
* 0 2
*/
private String delFlag; private String delFlag;
/** 最后登录IP */ /**
* IP
*/
@Excel(name = "最后登录IP", type = Type.EXPORT) @Excel(name = "最后登录IP", type = Type.EXPORT)
private String loginIp; private String loginIp;
/** 最后登录时间 */ /**
*
*/
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date loginDate; private Date loginDate;
/** 部门对象 */ /**
*
*/
@Excels({ @Excels({
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), @Excel(name = "部门编号", targetAttr = "deptId", type = Type.EXPORT),
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
}) })
private SysDept dept; private SysDept dept;
/** 角色对象 */ /**
*
*/
private List<SysRole> roles; private List<SysRole> roles;
/** 角色组 */ /**
*
*/
private Long[] roleIds; private Long[] roleIds;
/** 岗位组 */ /**
*
*/
private Long[] postIds; private Long[] postIds;
/** 角色ID */ /**
* ID
*/
private Long roleId; private Long roleId;
@Excel(name = "租户Id")
private Long tenantId;//租户ID private Long tenantId;//租户ID
@Excel(name = "租户名称")
private String tenantName;//租户名称 private String tenantName;//租户名称
public SysUser()
{ public SysUser() {
} }
public SysUser(Long userId) public SysUser(Long userId) {
{
this.userId = userId; this.userId = userId;
} }
public Long getUserId() public Long getUserId() {
{
return userId; return userId;
} }
public void setUserId(Long userId) public void setUserId(Long userId) {
{
this.userId = userId; this.userId = userId;
} }
public boolean isAdmin() public boolean isAdmin() {
{
return isAdmin(this.userId); return isAdmin(this.userId);
} }
public static boolean isAdmin(Long userId) public static boolean isAdmin(Long userId) {
{
return userId != null && 1L == userId; return userId != null && 1L == userId;
} }
public Long getDeptId() public Long getDeptId() {
{
return deptId; return deptId;
} }
public void setDeptId(Long deptId) public void setDeptId(Long deptId) {
{
this.deptId = deptId; this.deptId = deptId;
} }
@Xss(message = "用户昵称不能包含脚本字符") @Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
public String getNickName() public String getNickName() {
{
return nickName; return nickName;
} }
public void setNickName(String nickName) public void setNickName(String nickName) {
{
this.nickName = nickName; this.nickName = nickName;
} }
@Xss(message = "用户账号不能包含脚本字符") @Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空") @NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
public String getUserName() public String getUserName() {
{
return userName; return userName;
} }
public void setUserName(String userName) public void setUserName(String userName) {
{
this.userName = userName; this.userName = userName;
} }
@Email(message = "邮箱格式不正确") @Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail() public String getEmail() {
{
return email; return email;
} }
public void setEmail(String email) public void setEmail(String email) {
{
this.email = email; this.email = email;
} }
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
public String getPhonenumber() public String getPhonenumber() {
{
return phonenumber; return phonenumber;
} }
public void setPhonenumber(String phonenumber) public void setPhonenumber(String phonenumber) {
{
this.phonenumber = phonenumber; this.phonenumber = phonenumber;
} }
public String getSex() public String getSex() {
{
return sex; return sex;
} }
public void setSex(String sex) public void setSex(String sex) {
{
this.sex = sex; this.sex = sex;
} }
public String getAvatar() public String getAvatar() {
{
return avatar; return avatar;
} }
public void setAvatar(String avatar) public void setAvatar(String avatar) {
{
this.avatar = avatar; this.avatar = avatar;
} }
public String getPassword() public String getPassword() {
{
return password; return password;
} }
public void setPassword(String password) public void setPassword(String password) {
{
this.password = password; this.password = password;
} }
public String getStatus() public String getStatus() {
{
return status; return status;
} }
public void setStatus(String status) public void setStatus(String status) {
{
this.status = status; this.status = status;
} }
public String getDelFlag() public String getDelFlag() {
{
return delFlag; return delFlag;
} }
public void setDelFlag(String delFlag) public void setDelFlag(String delFlag) {
{
this.delFlag = delFlag; this.delFlag = delFlag;
} }
public String getLoginIp() public String getLoginIp() {
{
return loginIp; return loginIp;
} }
public void setLoginIp(String loginIp) public void setLoginIp(String loginIp) {
{
this.loginIp = loginIp; this.loginIp = loginIp;
} }
public Date getLoginDate() public Date getLoginDate() {
{
return loginDate; return loginDate;
} }
public void setLoginDate(Date loginDate) public void setLoginDate(Date loginDate) {
{
this.loginDate = loginDate; this.loginDate = loginDate;
} }
public SysDept getDept() public SysDept getDept() {
{
return dept; return dept;
} }
public void setDept(SysDept dept) public void setDept(SysDept dept) {
{
this.dept = dept; this.dept = dept;
} }
public List<SysRole> getRoles() public List<SysRole> getRoles() {
{
return roles; return roles;
} }
public void setRoles(List<SysRole> roles) public void setRoles(List<SysRole> roles) {
{
this.roles = roles; this.roles = roles;
} }
public Long[] getRoleIds() public Long[] getRoleIds() {
{
return roleIds; return roleIds;
} }
public void setRoleIds(Long[] roleIds) public void setRoleIds(Long[] roleIds) {
{
this.roleIds = roleIds; this.roleIds = roleIds;
} }
public Long[] getPostIds() public Long[] getPostIds() {
{
return postIds; return postIds;
} }
public void setPostIds(Long[] postIds) public void setPostIds(Long[] postIds) {
{
this.postIds = postIds; this.postIds = postIds;
} }
public Long getRoleId() public Long getRoleId() {
{
return roleId; return roleId;
} }
public void setRoleId(Long roleId) public void setRoleId(Long roleId) {
{
this.roleId = roleId; this.roleId = roleId;
} }
@ -318,26 +318,26 @@ public class SysUser extends BaseEntity
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("userId", getUserId()) .append("userId", getUserId())
.append("deptId", getDeptId()) .append("deptId", getDeptId())
.append("userName", getUserName()) .append("userName", getUserName())
.append("nickName", getNickName()) .append("nickName", getNickName())
.append("email", getEmail()) .append("email", getEmail())
.append("phonenumber", getPhonenumber()) .append("phonenumber", getPhonenumber())
.append("sex", getSex()) .append("sex", getSex())
.append("avatar", getAvatar()) .append("avatar", getAvatar())
.append("password", getPassword()) .append("password", getPassword())
.append("status", getStatus()) .append("status", getStatus())
.append("delFlag", getDelFlag()) .append("delFlag", getDelFlag())
.append("loginIp", getLoginIp()) .append("loginIp", getLoginIp())
.append("loginDate", getLoginDate()) .append("loginDate", getLoginDate())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("remark", getRemark()) .append("remark", getRemark())
.append("dept", getDept()) .append("dept", getDept())
.toString(); .toString();
} }
} }

@ -1,7 +1,6 @@
package com.ruoyi.common.core.constant; package com.ruoyi.common.core.constant;
import java.util.HashMap; import java.util.*;
import java.util.Map;
/** /**
* @Description: TdEngine * @Description: TdEngine
@ -66,6 +65,11 @@ public class TdEngineConstants {
TDENGINE_KEY_TRANSFER_MAP.put("value", "value1"); TDENGINE_KEY_TRANSFER_MAP.put("value", "value1");
} }
/**
*
*/
public static final List<String> ABNDON_FUNCTION_IDENTIFIERS = Arrays.asList("ts","value1");
public static final Map<String, String> DEVICE_DATA_COLUMN_MAP = new HashMap<String, String>(); public static final Map<String, String> DEVICE_DATA_COLUMN_MAP = new HashMap<String, String>();
static { static {

@ -56,4 +56,14 @@ public enum BusinessType
* *
*/ */
CLEAN, CLEAN,
/**
*
*/
PUBLISH,
/**
*
*/
CONTROL
} }

@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantGrade != null "> and tenant_grade = #{tenantGrade}</if> <if test="tenantGrade != null "> and tenant_grade = #{tenantGrade}</if>
<if test="tenantField != null and tenantField != ''"> and tenant_field = #{tenantField}</if> <if test="tenantField != null and tenantField != ''"> and tenant_field = #{tenantField}</if>
</where> </where>
order by tenant_id desc
</select> </select>
<select id="selectHwTenantByTenantId" parameterType="Long" resultMap="HwTenantResult"> <select id="selectHwTenantByTenantId" parameterType="Long" resultMap="HwTenantResult">

@ -5,9 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwDeviceMode; import com.ruoyi.business.domain.*;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.domain.HwScene;
import com.ruoyi.business.domain.VO.DeviceControlVo; import com.ruoyi.business.domain.VO.DeviceControlVo;
import com.ruoyi.business.domain.VO.DeviceModeVo; import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.HwMonitorUnitVo; import com.ruoyi.business.domain.VO.HwMonitorUnitVo;
@ -32,7 +30,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.service.IHwDeviceService; import com.ruoyi.business.service.IHwDeviceService;
import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
@ -100,10 +97,8 @@ public class HwDeviceController extends BaseController {
@Log(title = "设备信息", businessType = BusinessType.INSERT) @Log(title = "设备信息", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody HwDevice hwDevice) { public AjaxResult add(@RequestBody HwDevice hwDevice) {
LoginUser loginUser = SecurityUtils.getLoginUser(); hwDevice.setTenantId(SecurityUtils.getTenantId());
SysUser user = loginUser.getSysUser(); hwDevice.setCreateBy(SecurityUtils.getUsername());
hwDevice.setTenantId(user.getTenantId());
hwDevice.setCreateBy(user.getUserName());
return toAjax(hwDeviceService.insertHwDevice(hwDevice)); return toAjax(hwDeviceService.insertHwDevice(hwDevice));
} }
@ -179,11 +174,9 @@ public class HwDeviceController extends BaseController {
* *
*/ */
@RequiresPermissions("business:device:edit") @RequiresPermissions("business:device:edit")
@Log(title = "设备管理", businessType = BusinessType.UPDATE) @Log(title = "设备管理", businessType = BusinessType.PUBLISH)
@PutMapping("/changeDeviceStatus") @PutMapping("/changeDeviceStatus")
public AjaxResult changeDeviceStatus(@RequestBody HwDevice device) { public AjaxResult changeDeviceStatus(@RequestBody HwDevice device) {
device.setUpdateBy(SecurityUtils.getUsername());
device.setUpdateTime(new Date());
return toAjax(hwDeviceService.changeDeviceStatus(device)); return toAjax(hwDeviceService.changeDeviceStatus(device));
} }
@ -191,7 +184,7 @@ public class HwDeviceController extends BaseController {
* *
*/ */
@RequiresPermissions("business:device:edit") @RequiresPermissions("business:device:edit")
@Log(title = "下发设备控制指令", businessType = BusinessType.UPDATE) @Log(title = "下发设备控制指令", businessType = BusinessType.CONTROL)
@PutMapping("/publishControlCommand") @PutMapping("/publishControlCommand")
public AjaxResult publishControlCommand(@RequestBody DeviceControlVo deviceControlVo) { public AjaxResult publishControlCommand(@RequestBody DeviceControlVo deviceControlVo) {
hwDeviceService.publishControlCommand(deviceControlVo); hwDeviceService.publishControlCommand(deviceControlVo);

@ -64,6 +64,18 @@ public class HwDeviceModeController extends BaseController {
util.exportExcel(response, list, "设备模型数据"); util.exportExcel(response, list, "设备模型数据");
} }
/**
*
*/
@RequiresPermissions("business:deviceMode:export")
@Log(title = "设备模型功能", businessType = BusinessType.EXPORT)
@PostMapping("/exportFunction")
public void exportFunction(HttpServletResponse response, HwDeviceMode hwDeviceMode) {
List<HwDeviceModeFunction> functions = hwDeviceModeService.selectHwDeviceModeFunctionList(new HwDeviceModeFunction());
ExcelUtil<HwDeviceModeFunction> functionUtil = new ExcelUtil<HwDeviceModeFunction>(HwDeviceModeFunction.class);
functionUtil.exportExcel(response, functions, "设备模型功能数据");
}
/** /**
* *
*/ */
@ -88,10 +100,8 @@ public class HwDeviceModeController extends BaseController {
@Log(title = "设备模型", businessType = BusinessType.INSERT) @Log(title = "设备模型", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody HwDeviceMode hwDeviceMode) { public AjaxResult add(@RequestBody HwDeviceMode hwDeviceMode) {
LoginUser loginUser = SecurityUtils.getLoginUser(); hwDeviceMode.setTenantId(SecurityUtils.getTenantId());
SysUser user = loginUser.getSysUser(); hwDeviceMode.setCreateBy(SecurityUtils.getUsername());
hwDeviceMode.setTenantId(user.getTenantId());
hwDeviceMode.setCreateBy(user.getUserName());
return toAjax(hwDeviceModeService.insertHwDeviceMode(hwDeviceMode)); return toAjax(hwDeviceModeService.insertHwDeviceMode(hwDeviceMode));
} }

@ -52,6 +52,7 @@ public class HwDeviceModeFunctionController extends BaseController {
return toAjax(hwDeviceModeService.deleteHwDeviceModeFunctionByModeFunctionId(modeFunctionId)); return toAjax(hwDeviceModeService.deleteHwDeviceModeFunctionByModeFunctionId(modeFunctionId));
} }
@RequiresPermissions("business:deviceMode:list")
@GetMapping("/getDeviceModeParameters/{modeFunctionId}") @GetMapping("/getDeviceModeParameters/{modeFunctionId}")
public AjaxResult getDeviceModeParameters(@PathVariable("modeFunctionId") Long modeFunctionId) { public AjaxResult getDeviceModeParameters(@PathVariable("modeFunctionId") Long modeFunctionId) {
return success(hwDeviceModeService.selectDeviceModeParametersByModeFunctionId(modeFunctionId)); return success(hwDeviceModeService.selectDeviceModeParametersByModeFunctionId(modeFunctionId));

@ -8,6 +8,8 @@ import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.tdengine.api.domain.TdReturnDataVo; import com.ruoyi.tdengine.api.domain.TdReturnDataVo;
@ -85,6 +87,7 @@ public class HwMonitorPlatformController extends BaseController {
} }
@PutMapping("/handleAlarmInfo") @PutMapping("/handleAlarmInfo")
@Log(title = "监控平台处理报警信息", businessType = BusinessType.UPDATE)
@RequiresPermissions("business:monitor:alarm") @RequiresPermissions("business:monitor:alarm")
public AjaxResult handleAlarmInfo(@RequestBody HwAlarmInfo hwAlarmInfo) { public AjaxResult handleAlarmInfo(@RequestBody HwAlarmInfo hwAlarmInfo) {
hwAlarmInfo.setUpdateBy(SecurityUtils.getUsername()); hwAlarmInfo.setUpdateBy(SecurityUtils.getUsername());
@ -232,6 +235,7 @@ public class HwMonitorPlatformController extends BaseController {
@RequiresPermissions("business:monitor:deviceMonitor") @RequiresPermissions("business:monitor:deviceMonitor")
@Log(title = "监控平台下发控制指令", businessType = BusinessType.CONTROL)
@PostMapping("/publishControlCommand") @PostMapping("/publishControlCommand")
public AjaxResult publishControlCommand(@RequestBody DeviceControlVo deviceControlVo) { public AjaxResult publishControlCommand(@RequestBody DeviceControlVo deviceControlVo) {
hwDeviceService.publishControlCommand(deviceControlVo); hwDeviceService.publishControlCommand(deviceControlVo);

@ -108,8 +108,6 @@ public class HwSceneController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody HwScene hwScene) public AjaxResult add(@RequestBody HwScene hwScene)
{ {
// System.out.println(hwScene);
return toAjax(hwSceneService.insertHwScene(hwScene)); return toAjax(hwSceneService.insertHwScene(hwScene));
} }
@ -121,9 +119,7 @@ public class HwSceneController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody HwScene hwScene) public AjaxResult edit(@RequestBody HwScene hwScene)
{ {
LoginUser loginUser = SecurityUtils.getLoginUser(); hwScene.setUpdateBy(SecurityUtils.getUsername());
SysUser sysUser = loginUser.getSysUser();
hwScene.setUpdateBy(sysUser.getNickName());
return toAjax(hwSceneService.updateHwScene(hwScene)); return toAjax(hwSceneService.updateHwScene(hwScene));
} }
@ -137,18 +133,18 @@ public class HwSceneController extends BaseController
{ {
return toAjax(hwSceneService.deleteHwSceneBySceneIds(sceneIds)); return toAjax(hwSceneService.deleteHwSceneBySceneIds(sceneIds));
} }
@GetMapping("/isAdmin") // @GetMapping("/isAdmin")
public Boolean isAdmin(){ // public Boolean isAdmin(){
LoginUser loginUser = SecurityUtils.getLoginUser(); // LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser(); // SysUser sysUser = loginUser.getSysUser();
// System.out.println(sysUser.getUserName()); //// System.out.println(sysUser.getUserName());
if (sysUser.getUserName().equals("admin")){ // if (sysUser.getUserName().equals("admin")){
// System.out.println("true"); //// System.out.println("true");
return true; // return true;
}else { // }else {
return false; // return false;
} // }
} // }
/** /**
* 使 * 使

@ -48,6 +48,7 @@ public class HwTenantController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(HwTenant hwTenant) public TableDataInfo list(HwTenant hwTenant)
{ {
startPage();
return getDataTable(hwTenantService.selectHwTenantList(hwTenant)); return getDataTable(hwTenantService.selectHwTenantList(hwTenant));
} }

@ -20,6 +20,7 @@ public class HwDevice extends BaseEntity {
/** /**
* ID * ID
*/ */
@Excel(name = "设备ID")
private Long deviceId; private Long deviceId;
/** /**
@ -37,81 +38,88 @@ public class HwDevice extends BaseEntity {
/** /**
* hw_scenescene_id * hw_scenescene_id
*/ */
@Excel(name = "所属场景关联hw_scene表的scene_id字段") @Excel(name = "所属场景")
private Long sceneId; private Long sceneId;
/** /**
* hw_monitor_unitmonitor_unit_id * hw_monitor_unitmonitor_unit_id
*/ */
@Excel(name = "所属监控单元关联表hw_monitor_unit字段monitor_unit_id") @Excel(name = "所属监控单元")
private Long monitorUnitId; private Long monitorUnitId;
/** /**
* 123 * 123
*/ */
@Excel(name = "设备类型", readConverterExp = "1=网关设备2网关子设备3直连设备") @Excel(name = "设备类型", readConverterExp = "1=网关设备,2网关子设备,3直连设备")
private String deviceType; private String deviceType;
/** /**
* (1:Wi-Fi2(2G/3G/4G/5G),34) * (1:Wi-Fi2(2G/3G/4G/5G),34)
*/ */
@Excel(name = "联网方式(1:Wi-Fi2、蜂窝(2G/3G/4G/5G),3、以太网4、其他)") @Excel(name = "联网方式(1=Wi-Fi,2=蜂窝(2G/3G/4G/5G),3=以太网,4=其他)")
private String networkingMode; private String networkingMode;
/** /**
* 1MQTT * 1MQTT
*/ */
@Excel(name = "接入协议", readConverterExp = "1=MQTT") @Excel(name = "接入协议", readConverterExp = "1=MQTT")
private Long accessProtocol; private Long accessProtocol;
/** /**
* 1Json * 1Json
*/ */
@Excel(name = "数据格式", readConverterExp = "1=Json") @Excel(name = "数据格式", readConverterExp = "1=Json")
private Long dataFormat; private Long dataFormat;
/** /**
* hw_devicedevice_id * hw_devicedevice_id
*/ */
@Excel(name = "关联设备hw_device表中国的device_id") @Excel(name = "关联设备")
private Long releatedDeviceId; private Long releatedDeviceId;
/** /**
* hw_device_modedevice_mode_id * hw_device_modedevice_mode_id
*/ */
@Excel(name = "设备模型关联表hw_device_mode的字段device_mode_id") @Excel(name = "设备模型")
private Long deviceModeId; private Long deviceModeId;
/** /**
* 1Modbus * 1Modbus
* OPC-UA,Modbus * OPC-UA,Modbus
*/ */
@Excel(name = "接入网关协议", readConverterExp = "1=Modbus") @Excel(name = "接入网关协议", readConverterExp = "1=Modbus")
private Long accessGwProtocol; private Long accessGwProtocol;
/** /**
* 10 * 10
*/ */
@Excel(name = "激活状态", readConverterExp = "1=、激活0、未激活") @Excel(name = "激活状态", readConverterExp = "1=激活,0未激活")
private String activeStatus; private String activeStatus;
/** /**
* 019 * 019
*/ */
@Excel(name = "设备状态", readConverterExp = "0=、测试1、发布9、删除") @Excel(name = "设备状态", readConverterExp = "0=测试,1发布,9删除")
private String deviceStatus; private String deviceStatus;
/** /**
* *
*/ */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "设备激活时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "设备激活时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date activeTime; private Date activeTime;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "设备发布时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date publishTime;
/** /**
* 使 * 使
*/ */
@Excel(name = "设备图片地址", readConverterExp = "如=果为空则可以使用设备模型图片") @Excel(name = "设备图片地址")
private String devicePic; private String devicePic;
/** /**
@ -123,13 +131,13 @@ public class HwDevice extends BaseEntity {
/** /**
* IDhw_areaarea_id) * IDhw_areaarea_id)
*/ */
@Excel(name = "预留字段设备所在区域ID关联表hw_area字段area_id)") // @Excel(name = "预留字段设备所在区域ID关联表hw_area字段area_id)")
private Long areaId; private Long areaId;
/** /**
* G780V2(V2.2.0)PLCNET510G800 V2ModbusRTU() * G780V2(V2.2.0)PLCNET510G800 V2ModbusRTU()
*/ */
@Excel(name = "预留字段,设备位置", readConverterExp = "手=动定位(在地图上选择设备所在的固定位置") // @Excel(name = "预留字段,设备位置", readConverterExp = "手=动定位(在地图上选择设备所在的固定位置")
private String deviceLocation; private String deviceLocation;
/** /**
@ -147,19 +155,19 @@ public class HwDevice extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "预留字段") // @Excel(name = "预留字段")
private String deviceField; private String deviceField;
/** /**
* IDhw_tenanttenant_id * IDhw_tenanttenant_id
*/ */
@Excel(name = "租户ID关联hw_tenant的tenant_id") @Excel(name = "租户ID")
private Long tenantId; private Long tenantId;
/** /**
* 线1线0线 * 线1线0线
*/ */
@Excel(name = "在线状态", readConverterExp = "1=、在线0、离线") // @Excel(name = "在线状态", readConverterExp = "1=在线,0离线")
private String onlineStatus; private String onlineStatus;
private String monitorUnitName; private String monitorUnitName;
@ -291,6 +299,14 @@ public class HwDevice extends BaseEntity {
return activeTime; return activeTime;
} }
public Date getPublishTime() {
return publishTime;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}
public void setDevicePic(String devicePic) { public void setDevicePic(String devicePic) {
this.devicePic = devicePic; this.devicePic = devicePic;
} }
@ -421,6 +437,7 @@ public class HwDevice extends BaseEntity {
.append("activeStatus", getActiveStatus()) .append("activeStatus", getActiveStatus())
.append("deviceStatus", getDeviceStatus()) .append("deviceStatus", getDeviceStatus())
.append("activeTime", getActiveTime()) .append("activeTime", getActiveTime())
.append("publishTime", getPublishTime())
.append("devicePic", getDevicePic()) .append("devicePic", getDevicePic())
.append("ipAddress", getIpAddress()) .append("ipAddress", getIpAddress())
.append("areaId", getAreaId()) .append("areaId", getAreaId())

@ -17,6 +17,7 @@ public class HwDeviceMode extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 设备模型ID */ /** 设备模型ID */
@Excel(name = "设备模型ID")
private Long deviceModeId; private Long deviceModeId;
/** 设备模型名称 */ /** 设备模型名称 */
@ -24,31 +25,31 @@ public class HwDeviceMode extends BaseEntity
private String deviceModeName; private String deviceModeName;
/** 租户ID关联hw_tenant的tenant_id */ /** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id") @Excel(name = "租户ID")
private Long tenantId; private Long tenantId;
/** 所属场景关联hw_scene表的scene_id字段 */ /** 所属场景关联hw_scene表的scene_id字段 */
@Excel(name = "所属场景关联hw_scene表的scene_id字段") @Excel(name = "所属场景")
private Long sceneId; private Long sceneId;
/** 语言code,关联表hw_language的language_code字段 */ /** 语言code,关联表hw_language的language_code字段 */
@Excel(name = "语言code,关联表hw_language的language_code字段") @Excel(name = "语言")
private String languageCode; private String languageCode;
/** 定位标识10 */ /** 定位标识10 */
@Excel(name = "定位标识", readConverterExp = "1=0否") @Excel(name = "定位标识", readConverterExp = "1=是,0=否")
private String gpsFlag; private String gpsFlag;
/** 设备模型状态1启用9删除 */ /** 设备模型状态1启用9删除 */
@Excel(name = "设备模型状态", readConverterExp = "1=启用9删除") @Excel(name = "设备模型状态", readConverterExp = "1=启用,9=删除")
private String deviceModeStatus; private String deviceModeStatus;
/** 是否通用物模型1、是0 */ /** 是否通用物模型1、是0 */
@Excel(name = "是否通用物模型", readConverterExp = "1=、是0否") @Excel(name = "通用标识", readConverterExp = "1=是,0=否")
private String commonFlag; private String commonFlag;
/** 模型分类(在平台字典数据表中定义) */ /** 模型分类(在平台字典数据表中定义) */
@Excel(name = "模型分类", readConverterExp = "在=平台字典数据表中定义") @Excel(name = "模型分类")
private Long modeClassfication; private Long modeClassfication;
/** 设备模型图片地址 */ /** 设备模型图片地址 */
@ -56,11 +57,11 @@ public class HwDeviceMode extends BaseEntity
private String deviceModePic; private String deviceModePic;
/** 预留字段,数据校验级别 */ /** 预留字段,数据校验级别 */
@Excel(name = "预留字段,数据校验级别") // @Excel(name = "预留字段,数据校验级别")
private String dataVerifyLevel; private String dataVerifyLevel;
/** 预留字段 */ /** 预留字段 */
@Excel(name = "预留字段") // @Excel(name = "预留字段")
private String deviceModeField; private String deviceModeField;
private String tenantName; private String tenantName;

@ -19,18 +19,19 @@ public class HwDeviceModeFunction extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 设备模型功能ID */ /** 设备模型功能ID */
@Excel(name = "设备模型功能ID")
private Long modeFunctionId; private Long modeFunctionId;
/** 设备模型ID关联表hw_device_mode的device_mode_id */ /** 设备模型ID关联表hw_device_mode的device_mode_id */
@Excel(name = "设备模型ID关联表hw_device_mode的device_mode_id") @Excel(name = "设备模型ID")
private Long deviceModeId; private Long deviceModeId;
/** 功能模式1、属性2、服务3、事件 */ /** 功能模式1、属性2、服务3、事件 */
@Excel(name = "功能模式", readConverterExp = "1=、属性2、服务3、事件") @Excel(name = "功能模式", readConverterExp = "1=属性,2=服务,3=事件")
private String functionMode; private String functionMode;
/** 坐标标识1、经度2、纬度 */ /** 坐标标识1、经度2、纬度 */
@Excel(name = "坐标标识", readConverterExp = "1=、经度2、纬度") @Excel(name = "坐标标识", readConverterExp = "1=经度,2=纬度")
private String coordinate; private String coordinate;
/** 功能名称 */ /** 功能名称 */
@ -38,15 +39,15 @@ public class HwDeviceModeFunction extends BaseEntity
private String functionName; private String functionName;
/** 标识符支持大小写字母、数字和下划线对外暂时不超过50个字符 */ /** 标识符支持大小写字母、数字和下划线对外暂时不超过50个字符 */
@Excel(name = "标识符", readConverterExp = "支=持大小写字母、数字和下划线对外暂时不超过50个字符") @Excel(name = "标识符")
private String functionIdentifier; private String functionIdentifier;
/** 功能类型(1、直采变量 2、手录变量 3、运算性变量) */ /** 功能类型(1、直采变量 2、手录变量 3、运算性变量) */
@Excel(name = "功能类型(1、直采变量 2、手录变量 3、运算性变量)") @Excel(name = "功能类型", readConverterExp = "1=直采变量,2=手录变量,3=运算型变量")
private String functionType; private String functionType;
/** 数据类型2、int4、float5、double6、binary(image/base64),9、bool10、string */ /** 数据类型2、int4、float5、double6、binary(image/base64),9、bool10、string */
@Excel(name = "数据类型", readConverterExp = "2=、int4、float5、double6、binary(image/base64),9、bool10、string") @Excel(name = "数据类型", readConverterExp = "2=int,4=float,5=double,9=bool,10=string")
private Long dataType; private Long dataType;
/** json /** json
@ -59,11 +60,11 @@ public class HwDeviceModeFunction extends BaseEntity
{'dataLength'1024} {'dataLength'1024}
5String 5String
{'dateFormat':'StringUTC'} */ {'dateFormat':'StringUTC'} */
@Excel(name = "数据定义按json保存示例如下1、取值范围{'minValue':1,'maxValue':100},2、枚举型{'1':'成功','2','失败','3','提示}3、bool型 {'0':'关','1','开'}4、Text型{'dataLength'1024}5、String类型", readConverterExp = "此=类型需要定义在数据字典中,支持多语言") @Excel(name = "数据定义")
private String dataDefinition; private String dataDefinition;
/** 运算性变量公式标识符1*标识符2*100 */ /** 运算性变量公式标识符1*标识符2*100 */
@Excel(name = "运算性变量公式", readConverterExp = "标=识符1*标识符2*100") @Excel(name = "运算型变量公式")
private String functionFormula; private String functionFormula;
/** 单位 */ /** 单位 */
@ -71,19 +72,19 @@ public class HwDeviceModeFunction extends BaseEntity
private String propertyUnit; private String propertyUnit;
/** 显示标识0、不显示1、显示2、可累积显示 */ /** 显示标识0、不显示1、显示2、可累积显示 */
@Excel(name = "显示标识", readConverterExp = "0=、不显示1、显示2、可累积显示") @Excel(name = "显示标识", readConverterExp = "0=不显示,1=显示,2=可累积显示")
private String displayFlag; private String displayFlag;
/** 读写标识1、读写2、只读 */ /** 读写标识1、读写2、只读 */
@Excel(name = "读写标识", readConverterExp = "1=、读写2、只读") @Excel(name = "读写标识", readConverterExp = "1=读写,2=只读")
private String rwFlag; private String rwFlag;
/** 调用方式1、异步2、同步当功能模式为服务时必填 */ /** 调用方式1、异步2、同步当功能模式为服务时必填 */
@Excel(name = "调用方式", readConverterExp = "1=、异步2、同步") @Excel(name = "调用方式", readConverterExp = "1=异步,2=同步")
private String invokeMethod; private String invokeMethod;
/** 事件类型1、信息2、告警3、故障当功能类型为事件时必填 */ /** 事件类型1、信息2、告警3、故障当功能类型为事件时必填 */
@Excel(name = "事件类型", readConverterExp = "1=、信息2、告警3、故障") @Excel(name = "事件类型", readConverterExp = "1=信息,2=告警,3=故障")
private String eventType; private String eventType;
/** %s /** %s
@ -93,23 +94,23 @@ public class HwDeviceModeFunction extends BaseEntity
%s10 %s10
%s/10 %s/10
%s%10 */ %s%10 */
@Excel(name = "预留字段,采集公式:设备上行数据经采集公式计算后显示,公式中的%s为占位符是固定字段。如%s+10减%s-10乘%s10除%s/10余数%s%10") // @Excel(name = "预留字段,采集公式:设备上行数据经采集公式计算后显示,公式中的%s为占位符是固定字段。如%s+10减%s-10乘%s10除%s/10余数%s%10")
private String acquisitionFormula; private String acquisitionFormula;
/** 预留字段,顺序 */ /** 预留字段,顺序 */
@Excel(name = "预留字段,顺序") // @Excel(name = "预留字段,顺序")
private Long orderFlag; private Long orderFlag;
/** 预留字段,寄存器 */ /** 预留字段,寄存器 */
@Excel(name = "预留字段,寄存器") // @Excel(name = "预留字段,寄存器")
private String deviceRegister; private String deviceRegister;
/** 预留字段,步长 */ /** 预留字段,步长 */
@Excel(name = "预留字段,步长") // @Excel(name = "预留字段,步长")
private BigDecimal propertyStep; private BigDecimal propertyStep;
/** 预留字段 */ /** 预留字段 */
@Excel(name = "预留字段") // @Excel(name = "预留字段")
private String propertyField; private String propertyField;
private List<HwDeviceModeParameter> inputParameters; private List<HwDeviceModeParameter> inputParameters;

@ -16,19 +16,21 @@ public class HwMonitorUnitType extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 监控单元类型ID */ /** 监控单元类型ID */
@Excel(name = "监控单元类型ID")
private Long monitorUnitTypeId; private Long monitorUnitTypeId;
@Excel(name = "租户ID")
private Long tenantId; private Long tenantId;
/** 监控单元类型名称 */ /** 监控单元类型名称 */
@Excel(name = "监控单元类型名称") @Excel(name = "监控单元类型名称")
private String monitorUnitTypeName; private String monitorUnitTypeName;
/** 虚拟标识 */ /** 虚拟标识 */
@Excel(name = "虚拟标识") @Excel(name = "虚拟标识",readConverterExp = "1=是,0=否")
private String vitualFlag; private String vitualFlag;
/** 状态 */ /** 状态 */
@Excel(name = "状态") @Excel(name = "状态", readConverterExp = "1=正常,9=删除")
private String monitorUnitTypeStatus; private String monitorUnitTypeStatus;
/** 语言code */ /** 语言code */
@ -36,7 +38,7 @@ public class HwMonitorUnitType extends BaseEntity
private String languageCode; private String languageCode;
/** 通用标识10 */ /** 通用标识10 */
@Excel(name = "通用标识", readConverterExp = "1=0否") @Excel(name = "通用标识", readConverterExp = "1=0否")
private String commonFlag; private String commonFlag;
/** 所属场景 */ /** 所属场景 */
@ -48,7 +50,7 @@ public class HwMonitorUnitType extends BaseEntity
private String unitTypeIcon; private String unitTypeIcon;
/** 预留字段 */ /** 预留字段 */
@Excel(name = "预留字段") // @Excel(name = "预留字段")
private String unitTypeField; private String unitTypeField;
private String sceneName; private String sceneName;

@ -19,6 +19,7 @@ public class HwScene extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 场景ID */ /** 场景ID */
@Excel(name = "场景ID")
private Long sceneId; private Long sceneId;
/** 场景名称 */ /** 场景名称 */
@ -26,11 +27,11 @@ public class HwScene extends BaseEntity
private String sceneName; private String sceneName;
/** 租户ID关联hw_tenant的tenant_id */ /** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id") @Excel(name = "租户ID")
private Long tenantId; private Long tenantId;
/** 场景类型关联表hw_scene_mode的scene_mode_id */ /** 场景类型关联表hw_scene_mode的scene_mode_id */
@Excel(name = "场景类型关联表hw_scene_mode的scene_mode_id") @Excel(name = "场景类型")
private Long sceneModeId; private Long sceneModeId;
/** 场景图片地址 */ /** 场景图片地址 */
@ -38,24 +39,24 @@ public class HwScene extends BaseEntity
private String scenePic; private String scenePic;
/** 是否默认1、正常 0、否 */ /** 是否默认1、正常 0、否 */
@Excel(name = "是否默认", readConverterExp = "1=、正常,0=、否") @Excel(name = "默认标识", readConverterExp = "1=是,0=否")
private String defaultFlag; private String defaultFlag;
/** 状态1、正常 9、删除 */ /** 状态1、正常 9、删除 */
@NotNull(message = "{user.login.username}") // @NotNull(message = "{user.login.username}")
@Excel(name = "状态", readConverterExp = "1=正常,9=删除") @Excel(name = "状态", readConverterExp = "1=正常,9=删除")
private String sceneStatus; private String sceneStatus;
/** 认证方式1、密钥认证 */ /** 认证方式1、密钥认证 */
@Excel(name = "认证方式", readConverterExp = "1=密钥认证") @Excel(name = "认证方式", readConverterExp = "1=密钥认证")
private String authMode; private String authMode;
/** 场景账号(暂时不用) */ /** 场景账号(暂时不用) */
@Excel(name = "场景账号", readConverterExp = "暂=时不用") @Excel(name = "场景账号")
private String modeAccount; private String modeAccount;
/** 场景key一场景一密 */ /** 场景key一场景一密 */
@Excel(name = "场景key", readConverterExp = "一=场景一密") @Excel(name = "场景key")
private String modeKey; private String modeKey;
/** 场景secret */ /** 场景secret */
@ -67,15 +68,15 @@ public class HwScene extends BaseEntity
private BigDecimal preserveTime; private BigDecimal preserveTime;
/** 测试环境保存周期(单位默认30天 */ /** 测试环境保存周期(单位默认30天 */
@Excel(name = "测试环境保存周期(单位默认30天") // @Excel(name = "测试环境保存周期(单位默认30天")
private BigDecimal testPreserveTime; private BigDecimal testPreserveTime;
/** 预留字段租户环境0测试环境1正式环境 */ /** 预留字段租户环境0测试环境1正式环境 */
@Excel(name = "预留字段,租户环境", readConverterExp = "0=测试环境1正式环境") // @Excel(name = "预留字段,租户环境", readConverterExp = "0=测试环境1正式环境")
private String sceneEnvironment; private String sceneEnvironment;
/** 预留字段 */ /** 预留字段 */
@Excel(name = "预留字段") // @Excel(name = "预留字段")
private String sceneField; private String sceneField;
private String router; private String router;

@ -7,204 +7,215 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
/** /**
* hw_tenant * hw_tenant
* *
* @author xins * @author xins
* @date 2023-09-04 * @date 2023-09-04
*/ */
public class HwTenant extends BaseEntity public class HwTenant extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 租户ID */ /**
* ID
*/
private Long tenantId; private Long tenantId;
/** 租户类型,(1、企业2、个人) */ /**
@Excel(name = "租户类型,(1、企业2、个人)") * (12)
*/
@Excel(name = "租户类型", readConverterExp = "1=企业,2=个人")
private String tenantType; private String tenantType;
/** 租户名称 */ /**
*
*/
@Excel(name = "租户名称") @Excel(name = "租户名称")
private String tenantName; private String tenantName;
/** 行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value */ /**
@Excel(name = "行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value") * sys_dict_datadict_typehw_tenant_industrydict_value
*/
@Excel(name = "租户行业", readConverterExp = "1=机构组织,2=农林牧渔,3=建筑建材,4=冶金矿产,5=石油化工,6=水利水电,7=交通运输,8=信息产业,9=机械机电,10=轻工食品,11=服装纺织,12=专业服务,13=安全防护,14=环保绿化,15=旅游休闲,16=办公文教,17=电子电工,18=玩具礼品,19=家具用品,20=物资,21=包装,22=体育,23=办公,99=其他")
private Long tenantIndustry; private Long tenantIndustry;
/** 联系人姓名 */ /**
*
*/
@Excel(name = "联系人姓名") @Excel(name = "联系人姓名")
private String contactName; private String contactName;
/** 联系人电话 */ /**
*
*/
@Excel(name = "联系人电话") @Excel(name = "联系人电话")
private String contactPhone; private String contactPhone;
/** 邮箱地址 */ /**
*
*/
@Excel(name = "邮箱地址") @Excel(name = "邮箱地址")
private String email; private String email;
/** 区域ID管理区域hw_area */ /**
@Excel(name = "区域ID管理区域hw_area") * IDhw_area
*/
// @Excel(name = "区域ID")
private Long areaId; private Long areaId;
/** 联系人地址 */ /**
*
*/
@Excel(name = "联系人地址") @Excel(name = "联系人地址")
private String contactAddress; private String contactAddress;
/** 状态1、正常 9、删除 */ /**
@Excel(name = "状态", readConverterExp = "1=、正常,9=、删除") * 1 9
*/
@Excel(name = "状态", readConverterExp = "1=正常,9=删除")
private String tenantStatus; private String tenantStatus;
/** 是否外部注册1、是 0、否 */ /**
@Excel(name = "是否外部注册", readConverterExp = "1=、是,0=、否") * 1 0
*/
@Excel(name = "是否外部注册", readConverterExp = "1=是,0=否")
private String isRegister; private String isRegister;
/** 租户等级,预留字段 */ /**
@Excel(name = "租户等级,预留字段") *
*/
// @Excel(name = "租户等级,预留字段")
private Long tenantGrade; private Long tenantGrade;
/** 预留字段 */ /**
@Excel(name = "预留字段") *
*/
// @Excel(name = "预留字段")
private String tenantField; private String tenantField;
public void setTenantId(Long tenantId) public void setTenantId(Long tenantId) {
{
this.tenantId = tenantId; this.tenantId = tenantId;
} }
public Long getTenantId() public Long getTenantId() {
{
return tenantId; return tenantId;
} }
public void setTenantType(String tenantType)
{ public void setTenantType(String tenantType) {
this.tenantType = tenantType; this.tenantType = tenantType;
} }
public String getTenantType() public String getTenantType() {
{
return tenantType; return tenantType;
} }
public void setTenantName(String tenantName)
{ public void setTenantName(String tenantName) {
this.tenantName = tenantName; this.tenantName = tenantName;
} }
public String getTenantName() public String getTenantName() {
{
return tenantName; return tenantName;
} }
public void setTenantIndustry(Long tenantIndustry)
{ public void setTenantIndustry(Long tenantIndustry) {
this.tenantIndustry = tenantIndustry; this.tenantIndustry = tenantIndustry;
} }
public Long getTenantIndustry() public Long getTenantIndustry() {
{
return tenantIndustry; return tenantIndustry;
} }
public void setContactName(String contactName)
{ public void setContactName(String contactName) {
this.contactName = contactName; this.contactName = contactName;
} }
public String getContactName() public String getContactName() {
{
return contactName; return contactName;
} }
public void setContactPhone(String contactPhone)
{ public void setContactPhone(String contactPhone) {
this.contactPhone = contactPhone; this.contactPhone = contactPhone;
} }
public String getContactPhone() public String getContactPhone() {
{
return contactPhone; return contactPhone;
} }
public void setEmail(String email)
{ public void setEmail(String email) {
this.email = email; this.email = email;
} }
public String getEmail() public String getEmail() {
{
return email; return email;
} }
public void setAreaId(Long areaId)
{ public void setAreaId(Long areaId) {
this.areaId = areaId; this.areaId = areaId;
} }
public Long getAreaId() public Long getAreaId() {
{
return areaId; return areaId;
} }
public void setContactAddress(String contactAddress)
{ public void setContactAddress(String contactAddress) {
this.contactAddress = contactAddress; this.contactAddress = contactAddress;
} }
public String getContactAddress() public String getContactAddress() {
{
return contactAddress; return contactAddress;
} }
public void setTenantStatus(String tenantStatus)
{ public void setTenantStatus(String tenantStatus) {
this.tenantStatus = tenantStatus; this.tenantStatus = tenantStatus;
} }
public String getTenantStatus() public String getTenantStatus() {
{
return tenantStatus; return tenantStatus;
} }
public void setIsRegister(String isRegister)
{ public void setIsRegister(String isRegister) {
this.isRegister = isRegister; this.isRegister = isRegister;
} }
public String getIsRegister() public String getIsRegister() {
{
return isRegister; return isRegister;
} }
public void setTenantGrade(Long tenantGrade)
{ public void setTenantGrade(Long tenantGrade) {
this.tenantGrade = tenantGrade; this.tenantGrade = tenantGrade;
} }
public Long getTenantGrade() public Long getTenantGrade() {
{
return tenantGrade; return tenantGrade;
} }
public void setTenantField(String tenantField)
{ public void setTenantField(String tenantField) {
this.tenantField = tenantField; this.tenantField = tenantField;
} }
public String getTenantField() public String getTenantField() {
{
return tenantField; return tenantField;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("tenantId", getTenantId()) .append("tenantId", getTenantId())
.append("tenantType", getTenantType()) .append("tenantType", getTenantType())
.append("tenantName", getTenantName()) .append("tenantName", getTenantName())
.append("tenantIndustry", getTenantIndustry()) .append("tenantIndustry", getTenantIndustry())
.append("contactName", getContactName()) .append("contactName", getContactName())
.append("contactPhone", getContactPhone()) .append("contactPhone", getContactPhone())
.append("email", getEmail()) .append("email", getEmail())
.append("areaId", getAreaId()) .append("areaId", getAreaId())
.append("contactAddress", getContactAddress()) .append("contactAddress", getContactAddress())
.append("remark", getRemark()) .append("remark", getRemark())
.append("tenantStatus", getTenantStatus()) .append("tenantStatus", getTenantStatus())
.append("isRegister", getIsRegister()) .append("isRegister", getIsRegister())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("tenantGrade", getTenantGrade()) .append("tenantGrade", getTenantGrade())
.append("tenantField", getTenantField()) .append("tenantField", getTenantField())
.toString(); .toString();
} }
} }

@ -113,14 +113,6 @@ public interface HwMonitorUnitMapper
*/ */
public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds); public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds);
/**
* join
*
* @param hwMonitorUnit
* @return
*/
public List<HwMonitorUnit> selectHwMonitorUnitListJoinScene(HwMonitorUnit hwMonitorUnit);
/** /**
* *

@ -108,4 +108,13 @@ public interface IHwDeviceModeService
*/ */
public List<HwDeviceMode> selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode); public List<HwDeviceMode> selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode);
/**
* @param: hwDeviceModeFunction
* @description
* @author xins
* @date 2023-10-10 11:19
* @return List<HwDeviceModeFunction>
*/
public List<HwDeviceModeFunction> selectHwDeviceModeFunctionList(HwDeviceModeFunction hwDeviceModeFunction);
} }

@ -105,8 +105,8 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
String keyLatitude = keyLatitudeR.getData(); String keyLatitude = keyLatitudeR.getData();
hwDeviceModeFunctionList.forEach(d -> { hwDeviceModeFunctionList.forEach(d -> {
if (d.getFunctionIdentifier().equalsIgnoreCase(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME)) { if (TdEngineConstants.ABNDON_FUNCTION_IDENTIFIERS.contains(d.getFunctionIdentifier())) {
throw new ServiceException("标识符不能等于:" + TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); throw new ServiceException("标识符不能等于:" + d.getFunctionIdentifier());
} }
if (StringUtils.isEmpty(d.getCoordinate()) && if (StringUtils.isEmpty(d.getCoordinate()) &&
(d.getFunctionIdentifier().equalsIgnoreCase(keyLongitude) (d.getFunctionIdentifier().equalsIgnoreCase(keyLongitude)
@ -289,6 +289,8 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
|| !dbDataType.equals(dataType)) { || !dbDataType.equals(dataType)) {
this.dropTdSuperTableColumn(dbHwDeviceModeFunction); this.dropTdSuperTableColumn(dbHwDeviceModeFunction);
this.addTdSuperTableColumn(hwDeviceModeFunction); this.addTdSuperTableColumn(hwDeviceModeFunction);
}else{
//todo:修改tdengine字符串长度
} }
} }
@ -339,6 +341,17 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
return hwDeviceModeMapper.selectHwDeviceModeJoinList(hwDeviceMode); return hwDeviceModeMapper.selectHwDeviceModeJoinList(hwDeviceMode);
} }
/**
* @param: hwDeviceModeFunction
* @description
* @author xins
* @date 2023-10-10 11:19
* @return List<HwDeviceModeFunction>
*/
@Override
public List<HwDeviceModeFunction> selectHwDeviceModeFunctionList(HwDeviceModeFunction hwDeviceModeFunction) {
return hwDeviceModeFunctionMapper.selectHwDeviceModeFunctionList(hwDeviceModeFunction);
}
/** /**
* @param: hwDeviceModeFunction * @param: hwDeviceModeFunction
* @description * @description
@ -346,8 +359,9 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
* @date 2023-09-13 13:38 * @date 2023-09-13 13:38
*/ */
private void checkDuplicateIdentifiers(HwDeviceModeFunction hwDeviceModeFunction) { private void checkDuplicateIdentifiers(HwDeviceModeFunction hwDeviceModeFunction) {
if (hwDeviceModeFunction.getFunctionIdentifier().equalsIgnoreCase(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME)) { String functionIdentifier = hwDeviceModeFunction.getFunctionIdentifier();
throw new ServiceException("标识符不能等于:" + TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); if (TdEngineConstants.ABNDON_FUNCTION_IDENTIFIERS.contains(functionIdentifier)) {
throw new ServiceException("标识符不能等于:" + functionIdentifier);
} }
R<String> keyLongitudeR = remoteConfigService.getConfigKeyStr("hw.gps.longitude"); R<String> keyLongitudeR = remoteConfigService.getConfigKeyStr("hw.gps.longitude");
@ -419,7 +433,9 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
String functionMode = hwDeviceModeFunction.getFunctionMode(); String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equalsIgnoreCase(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) { if (functionMode.equalsIgnoreCase(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
schemaField = new TdField(); schemaField = new TdField();
schemaField.setFieldName(hwDeviceModeFunction.getFunctionIdentifier()); String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(hwDeviceModeFunction.getFunctionIdentifier());
String functionIdentifier = functionIdentifierTransfer == null ? hwDeviceModeFunction.getFunctionIdentifier() : functionIdentifierTransfer;
schemaField.setFieldName(functionIdentifier);
Long dataType = hwDeviceModeFunction.getDataType(); Long dataType = hwDeviceModeFunction.getDataType();
schemaField.setDataTypeCode(dataType.intValue()); schemaField.setDataTypeCode(dataType.intValue());
if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) { if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) {
@ -450,7 +466,9 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
String superTableName = TdEngineConstants.DEFAULT_SUPER_TABLE_NAME_PREFIX + deviceModeId; String superTableName = TdEngineConstants.DEFAULT_SUPER_TABLE_NAME_PREFIX + deviceModeId;
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo(); TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
TdField schemaField = new TdField(); TdField schemaField = new TdField();
schemaField.setFieldName(hwDeviceModeFunction.getFunctionIdentifier()); String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(hwDeviceModeFunction.getFunctionIdentifier());
String functionIdentifier = functionIdentifierTransfer == null ? hwDeviceModeFunction.getFunctionIdentifier() : functionIdentifierTransfer;
schemaField.setFieldName(functionIdentifier);
Long dataType = hwDeviceModeFunction.getDataType(); Long dataType = hwDeviceModeFunction.getDataType();
schemaField.setDataTypeCode(dataType.intValue()); schemaField.setDataTypeCode(dataType.intValue());
//一个integer类型一个long类型需要转换为string类型比较 //一个integer类型一个long类型需要转换为string类型比较

@ -20,6 +20,7 @@ import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils; import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.*; import com.ruoyi.tdengine.api.domain.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -172,7 +173,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
if (!redisUpdated) { if (!redisUpdated) {
JSONObject deviceInfoJson = new JSONObject(); JSONObject deviceInfoJson = new JSONObject();
deviceInfoJson.put("deviceCode", hwDevice.getDeviceCode()); deviceInfoJson.put("deviceCode", hwDevice.getDeviceCode());
deviceInfoJson.put("username", modeAccount); deviceInfoJson.put("userName", modeAccount);
deviceInfoJson.put("password", modeKey); deviceInfoJson.put("password", modeKey);
deviceInfoJsonArr.add(deviceInfoJson); deviceInfoJsonArr.add(deviceInfoJson);
} }
@ -335,7 +336,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH)) { if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH)) {
throw new ServiceException("已发布状态不能修改"); throw new ServiceException("已发布状态不能修改");
} }
hwDevice.setUpdateTime(DateUtils.getNowDate()); hwDevice.setUpdateBy(SecurityUtils.getUsername());
Date currentDate = new Date();
hwDevice.setUpdateTime(currentDate);
hwDevice.setPublishTime(currentDate);
return hwDeviceMapper.updateHwDevice(hwDevice); return hwDeviceMapper.updateHwDevice(hwDevice);
} }

@ -238,18 +238,17 @@ public class HwSceneServiceImpl implements IHwSceneService {
*/ */
@Override @Override
public List<HwScene> selectHwSceneList4Select(HwScene hwScene) { public List<HwScene> selectHwSceneList4Select(HwScene hwScene) {
LoginUser loginUser = SecurityUtils.getLoginUser(); Long tenantId = SecurityUtils.getTenantId();
SysUser user = loginUser.getSysUser();
//如果不是管理租户,需要过滤 //如果不是管理租户,需要过滤
if(!user.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)){ if(!tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)){
hwScene.setTenantId(user.getTenantId()); hwScene.setTenantId(tenantId);
} }
List<HwScene> scenes = hwSceneMapper.selectHwSceneList(hwScene); List<HwScene> scenes = hwSceneMapper.selectHwSceneList(hwScene);
//如果是管理员租户,则需要过滤不是自己的只能显示,不能选择 //如果是管理员租户,则需要过滤不是自己的只能显示,不能选择
if(user.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { if(tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) {
scenes.forEach(s -> { scenes.forEach(s -> {
if (!s.getTenantId().equals(user.getTenantId())) { if (!s.getTenantId().equals(tenantId)) {
s.setSelectedDisable("1"); s.setSelectedDisable("1");
} }
}); });

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="activeStatus" column="active_status" /> <result property="activeStatus" column="active_status" />
<result property="deviceStatus" column="device_status" /> <result property="deviceStatus" column="device_status" />
<result property="activeTime" column="active_time" /> <result property="activeTime" column="active_time" />
<result property="publishTime" column="publish_time" />
<result property="devicePic" column="device_pic" /> <result property="devicePic" column="device_pic" />
<result property="ipAddress" column="ip_address" /> <result property="ipAddress" column="ip_address" />
<result property="areaId" column="area_id" /> <result property="areaId" column="area_id" />
@ -198,6 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="activeStatus != null and activeStatus != ''">active_status = #{activeStatus},</if> <if test="activeStatus != null and activeStatus != ''">active_status = #{activeStatus},</if>
<if test="deviceStatus != null and deviceStatus != ''">device_status = #{deviceStatus},</if> <if test="deviceStatus != null and deviceStatus != ''">device_status = #{deviceStatus},</if>
<if test="activeTime != null">active_time = #{activeTime},</if> <if test="activeTime != null">active_time = #{activeTime},</if>
<if test="publishTime != null">publish_time = #{publishTime},</if>
<if test="devicePic != null">device_pic = #{devicePic},</if> <if test="devicePic != null">device_pic = #{devicePic},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if> <if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="areaId != null">area_id = #{areaId},</if> <if test="areaId != null">area_id = #{areaId},</if>
@ -252,7 +254,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwDeviceJoinList" parameterType="HwDevice" resultMap="HwDeviceResult"> <select id="selectHwDeviceJoinList" parameterType="HwDevice" resultMap="HwDeviceResult">
select hd.device_id,hd.device_code,hd.device_name,hd.device_type, 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.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 hs.scene_name,hmu.monitor_unit_name,hdmf.device_mode_name,ht.tenant_name
from hw_device hd from hw_device hd
left join hw_scene hs on hd.scene_id = hs.scene_id left join hw_scene hs on hd.scene_id = hs.scene_id

@ -295,7 +295,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwDeviceModeJoinList" parameterType="HwDeviceMode" resultMap="HwDeviceModeResult"> <select id="selectHwDeviceModeJoinList" parameterType="HwDeviceMode" resultMap="HwDeviceModeResult">
select hdm.device_mode_id,hdm.device_mode_name,hdm.gps_flag,hdm.mode_classfication, select hdm.device_mode_id,hdm.device_mode_name,hdm.gps_flag,hdm.mode_classfication,
hs.scene_name,ht.tenant_name,hdm.tenant_id,hdm.scene_id hs.scene_name,ht.tenant_name,hdm.tenant_id,hdm.scene_id,hdm.common_flag,hdm.device_mode_status,hdm.device_mode_pic
from hw_device_mode hdm from hw_device_mode hdm
left join hw_scene hs on hdm.scene_id = hs.scene_id left join hw_scene hs on hdm.scene_id = hs.scene_id
left join hw_tenant ht on hdm.tenant_id=ht.tenant_id left join hw_tenant ht on hdm.tenant_id=ht.tenant_id
@ -314,6 +314,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} ${params.tenantDataScope}
</where> </where>
order by hdm.device_mode_id desc
</select> </select>

@ -22,6 +22,7 @@
<result property="monitorUnitField" column="monitor_unit_field" /> <result property="monitorUnitField" column="monitor_unit_field" />
<result property="sceneName" column="scene_name" /> <result property="sceneName" column="scene_name" />
<result property="monitorUnitTypeName" column="monitor_unit_type_name" /> <result property="monitorUnitTypeName" column="monitor_unit_type_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" /> <result property="tenantName" column="tenant_name" />
</resultMap> </resultMap>
@ -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 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
</sql> </sql>
<sql id="selectHwMonitorUnitJoinScene">
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
</sql>
<select id="selectHaveEleDevice" parameterType="Long" resultMap="MonitorUnitNumVoResult"> <select id="selectHaveEleDevice" parameterType="Long" resultMap="MonitorUnitNumVoResult">
SELECT monitor_unit_id,count(*) as num from hw_device where monitor_unit_id SELECT monitor_unit_id,count(*) as num from hw_device where monitor_unit_id
@ -275,26 +269,10 @@
</foreach> </foreach>
</delete> </delete>
<select id="selectHwMonitorUnitListJoinScene" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitJoinScene"/>
<where>
hmu.monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
<if test="monitorUnitName != null and monitorUnitName != ''"> and monitor_unit_name like concat('%', #{monitorUnitName}, '%')</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="monitorUnitTypeId != null "> and monitor_unit_type_id = #{monitorUnitTypeId}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="monitorAddress != null and monitorAddress != ''"> and monitor_address = #{monitorAddress}</if>
<if test="monitorPic != null and monitorPic != ''"> and monitor_pic = #{monitorPic}</if>
<if test="preserveTime != null "> and preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and monitor_unit_status = #{monitorUnitStatus}</if>
<if test="monitorUnitField != null and monitorUnitField != ''"> and monitor_unit_field = #{monitorUnitField}</if>
</where>
</select>
<select id="selectHwMonitorUnitJoinList" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult"> <select id="selectHwMonitorUnitJoinList" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
select hmu.*,hmut.monitor_unit_type_name,ht.tenant_name,hs.scene_name 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,hmut.monitor_unit_type_name,ht.tenant_name,hs.scene_name from hw_monitor_unit hmu
left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id
left join hw_tenant ht on hmu.tenant_id = ht.tenant_id left join hw_tenant ht on hmu.tenant_id = ht.tenant_id
left join hw_scene hs on hmu.scene_id = hs.scene_id left join hw_scene hs on hmu.scene_id = hs.scene_id
@ -311,6 +289,7 @@
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} ${params.tenantDataScope}
</where> </where>
order by hmu.tenant_id,hmu.parent_id
</select> </select>

@ -20,11 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="unitTypeIcon" column="unit_type_icon" /> <result property="unitTypeIcon" column="unit_type_icon" />
<result property="unitTypeField" column="unit_type_field" /> <result property="unitTypeField" column="unit_type_field" />
<result property="sceneName" column="scene_name" /> <result property="sceneName" column="scene_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" /> <result property="tenantName" column="tenant_name" />
</resultMap> </resultMap>
<sql id="selectHwMonitorUnitTypeVo"> <sql id="selectHwMonitorUnitTypeVo">
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
</sql> </sql>
<select id="selectHwMonitorUnitTypeByMonitorUnitTypeId" parameterType="Long" resultMap="HwMonitorUnitTypeResult"> <select id="selectHwMonitorUnitTypeByMonitorUnitTypeId" parameterType="Long" resultMap="HwMonitorUnitTypeResult">
@ -132,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} ${params.tenantDataScope}
</where> </where>
order by hmut.monitor_unit_type_id desc
</select> </select>
</mapper> </mapper>

@ -129,21 +129,22 @@ public class MqttConfiguration {
@Override @Override
public void onMessage(ChannelContext channelContext, String topic, MqttPublishMessage mqttPublishMessage, ByteBuffer payload) { public void onMessage(ChannelContext channelContext, String topic, MqttPublishMessage mqttPublishMessage, ByteBuffer payload) {
String payloadString = new String(payload.array(), StandardCharsets.UTF_8); String payloadString = new String(payload.array(), StandardCharsets.UTF_8);
System.out.println("paa:" + topic); Long start = System.currentTimeMillis();
logger.info("topic:{} payload:{}", topic, payloadString); logger.info("topic:{},start:{}ms", topic, start);
try{ try {
if (topic.startsWith(dataTopicFilter.replace("#","")) && topic.endsWith(TOPIC_TYPE_DATA_POSTFIX)) { if (topic.startsWith(dataTopicFilter.replace("#", "")) && topic.endsWith(TOPIC_TYPE_DATA_POSTFIX)) {
dataProcessService.processBusinessData(payloadString, imagePath, imagePatterns,imageDomain,imagePrefix); 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)) { } else if (topic.equals(deviceStatusTopic)) {
deviceStatusService.handleDeviceStatus(payloadString,clientId); deviceStatusService.handleDeviceStatus(payloadString, clientId);
}else { } else {
dataProcessService.testBase64(payloadString,imagePath,imagePatterns,imageDomain,imagePrefix); dataProcessService.testBase64(payloadString, imagePath, imagePatterns, imageDomain, imagePrefix);
} }
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("Error processing business data:"+e.getMessage()); logger.error("Error processing business data:" + e.getMessage());
} }
} }
}); });

@ -12,7 +12,7 @@ public interface IDataProcessService {
* @author xins * @author xins
* @date 2023-08-31 16:16 * @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); String imagePatterns,String imageDomain,String imagePrefix);

@ -76,7 +76,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
* @date 2023-08-31 16:16 * @date 2023-08-31 16:16
*/ */
@Override @Override
public void processBusinessData(String jsonData, String imagePath, public int processBusinessData(String jsonData, String imagePath,
String imagePatterns,String imageDomain,String imagePrefix) { String imagePatterns,String imageDomain,String imagePrefix) {
JSONObject json = JSON.parseObject(jsonData); JSONObject json = JSON.parseObject(jsonData);
Long ts = json.getLong(TdEngineConstants.PAYLOAD_TS); Long ts = json.getLong(TdEngineConstants.PAYLOAD_TS);
@ -90,7 +90,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
for (int i = 0; i < paramArr.size(); i++) { for (int i = 0; i < paramArr.size(); i++) {
JSONObject paramJson = paramArr.getJSONObject(i); JSONObject paramJson = paramArr.getJSONObject(i);
JSONObject dataValueJson = paramJson.getJSONObject(TdEngineConstants.PAYLOAD_DATAVALUE); 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); HwDevice hwDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(deviceCode);
Long sceneId = hwDevice.getSceneId(); Long sceneId = hwDevice.getSceneId();
Long deviceId = hwDevice.getDeviceId(); Long deviceId = hwDevice.getDeviceId();
@ -182,6 +182,8 @@ public class DataProcessServiceImpl implements IDataProcessService {
checkElectronicFence(deviceId, tenantId, monitorUnitId, sceneId, longitude, latitude, ts); checkElectronicFence(deviceId, tenantId, monitorUnitId, sceneId, longitude, latitude, ts);
} }
} }
return paramArr.size();
} }
/** /**

@ -39,7 +39,7 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService {
// ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1, // ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1,
// "statusTime":1694506127199,"deviceCode":"hw-data-process-1"} // "statusTime":1694506127199,"deviceCode":"hw-data-process-1"}
JSONObject json = JSON.parseObject(payloadString); JSONObject json = JSON.parseObject(payloadString);
String deviceCode = json.getString("deviceCode"); String deviceCode = json.getString("deviceCode").toLowerCase();
if (clientId.equals(deviceCode)) { //校验是不是自己,如果是自己则不记录状态,返回即可。 if (clientId.equals(deviceCode)) { //校验是不是自己,如果是自己则不记录状态,返回即可。
return; return;
} }

@ -1,6 +1,11 @@
package com.ruoyi.system.controller; package com.ruoyi.system.controller;
import java.util.List; 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.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; 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.api.domain.SysDept;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
import javax.annotation.Resource;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@RestController @RestController
@RequestMapping("/dept") @RequestMapping("/dept")
public class SysDeptController extends BaseController public class SysDeptController extends BaseController {
{
@Autowired @Autowired
private ISysDeptService deptService; private ISysDeptService deptService;
@Resource
private RemoteBasicService remoteBasicService;
/** /**
* *
*/ */
@RequiresPermissions("system:dept:list") @RequiresPermissions("system:dept:list")
@GetMapping("/list") @GetMapping("/list")
public AjaxResult list(SysDept dept) public AjaxResult list(SysDept dept) {
{
List<SysDept> depts = deptService.selectDeptList(dept); List<SysDept> 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); return success(depts);
} }
@ -50,10 +66,12 @@ public class SysDeptController extends BaseController
* *
*/ */
@RequiresPermissions("system:dept:list") @RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}") @GetMapping("/list/exclude/{deptId}/{tenantId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId,
{ @PathVariable(value = "tenantId", required = false) Long tenantId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept()); SysDept dept = new SysDept();
dept.setTenantId(tenantId);
List<SysDept> depts = deptService.selectDeptList(dept);
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts); return success(depts);
} }
@ -63,8 +81,7 @@ public class SysDeptController extends BaseController
*/ */
@RequiresPermissions("system:dept:query") @RequiresPermissions("system:dept:query")
@GetMapping(value = "/{deptId}") @GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId) public AjaxResult getInfo(@PathVariable Long deptId) {
{
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId)); return success(deptService.selectDeptById(deptId));
} }
@ -75,12 +92,14 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:add") @RequiresPermissions("system:dept:add")
@Log(title = "部门管理", businessType = BusinessType.INSERT) @Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept) public AjaxResult add(@Validated @RequestBody SysDept dept) {
{ if (!deptService.checkDeptNameUnique(dept)) {
if (!deptService.checkDeptNameUnique(dept))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); 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()); dept.setCreateBy(SecurityUtils.getUsername());
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
} }
@ -91,20 +110,14 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:edit") @RequiresPermissions("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE) @Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept) public AjaxResult edit(@Validated @RequestBody SysDept dept) {
{
Long deptId = dept.getDeptId(); Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) if (!deptService.checkDeptNameUnique(dept)) {
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} } else if (dept.getParentId().equals(deptId)) {
else if (dept.getParentId().equals(deptId))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); 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("该部门包含未停用的子部门!"); return error("该部门包含未停用的子部门!");
} }
dept.setUpdateBy(SecurityUtils.getUsername()); dept.setUpdateBy(SecurityUtils.getUsername());
@ -117,17 +130,30 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:remove") @RequiresPermissions("system:dept:remove")
@Log(title = "部门管理", businessType = BusinessType.DELETE) @Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}") @DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId) public AjaxResult remove(@PathVariable Long deptId) {
{ if (deptService.hasChildByDeptId(deptId)) {
if (deptService.hasChildByDeptId(deptId))
{
return warn("存在下级部门,不允许删除"); return warn("存在下级部门,不允许删除");
} }
if (deptService.checkDeptExistUser(deptId)) if (deptService.checkDeptExistUser(deptId)) {
{
return warn("部门存在用户,不允许删除"); return warn("部门存在用户,不允许删除");
} }
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(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();
}
}
} }

@ -1,7 +1,13 @@
package com.ruoyi.system.controller; package com.ruoyi.system.controller;
import java.util.List; import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; 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.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
@ -35,6 +41,9 @@ public class SysPostController extends BaseController
@Autowired @Autowired
private ISysPostService postService; private ISysPostService postService;
@Resource
private RemoteBasicService remoteBasicService;
/** /**
* *
*/ */
@ -83,6 +92,10 @@ public class SysPostController extends BaseController
{ {
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); 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()); post.setCreateBy(SecurityUtils.getUsername());
return toAjax(postService.insertPost(post)); return toAjax(postService.insertPost(post));
} }
@ -127,4 +140,18 @@ public class SysPostController extends BaseController
List<SysPost> posts = postService.selectPostAll(); List<SysPost> posts = postService.selectPostAll();
return success(posts); 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();
}
}
} }

@ -2,6 +2,8 @@ package com.ruoyi.system.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.constant.HwDictConstants;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
@ -52,6 +54,14 @@ public class SysRoleController extends BaseController
{ {
startPage(); startPage();
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> 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); return getDataTable(list);
} }
@ -188,6 +198,7 @@ public class SysRoleController extends BaseController
public TableDataInfo unallocatedList(SysUser user) public TableDataInfo unallocatedList(SysUser user)
{ {
startPage(); startPage();
user.setTenantId(SecurityUtils.getTenantId());
List<SysUser> list = userService.selectUnallocatedList(user); List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list); return getDataTable(list);
} }

@ -211,11 +211,9 @@ public class SysUserController extends BaseController {
} }
user.setCreateBy(SecurityUtils.getUsername()); user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser loginSysUser = loginUser.getSysUser();
//如果不是admin的租户则就保存为登录用户的租户id如果是adimin则需要保存admin在创建时选择的租户ID //如果不是admin的租户则就保存为登录用户的租户id如果是adimin则需要保存admin在创建时选择的租户ID
if (!loginSysUser.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { if (!SecurityUtils.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) {
user.setTenantId(loginSysUser.getTenantId()); user.setTenantId(SecurityUtils.getTenantId());
} }
return toAjax(userService.insertUser(user)); return toAjax(userService.insertUser(user));
@ -314,7 +312,6 @@ public class SysUserController extends BaseController {
@GetMapping("/deptTree") @GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept) { public AjaxResult deptTree(SysDept dept) {
System.out.println("ddddd:" + dept.getTenantId());
return success(deptService.selectDeptTreeList(dept)); return success(deptService.selectDeptTreeList(dept));
} }
@ -324,9 +321,7 @@ public class SysUserController extends BaseController {
@RequiresPermissions("system:user:list") @RequiresPermissions("system:user:list")
@GetMapping("/getTenants") @GetMapping("/getTenants")
public AjaxResult getTenants() { public AjaxResult getTenants() {
LoginUser loginUser = SecurityUtils.getLoginUser(); Long tenantId = SecurityUtils.getTenantId();
SysUser user = loginUser.getSysUser();
Long tenantId = user.getTenantId();
if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) {
return success(remoteBasicService.getTenants().getData()); return success(remoteBasicService.getTenants().getData());
} else { } else {

@ -40,6 +40,7 @@ public class SysPost extends BaseEntity
private Long tenantId; private Long tenantId;
private String tenantName;
/** 用户是否存在此岗位标识 默认不存在 */ /** 用户是否存在此岗位标识 默认不存在 */
private boolean flag = false; private boolean flag = false;
@ -108,6 +109,14 @@ public class SysPost extends BaseEntity
this.tenantId = tenantId; this.tenantId = tenantId;
} }
public String getTenantName() {
return tenantName;
}
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
public boolean isFlag() public boolean isFlag()
{ {
return flag; return flag;

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.constant.UserConstants;
@ -23,12 +24,11 @@ import com.ruoyi.system.service.ISysDeptService;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Service @Service
public class SysDeptServiceImpl implements ISysDeptService public class SysDeptServiceImpl implements ISysDeptService {
{
@Autowired @Autowired
private SysDeptMapper deptMapper; private SysDeptMapper deptMapper;
@ -37,52 +37,46 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
* *
* @param dept * @param dept
* @return * @return
*/ */
@Override @Override
@DataScope(deptAlias = "d",tenantAlias = "d") @DataScope(deptAlias = "d", tenantAlias = "d")
public List<SysDept> selectDeptList(SysDept dept) public List<SysDept> selectDeptList(SysDept dept) {
{
return deptMapper.selectDeptList(dept); return deptMapper.selectDeptList(dept);
} }
/** /**
* *
* *
* @param dept * @param dept
* @return * @return
*/ */
@Override @Override
public List<TreeSelect> selectDeptTreeList(SysDept dept) public List<TreeSelect> selectDeptTreeList(SysDept dept) {
{
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts); return buildDeptTreeSelect(depts);
} }
/** /**
* *
* *
* @param depts * @param depts
* @return * @return
*/ */
@Override @Override
public List<SysDept> buildDeptTree(List<SysDept> depts) public List<SysDept> buildDeptTree(List<SysDept> depts) {
{
List<SysDept> returnList = new ArrayList<SysDept>(); List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()); List<Long> 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); recursionFn(depts, dept);
returnList.add(dept); returnList.add(dept);
} }
} }
if (returnList.isEmpty()) if (returnList.isEmpty()) {
{
returnList = depts; returnList = depts;
} }
return returnList; return returnList;
@ -90,93 +84,85 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
* *
* @param depts * @param depts
* @return * @return
*/ */
@Override @Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
{
List<SysDept> deptTrees = buildDeptTree(depts); List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
} }
/** /**
* ID * ID
* *
* @param roleId ID * @param roleId ID
* @return * @return
*/ */
@Override @Override
public List<Long> selectDeptListByRoleId(Long roleId) public List<Long> selectDeptListByRoleId(Long roleId) {
{
SysRole role = roleMapper.selectRoleById(roleId); SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
} }
/** /**
* ID * ID
* *
* @param deptId ID * @param deptId ID
* @return * @return
*/ */
@Override @Override
public SysDept selectDeptById(Long deptId) public SysDept selectDeptById(Long deptId) {
{
return deptMapper.selectDeptById(deptId); return deptMapper.selectDeptById(deptId);
} }
/** /**
* ID * ID
* *
* @param deptId ID * @param deptId ID
* @return * @return
*/ */
@Override @Override
public int selectNormalChildrenDeptById(Long deptId) public int selectNormalChildrenDeptById(Long deptId) {
{
return deptMapper.selectNormalChildrenDeptById(deptId); return deptMapper.selectNormalChildrenDeptById(deptId);
} }
/** /**
* *
* *
* @param deptId ID * @param deptId ID
* @return * @return
*/ */
@Override @Override
public boolean hasChildByDeptId(Long deptId) public boolean hasChildByDeptId(Long deptId) {
{
int result = deptMapper.hasChildByDeptId(deptId); int result = deptMapper.hasChildByDeptId(deptId);
return result > 0; return result > 0;
} }
/** /**
* *
* *
* @param deptId ID * @param deptId ID
* @return true false * @return true false
*/ */
@Override @Override
public boolean checkDeptExistUser(Long deptId) public boolean checkDeptExistUser(Long deptId) {
{
int result = deptMapper.checkDeptExistUser(deptId); int result = deptMapper.checkDeptExistUser(deptId);
return result > 0; return result > 0;
} }
/** /**
* *
* *
* @param dept * @param dept
* @return * @return
*/ */
@Override @Override
public boolean checkDeptNameUnique(SysDept dept) public boolean checkDeptNameUnique(SysDept dept) {
{
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); 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.NOT_UNIQUE;
} }
return UserConstants.UNIQUE; return UserConstants.UNIQUE;
@ -184,19 +170,16 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
* *
* @param deptId id * @param deptId id
*/ */
@Override @Override
public void checkDeptDataScope(Long deptId) public void checkDeptDataScope(Long deptId) {
{ if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
{
SysDept dept = new SysDept(); SysDept dept = new SysDept();
dept.setDeptId(deptId); dept.setDeptId(deptId);
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
if (StringUtils.isEmpty(depts)) if (StringUtils.isEmpty(depts)) {
{
throw new ServiceException("没有权限访问部门数据!"); throw new ServiceException("没有权限访问部门数据!");
} }
} }
@ -204,36 +187,38 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
* *
* @param dept * @param dept
* @return * @return
*/ */
@Override @Override
public int insertDept(SysDept dept) public int insertDept(SysDept dept) {
{ if (dept.getParentId() == null) {
SysDept info = deptMapper.selectDeptById(dept.getParentId()); dept.setParentId(0L);
// 如果父节点不为正常状态,则不允许新增子节点 dept.setAncestors("0");
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) } else {
{ SysDept info = deptMapper.selectDeptById(dept.getParentId());
throw new ServiceException("部门停用,不允许新增"); // 如果父节点不为正常状态,则不允许新增子节点
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); return deptMapper.insertDept(dept);
} }
/** /**
* *
* *
* @param dept * @param dept
* @return * @return
*/ */
@Override @Override
public int updateDept(SysDept dept) public int updateDept(SysDept dept) {
{
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); 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 newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors(); String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors); dept.setAncestors(newAncestors);
@ -241,8 +226,7 @@ public class SysDeptServiceImpl implements ISysDeptService
} }
int result = deptMapper.updateDept(dept); int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors())) && !StringUtils.equals("0", dept.getAncestors())) {
{
// 如果该部门是启用状态,则启用该部门的所有上级部门 // 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept); updateParentDeptStatusNormal(dept);
} }
@ -251,11 +235,10 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
* *
* @param dept * @param dept
*/ */
private void updateParentDeptStatusNormal(SysDept dept) private void updateParentDeptStatusNormal(SysDept dept) {
{
String ancestors = dept.getAncestors(); String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors); Long[] deptIds = Convert.toLongArray(ancestors);
deptMapper.updateDeptStatusNormal(deptIds); deptMapper.updateDeptStatusNormal(deptIds);
@ -263,48 +246,41 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
* *
* @param deptId ID * @param deptId ID
* @param newAncestors ID * @param newAncestors ID
* @param oldAncestors ID * @param oldAncestors ID
*/ */
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
{
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId); List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children) for (SysDept child : children) {
{
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
} }
if (children.size() > 0) if (children.size() > 0) {
{
deptMapper.updateDeptChildren(children); deptMapper.updateDeptChildren(children);
} }
} }
/** /**
* *
* *
* @param deptId ID * @param deptId ID
* @return * @return
*/ */
@Override @Override
public int deleteDeptById(Long deptId) public int deleteDeptById(Long deptId) {
{
return deptMapper.deleteDeptById(deptId); return deptMapper.deleteDeptById(deptId);
} }
/** /**
* *
*/ */
private void recursionFn(List<SysDept> list, SysDept t) private void recursionFn(List<SysDept> list, SysDept t) {
{
// 得到子节点列表 // 得到子节点列表
List<SysDept> childList = getChildList(list, t); List<SysDept> childList = getChildList(list, t);
t.setChildren(childList); t.setChildren(childList);
for (SysDept tChild : childList) for (SysDept tChild : childList) {
{ if (hasChild(list, tChild)) {
if (hasChild(list, tChild))
{
recursionFn(list, tChild); recursionFn(list, tChild);
} }
} }
@ -313,15 +289,12 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
*/ */
private List<SysDept> getChildList(List<SysDept> list, SysDept t) private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
{
List<SysDept> tlist = new ArrayList<SysDept>(); List<SysDept> tlist = new ArrayList<SysDept>();
Iterator<SysDept> it = list.iterator(); Iterator<SysDept> it = list.iterator();
while (it.hasNext()) while (it.hasNext()) {
{
SysDept n = (SysDept) it.next(); 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); tlist.add(n);
} }
} }
@ -331,8 +304,7 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* *
*/ */
private boolean hasChild(List<SysDept> list, SysDept t) private boolean hasChild(List<SysDept> list, SysDept t) {
{
return getChildList(list, t).size() > 0 ? true : false; return getChildList(list, t).size() > 0 ? true : false;
} }
} }

@ -34,6 +34,7 @@ public class SysPostServiceImpl implements ISysPostService
* @return * @return
*/ */
@Override @Override
@DataScope(tenantAlias = "p")
public List<SysPost> selectPostList(SysPost post) public List<SysPost> selectPostList(SysPost post)
{ {
return postMapper.selectPostList(post); return postMapper.selectPostList(post);

@ -92,7 +92,7 @@ public class SysUserServiceImpl implements ISysUserService {
* @return * @return
*/ */
@Override @Override
@DataScope(deptAlias = "d", userAlias = "u") @DataScope(deptAlias = "d", userAlias = "u",tenantAlias = "u")
public List<SysUser> selectUnallocatedList(SysUser user) { public List<SysUser> selectUnallocatedList(SysUser user) {
return userMapper.selectUnallocatedList(user); return userMapper.selectUnallocatedList(user);
} }

@ -20,30 +20,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
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 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 from sys_dept d left join hw_tenant ht on d.tenant_id=ht.tenant_id
</sql> </sql>
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where d.del_flag = '0' where d.del_flag = '0'
<if test="deptId != null and deptId != 0"> <if test="deptId != null and deptId != 0">
AND dept_id = #{deptId} AND d.dept_id = #{deptId}
</if> </if>
<if test="parentId != null and parentId != 0"> <if test="parentId != null and parentId != 0">
AND parent_id = #{parentId} AND d.parent_id = #{parentId}
</if> </if>
<if test="deptName != null and deptName != ''"> <if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%') AND d.dept_name like concat('%', #{deptName}, '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND d.status = #{status}
</if> </if>
<if test="tenantId != null"> <if test="tenantId != null and tenantId!=0">
AND tenant_id = #{tenantId} AND d.tenant_id = #{tenantId}
</if> </if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
@ -102,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">email,</if> <if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="tenantId != null and tenantId != 0">tenant_id,</if>
create_time create_time
)values( )values(
<if test="deptId != null and deptId != 0">#{deptId},</if> <if test="deptId != null and deptId != 0">#{deptId},</if>
@ -114,6 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">#{email},</if> <if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="tenantId != null and tenantId != 0">#{tenantId},</if>
sysdate() sysdate()
) )
</insert> </insert>

@ -15,32 +15,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
</resultMap> </resultMap>
<sql id="selectPostVo"> <sql id="selectPostVo">
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark select p.post_id, p.post_code, p.post_name, p.post_sort, p.status, p.create_by, p.create_time, p.remark,p.tenant_id,ht.tenant_name
from sys_post p from sys_post p left join hw_tenant ht on p.tenant_id=ht.tenant_id
</sql> </sql>
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult"> <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
<where> <where>
<if test="postCode != null and postCode != ''"> <if test="postCode != null and postCode != ''">
AND post_code like concat('%', #{postCode}, '%') AND p.post_code like concat('%', #{postCode}, '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND p.status = #{status}
</if> </if>
<if test="postName != null and postName != ''"> <if test="postName != null and postName != ''">
AND post_name like concat('%', #{postName}, '%') AND p.post_name like concat('%', #{postName}, '%')
</if> </if>
<if test="tenantId != null"> <if test="tenantId != null and tenantId!=0">
AND tenant_id = #{tenantId} AND p.tenant_id = #{tenantId}
</if> </if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} ${params.tenantDataScope}
</where> </where>
order by p.tenant_id,p.post_sort
</select> </select>
<select id="selectPostAll" resultMap="SysPostResult"> <select id="selectPostAll" resultMap="SysPostResult">
@ -102,7 +104,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
create_time <if test="tenantId != null and tenantId != 0">tenant_id,</if>
create_time
)values( )values(
<if test="postId != null and postId != 0">#{postId},</if> <if test="postId != null and postId != 0">#{postId},</if>
<if test="postCode != null and postCode != ''">#{postCode},</if> <if test="postCode != null and postCode != ''">#{postCode},</if>
@ -111,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="tenantId != null and tenantId != 0">#{tenantId},</if>
sysdate() sysdate()
) )
</insert> </insert>

@ -19,16 +19,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="tenantId" column="tenant_id" /> <result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
</resultMap> </resultMap>
<sql id="selectRoleVo"> <sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark,r.tenant_id r.status, r.del_flag, r.create_time, r.remark,r.tenant_id,ht.tenant_name
from sys_role r from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id left join sys_user u on u.user_id = ur.user_id
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
left join hw_tenant ht on r.tenant_id = ht.tenant_id
</sql> </sql>
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult"> <select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
@ -59,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope} ${params.dataScope}
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} ${params.tenantDataScope}
order by r.role_sort order by r.tenant_id,r.role_sort
</select> </select>
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult"> <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">

@ -118,7 +118,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_role r on r.role_id = ur.role_id left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL) where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId}) and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
<if test="userName != null and userName != ''"> <if test="tenantId==1 and roleId!=3">
and exists (select 1 from sys_role sr where sr.role_id=#{roleId} and sr.tenant_id=u.tenant_id)
</if>
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%') AND u.user_name like concat('%', #{userName}, '%')
</if> </if>
<if test="phonenumber != null and phonenumber != ''"> <if test="phonenumber != null and phonenumber != ''">

@ -10,9 +10,9 @@ export function listDept(query) {
} }
// 查询部门列表(排除节点) // 查询部门列表(排除节点)
export function listDeptExcludeChild(deptId) { export function listDeptExcludeChild(deptId, tenantId) {
return request({ return request({
url: '/system/dept/list/exclude/' + deptId, url: '/system/dept/list/exclude/' + deptId + '/' + tenantId,
method: 'get' method: 'get'
}) })
} }
@ -49,4 +49,12 @@ export function delDept(deptId) {
url: '/system/dept/' + deptId, url: '/system/dept/' + deptId,
method: 'delete' method: 'delete'
}) })
} }
// 查询租户列表
export function getTenants() {
return request({
url: '/system/post/getTenants',
method: 'get'
})
}

@ -42,3 +42,11 @@ export function delPost(postId) {
method: 'delete' method: 'delete'
}) })
} }
// 查询租户列表
export function getTenants() {
return request({
url: '/system/post/getTenants',
method: 'get'
})
}

@ -136,7 +136,7 @@ export function deptTreeSelect(query) {
} }
// 查询用户详细 // 查询租户列表
export function getTenants() { export function getTenants() {
return request({ return request({
url: '/system/user/getTenants', url: '/system/user/getTenants',

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

@ -39,7 +39,7 @@
</el-form-item> </el-form-item>
<el-form-item label="监控单元" prop="monitorUnitId"> <el-form-item label="监控单元" prop="monitorUnitId">
<treeselect v-model="queryParams.monitorUnitId" :options="editedMonitorUnits" :show-count="true" <treeselect v-model="queryParams.monitorUnitId" :options="monitorUnits" :show-count="true"
placeholder="请选择所属监控单元" :normalizer="normalizer" :flat="true" clearable style="width: 200px;"/> placeholder="请选择所属监控单元" :normalizer="normalizer" :flat="true" clearable style="width: 200px;"/>
</el-form-item> </el-form-item>
@ -47,7 +47,7 @@
<el-form-item label="设备模型" prop="deviceModeId"> <el-form-item label="设备模型" prop="deviceModeId">
<el-select v-model="queryParams.deviceModeId" placeholder="请选择" clearable> <el-select v-model="queryParams.deviceModeId" placeholder="请选择" clearable>
<el-option <el-option
v-for="(editedDeviceMode, index) in editedDeviceModes" v-for="(editedDeviceMode, index) in deviceModes"
:key="index" :key="index"
:label="editedDeviceMode.deviceModeName" :label="editedDeviceMode.deviceModeName"
:value="editedDeviceMode.deviceModeId" :value="editedDeviceMode.deviceModeId"
@ -131,11 +131,11 @@
<dict-tag :options="dict.type.hw_device_active_status" :value="scope.row.activeStatus"/> <dict-tag :options="dict.type.hw_device_active_status" :value="scope.row.activeStatus"/>
</template> </template>
</el-table-column--> </el-table-column-->
<!--el-table-column label="设备激活时间" align="center" prop="activeTime" width="180"> <el-table-column label="设备发布时间" align="center" prop="publishTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.activeTime, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column--> </el-table-column>
<el-table-column label="设备状态" align="center" prop="deviceStatus"> <el-table-column label="设备状态" align="center" prop="deviceStatus">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -224,7 +224,7 @@
<el-form-item label="设备名称" prop="deviceName"> <el-form-item label="设备名称" prop="deviceName">
<el-input v-model="form.deviceName" placeholder="请输入设备名称"/> <el-input v-model="form.deviceName" placeholder="请输入设备名称"/>
</el-form-item> </el-form-item>
<el-form-item label="设备类型" prop="networkingMode"> <el-form-item label="设备类型" prop="deviceType">
<el-select v-model="form.deviceType" placeholder="请选择设备类型" @input="deviceTypeChange" :disabled="deviceTypeDisabled"> <el-select v-model="form.deviceType" placeholder="请选择设备类型" @input="deviceTypeChange" :disabled="deviceTypeDisabled">
<el-option <el-option
v-for="dict in dict.type.hw_device_type" v-for="dict in dict.type.hw_device_type"
@ -236,7 +236,7 @@
</el-form-item> </el-form-item>
<el-form-item label="所属场景" prop="sceneId"> <el-form-item label="所属场景" prop="sceneId">
<el-select v-model="form.sceneId" placeholder="请选择" @input="sceneChange" :disabled="sceneDisabled"> <el-select v-model="form.sceneId" placeholder="请选择" @input="editedSceneChange" :disabled="sceneDisabled">
<el-option <el-option
v-for="(scene, index) in editedScenes" v-for="(scene, index) in editedScenes"
:key="index" :key="index"
@ -427,10 +427,15 @@ export default {
deviceList: [], deviceList: [],
// //
scenes: [], scenes: [],
//
monitorUnits: [],
//
deviceModes: [],
// //
editedScenes:[], editedScenes:[],
// //
editedMonitorUnits: undefined, editedMonitorUnits: [],
// //
editedDeviceModes: [], editedDeviceModes: [],
// //
@ -492,8 +497,8 @@ export default {
deviceCode: [ deviceCode: [
{required: true, message: "设备编号不能为空", trigger: "blur"}, {required: true, message: "设备编号不能为空", trigger: "blur"},
{ {
pattern: /^[a-z][a-z0-9_]+$/, pattern: /^[a-z0-9_]+$/,
message: "2-20个字符由小写字母、数字或下划线组成,开头必须为小写字母", message: "2-20个字符由小写字母、数字或下划线组成",
trigger: "blur" trigger: "blur"
} }
], ],
@ -509,6 +514,22 @@ export default {
monitorUnitId: [ monitorUnitId: [
{required: true, message: "监控单元不能为空", trigger: "change"} {required: true, message: "监控单元不能为空", trigger: "change"}
], ],
releatedDeviceId: [
{required: true, message: "关联网关不能为空", trigger: "change"}
],
deviceModeId: [
{required: true, message: "设备模型不能为空", trigger: "change"}
],
networkingMode: [
{required: true, message: "联网方式不能为空", trigger: "change"}
],
accessProtocol: [
{required: true, message: "接入协议不能为空", trigger: "change"}
],
dataFormat: [
{required: true, message: "数据格式不能为空", trigger: "change"}
],
}, },
number: 0, number: 0,
uploadList: [], uploadList: [],
@ -595,6 +616,7 @@ export default {
onlineStatus: null onlineStatus: null
}; };
this.resetForm("form"); this.resetForm("form");
this.fileList = [];
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -621,7 +643,6 @@ export default {
this.sceneDisabled = false; this.sceneDisabled = false;
this.deviceModeDisabled = false; this.deviceModeDisabled = false;
this.confirmBtnVisible = true; this.confirmBtnVisible = true;
this.fileList = [];
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加设备信息"; this.title = "添加设备信息";
@ -636,7 +657,6 @@ export default {
this.deviceTypeDisabled = true; this.deviceTypeDisabled = true;
this.sceneDisabled = true; this.sceneDisabled = true;
this.reset(); this.reset();
this.fileList = [];
const deviceId = row.deviceId || this.ids const deviceId = row.deviceId || this.ids
getDevice(deviceId).then(response => { getDevice(deviceId).then(response => {
if(response.data.deviceStatus===this.DEVICE_STATUS_PUBLISHED){ if(response.data.deviceStatus===this.DEVICE_STATUS_PUBLISHED){
@ -831,6 +851,18 @@ export default {
return strs != '' ? strs.substr(0, strs.length - 1) : ''; return strs != '' ? strs.substr(0, strs.length - 1) : '';
}, },
getMonitorTree(sceneId) {
getMonitorTree(sceneId).then(response => {
this.monitorUnits = response.data;
});
},
getDeviceModes(sceneId) {
getDeviceModes(sceneId).then(response => {
this.deviceModes = response.data;
});
},
getEditedMonitorTree(sceneId) { getEditedMonitorTree(sceneId) {
getMonitorTree(sceneId).then(response => { getMonitorTree(sceneId).then(response => {
this.editedMonitorUnits = response.data; this.editedMonitorUnits = response.data;
@ -850,10 +882,19 @@ export default {
}, },
sceneChange(sceneId) { sceneChange(sceneId) {
this.form.monitorUnitId = null;
this.queryParams.monitorUnitId = null; this.queryParams.monitorUnitId = null;
this.form.deivceModeId = null;
this.queryParams.deviceModeId = null; this.queryParams.deviceModeId = null;
this.getMonitorTree(sceneId);
this.getDeviceModes(sceneId);
},
editedSceneChange(sceneId) {
this.editedMonitorUnits = [];
this.editedDeviceModes = [];
this.editedGatewayDevices = [];
this.form.monitorUnitId = null;
this.form.deviceModeId = null;
this.form.releatedDeviceId = null;
this.getEditedMonitorTree(sceneId); this.getEditedMonitorTree(sceneId);
this.getEditedDeviceModes(sceneId); this.getEditedDeviceModes(sceneId);
this.getGatewayDevices(sceneId); this.getGatewayDevices(sceneId);

@ -263,7 +263,7 @@ export default {
inputParameterRules: { inputParameterRules: {
parameterName: [ parameterName: [
{required: true, message: "请输入功能名称", trigger: "blur"} {required: true, message: "请输入参数名称", trigger: "blur"}
], ],
parameterIdentifier: [ parameterIdentifier: [
{required: true, message: "请输入标识符", trigger: "blur"}, {required: true, message: "请输入标识符", trigger: "blur"},

@ -318,7 +318,7 @@ export default {
inputParameterRules: { inputParameterRules: {
parameterName: [ parameterName: [
{required: true, message: "请输入功能名称", trigger: "blur"} {required: true, message: "请输入参数名称", trigger: "blur"}
], ],
parameterIdentifier: [ parameterIdentifier: [
{required: true, message: "请输入标识符", trigger: "blur"}, {required: true, message: "请输入标识符", trigger: "blur"},
@ -504,7 +504,6 @@ export default {
convertParameterDefinition(row) { convertParameterDefinition(row) {
if (parseInt(row.dataType) === 8) { if (parseInt(row.dataType) === 8) {
let dataDefinitionJson = JSON.parse(row.dataDefinition) let dataDefinitionJson = JSON.parse(row.dataDefinition)
alert(row.dataDefinition)
row.boolFalse = dataDefinitionJson["0"]; row.boolFalse = dataDefinitionJson["0"];
row.boolTrue = dataDefinitionJson["1"]; row.boolTrue = dataDefinitionJson["1"];
} }

@ -431,7 +431,15 @@ export default {
trigger: "blur" trigger: "blur"
} }
], ],
dataType: [
{required: true, message: "请选择数据类型", trigger: "change"}
],
displayFlag: [
{required: true, message: "请选择显示标识", trigger: "change"}
],
rwFlag: [
{required: true, message: "请选择读写标识", trigger: "change"}
],
}, },
// name // name
activeName: "attributesInfo", activeName: "attributesInfo",

@ -10,7 +10,7 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属场景" prop="sceneId"> <el-form-item label="所属场景" prop="sceneId">
<el-select v-model="queryParams.sceneId" placeholder="请选择" @input="sceneChange"> <el-select v-model="queryParams.sceneId" placeholder="请选择所属场景">
<el-option <el-option
v-for="(scene, index) in scenes" v-for="(scene, index) in scenes"
:key="index" :key="index"
@ -21,7 +21,7 @@
</el-form-item> </el-form-item>
<el-form-item label="定位标识" prop="gpsFlag"> <el-form-item label="定位标识" prop="gpsFlag">
<el-select v-model="queryParams.gpsFlag" placeholder="请选择" clearable> <el-select v-model="queryParams.gpsFlag" placeholder="请选择定位标识" clearable>
<el-option <el-option
v-for="dict in dict.type.hw_device_mode_gps_flag" v-for="dict in dict.type.hw_device_mode_gps_flag"
:key="dict.value" :key="dict.value"
@ -31,7 +31,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="模型分类" prop="modeClassfication"> <el-form-item label="模型分类" prop="modeClassfication">
<el-select v-model="queryParams.modeClassfication" placeholder="请选择" clearable> <el-select v-model="queryParams.modeClassfication" placeholder="请选择模型分类" clearable>
<el-option <el-option
v-for="dict in dict.type.hw_mode_function_mode_classfication" v-for="dict in dict.type.hw_mode_function_mode_classfication"
:key="dict.value" :key="dict.value"
@ -86,6 +86,7 @@
</el-row> </el-row>
<el-table v-loading="loading" :data="deviceModeList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="deviceModeList" @selection-change="handleSelectionChange">
<el-table-column label="模型ID" align="center" prop="deviceModeId"/>
<el-table-column label="模型名称" align="center" prop="deviceModeName"/> <el-table-column label="模型名称" align="center" prop="deviceModeName"/>
<el-table-column label="所属租户" align="center" prop="tenantName"/> <el-table-column label="所属租户" align="center" prop="tenantName"/>
<el-table-column label="所属场景" align="center" prop="sceneName"/> <el-table-column label="所属场景" align="center" prop="sceneName"/>
@ -329,9 +330,8 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const deviceModeName = row.deviceModeName;
const deviceModeIds = row.deviceModeId || this.ids; const deviceModeIds = row.deviceModeId || this.ids;
this.$modal.confirm('是否确认删除设备模型名称为"' + deviceModeName + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除设备模型ID为"' + deviceModeIds + '"的数据项?').then(function () {
return delDeviceMode(deviceModeIds); return delDeviceMode(deviceModeIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
@ -388,6 +388,9 @@ export default {
this.download('business/deviceMode/export', { this.download('business/deviceMode/export', {
...this.queryParams ...this.queryParams
}, `deviceMode_${new Date().getTime()}.xlsx`) }, `deviceMode_${new Date().getTime()}.xlsx`)
this.download('business/deviceMode/exportFunction', {
}, `deviceModeFunction_${new Date().getTime()}.xlsx`)
} }
} }
}; };

@ -66,7 +66,7 @@
<el-table v-loading="loading" :data="electronicFenceList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="electronicFenceList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="电子围栏编号" align="center" prop="electronicFenceId" /> <el-table-column label="电子围栏ID" align="center" prop="electronicFenceId" />
<el-table-column label="电子围栏名称" align="center" prop="electronicFenceName" /> <el-table-column label="电子围栏名称" align="center" prop="electronicFenceName" />
<el-table-column label="所属场景" align="center" prop="sceneName" /> <el-table-column label="所属场景" align="center" prop="sceneName" />
<el-table-column label="规则类型" align="center" prop="fenceType" > <el-table-column label="规则类型" align="center" prop="fenceType" >
@ -252,7 +252,7 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const electronicFenceIds = row.electronicFenceId || this.ids; const electronicFenceIds = row.electronicFenceId || this.ids;
this.$modal.confirm('是否确认删除电子围栏编号为"' + electronicFenceIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除电子围栏ID为"' + electronicFenceIds + '"的数据项?').then(function() {
return delElectronicFence(electronicFenceIds); return delElectronicFence(electronicFenceIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();

@ -70,8 +70,9 @@
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
<el-table-column label="监控单元编号" prop="monitorUnitId"/> <el-table-column label="监控单元ID" prop="monitorUnitId"/>
<el-table-column label="监控单元名称" prop="monitorUnitName"/> <el-table-column label="监控单元名称" prop="monitorUnitName"/>
<el-table-column label="所属租户" align="center" prop="tenantName"/>
<el-table-column label="所属场景" align="center" prop="sceneName"/> <el-table-column label="所属场景" align="center" prop="sceneName"/>
<el-table-column label="监控单元类型" align="center" prop="monitorUnitTypeName"/> <el-table-column label="监控单元类型" align="center" prop="monitorUnitTypeName"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@ -124,7 +125,7 @@
</el-form-item> </el-form-item>
<el-form-item label="父级监控单元" prop="parentId"> <el-form-item label="父级监控单元" prop="parentId">
<treeselect v-model="form.parentId" :options="monitorUnitOptions" :normalizer="normalizer" <treeselect v-model="form.parentId" :options="monitorUnitOptions" :normalizer="normalizer"
placeholder="请选择父级监控单元ID"/> placeholder="请选择父级监控单元"/>
</el-form-item> </el-form-item>
<el-form-item label="监控单元类型" prop="monitorUnitTypeId"> <el-form-item label="监控单元类型" prop="monitorUnitTypeId">
<el-select v-model="form.monitorUnitTypeId" placeholder="请选择"> <el-select v-model="form.monitorUnitTypeId" placeholder="请选择">
@ -328,6 +329,8 @@ export default {
editedSceneChange(sceneId) { editedSceneChange(sceneId) {
this.form.monitorUnitTypeId = null; this.form.monitorUnitTypeId = null;
this.editedMonitorUnitTypes = [];
this.monitorUnitOptions = [];
this.getEditedMonitorUnitTypes(sceneId); this.getEditedMonitorUnitTypes(sceneId);
this.getTreeselect(sceneId); this.getTreeselect(sceneId);
}, },
@ -402,6 +405,7 @@ export default {
this.resetForm("form"); this.resetForm("form");
this.editedScenes = []; this.editedScenes = [];
this.editedMonitorUnitTypes = []; this.editedMonitorUnitTypes = [];
this.fileList = [];
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -478,7 +482,7 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$modal.confirm('是否确认删除监控单元编号为"' + row.monitorUnitId + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除监控单元ID为"' + row.monitorUnitId + '"的数据项?').then(function () {
return delMonitorUnit(row.monitorUnitId); return delMonitorUnit(row.monitorUnitId);
}).then(() => { }).then(() => {
this.getList(); this.getList();

@ -74,13 +74,14 @@
<el-table v-loading="loading" :data="monitorUnitTypeList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="monitorUnitTypeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="monitorUnitTypeId" /> <el-table-column label="类型ID" align="center" prop="monitorUnitTypeId" />
<el-table-column label="类型名称" align="center" prop="monitorUnitTypeName" /> <el-table-column label="类型名称" align="center" prop="monitorUnitTypeName" />
<el-table-column label="虚拟标识" align="center" prop="vitualFlag" > <el-table-column label="虚拟标识" align="center" prop="vitualFlag" >
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.hw_unit_type_vitual_flag" :value="scope.row.vitualFlag"/> <dict-tag :options="dict.type.hw_unit_type_vitual_flag" :value="scope.row.vitualFlag"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="所属租户" align="center" prop="tenantName" />
<el-table-column label="所属场景" align="center" prop="sceneName" /> <el-table-column label="所属场景" align="center" prop="sceneName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
@ -320,7 +321,7 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const monitorUnitTypeIds = row.monitorUnitTypeId || this.ids; const monitorUnitTypeIds = row.monitorUnitTypeId || this.ids;
this.$modal.confirm('是否确认删除监控单元类型编号为"' + monitorUnitTypeIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除监控单元类型ID为"' + monitorUnitTypeIds + '"的数据项?').then(function() {
return delMonitorUnitType(monitorUnitTypeIds); return delMonitorUnitType(monitorUnitTypeIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();

@ -97,6 +97,7 @@
>导出 >导出
</el-button> </el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -183,7 +184,7 @@
</el-form-item> </el-form-item>
<el-form-item label="认证方式" prop="authMode"> <el-form-item label="认证方式" prop="authMode">
<el-select v-model="form.authMode" placeholder="请选择认证方式"> <el-select v-model="form.authMode" placeholder="请选择认证方式" :disabled="editedDisable">
<el-option <el-option
v-for="dict in dict.type.hw_scene_auth_mode" v-for="dict in dict.type.hw_scene_auth_mode"
:key="dict.value" :key="dict.value"
@ -200,57 +201,58 @@
</el-form-item> </el-form-item>
<el-form-item label="保存周期(天)" prop="preserveTime"> <el-form-item label="保存周期(天)" prop="preserveTime">
<el-input-number v-model="form.preserveTime" placeholder="请输入保存周期(单位默认90天" :min="1" :max="9999" <el-input-number v-model="form.preserveTime" placeholder="请输入保存周期(单位默认90天" :min="1"
:max="9999"
style="width:150px;"/> style="width:150px;"/>
</el-form-item> </el-form-item>
<el-form-item label="场景描述" prop="remark"> <el-form-item label="场景描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item> </el-form-item>
<el-form-item label="场景图片" prop="scenePic"> <el-form-item label="场景图片" prop="scenePic">
<el-upload <el-upload
single single
:action="uploadImgUrl" :action="uploadImgUrl"
list-type="picture-card" list-type="picture-card"
:limit="limit" :limit="limit"
:on-success="handleUploadSuccess" :on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload" :before-upload="handleBeforeUpload"
:on-error="handleUploadError" :on-error="handleUploadError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
ref="imageUpload" ref="imageUpload"
:on-remove="handleDeletePicture" :on-remove="handleDeletePicture"
:show-file-list="true" :show-file-list="true"
:headers="headers" :headers="headers"
:file-list="fileList" :file-list="fileList"
:on-preview="handlePictureCardPreview" :on-preview="handlePictureCardPreview"
:class="{hide: this.fileList.length >= 1}" :class="{hide: this.fileList.length >= 1}"
> >
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</el-upload> </el-upload>
<!-- 上传提示 --> <!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip"> <div class="el-upload__tip" slot="tip" v-if="showTip">
请上传 请上传
<template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b></template> <template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b></template>
<template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template> <template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
的文件 的文件
</div> </div>
<el-dialog <el-dialog
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
title="预览" title="预览"
width="800" width="800"
append-to-body append-to-body
> >
<img <img
:src="dialogImageUrl" :src="dialogImageUrl"
style="display: block; max-width: 100%; margin: 0 auto" style="display: block; max-width: 100%; margin: 0 auto"
/> />
</el-dialog> </el-dialog>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm" :disabled="confirmDisabled"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -309,8 +311,8 @@ export default {
open: false, open: false,
sceneModes: [], sceneModes: [],
tenants: [], tenants: [],
editedDisable:true, editedDisable: true,
confirmDisabled: false,
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -334,17 +336,20 @@ export default {
form: {}, form: {},
// //
rules: { rules: {
tenantId: [
{required: true, message: "所属租户不能为空", trigger: "change"}
],
sceneName: [ sceneName: [
{required: true, message: "场景名称不能为空", trigger: "blur"} {required: true, message: "场景名称不能为空", trigger: "blur"}
], ],
sceneModeId: [ sceneModeId: [
{required: true, message: "场景类型不能为空", trigger: "blur"} {required: true, message: "场景类型不能为空", trigger: "change"}
], ],
defaultFlag: [ defaultFlag: [
{required: true, message: "默认标识不能为空", trigger: "blur"} {required: true, message: "默认标识不能为空", trigger: "change"}
], ],
authMode: [ authMode: [
{required: true, message: "认证方式不能为空", trigger: "blur"} {required: true, message: "认证方式不能为空", trigger: "change"}
], ],
preserveTime: [ preserveTime: [
{required: true, message: "保存周期不能为空", trigger: "blur"} {required: true, message: "保存周期不能为空", trigger: "blur"}
@ -419,6 +424,7 @@ export default {
sceneField: null sceneField: null
}; };
this.resetForm("form"); this.resetForm("form");
this.fileList = [];
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -440,6 +446,7 @@ export default {
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.editedDisable = false; this.editedDisable = false;
this.confirmDisabled = false;
this.open = true; this.open = true;
this.title = "添加场景信息"; this.title = "添加场景信息";
}, },
@ -447,8 +454,8 @@ export default {
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
this.editedDisable = true; this.editedDisable = true;
this.confirmDisabled = false;
const sceneId = row.sceneId || this.ids const sceneId = row.sceneId || this.ids
this.fileList = [];
getScene(sceneId).then(response => { getScene(sceneId).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
@ -463,6 +470,7 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.confirmDisabled = true;
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.sceneId != null) { if (this.form.sceneId != null) {
@ -470,14 +478,20 @@ export default {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}).catch(() => {
this.confirmDisabled = false;
}); });
} else { } else {
addScene(this.form).then(response => { addScene(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}).catch(() => {
this.confirmDisabled = false;
}); });
} }
} else {
this.confirmDisabled = false;
} }
}); });
}, },

@ -11,16 +11,28 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="租户类型" prop="tenantType"> <el-form-item label="租户类型" prop="tenantType">
<el-select v-model="queryParams.tenantType" placeholder="租户类型" clearable> <el-select v-model="queryParams.tenantType" placeholder="请选择租户类型" clearable>
<el-option <el-option
v-for="dict in dict.type.hw_tenant_type" v-for="dict in dict.type.hw_tenant_type"
:key ="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value"> :value="dict.value">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="租户行业" prop="tenantIndustry">
<el-select v-model="queryParams.tenantIndustry" placeholder="请选择租户行业" clearable>
<el-option
v-for="dict in dict.type.hw_tenant_industry"
:key="dict.value"
:label="dict.label"
:value="dict.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="联系人姓名" prop="contactName"> <el-form-item label="联系人姓名" prop="contactName">
<el-input <el-input
v-model="queryParams.contactName" v-model="queryParams.contactName"
@ -53,7 +65,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['business:tenant:add']" v-hasPermi="['business:tenant:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -64,7 +77,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['business:tenant:edit']" v-hasPermi="['business:tenant:edit']"
>修改</el-button> >修改
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -75,7 +89,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['business:tenant:remove']" v-hasPermi="['business:tenant:remove']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -85,15 +100,16 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['business:tenant:export']" v-hasPermi="['business:tenant:export']"
>导出</el-button> >导出
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="tenantList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="tenantList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center"/>
<el-table-column label="租户ID" align="center" prop="tenantId" /> <el-table-column label="租户ID" align="center" prop="tenantId"/>
<el-table-column label="租户名称" align="center" prop="tenantName" /> <el-table-column label="租户名称" align="center" prop="tenantName"/>
<el-table-column label="租户类型" align="center" prop="tenantType"> <el-table-column label="租户类型" align="center" prop="tenantType">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag <dict-tag
@ -103,7 +119,7 @@
</dict-tag> </dict-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="行业类型" align="center" prop="tenantIndustry"> <el-table-column label="租户行业" align="center" prop="tenantIndustry" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag <dict-tag
@ -115,10 +131,10 @@
</el-table-column> </el-table-column>
<el-table-column label="联系人姓名" align="center" prop="contactName" /> <el-table-column label="联系人姓名" align="center" prop="contactName"/>
<el-table-column label="联系人电话" align="center" prop="contactPhone" /> <el-table-column label="联系人电话" align="center" prop="contactPhone"/>
<el-table-column label="邮箱地址" align="center" prop="email" /> <el-table-column label="邮箱地址" align="center" prop="email"/>
<el-table-column label="联系人地址" align="center" prop="contactAddress" /> <el-table-column label="联系人地址" align="center" prop="contactAddress"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -127,7 +143,8 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['business:tenant:edit']" v-hasPermi="['business:tenant:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -135,7 +152,8 @@
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['business:tenant:remove']" v-hasPermi="['business:tenant:remove']"
v-if="scope.row.tenantId!=1" v-if="scope.row.tenantId!=1"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -154,56 +172,57 @@
<el-row> <el-row>
<el-col span="12"> <el-col span="12">
<el-form-item label="租户类型"> <el-form-item label="租户类型">
<el-radio-group v-model="form.tenantType"> <el-radio-group v-model="form.tenantType" @input="tenantTypeChange">
<el-radio <el-radio
v-for="dict in dict.type.hw_tenant_type" v-for="dict in dict.type.hw_tenant_type"
:key="dict.value" :key="dict.value"
:label="dict.value" :label="dict.value"
>{{dict.label}}</el-radio> >{{ dict.label }}
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="租户名称" prop="tenantName"> <el-form-item label="租户行业" v-if="industryVisible" prop="tenantIndustry">
<el-input v-model="form.tenantName" placeholder="请输入租户名称" />
</el-form-item>
</el-col>
<el-col span="12">
<el-form-item label="租户行业">
<el-select v-model="form.tenantIndustry" placeholder="请选择租户行业"> <el-select v-model="form.tenantIndustry" placeholder="请选择租户行业">
<el-option <el-option
v-for="dict in dict.type.hw_tenant_industry" v-for="dict in dict.type.hw_tenant_industry"
:key ="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="parseInt(dict.value)"> :value="parseInt(dict.value)">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12">
<el-form-item label="租户名称" prop="tenantName">
<el-input v-model="form.tenantName" placeholder="请输入租户名称"/>
</el-form-item>
</el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="联系人姓名" prop="contactName"> <el-form-item label="联系人姓名" prop="contactName">
<el-input v-model="form.contactName" placeholder="请输入联系人姓名" /> <el-input v-model="form.contactName" placeholder="请输入联系人姓名"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="联系人电话" prop="contactPhone"> <el-form-item label="联系人电话" prop="contactPhone">
<el-input v-model="form.contactPhone" placeholder="请输入联系人电话" /> <el-input v-model="form.contactPhone" placeholder="请输入联系人电话"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="邮箱地址" prop="email"> <el-form-item label="邮箱地址" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱地址" /> <el-input v-model="form.email" placeholder="请输入邮箱地址"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="联系人地址" prop="contactAddress"> <el-form-item label="联系人地址" prop="contactAddress">
<el-input v-model="form.contactAddress" placeholder="请输入联系人地址" /> <el-input v-model="form.contactAddress" placeholder="请输入联系人地址"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="描述" prop="remark"> <el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -216,12 +235,11 @@
</template> </template>
<script> <script>
import { listTenant, getTenant, delTenant, addTenant, updateTenant } from "@/api/business/tenant"; import {addTenant, delTenant, getTenant, listTenant, updateTenant} from "@/api/business/tenant";
import {delUser} from "@/api/system/user";
export default { export default {
name: "Tenant", name: "Tenant",
dicts:['hw_tenant_industry','hw_tenant_type'], dicts: ['hw_tenant_industry', 'hw_tenant_type'],
data() { data() {
return { return {
// //
@ -242,6 +260,7 @@ export default {
title: "", title: "",
// //
open: false, open: false,
TENANT_TYPE_ENTERPRISE: "1",
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -259,21 +278,25 @@ export default {
tenantGrade: null, tenantGrade: null,
tenantField: null tenantField: null
}, },
industryVisible: false,
// //
form: {}, form: {},
// //
rules: { rules: {
tenantType: [ tenantType: [
{ required: true, message: "租户类型不能为空", trigger: "change" } {required: true, message: "租户类型不能为空", trigger: "change"}
],
tenantIndustry: [
{required: true, message: "租户行业不能为空", trigger: "change"}
], ],
tenantName: [ tenantName: [
{ required: true, message: "租户名称不能为空", trigger: "blur" } {required: true, message: "租户名称不能为空", trigger: "blur"}
], ],
contactName: [ contactName: [
{ required: true, message: "联系人姓名不能为空", trigger: "blur" } {required: true, message: "联系人姓名不能为空", trigger: "blur"}
], ],
contactPhone: [ contactPhone: [
{ required: true, message: "手机号码不能为空", trigger: "blur" }, {required: true, message: "手机号码不能为空", trigger: "blur"},
{ {
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码", message: "请输入正确的手机号码",
@ -345,12 +368,13 @@ export default {
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.tenantId) this.ids = selection.map(item => item.tenantId)
this.single = selection.length!==1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.industryVisible = true;
this.open = true; this.open = true;
this.title = "添加租户信息"; this.title = "添加租户信息";
}, },
@ -361,6 +385,7 @@ export default {
getTenant(tenantId).then(response => { getTenant(tenantId).then(response => {
//int //int
this.form = response.data; this.form = response.data;
this.industryVisible = this.form.tenantType === this.TENANT_TYPE_ENTERPRISE;
this.open = true; this.open = true;
this.title = "修改租户信息"; this.title = "修改租户信息";
}); });
@ -388,18 +413,23 @@ export default {
// /** */ // /** */
handleDelete(row) { handleDelete(row) {
const tenantIds = row.tenantId || this.ids; const tenantIds = row.tenantId || this.ids;
this.$modal.confirm('是否确认删除租户ID为"' + tenantIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除租户ID为"' + tenantIds + '"的数据项?删除后此租户下的用户等信息也将删除').then(function () {
return delTenant(tenantIds); return delTenant(tenantIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {
});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
this.download('business/tenant/export', { this.download('business/tenant/export', {
...this.queryParams ...this.queryParams
}, `tenant_${new Date().getTime()}.xlsx`) }, `tenant_${new Date().getTime()}.xlsx`)
},
tenantTypeChange(tenantType) {
this.industryVisible = tenantType === this.TENANT_TYPE_ENTERPRISE;
} }
} }
}; };

@ -1,7 +1,7 @@
<template> <template>
<div class="register"> <div class="register">
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form"> <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
<h3 class="title">若依后台管理系统</h3> <h3 class="title">智慧物联监控平台</h3>
<el-form-item prop="username"> <el-form-item prop="username">
<el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号"> <el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />

@ -9,6 +9,16 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属租户" prop="tenantId" v-if="tenantVisible">
<el-select v-model="queryParams.tenantId" placeholder="请选择" clearable>
<el-option
v-for="(tenant, index) in tenants"
:key="index"
:label="tenant.tenantName"
:value="tenant.tenantId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="部门状态" clearable> <el-select v-model="queryParams.status" placeholder="部门状态" clearable>
<el-option <el-option
@ -58,6 +68,7 @@
> >
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column> <el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
<el-table-column prop="tenantName" label="所属租户" width="200"></el-table-column>
<el-table-column prop="status" label="状态" width="100"> <el-table-column prop="status" label="状态" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/> <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
@ -99,10 +110,26 @@
<!-- 添加或修改部门对话框 --> <!-- 添加或修改部门对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row v-if="tenantVisible">
<el-col :span="12">
<el-form-item label="所属租户" prop="tenantId">
<el-select v-model="form.tenantId" placeholder="请选择租户" :disabled="tenantDisabled"
@input="tenantChange">
<el-option
v-for="item in tenants"
:key="item.tenantId"
:label="item.tenantName"
:value="item.tenantId"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :span="24" v-if="form.parentId !== 0"> <el-col :span="24" v-if="form.parentId !== 0">
<el-form-item label="上级部门" prop="parentId"> <el-form-item label="上级部门" prop="parentId">
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" /> <treeselect v-model="form.parentId" :options="editedDeptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -158,9 +185,10 @@
</template> </template>
<script> <script>
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild,getTenants } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getAddedInfo} from "@/api/system/user";
export default { export default {
name: "Dept", name: "Dept",
@ -176,6 +204,8 @@ export default {
deptList: [], deptList: [],
// //
deptOptions: [], deptOptions: [],
//
editedDeptOptions: [],
// //
title: "", title: "",
// //
@ -189,13 +219,16 @@ export default {
deptName: undefined, deptName: undefined,
status: undefined status: undefined
}, },
//
tenants: [],
//
tenantVisible: false,
//disabled
tenantDisabled: true,
// //
form: {}, form: {},
// //
rules: { rules: {
parentId: [
{ required: true, message: "上级部门不能为空", trigger: "blur" }
],
deptName: [ deptName: [
{ required: true, message: "部门名称不能为空", trigger: "blur" } { required: true, message: "部门名称不能为空", trigger: "blur" }
], ],
@ -221,6 +254,7 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.getTenants();
}, },
methods: { methods: {
/** 查询部门列表 */ /** 查询部门列表 */
@ -278,6 +312,7 @@ export default {
} }
this.open = true; this.open = true;
this.title = "添加部门"; this.title = "添加部门";
this.tenantDisabled = false;
listDept().then(response => { listDept().then(response => {
this.deptOptions = this.handleTree(response.data, "deptId"); this.deptOptions = this.handleTree(response.data, "deptId");
}); });
@ -292,13 +327,14 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.tenantDisabled = true;
this.reset(); this.reset();
getDept(row.deptId).then(response => { getDept(row.deptId).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改部门"; this.title = "修改部门";
}); });
listDeptExcludeChild(row.deptId).then(response => { listDeptExcludeChild(row.deptId,row.tenantId).then(response => {
this.deptOptions = this.handleTree(response.data, "deptId"); this.deptOptions = this.handleTree(response.data, "deptId");
}); });
}, },
@ -330,7 +366,24 @@ export default {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
} },
getTenants() {
getTenants().then(response => {
if (response.data !== undefined) {
this.tenants = response.data;
this.tenantVisible = true;
}
});
},
tenantChange(tenantId) {
this.editedDeptOptions = [];
this.form.parentId = undefined;
listDept({"tenantId":tenantId}).then(response => {
this.editedDeptOptions = this.handleTree(response.data, "deptId");
});
},
} }
}; };
</script> </script>

@ -17,6 +17,16 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属租户" prop="tenantId" v-if="tenantVisible">
<el-select v-model="queryParams.tenantId" placeholder="请选择" clearable>
<el-option
v-for="(tenant, index) in tenants"
:key="index"
:label="tenant.tenantName"
:value="tenant.tenantId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable> <el-select v-model="queryParams.status" placeholder="岗位状态" clearable>
<el-option <el-option
@ -66,16 +76,7 @@
v-hasPermi="['system:post:remove']" v-hasPermi="['system:post:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:post:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -85,6 +86,7 @@
<el-table-column label="岗位编码" align="center" prop="postCode" /> <el-table-column label="岗位编码" align="center" prop="postCode" />
<el-table-column label="岗位名称" align="center" prop="postName" /> <el-table-column label="岗位名称" align="center" prop="postName" />
<el-table-column label="岗位排序" align="center" prop="postSort" /> <el-table-column label="岗位排序" align="center" prop="postSort" />
<el-table-column prop="tenantName" label="所属租户" width="200"></el-table-column>
<el-table-column label="状态" align="center" prop="status"> <el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/> <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
@ -126,6 +128,22 @@
<!-- 添加或修改岗位对话框 --> <!-- 添加或修改岗位对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row v-if="tenantVisible">
<el-col :span="12">
<el-form-item label="所属租户" prop="tenantId">
<el-select v-model="form.tenantId" placeholder="请选择租户" :disabled="tenantDisabled"
@input="tenantChange">
<el-option
v-for="item in tenants"
:key="item.tenantId"
:label="item.tenantName"
:value="item.tenantId"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="岗位名称" prop="postName"> <el-form-item label="岗位名称" prop="postName">
<el-input v-model="form.postName" placeholder="请输入岗位名称" /> <el-input v-model="form.postName" placeholder="请输入岗位名称" />
</el-form-item> </el-form-item>
@ -157,7 +175,7 @@
</template> </template>
<script> <script>
import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post"; import { listPost, getPost, delPost, addPost, updatePost,getTenants } from "@/api/system/post";
export default { export default {
name: "Post", name: "Post",
@ -190,6 +208,10 @@ export default {
postName: undefined, postName: undefined,
status: undefined status: undefined
}, },
//
tenantVisible: false,
//disabled
tenantDisabled: true,
// //
form: {}, form: {},
// //
@ -208,6 +230,7 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.getTenants();
}, },
methods: { methods: {
/** 查询岗位列表 */ /** 查询岗位列表 */
@ -257,9 +280,11 @@ export default {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加岗位"; this.title = "添加岗位";
this.tenantDisabled = false;
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.tenantDisabled = true;
this.reset(); this.reset();
const postId = row.postId || this.ids const postId = row.postId || this.ids
getPost(postId).then(response => { getPost(postId).then(response => {
@ -303,7 +328,17 @@ export default {
this.download('system/post/export', { this.download('system/post/export', {
...this.queryParams ...this.queryParams
}, `post_${new Date().getTime()}.xlsx`) }, `post_${new Date().getTime()}.xlsx`)
} },
getTenants() {
getTenants().then(response => {
if (response.data !== undefined) {
this.tenants = response.data;
this.tenantVisible = true;
}
});
},
} }
}; };
</script> </script>

@ -60,7 +60,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['system:role:add']" v-hasPermi="['system:role:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -71,7 +72,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['system:role:edit']" v-hasPermi="['system:role:edit']"
>修改</el-button> >修改
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -82,27 +84,19 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['system:role:remove']" v-hasPermi="['system:role:remove']"
>删除</el-button> >删除
</el-col> </el-button>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:role:export']"
>导出</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center"/>
<el-table-column label="角色编号" prop="roleId" width="120" /> <el-table-column label="角色编号" prop="roleId" width="120"/>
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" /> <el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150"/>
<el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" /> <el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150"/>
<el-table-column label="显示顺序" prop="roleSort" width="100" /> <el-table-column label="显示顺序" prop="roleSort" width="100"/>
<el-table-column label="所属租户" prop="tenantName" width="100"/>
<el-table-column label="状态" align="center" width="100"> <el-table-column label="状态" align="center" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -126,21 +120,26 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['system:role:edit']" v-hasPermi="['system:role:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['system:role:remove']" v-hasPermi="['system:role:remove']"
>删除</el-button> >删除
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']"> </el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"
v-hasPermi="['system:role:edit']">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button> <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleDataScope" icon="el-icon-circle-check" <el-dropdown-item command="handleDataScope" icon="el-icon-circle-check"
v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item> v-hasPermi="['system:role:edit']">数据权限
</el-dropdown-item>
<el-dropdown-item command="handleAuthUser" icon="el-icon-user" <el-dropdown-item command="handleAuthUser" icon="el-icon-user"
v-hasPermi="['system:role:edit']">分配用户</el-dropdown-item> v-hasPermi="['system:role:edit']">分配用户
</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</template> </template>
@ -159,7 +158,7 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> <el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="角色名称" prop="roleName"> <el-form-item label="角色名称" prop="roleName">
<el-input v-model="form.roleName" placeholder="请输入角色名称" /> <el-input v-model="form.roleName" placeholder="请输入角色名称"/>
</el-form-item> </el-form-item>
<el-form-item prop="roleKey"> <el-form-item prop="roleKey">
<span slot="label"> <span slot="label">
@ -168,10 +167,10 @@
</el-tooltip> </el-tooltip>
权限字符 权限字符
</span> </span>
<el-input v-model="form.roleKey" placeholder="请输入权限字符" /> <el-input v-model="form.roleKey" placeholder="请输入权限字符"/>
</el-form-item> </el-form-item>
<el-form-item label="角色顺序" prop="roleSort"> <el-form-item label="角色顺序" prop="roleSort">
<el-input-number v-model="form.roleSort" controls-position="right" :min="0" /> <el-input-number v-model="form.roleSort" controls-position="right" :min="0"/>
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
@ -179,13 +178,16 @@
v-for="dict in dict.type.sys_normal_disable" v-for="dict in dict.type.sys_normal_disable"
:key="dict.value" :key="dict.value"
:label="dict.value" :label="dict.value"
>{{dict.label}}</el-radio> >{{ dict.label }}
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="菜单权限"> <el-form-item label="菜单权限">
<el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">/</el-checkbox> <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">/</el-checkbox>
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">/</el-checkbox> <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">/
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')"></el-checkbox> </el-checkbox>
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">
</el-checkbox>
<el-tree <el-tree
class="tree-border" class="tree-border"
:data="menuOptions" :data="menuOptions"
@ -202,7 +204,7 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm" v-if="editable"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -211,10 +213,10 @@
<el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body>
<el-form :model="form" label-width="80px"> <el-form :model="form" label-width="80px">
<el-form-item label="角色名称"> <el-form-item label="角色名称">
<el-input v-model="form.roleName" :disabled="true" /> <el-input v-model="form.roleName" :disabled="true"/>
</el-form-item> </el-form-item>
<el-form-item label="权限字符"> <el-form-item label="权限字符">
<el-input v-model="form.roleKey" :disabled="true" /> <el-input v-model="form.roleKey" :disabled="true"/>
</el-form-item> </el-form-item>
<el-form-item label="权限范围"> <el-form-item label="权限范围">
<el-select v-model="form.dataScope" @change="dataScopeSelectChange"> <el-select v-model="form.dataScope" @change="dataScopeSelectChange">
@ -228,8 +230,10 @@
</el-form-item> </el-form-item>
<el-form-item label="数据权限" v-show="form.dataScope == 2"> <el-form-item label="数据权限" v-show="form.dataScope == 2">
<el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">/</el-checkbox> <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">/</el-checkbox>
<el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">/</el-checkbox> <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">/
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')"></el-checkbox> </el-checkbox>
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">
</el-checkbox>
<el-tree <el-tree
class="tree-border" class="tree-border"
:data="deptOptions" :data="deptOptions"
@ -252,8 +256,17 @@
</template> </template>
<script> <script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role"; import {
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; listRole,
getRole,
delRole,
addRole,
updateRole,
dataScope,
changeRoleStatus,
deptTreeSelect
} from "@/api/system/role";
import {treeselect as menuTreeselect, roleMenuTreeselect} from "@/api/system/menu";
export default { export default {
name: "Role", name: "Role",
@ -330,15 +343,16 @@ export default {
// //
rules: { rules: {
roleName: [ roleName: [
{ required: true, message: "角色名称不能为空", trigger: "blur" } {required: true, message: "角色名称不能为空", trigger: "blur"}
], ],
roleKey: [ roleKey: [
{ required: true, message: "权限字符不能为空", trigger: "blur" } {required: true, message: "权限字符不能为空", trigger: "blur"}
], ],
roleSort: [ roleSort: [
{ required: true, message: "角色顺序不能为空", trigger: "blur" } {required: true, message: "角色顺序不能为空", trigger: "blur"}
] ]
} },
editable: false
}; };
}, },
created() { created() {
@ -396,11 +410,11 @@ export default {
// //
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function() { this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function () {
return changeRoleStatus(row.roleId, row.status); return changeRoleStatus(row.roleId, row.status);
}).then(() => { }).then(() => {
this.$modal.msgSuccess(text + "成功"); this.$modal.msgSuccess(text + "成功");
}).catch(function() { }).catch(function () {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}); });
}, },
@ -420,21 +434,21 @@ export default {
this.$refs.menu.setCheckedKeys([]); this.$refs.menu.setCheckedKeys([]);
} }
this.menuExpand = false, this.menuExpand = false,
this.menuNodeAll = false, this.menuNodeAll = false,
this.deptExpand = true, this.deptExpand = true,
this.deptNodeAll = false, this.deptNodeAll = false,
this.form = { this.form = {
roleId: undefined, roleId: undefined,
roleName: undefined, roleName: undefined,
roleKey: undefined, roleKey: undefined,
roleSort: 0, roleSort: 0,
status: "0", status: "0",
menuIds: [], menuIds: [],
deptIds: [], deptIds: [],
menuCheckStrictly: true, menuCheckStrictly: true,
deptCheckStrictly: true, deptCheckStrictly: true,
remark: undefined remark: undefined
}; };
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -451,7 +465,7 @@ export default {
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.roleId) this.ids = selection.map(item => item.roleId)
this.single = selection.length!=1 this.single = selection.length != 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
// //
@ -484,21 +498,22 @@ export default {
// / // /
handleCheckedTreeNodeAll(value, type) { handleCheckedTreeNodeAll(value, type) {
if (type == 'menu') { if (type == 'menu') {
this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []); this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []);
} else if (type == 'dept') { } else if (type == 'dept') {
this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []); this.$refs.dept.setCheckedNodes(value ? this.deptOptions : []);
} }
}, },
// //
handleCheckedTreeConnect(value, type) { handleCheckedTreeConnect(value, type) {
if (type == 'menu') { if (type == 'menu') {
this.form.menuCheckStrictly = value ? true: false; this.form.menuCheckStrictly = value ? true : false;
} else if (type == 'dept') { } else if (type == 'dept') {
this.form.deptCheckStrictly = value ? true: false; this.form.deptCheckStrictly = value ? true : false;
} }
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.editable = true;
this.reset(); this.reset();
this.getMenuTreeselect(); this.getMenuTreeselect();
this.open = true; this.open = true;
@ -506,6 +521,12 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.editable = false;
if (row.roleId !== 3 && (row.notEditable === undefined || row.notEditable === null)) {
this.editable = true;
}
this.reset(); this.reset();
const roleId = row.roleId || this.ids const roleId = row.roleId || this.ids
const roleMenu = this.getRoleMenuTreeselect(roleId); const roleMenu = this.getRoleMenuTreeselect(roleId);
@ -516,9 +537,9 @@ export default {
roleMenu.then(res => { roleMenu.then(res => {
let checkedKeys = res.checkedKeys let checkedKeys = res.checkedKeys
checkedKeys.forEach((v) => { checkedKeys.forEach((v) => {
this.$nextTick(()=>{ this.$nextTick(() => {
this.$refs.menu.setChecked(v, true ,false); this.$refs.menu.setChecked(v, true, false);
}) })
}) })
}); });
}); });
@ -527,7 +548,7 @@ export default {
}, },
/** 选择角色权限范围触发 */ /** 选择角色权限范围触发 */
dataScopeSelectChange(value) { dataScopeSelectChange(value) {
if(value !== '2') { if (value !== '2') {
this.$refs.dept.setCheckedKeys([]); this.$refs.dept.setCheckedKeys([]);
} }
}, },
@ -547,12 +568,12 @@ export default {
}); });
}, },
/** 分配用户操作 */ /** 分配用户操作 */
handleAuthUser: function(row) { handleAuthUser: function (row) {
const roleId = row.roleId; const roleId = row.roleId;
this.$router.push("/system/role-auth/user/" + roleId); this.$router.push("/system/role-auth/user/" + roleId);
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function () {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.roleId != undefined) { if (this.form.roleId != undefined) {
@ -574,7 +595,7 @@ export default {
}); });
}, },
/** 提交按钮(数据权限) */ /** 提交按钮(数据权限) */
submitDataScope: function() { submitDataScope: function () {
if (this.form.roleId != undefined) { if (this.form.roleId != undefined) {
this.form.deptIds = this.getDeptAllCheckedKeys(); this.form.deptIds = this.getDeptAllCheckedKeys();
dataScope(this.form).then(response => { dataScope(this.form).then(response => {
@ -587,12 +608,13 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const roleIds = row.roleId || this.ids; const roleIds = row.roleId || this.ids;
this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function () {
return delRole(roleIds); return delRole(roleIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {
});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
@ -602,4 +624,4 @@ export default {
} }
} }
}; };
</script> </script>

@ -49,6 +49,17 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属租户" prop="tenantId" v-if="tenantVisible">
<el-select v-model="queryParams.tenantId" placeholder="请选择" clearable>
<el-option
v-for="(tenant, index) in tenants"
:key="index"
:label="tenant.tenantName"
:value="tenant.tenantId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select <el-select
v-model="queryParams.status" v-model="queryParams.status"
@ -75,6 +86,7 @@
end-placeholder="结束日期" end-placeholder="结束日期"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -124,9 +136,8 @@
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:user:export']" v-hasPermi="['system:dict:export']"
>导出 >导出</el-button>
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
@ -144,7 +155,6 @@
v-if="columns[4].visible" width="120"/> v-if="columns[4].visible" width="120"/>
<el-table-column label="所属租户" align="center" key="tenantName" prop="tenantName" v-if="columns[5].visible" <el-table-column label="所属租户" align="center" key="tenantName" prop="tenantName" v-if="columns[5].visible"
:show-overflow-tooltip="true"/> :show-overflow-tooltip="true"/>
<el-table-column label="状态" align="center" key="status" v-if="columns[6].visible"> <el-table-column label="状态" align="center" key="status" v-if="columns[6].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -214,8 +224,9 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row v-if="tenantVisible"> <el-row v-if="tenantVisible">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="所属租户"> <el-form-item label="所属租户" prop="tenantId">
<el-select v-model="form.tenantId" placeholder="请选择租户" :disabled="tenantDisabled" @input="tenantChange"> <el-select v-model="form.tenantId" placeholder="请选择租户" :disabled="tenantDisabled"
@input="tenantChange">
<el-option <el-option
v-for="item in tenants" v-for="item in tenants"
:key="item.tenantId" :key="item.tenantId"
@ -235,7 +246,8 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="归属部门" prop="deptId"> <el-form-item label="归属部门" prop="deptId">
<treeselect v-model="form.deptId" :options="editedDeptOptions" :show-count="true" placeholder="请选择归属部门"/> <treeselect v-model="form.deptId" :options="editedDeptOptions" :show-count="true"
placeholder="请选择归属部门"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -312,7 +324,6 @@
:key="item.roleId" :key="item.roleId"
:label="item.roleName" :label="item.roleName"
:value="item.roleId" :value="item.roleId"
:disabled="item.roleId != 3 && form.tenantId !== undefined && form.tenantId !==1"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -321,7 +332,7 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="备注"> <el-form-item label="备注">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> <el-input v-model="form.remark" :rows="2" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -408,10 +419,10 @@ export default {
// //
title: "", title: "",
// //
deptOptions: undefined, deptOptions: [],
// //
editedDeptOptions:undefined, editedDeptOptions: [],
// //
open: false, open: false,
// //
@ -424,7 +435,7 @@ export default {
postOptions: [], postOptions: [],
// //
roleOptions: [], roleOptions: [],
// //
tenants: [], tenants: [],
// //
tenantVisible: false, tenantVisible: false,
@ -477,6 +488,9 @@ export default {
}, },
// //
rules: { rules: {
tenantId: [
{required: true, message: "所属租户不能为空", trigger: "change"}
],
userName: [ userName: [
{required: true, message: "用户名称不能为空", trigger: "blur"}, {required: true, message: "用户名称不能为空", trigger: "blur"},
{min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur'} {min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur'}
@ -519,6 +533,11 @@ export default {
this.initPassword = response.msg; this.initPassword = response.msg;
}); });
}, },
activated() {
//
this.getTenants();
},
methods: { methods: {
/** 查询用户列表 */ /** 查询用户列表 */
getList() { getList() {
@ -550,12 +569,6 @@ export default {
if (response.data !== undefined) { if (response.data !== undefined) {
this.tenants = response.data; this.tenants = response.data;
this.tenantVisible = true; this.tenantVisible = true;
}else{
this.getEditDeptTree();
getAddedInfo().then(response => {
this.postOptions = response.posts;
this.roleOptions = response.roles;
});
} }
}); });
}, },
@ -642,14 +655,22 @@ export default {
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
getUser().then(response => { // getUser().then(response => {
//this.postOptions = response.posts; //this.postOptions = response.posts;
//this.roleOptions = response.roles; //this.roleOptions = response.roles;
this.open = true; if (this.tenants === undefined || this.tenants === '' || this.tenants.length <= 0) {
this.title = "添加用户"; this.getEditDeptTree();
this.form.password = this.initPassword; getAddedInfo().then(response => {
this.tenantDisabled = false; this.postOptions = response.posts;
}); this.roleOptions = response.roles;
});
}
this.open = true;
this.title = "添加用户";
this.form.password = this.initPassword;
this.tenantDisabled = false;
// });
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
@ -704,7 +725,7 @@ export default {
this.getList(); this.getList();
}); });
} else { } else {
if (this.tenantVisible===true && (this.form.tenantId === undefined || this.form.tenantId === '')) { if (this.tenantVisible === true && (this.form.tenantId === undefined || this.form.tenantId === '')) {
this.$modal.msgWarning("请选择租户"); this.$modal.msgWarning("请选择租户");
return; return;
} }
@ -760,8 +781,11 @@ export default {
// this.$refs.upload.submit(); // this.$refs.upload.submit();
// } // }
tenantChange(tenantId){ tenantChange(tenantId) {
this.editedDeptOptions = undefined; this.editedDeptOptions = [];
this.postOptions = [];
this.roleOptions = [];
this.form.deptId = undefined; this.form.deptId = undefined;
this.form.roleIds = []; this.form.roleIds = [];
this.form.postIds = []; this.form.postIds = [];

Loading…
Cancel
Save