diff --git a/ruoyi-api/hw-api-basic/src/main/java/com/ruoyi/basic/api/domain/HwTenant.java b/ruoyi-api/hw-api-basic/src/main/java/com/ruoyi/basic/api/domain/HwTenant.java new file mode 100644 index 0000000..a6c6698 --- /dev/null +++ b/ruoyi-api/hw-api-basic/src/main/java/com/ruoyi/basic/api/domain/HwTenant.java @@ -0,0 +1,210 @@ +package com.ruoyi.basic.api.domain; + +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 租户信息对象 hw_tenant + * + * @author xins + * @date 2023-09-04 + */ +public class HwTenant extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户ID */ + private Long tenantId; + + /** 租户类型,(1、企业,2、个人) */ + @Excel(name = "租户类型,(1、企业,2、个人)") + private String tenantType; + + /** 租户名称 */ + @Excel(name = "租户名称") + 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") + private Long tenantIndustry; + + /** 联系人姓名 */ + @Excel(name = "联系人姓名") + private String contactName; + + /** 联系人电话 */ + @Excel(name = "联系人电话") + private String contactPhone; + + /** 邮箱地址 */ + @Excel(name = "邮箱地址") + private String email; + + /** 区域ID,管理区域hw_area */ + @Excel(name = "区域ID,管理区域hw_area") + private Long areaId; + + /** 联系人地址 */ + @Excel(name = "联系人地址") + private String contactAddress; + + /** 状态(1、正常 9、删除) */ + @Excel(name = "状态", readConverterExp = "1=、正常,9=、删除") + private String tenantStatus; + + /** 是否外部注册(1、是 0、否) */ + @Excel(name = "是否外部注册", readConverterExp = "1=、是,0=、否") + private String isRegister; + + /** 租户等级,预留字段 */ + @Excel(name = "租户等级,预留字段") + private Long tenantGrade; + + /** 预留字段 */ + @Excel(name = "预留字段") + private String tenantField; + + public void setTenantId(Long tenantId) + { + this.tenantId = tenantId; + } + + public Long getTenantId() + { + return tenantId; + } + public void setTenantType(String tenantType) + { + this.tenantType = tenantType; + } + + public String getTenantType() + { + return tenantType; + } + public void setTenantName(String tenantName) + { + this.tenantName = tenantName; + } + + public String getTenantName() + { + return tenantName; + } + public void setTenantIndustry(Long tenantIndustry) + { + this.tenantIndustry = tenantIndustry; + } + + public Long getTenantIndustry() + { + return tenantIndustry; + } + public void setContactName(String contactName) + { + this.contactName = contactName; + } + + public String getContactName() + { + return contactName; + } + public void setContactPhone(String contactPhone) + { + this.contactPhone = contactPhone; + } + + public String getContactPhone() + { + return contactPhone; + } + public void setEmail(String email) + { + this.email = email; + } + + public String getEmail() + { + return email; + } + public void setAreaId(Long areaId) + { + this.areaId = areaId; + } + + public Long getAreaId() + { + return areaId; + } + public void setContactAddress(String contactAddress) + { + this.contactAddress = contactAddress; + } + + public String getContactAddress() + { + return contactAddress; + } + public void setTenantStatus(String tenantStatus) + { + this.tenantStatus = tenantStatus; + } + + public String getTenantStatus() + { + return tenantStatus; + } + public void setIsRegister(String isRegister) + { + this.isRegister = isRegister; + } + + public String getIsRegister() + { + return isRegister; + } + public void setTenantGrade(Long tenantGrade) + { + this.tenantGrade = tenantGrade; + } + + public Long getTenantGrade() + { + return tenantGrade; + } + public void setTenantField(String tenantField) + { + this.tenantField = tenantField; + } + + public String getTenantField() + { + return tenantField; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("tenantId", getTenantId()) + .append("tenantType", getTenantType()) + .append("tenantName", getTenantName()) + .append("tenantIndustry", getTenantIndustry()) + .append("contactName", getContactName()) + .append("contactPhone", getContactPhone()) + .append("email", getEmail()) + .append("areaId", getAreaId()) + .append("contactAddress", getContactAddress()) + .append("remark", getRemark()) + .append("tenantStatus", getTenantStatus()) + .append("isRegister", getIsRegister()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("tenantGrade", getTenantGrade()) + .append("tenantField", getTenantField()) + .toString(); + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java index 0d098d1..2a72035 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java @@ -1,5 +1,8 @@ package com.ruoyi.common.core.constant; +import java.util.HashMap; +import java.util.Map; + /** * @Description: 平台常量字典信息 * @ClassName: HwDictConstants @@ -49,7 +52,6 @@ public class HwDictConstants { public static final Long ADMINISTRATOR_TENANT_ID = 0L;//金瑞铭租户ID - public static final String DEVICE_TYPE_GATEWAY_DEVICE = "1";//网关设备 public static final String DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT = "2";//网关子设备 public static final String DEVICE_TYPE_DIRECT_CONNECT_DEVICE = "3";//直连设备 @@ -58,4 +60,21 @@ public class HwDictConstants { public static final String DEVICE_MODE_STATUS_NORMAL = "1";//设备模型正常状态 + public static final String SCENE_DEFAULT_FLAG_YES = "1";//场景是否默认标识:是 + public static final String SCENE_DEFAULT_FLAG_NO = "0";//场景是否默认标识:否 + + + public static final Long SCENE_MODE_STANDARD = 1L;//场景类型:标准 + public static final Long SCENE_MODE_GPS = 2L;//场景类型:定位 + + public static final String ROUTER_STANDARD = "smartScene";//标准场景路由地址 + public static final String ROUTER_GPS = "GPS";//定位场景路由地址 + + public static final Map SCENE_MODE_ROUTER_MAP = new HashMap<>(); + + static { + SCENE_MODE_ROUTER_MAP.put(SCENE_MODE_STANDARD, ROUTER_STANDARD); + SCENE_MODE_ROUTER_MAP.put(SCENE_MODE_GPS, ROUTER_GPS); + } + } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java index 79db57d..28df6da 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/TdEngineConstants.java @@ -49,6 +49,9 @@ public class TdEngineConstants { public static final int ST_TAG_DEVICEMODEID_TYPE = 2; public static final String ST_TAG_MONITORUNITID = "monitorunitid"; + + public static final String ST_TAG_SCENEID = "sceneid"; + public static final int ST_TAG_MONITORUNITID_TYPE = 2; /** @@ -89,10 +92,6 @@ public class TdEngineConstants { return DEFAULT_SUPER_TABLE_NAME_PREFIX + deviceModeId; } - public static String getTableName(Long deviceId) { - return DEFAULT_TABLE_NAME_PREFIX + deviceId; - } - /** * @param: deviceId * @return String @@ -104,5 +103,15 @@ public class TdEngineConstants { return DEFAULT_TABLE_NAME_PREFIX + deviceId; } + /** + * @param: deviceId + * @return String + * @description 获取设备状态信息数据子表名称 + * @author xins + * @date 2023-09-05 9:42 + */ + public static String getDeviceStatusTableName(Long deviceId) { + return DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX + deviceId; + } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwElectronicFenceController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwElectronicFenceController.java index 8173367..684ca35 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwElectronicFenceController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwElectronicFenceController.java @@ -3,6 +3,12 @@ package com.ruoyi.business.controller; import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.business.domain.HwScene; +import com.ruoyi.business.service.IHwSceneService; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -34,7 +40,8 @@ public class HwElectronicFenceController extends BaseController { @Autowired private IHwElectronicFenceService hwElectronicFenceService; - + @Autowired + private IHwSceneService hwSceneService; /** * 查询电子围栏列表 */ @@ -43,7 +50,7 @@ public class HwElectronicFenceController extends BaseController public TableDataInfo list(HwElectronicFence hwElectronicFence) { startPage(); - List list = hwElectronicFenceService.selectHwElectronicFenceList(hwElectronicFence); + List list = hwElectronicFenceService.selectHwElectronicFenceJoinList(hwElectronicFence); return getDataTable(list); } @@ -78,6 +85,10 @@ public class HwElectronicFenceController extends BaseController @PostMapping public AjaxResult add(@RequestBody HwElectronicFence hwElectronicFence) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + hwElectronicFence.setTenantId(user.getTenantId()); + hwElectronicFence.setCreateBy(user.getUserName()); return toAjax(hwElectronicFenceService.insertHwElectronicFence(hwElectronicFence)); } @@ -102,4 +113,18 @@ public class HwElectronicFenceController extends BaseController { return toAjax(hwElectronicFenceService.deleteHwElectronicFenceByElectronicFenceIds(electronicFenceIds)); } + + @RequiresPermissions("business:electronicFence:list") + @GetMapping("/getScenes") + public AjaxResult getScenes(HwScene scene) + { + return success(hwSceneService.selectHwSceneList(scene)); + } + + @RequiresPermissions("business:electronicFence:list") + @GetMapping("/getEditedScenes") + public AjaxResult getEditedScenes(HwScene scene) + { + return success(hwSceneService.selectHwSceneList4Select(scene)); + } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java index 749d965..ae75e84 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java @@ -250,9 +250,9 @@ public class HwMonitorPlatformController extends BaseController { JSONObject returnObj = new JSONObject(); List> latestDataMaps = hwMonitorPlatformService.selectLatestDataByTags(deviceLatestData); List deviceDataColumnVos = this.getDeviceDataColumns(latestDataMaps); - TableDataInfo tableDataInfo = getDataTable(latestDataMaps); +// TableDataInfo tableDataInfo = getDataTable(latestDataMaps); returnObj.put("deviceDataColumns", deviceDataColumnVos); - returnObj.put("latestData", tableDataInfo); + returnObj.put("latestData", latestDataMaps); return success(returnObj); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java index 527841f..8935c84 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java @@ -1,18 +1,13 @@ package com.ruoyi.business.controller; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import javax.annotation.Resource; +import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.business.domain.HwMonitorUnitType; import com.ruoyi.business.domain.HwScene; -import com.ruoyi.business.domain.VO.*; -import com.ruoyi.business.mapper.HwSceneMapper; -import com.ruoyi.business.service.IHwDeviceService; -import com.ruoyi.business.service.IHwElectronicFenceService; +import com.ruoyi.business.service.IHwMonitorUnitTypeService; import com.ruoyi.business.service.IHwSceneService; -import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.model.LoginUser; @@ -33,13 +28,12 @@ import com.ruoyi.business.service.IHwMonitorUnitService; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.utils.poi.ExcelUtil; -import com.ruoyi.common.core.web.page.TableDataInfo; /** * 监控单元Controller - * - * @author YINQ - * @date 2023-08-31 + * + * @author xins + * @date 2023-09-14 */ @RestController @RequestMapping("/monitorUnit") @@ -47,28 +41,24 @@ public class HwMonitorUnitController extends BaseController { @Autowired private IHwMonitorUnitService hwMonitorUnitService; - @Autowired - private IHwDeviceService hwDeviceService; + @Autowired private IHwSceneService hwSceneService; + @Autowired - private IHwElectronicFenceService hwElectronicFenceService; - - + private IHwMonitorUnitTypeService monitorUnitTypeService; /** * 查询监控单元列表 */ @RequiresPermissions("business:monitorUnit:list") @GetMapping("/list") - public TableDataInfo list(HwMonitorUnit hwMonitorUnit) + public AjaxResult list(HwMonitorUnit hwMonitorUnit) { -// startPage(); - List list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit); - return getDataTable(list); + List list = hwMonitorUnitService.selectHwMonitorUnitJoinList(hwMonitorUnit); + return success(list); } - /** * 导出监控单元列表 */ @@ -77,7 +67,7 @@ public class HwMonitorUnitController extends BaseController @PostMapping("/export") public void export(HttpServletResponse response, HwMonitorUnit hwMonitorUnit) { - List list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit); + List list = hwMonitorUnitService.selectHwMonitorUnitJoinList(hwMonitorUnit); ExcelUtil util = new ExcelUtil(HwMonitorUnit.class); util.exportExcel(response, list, "监控单元数据"); } @@ -92,7 +82,6 @@ public class HwMonitorUnitController extends BaseController return success(hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId)); } - /** * 新增监控单元 */ @@ -101,14 +90,12 @@ public class HwMonitorUnitController extends BaseController @PostMapping public AjaxResult add(@RequestBody HwMonitorUnit hwMonitorUnit) { - - - if (hwMonitorUnitService.insertHwMonitorUnit(hwMonitorUnit)!=0){ - return AjaxResult.success(); - } - else{ - return AjaxResult.error("以关联设备不可作为父集设备"); - }} + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + hwMonitorUnit.setTenantId(user.getTenantId()); + hwMonitorUnit.setCreateBy(user.getUserName()); + return toAjax(hwMonitorUnitService.insertHwMonitorUnit(hwMonitorUnit)); + } /** * 修改监控单元 @@ -129,25 +116,54 @@ public class HwMonitorUnitController extends BaseController @DeleteMapping("/{monitorUnitIds}") public AjaxResult remove(@PathVariable Long[] monitorUnitIds) { - if (hwMonitorUnitService.deleteHwMonitorUnitByMonitorUnitIds(monitorUnitIds)==0){ - return AjaxResult.error("带有子集设备的监控单元不可删除"); - } - else - return AjaxResult.success("删除成功"); + return toAjax(hwMonitorUnitService.deleteHwMonitorUnitByMonitorUnitIds(monitorUnitIds)); } + + + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getScenes") + public AjaxResult getScenes(HwScene scene) + { + return success(hwSceneService.selectHwSceneList(scene)); + } + + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getEditedScenes") + public AjaxResult getEditedScenes(HwScene scene) + { + return success(hwSceneService.selectHwSceneList4Select(scene)); + } + + + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getMonitorUnitTypes") + public AjaxResult getMonitorUnitTypes(HwMonitorUnitType monitorUnitType) + { + return success(monitorUnitTypeService.selectHwMonitorUnitTypeList(monitorUnitType)); + } + + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getEditedMonitorUnitTypes") + public AjaxResult getEditedMonitorUnitTypes(HwMonitorUnitType monitorUnitType) + { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + monitorUnitType.setTenantId(user.getTenantId()); + return success(monitorUnitTypeService.selectHwMonitorUnitTypeList4Select(monitorUnitType)); + } + /** - * 根据id查询监控单元是否有关联 - * */ - @GetMapping("/getMonitorIsRelevancy") - public String getMonitorIsRelevancy(Long monitorUnitId){ - //如果关联设备 不能作为父级监控单元 - if (hwMonitorUnitService.getMonitorIsRelevancy(monitorUnitId)==0){ - return "y"; - } - return "n"; + * 查询监控单元列表供编辑 + */ + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getEditedMonitorUnits") + public AjaxResult getEditedMonitorUnits(HwMonitorUnit hwMonitorUnit) + { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + hwMonitorUnit.setTenantId(user.getTenantId()); + List list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit); + return success(list); } - - - } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitTypeController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitTypeController.java index 6da972f..6cebcf6 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitTypeController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitTypeController.java @@ -3,6 +3,11 @@ package com.ruoyi.business.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.business.domain.HwScene; +import com.ruoyi.business.service.IHwSceneService; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -35,6 +40,8 @@ public class HwMonitorUnitTypeController extends BaseController @Autowired private IHwMonitorUnitTypeService hwMonitorUnitTypeService; + @Autowired + private IHwSceneService hwSceneService; /** * 查询监控单元类型列表 */ @@ -43,11 +50,10 @@ public class HwMonitorUnitTypeController extends BaseController public TableDataInfo list(HwMonitorUnitType hwMonitorUnitType) { startPage(); - List list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeList(hwMonitorUnitType); + List list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType); return getDataTable(list); } - /** * 导出监控单元类型列表 */ @@ -56,7 +62,7 @@ public class HwMonitorUnitTypeController extends BaseController @PostMapping("/export") public void export(HttpServletResponse response, HwMonitorUnitType hwMonitorUnitType) { - List list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeList(hwMonitorUnitType); + List list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType); ExcelUtil util = new ExcelUtil(HwMonitorUnitType.class); util.exportExcel(response, list, "监控单元类型数据"); } @@ -79,6 +85,10 @@ public class HwMonitorUnitTypeController extends BaseController @PostMapping public AjaxResult add(@RequestBody HwMonitorUnitType hwMonitorUnitType) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + hwMonitorUnitType.setTenantId(user.getTenantId()); + hwMonitorUnitType.setCreateBy(user.getUserName()); return toAjax(hwMonitorUnitTypeService.insertHwMonitorUnitType(hwMonitorUnitType)); } @@ -101,11 +111,21 @@ public class HwMonitorUnitTypeController extends BaseController @DeleteMapping("/{monitorUnitTypeIds}") public AjaxResult remove(@PathVariable Long[] monitorUnitTypeIds) { - - if (hwMonitorUnitTypeService.deleteHwMonitorUnitTypeByMonitorUnitTypeIds(monitorUnitTypeIds)==0){ - return AjaxResult.error("该类型下仍有监控单元,不可删除"); - } - else{ return toAjax(hwMonitorUnitTypeService.deleteHwMonitorUnitTypeByMonitorUnitTypeIds(monitorUnitTypeIds)); - }} + } + + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getScenes") + public AjaxResult getScenes(HwScene scene) + { + return success(hwSceneService.selectHwSceneList(scene)); + } + + @RequiresPermissions("business:monitorUnit:list") + @GetMapping("/getEditedScenes") + public AjaxResult getEditedScenes(HwScene scene) + { + return success(hwSceneService.selectHwSceneList4Select(scene)); + } + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java index 077cae2..331866a 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java @@ -10,7 +10,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ruoyi.business.domain.HwSceneMode; +import com.ruoyi.business.domain.HwTenant; import com.ruoyi.business.domain.VO.HwSceneVo; +import com.ruoyi.business.service.IHwSceneModeService; +import com.ruoyi.business.service.IHwTenantService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.i18n.utils.MessageUtils; import com.ruoyi.system.api.domain.SysUser; @@ -43,6 +46,13 @@ public class HwSceneController extends BaseController @Autowired private IHwSceneService hwSceneService; + @Autowired + private IHwSceneModeService hwSceneModeService; + + @Autowired + private IHwTenantService hwTenantService; + + @ResponseBody @RequestMapping("getLanDemo") public String getLanDemo(HttpServletResponse response) { @@ -62,20 +72,10 @@ public class HwSceneController extends BaseController public TableDataInfo list(HwSceneVo hwScene) { startPage(); - List list = hwSceneService.selectHwSceneList2(hwScene); + List list = hwSceneService.selectHwSceneJoinList(hwScene); return getDataTable(list); } - /** - * 查询场景信息id与名称 - * */ - @GetMapping("/sceneIdAndName") - public TableDataInfo sceneIdAndName() - { - HwSceneVo hwScene = new HwSceneVo(); - List list = hwSceneService.selectHwSceneList2(hwScene); - return getDataTable(list); - } /** * 导出场景信息列表 @@ -150,7 +150,32 @@ public class HwSceneController extends BaseController } } + /** + * 查询场景信息列表供选择使用(例如下拉列表) + */ + @GetMapping("/getScenes") + public AjaxResult getScenes(HwScene hwScene) { + return success(hwSceneService.selectHwSceneList(hwScene)); + } + + /** + * 查询租户列表(例如下拉列表) + */ + @RequiresPermissions("business:scene:list") + @GetMapping("/getTenants") + public AjaxResult getTenants() { + return success(hwTenantService.selectHwTenantList(new HwTenant())); + } + + /** + * 查询场景类型列表(例如下拉列表) + */ + @RequiresPermissions("business:scene:list") + @GetMapping("/getSceneModes") + public AjaxResult getSceneModes() { + return success(hwSceneModeService.selectHwSceneModeList(new HwSceneMode())); + } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java index 729e6fb..c375d39 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java @@ -54,15 +54,6 @@ public class HwTenantController extends BaseController list = hwTenantService.selectHwTenantList(hwTenant); return getDataTable(list); } - /** - * 查询租户id与名称 - * */ - @GetMapping("/tenantIdAndName") - public TableDataInfo tenantIdAndName(){ - - HwTenant hwTenant = new HwTenant(); - return getDataTable(hwTenantService.selectHwTenantList(hwTenant)); - } /** * 导出租户信息列表 diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwElectronicFence.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwElectronicFence.java index d26c35f..0e4cb62 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwElectronicFence.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwElectronicFence.java @@ -10,7 +10,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity; * 电子围栏对象 hw_electronic_fence * * @author xins - * @date 2023-09-15 + * @date 2023-09-19 */ public class HwElectronicFence extends BaseEntity { @@ -23,6 +23,10 @@ public class HwElectronicFence extends BaseEntity @Excel(name = "电子围栏名称") private String electronicFenceName; + /** 租户ID,关联hw_tenant的tenant_id */ + @Excel(name = "租户ID,关联hw_tenant的tenant_id") + private Long tenantId; + /** 所属场景,关联hw_scene表的scene_id字段 */ @Excel(name = "所属场景,关联hw_scene表的scene_id字段") private Long sceneId; @@ -47,14 +51,6 @@ public class HwElectronicFence extends BaseEntity @Excel(name = "触发状态", readConverterExp = "0=、关闭,1、出界,2、入界,3、双向") private String triggerStatus; - /** 区域形状(1、多边形,2、圆形) */ - @Excel(name = "区域形状", readConverterExp = "1=、多边形,2、圆形") - private String areaShapeFlag; - - /** 区域范围:为多边形时保存格式,经度_纬度,多个以|隔开;为圆形时的中心点和半径,下划线隔开 */ - @Excel(name = "区域范围:为多边形时保存格式,经度_纬度,多个以|隔开;为圆形时的中心点和半径,下划线隔开") - private String areaRange; - /** 报警推送标识(1、是,0、否) */ @Excel(name = "报警推送标识(1、是,0、否)") private String fencePushFlag; @@ -74,6 +70,13 @@ public class HwElectronicFence extends BaseEntity /** 电子围栏目标信息 */ private List hwFenceTargetList; + private String sceneName; + + private String polygonAreaListStr; + private String circleAreaListStr; + + + public void setElectronicFenceId(Long electronicFenceId) { this.electronicFenceId = electronicFenceId; @@ -92,6 +95,15 @@ public class HwElectronicFence extends BaseEntity { return electronicFenceName; } + public void setTenantId(Long tenantId) + { + this.tenantId = tenantId; + } + + public Long getTenantId() + { + return tenantId; + } public void setSceneId(Long sceneId) { this.sceneId = sceneId; @@ -146,24 +158,6 @@ public class HwElectronicFence extends BaseEntity { return triggerStatus; } - public void setAreaShapeFlag(String areaShapeFlag) - { - this.areaShapeFlag = areaShapeFlag; - } - - public String getAreaShapeFlag() - { - return areaShapeFlag; - } - public void setAreaRange(String areaRange) - { - this.areaRange = areaRange; - } - - public String getAreaRange() - { - return areaRange; - } public void setFencePushFlag(String fencePushFlag) { this.fencePushFlag = fencePushFlag; @@ -211,19 +205,42 @@ public class HwElectronicFence extends BaseEntity this.hwFenceTargetList = hwFenceTargetList; } + public String getSceneName() { + return sceneName; + } + + public void setSceneName(String sceneName) { + this.sceneName = sceneName; + } + + public String getPolygonAreaListStr() { + return polygonAreaListStr; + } + + public void setPolygonAreaListStr(String polygonAreaListStr) { + this.polygonAreaListStr = polygonAreaListStr; + } + + public String getCircleAreaListStr() { + return circleAreaListStr; + } + + public void setCircleAreaListStr(String circleAreaListStr) { + this.circleAreaListStr = circleAreaListStr; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("electronicFenceId", getElectronicFenceId()) .append("electronicFenceName", getElectronicFenceName()) + .append("tenantId", getTenantId()) .append("sceneId", getSceneId()) .append("fenceType", getFenceType()) .append("effectiveTimeFlag", getEffectiveTimeFlag()) .append("timeZone", getTimeZone()) .append("effectiveTime", getEffectiveTime()) .append("triggerStatus", getTriggerStatus()) - .append("areaShapeFlag", getAreaShapeFlag()) - .append("areaRange", getAreaRange()) .append("fencePushFlag", getFencePushFlag()) .append("fencePushContent", getFencePushContent()) .append("fenceRecoverContent", getFenceRecoverContent()) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnit.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnit.java index c99899e..cf20fc8 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnit.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnit.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import com.ruoyi.system.api.domain.SysDept; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; @@ -30,6 +31,8 @@ public class HwMonitorUnit extends BaseEntity @Excel(name = "所属场景") private Long sceneId; + private Long tenantId; + /** 父级监控单元ID */ @Excel(name = "父级监控单元ID") private Long parentId; @@ -62,25 +65,32 @@ public class HwMonitorUnit extends BaseEntity @Excel(name = "预留字段") private String monitorUnitField; - private Long tenantId; + private String sceneName; + private String monitorUnitTypeName; + private String tenantName; + + private List child = new ArrayList(); + /** 子部门 */ + private List children = new ArrayList(); + public List getChild() { return child; } - public Long getTenantId() { - return tenantId; - } - - public void setTenantId(Long tenantId) { - this.tenantId = tenantId; - } - public void setChild(List child) { this.child = child; } + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + public void setMonitorUnitId(Long monitorUnitId) { this.monitorUnitId = monitorUnitId; @@ -108,6 +118,15 @@ public class HwMonitorUnit extends BaseEntity { return sceneId; } + + public Long getTenantId() { + return tenantId; + } + + public void setTenantId(Long tenantId) { + this.tenantId = tenantId; + } + public void setParentId(Long parentId) { this.parentId = parentId; @@ -181,22 +200,49 @@ public class HwMonitorUnit extends BaseEntity return monitorUnitField; } + public String getSceneName() { + return sceneName; + } + + public void setSceneName(String sceneName) { + this.sceneName = sceneName; + } + + public String getMonitorUnitTypeName() { + return monitorUnitTypeName; + } + + public void setMonitorUnitTypeName(String monitorUnitTypeName) { + this.monitorUnitTypeName = monitorUnitTypeName; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + @Override public String toString() { - return "HwMonitorUnit{" + - "monitorUnitId=" + monitorUnitId + - ", monitorUnitName='" + monitorUnitName + '\'' + - ", sceneId=" + sceneId + - ", parentId=" + parentId + - ", monitorUnitTypeId=" + monitorUnitTypeId + - ", areaId=" + areaId + - ", monitorAddress='" + monitorAddress + '\'' + - ", monitorPic='" + monitorPic + '\'' + - ", preserveTime=" + preserveTime + - ", monitorUnitStatus=" + monitorUnitStatus + - ", monitorUnitField='" + monitorUnitField + '\'' + - ", tenantId=" + tenantId + - ", child=" + child + - '}'; + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("monitorUnitId", getMonitorUnitId()) + .append("monitorUnitName", getMonitorUnitName()) + .append("sceneId", getSceneId()) + .append("parentId", getParentId()) + .append("monitorUnitTypeId", getMonitorUnitTypeId()) + .append("areaId", getAreaId()) + .append("monitorAddress", getMonitorAddress()) + .append("monitorPic", getMonitorPic()) + .append("preserveTime", getPreserveTime()) + .append("remark", getRemark()) + .append("monitorUnitStatus", getMonitorUnitStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("monitorUnitField", getMonitorUnitField()) + .toString(); } -} +} \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitType.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitType.java index 5dd63e5..435125c 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitType.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitType.java @@ -7,7 +7,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity; /** * 监控单元类型对象 hw_monitor_unit_type - * + * * @author YINQ * @date 2023-08-31 */ @@ -18,6 +18,7 @@ public class HwMonitorUnitType extends BaseEntity /** 监控单元类型ID */ private Long monitorUnitTypeId; + private Long tenantId; /** 监控单元类型名称 */ @Excel(name = "监控单元类型名称") private String monitorUnitTypeName; @@ -41,8 +42,6 @@ public class HwMonitorUnitType extends BaseEntity /** 所属场景 */ @Excel(name = "所属场景") private Long sceneId; - //租户id - private Long tenantId; /** 监控单元类型图标 */ @Excel(name = "监控单元类型图标") @@ -52,6 +51,23 @@ public class HwMonitorUnitType extends BaseEntity @Excel(name = "预留字段") private String unitTypeField; + private String sceneName; + private String tenantName; + + + public void setMonitorUnitTypeId(Long monitorUnitTypeId) + { + this.monitorUnitTypeId = monitorUnitTypeId; + } + + public Long getMonitorUnitTypeId() + { + return monitorUnitTypeId; + } + public void setMonitorUnitTypeName(String monitorUnitTypeName) + { + this.monitorUnitTypeName = monitorUnitTypeName; + } public Long getTenantId() { return tenantId; @@ -61,88 +77,90 @@ public class HwMonitorUnitType extends BaseEntity this.tenantId = tenantId; } - public void setMonitorUnitTypeId(Long monitorUnitTypeId) - { - this.monitorUnitTypeId = monitorUnitTypeId; - } - - public Long getMonitorUnitTypeId() - { - return monitorUnitTypeId; - } - public void setMonitorUnitTypeName(String monitorUnitTypeName) - { - this.monitorUnitTypeName = monitorUnitTypeName; - } - public String getMonitorUnitTypeName() { return monitorUnitTypeName; } - public void setVitualFlag(String vitualFlag) + public void setVitualFlag(String vitualFlag) { this.vitualFlag = vitualFlag; } - public String getVitualFlag() + public String getVitualFlag() { return vitualFlag; } - public void setMonitorUnitTypeStatus(String monitorUnitTypeStatus) + public void setMonitorUnitTypeStatus(String monitorUnitTypeStatus) { this.monitorUnitTypeStatus = monitorUnitTypeStatus; } - public String getMonitorUnitTypeStatus() + public String getMonitorUnitTypeStatus() { return monitorUnitTypeStatus; } - public void setLanguageCode(String languageCode) + public void setLanguageCode(String languageCode) { this.languageCode = languageCode; } - public String getLanguageCode() + public String getLanguageCode() { return languageCode; } - public void setCommonFlag(String commonFlag) + public void setCommonFlag(String commonFlag) { this.commonFlag = commonFlag; } - public String getCommonFlag() + public String getCommonFlag() { return commonFlag; } - public void setSceneId(Long sceneId) + public void setSceneId(Long sceneId) { this.sceneId = sceneId; } - public Long getSceneId() + public Long getSceneId() { return sceneId; } - public void setUnitTypeIcon(String unitTypeIcon) + public void setUnitTypeIcon(String unitTypeIcon) { this.unitTypeIcon = unitTypeIcon; } - public String getUnitTypeIcon() + public String getUnitTypeIcon() { return unitTypeIcon; } - public void setUnitTypeField(String unitTypeField) + public void setUnitTypeField(String unitTypeField) { this.unitTypeField = unitTypeField; } - public String getUnitTypeField() + public String getUnitTypeField() { return unitTypeField; } + public String getSceneName() { + return sceneName; + } + + public void setSceneName(String sceneName) { + this.sceneName = sceneName; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -160,7 +178,6 @@ public class HwMonitorUnitType extends BaseEntity .append("updateTime", getUpdateTime()) .append("unitTypeIcon", getUnitTypeIcon()) .append("unitTypeField", getUnitTypeField()) - .append("tenantId", getTenantId()) .toString(); } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwScene.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwScene.java index a9a2c2e..1f31393 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwScene.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwScene.java @@ -78,6 +78,10 @@ public class HwScene extends BaseEntity @Excel(name = "预留字段") private String sceneField; + private String router; + + private String selectedDisable; + public void setSceneId(Long sceneId) { this.sceneId = sceneId; @@ -214,6 +218,22 @@ public class HwScene extends BaseEntity return sceneField; } + public String getRouter() { + return router; + } + + public void setRouter(String router) { + this.router = router; + } + + public String getSelectedDisable() { + return selectedDisable; + } + + public void setSelectedDisable(String selectedDisable) { + this.selectedDisable = selectedDisable; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/HwMonitorUnitVo.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/HwMonitorUnitVo.java index 43ba2f8..e5467bf 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/HwMonitorUnitVo.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/HwMonitorUnitVo.java @@ -9,26 +9,26 @@ package com.ruoyi.business.domain.VO; public class HwMonitorUnitVo { public String sceneName; - public String sceneId; + public Long sceneId; public Integer sum; public Integer err; - public Double percentage; + public String percentage; - public Double getPercentage() { + public String getPercentage() { return percentage; } - public void setPercentage(Double percentage) { + public void setPercentage(String percentage) { this.percentage = percentage; } - public String getSceneId() { + public Long getSceneId() { return sceneId; } - public void setSceneId(String sceneId) { + public void setSceneId(Long sceneId) { this.sceneId = sceneId; } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java index 9c3d1b4..6932694 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java @@ -81,4 +81,12 @@ public interface HwElectronicFenceMapper public int selectDeviceCountByMonitorUnit(Long electronicFenceId); public int selectDeviceCountByScene(Long sceneId); + + /** + * 查询电子围栏列表Join场景 + * + * @param hwElectronicFence 电子围栏 + * @return 电子围栏集合 + */ + public List selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java index a93679f..054cff2 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java @@ -33,20 +33,20 @@ public interface HwMonitorUnitMapper public List selectsum(); //查询id与name的结果集 List selectSceneNameById(); - String selectSubSetNums(); + Integer selectSubSetNums(Long sceneId); /** * 分页获取最子集监控单元列表 * */ public List selectLimitSubMonitorUnit(); Integer selectReleatedDeviceIdNums(Long deviceCode); - String selectDeviceNums(); + Integer selectDeviceNums(Long sceneId); Integer selectSubDeviceSum(Long sceneId); /** * 监控单元报警统计 * */ - public List selectAlarmStats(); + public List selectAlarmStats(Long sceneId); /** * 获取最子级监控单元数量、设备数量和在线设备数量 * */ @@ -113,10 +113,21 @@ public interface HwMonitorUnitMapper */ public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds); - int selectIsParent(Long monitorUnitId); + /** + * 查询监控单元列表join场景 + * + * @param hwMonitorUnit 监控单元 + * @return 监控单元集合 + */ + public List selectHwMonitorUnitListJoinScene(HwMonitorUnit hwMonitorUnit); - //查询设备是否关联了该监控单元 - Integer selectDeviceRelevancyMontiorUnit(Long monitorUnitId); - //查询电子围栏是否关联了该监控单元 - Integer selectElectronicFenceRelevancyMonitorUnit(Long monitorUnitId); -} + + /** + * 查询监控单元列表 + * + * @param hwMonitorUnit 监控单元 + * @return 监控单元集合 + */ + public List selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit); + +} \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitTypeMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitTypeMapper.java index 49e16c5..fd370c8 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitTypeMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitTypeMapper.java @@ -63,5 +63,7 @@ public interface HwMonitorUnitTypeMapper */ public int deleteHwMonitorUnitTypeByMonitorUnitTypeIds(Long[] monitorUnitTypeIds); - public int getNumsHwMonitorUnitTypeByMonitorUnitTypeId(Long monitorUnitTypeId); + + public List selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType); + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java index 42744b6..917cc85 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java @@ -22,7 +22,6 @@ public interface HwSceneMapper public List selectHwSceneBySceneModeId(Long sceneModeId); public List selectHwSceneByTenantId0(Long tenantId); public List selectHwSceneByTenantIdNot0(Long tenantId); - List selectHwSceneVoListByTenantId(Long tenantId); /** diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java index 99cb8ea..8041806 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java @@ -65,4 +65,13 @@ public interface IHwElectronicFenceService * @return 结果 */ public int deleteHwElectronicFenceByElectronicFenceId(Long electronicFenceId); + + /** + * 查询电子围栏列表Join场景 + * + * @param hwElectronicFence 电子围栏 + * @return 电子围栏 + */ + public List selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence); + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java index 01ba7b9..f73fa15 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java @@ -2,10 +2,12 @@ package com.ruoyi.business.service; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import com.ruoyi.business.domain.HwMonitorUnit; import com.ruoyi.business.domain.VO.*; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.datascope.annotation.DataScope; /** @@ -30,21 +32,25 @@ public interface IHwMonitorUnitService /** *  展示总的设备数量和总的监控单元数量(最低级的监控单元) * */ - public AllNumsVo selectAllNums(); - public List selectSenceAllNums(); + public AllNumsVo selectAllNums(Long sceneId); +// public List selectSenceAllNums(); /** * 分页获取最子集监控单元列表 * */ public List selectLimitSubMonitorUnit(); + /** + * 报警信息列表 + * */ + /** * 监控单元报警统计 * */ - public List selectAlarmStats(); + public List selectAlarmStats(Long sceneId); /** * 查询监控单元列表 * @@ -57,10 +63,7 @@ public interface IHwMonitorUnitService * 获取最子级监控单元数量、设备数量和在线设备数量 * */ public SubDeviceSumVo selectSubDeviceSum(Long sceneId); - /** - * 按电子围栏定位显示其下设备数量,以及报警的设备数量。 - * */ - public Integer selectElectronicNum(Long sceneId); + /** * 树状获取监控单元列表 * */ @@ -69,19 +72,9 @@ public interface IHwMonitorUnitService * 获取监控单元详细信息 * */ public HwMonitorUnit selectHwmonitorUnitSub(Long monitorUnitId); + + /** - * 通过tdengine获取设备运行情况 - * - * @return*/ - public Map selectTdengine(String beginTime, String endTime, Long sceneId); - /** - * 设备汇总 - * - * @return*/ - public R>> selectLatestDataByTags(Long monitorUnitId); - - - /** * 新增监控单元 * * @param hwMonitorUnit 监控单元 @@ -114,9 +107,36 @@ public interface IHwMonitorUnitService public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId); + /** + * 查询监控单元树结构信息 + * + * @param hwMonitorUnit 监控单元信息 + * @return 监控单元树信息集合 + */ + public List selectMonitorTreeList(HwMonitorUnit hwMonitorUnit); /** - * 根据id查询该监控单元是否有查询 - * */ - int getMonitorIsRelevancy(Long monitorUnitId); -} + * 构建前端所需要下拉树结构 + * + * @param hwMonitorUnits 监控单元列表 + * @return 下拉树结构列表 + */ + public List buildMonitorUnitTreeSelect(List hwMonitorUnits); + + /** + * 构建前端所需要树结构 + * + * @param hwMonitorUnits 监控单元列表 + * @return 树结构列表 + */ + public List buildMonitorUnitTree(List hwMonitorUnits); + + /** + * 查询监控单元列表,Join监控单元类型,租户和场景 + * + * @param hwMonitorUnit 监控单元 + * @return 监控单元 + */ + public List selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit); + +} \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java index f65da07..48388eb 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java @@ -23,8 +23,6 @@ public interface IHwSceneService public List selectHwSceneBySceneModeId(Long sceneModeId); - //场景选择 - List selectHwSceneByTenantId(Long tenantId); /** * 查询场景信息列表 * @@ -32,8 +30,7 @@ public interface IHwSceneService * @return 场景信息集合 */ public List selectHwSceneList(HwScene hwScene); - public List selectHwSceneList2(HwSceneVo hwScene); - + public List selectHwSceneJoinList(HwSceneVo hwScene); /** * 新增场景信息 @@ -66,4 +63,12 @@ public interface IHwSceneService * @return 结果 */ public int deleteHwSceneBySceneId(Long sceneId); + + /** + * 查询场景信息列表供其他页面选择使用 + * + * @param hwScene 场景信息 + * @return 场景信息 + */ + public List selectHwSceneList4Select(HwScene hwScene); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index bbfbeef..bae9b71 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -3,7 +3,6 @@ package com.ruoyi.business.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.alibaba.nacos.shaded.com.google.gson.JsonElement; import com.ruoyi.business.domain.HwDevice; import com.ruoyi.business.domain.HwDeviceModeFunction; import com.ruoyi.business.domain.HwScene; @@ -33,6 +32,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -53,7 +53,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { private HwSceneMapper hwSceneMapper; @Autowired private HwDeviceModeFunctionMapper hwDevieModeFunctionMapper; - @Autowired + @Resource private RemoteTdEngineService remoteTdEngineService; @Autowired private StringRedisTemplate redisTemplate; @@ -117,14 +117,21 @@ public class HwDeviceServiceImpl implements IHwDeviceService { hwDevice.setCreateTime(DateUtils.getNowDate()); String deviceType = hwDevice.getDeviceType(); int deviceId = hwDeviceMapper.insertHwDevice(hwDevice); - if (deviceType.equals(HwDictConstants.DEVICE_TYPE_GATEWAY_DEVICE)) { - this.updateMqttAuth(hwDevice); - } else if (deviceType.equals(HwDictConstants.DEVICE_TYPE_DIRECT_CONNECT_DEVICE)) { - this.updateMqttAuth(hwDevice); - this.createTdTable(hwDevice); - } else if (deviceType.equals(HwDictConstants.DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT)) { - this.createTdTable(hwDevice); + switch (deviceType) { + case HwDictConstants.DEVICE_TYPE_GATEWAY_DEVICE: + this.updateMqttAuth(hwDevice); + break; + case HwDictConstants.DEVICE_TYPE_DIRECT_CONNECT_DEVICE: + this.updateMqttAuth(hwDevice); + this.createTdTable(hwDevice); + break; + case HwDictConstants.DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT: + this.createTdTable(hwDevice); + break; + default: + throw new ServiceException("Unknown device type: " + deviceType); } + this.createTdDeviceStatusTable(hwDevice); return deviceId; } @@ -142,7 +149,6 @@ public class HwDeviceServiceImpl implements IHwDeviceService { if (StringUtils.isNotEmpty(modeAccount) && StringUtils.isNotEmpty(modeKey)) { String deviceInfoStr = redisTemplate.opsForValue().get(HwDictConstants.REDIS_KEY_DEVICE_INFO); JSONArray deviceInfoJsonArr = new JSONArray(); -// JSONObject deviceInfoJson; if (StringUtils.isNotEmpty(deviceInfoStr)) { deviceInfoJsonArr = JSON.parseArray(deviceInfoStr); } @@ -164,7 +170,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { deviceInfoJsonArr.add(deviceInfoJson); } - redisTemplate.opsForValue().set(HwDictConstants.REDIS_KEY_DEVICE_INFO, deviceInfoJsonArr.toJSONString()); + redisTemplate.opsForValue().set(HwDictConstants.REDIS_KEY_DEVICE_INFO, deviceInfoJsonArr.toString()); } } catch (Exception e) { throw new RuntimeException(e.getMessage()); @@ -179,10 +185,45 @@ public class HwDeviceServiceImpl implements IHwDeviceService { */ private void createTdTable(HwDevice hwDevice) { TdTableVo tdTableVo = new TdTableVo(); - String databaseName = TdEngineConstants.getDatabaseName(1L); + String databaseName = TdEngineConstants.getDatabaseName(hwDevice.getSceneId()); String superTableName = TdEngineConstants.getSuperTableName(hwDevice.getDeviceModeId()); - String tableName = TdEngineConstants.getTableName(hwDevice.getDeviceId()); + String tableName = TdEngineConstants.getDeviceDataTableName(hwDevice.getDeviceId()); + List tagsFields = getTdTagsFields(hwDevice); + + tdTableVo.setDatabaseName(databaseName); + tdTableVo.setSuperTableName(superTableName); + tdTableVo.setTableName(tableName); + tdTableVo.setTagsFieldValues(tagsFields); + + R tdReturnMsg = this.remoteTdEngineService.createTable(tdTableVo); + if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 + throw new RuntimeException(tdReturnMsg.getMsg()); + } + } + + private void createTdDeviceStatusTable(HwDevice hwDevice) { + TdTableVo tdTableVo = new TdTableVo(); + tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); + tdTableVo.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME); + tdTableVo.setTableName(TdEngineConstants.getDeviceStatusTableName(hwDevice.getDeviceId())); + + List tagsFields = getTdTagsFields(hwDevice); + + TdField sceneIdTag = new TdField(); + sceneIdTag.setFieldName(TdEngineConstants.ST_TAG_SCENEID); + sceneIdTag.setFieldValue(hwDevice.getSceneId()); + tagsFields.add(sceneIdTag); + + tdTableVo.setTagsFieldValues(tagsFields); + + R tdReturnMsg = this.remoteTdEngineService.createTable(tdTableVo); + if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 + throw new RuntimeException(tdReturnMsg.getMsg()); + } + } + + private List getTdTagsFields(HwDevice hwDevice) { List tagsFields = new ArrayList<>(); TdField deviceIdTag = new TdField(); @@ -212,17 +253,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService { monitorUnitIdTag.setFieldValue(hwDevice.getMonitorUnitId()); tagsFields.add(monitorUnitIdTag); - tdTableVo.setDatabaseName(databaseName); - tdTableVo.setSuperTableName(superTableName); - tdTableVo.setTableName(tableName); - tdTableVo.setTagsFieldValues(tagsFields); - - R tdReturnMsg = this.remoteTdEngineService.createTable(tdTableVo); - if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 - throw new RuntimeException(tdReturnMsg.getMsg()); - } + return tagsFields; } + /** * 查询3. 设备各类型占所有设备数量百分比饼状图(左下角) */ @@ -292,8 +326,8 @@ public class HwDeviceServiceImpl implements IHwDeviceService { */ private void updateTdEngine(HwDevice hwDevice, HwDevice dbDevice) { String deviceType = hwDevice.getDeviceType(); - String databaseName = TdEngineConstants.getDatabaseName(1L);//TODO - String tableName = TdEngineConstants.getTableName(hwDevice.getDeviceId()); + String databaseName = TdEngineConstants.getDatabaseName(hwDevice.getSceneId()); + String tableName = TdEngineConstants.getDeviceDataTableName(hwDevice.getDeviceId()); AlterTagVo alterTagVo = new AlterTagVo(); alterTagVo.setDatabaseName(databaseName); alterTagVo.setTableName(tableName); @@ -302,7 +336,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { || deviceType.equals(HwDictConstants.DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT)) { if (!hwDevice.getDeviceCode().equals(dbDevice.getDeviceCode())) { alterTagVo.setTagName(TdEngineConstants.ST_TAG_DEVICECODE); - alterTagVo.setTagValue("'"+hwDevice.getDeviceCode()+"'"); + alterTagVo.setTagValue("'" + hwDevice.getDeviceCode() + "'"); tdReturnMsg = this.remoteTdEngineService.alterTableTag(alterTagVo); if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 @@ -311,7 +345,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { } if (!hwDevice.getDeviceName().equals(dbDevice.getDeviceName())) { alterTagVo.setTagName(TdEngineConstants.ST_TAG_DEVICENAME); - alterTagVo.setTagValue("'"+hwDevice.getDeviceName()+"'"); + alterTagVo.setTagValue("'" + hwDevice.getDeviceName() + "'"); tdReturnMsg = this.remoteTdEngineService.alterTableTag(alterTagVo); if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 throw new RuntimeException(tdReturnMsg.getMsg()); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java index 0af93d0..372079a 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java @@ -1,21 +1,29 @@ package com.ruoyi.business.service.impl; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.business.domain.HwFenceArea; import com.ruoyi.business.domain.HwFenceTarget; import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo; import com.ruoyi.business.domain.VO.ElectronicFenceVo; +import com.ruoyi.business.mapper.HwFenceAreaMapper; import com.ruoyi.business.mapper.HwFenceTargetMapper; import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.datascope.annotation.DataScope; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.business.mapper.HwElectronicFenceMapper; import com.ruoyi.business.domain.HwElectronicFence; import com.ruoyi.business.service.IHwElectronicFenceService; +import org.springframework.transaction.annotation.Transactional; /** * 电子围栏Service业务层处理 @@ -31,6 +39,9 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { @Autowired private HwFenceTargetMapper hwFenceTargetMapper; + @Autowired + private HwFenceAreaMapper hwFenceAreaMapper; + /** * 查询电子围栏 * @@ -39,7 +50,48 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { */ @Override public HwElectronicFence selectHwElectronicFenceByElectronicFenceId(Long electronicFenceId) { - return hwElectronicFenceMapper.selectHwElectronicFenceByElectronicFenceId(electronicFenceId); + HwElectronicFence electronicFence = hwElectronicFenceMapper.selectHwElectronicFenceByElectronicFenceId(electronicFenceId); + HwFenceArea queryFenceArea = new HwFenceArea(); + queryFenceArea.setElectronicFenceId(electronicFence.getElectronicFenceId()); + List fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea); + JSONArray polygonJsonArr = new JSONArray(); + JSONArray circleJsonArr = new JSONArray(); + if (fenceAreas != null && !fenceAreas.isEmpty()) { + int polygonIndex = 0; + int circleIndex = 0; + for (HwFenceArea fenceArea : fenceAreas) { + String areaShapeFlag = fenceArea.getAreaShapeFlag(); + String areaRange = fenceArea.getAreaRange(); + if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) { + String[] polygonRangePointsArr = areaRange.split("_"); + for (String polygonRangePoint : polygonRangePointsArr) { + JSONObject polygonJson = new JSONObject(); + polygonJson.put("longitude", new BigDecimal(polygonRangePoint.split(",")[0])); + polygonJson.put("latitude", new BigDecimal(polygonRangePoint.split(",")[1])); + polygonJson.put("index", polygonIndex); + polygonJsonArr.add(polygonJson); + } + polygonIndex++; + + } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) { + String[] circleRangePointsArr = areaRange.split(","); + JSONObject circleJson = new JSONObject(); + JSONArray centerPointJsonArr = new JSONArray(); + centerPointJsonArr.add(new BigDecimal(circleRangePointsArr[0])); + centerPointJsonArr.add(new BigDecimal(circleRangePointsArr[1])); + circleJson.put("center", centerPointJsonArr.toString()); + circleJson.put("radius", new BigDecimal(circleRangePointsArr[2])); + circleJson.put("index", circleIndex); + circleJsonArr.add(circleJson); + + circleIndex++; + + } + } + } + electronicFence.setCircleAreaListStr(circleJsonArr.toString()); + electronicFence.setPolygonAreaListStr(polygonJsonArr.toString()); + return electronicFence; } @Override @@ -54,49 +106,54 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { queryElectronicFence.setSceneId(sceneId); List electronicFenceList = hwElectronicFenceMapper.selectHwElectronicFenceList(queryElectronicFence); electronicFenceList.forEach(electronicFence -> { - ElectronicFenceVo e = new ElectronicFenceVo(); - String fenceType = electronicFence.getFenceType(); - String areaShapeFlag = electronicFence.getAreaShapeFlag(); - String areaRange = electronicFence.getAreaRange(); - Integer deviceCount = 0; - if (fenceType.equals(HwDictConstants.FENCE_TYPE_DEVICE) - || fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { - deviceCount = hwElectronicFenceMapper.selectDeviceCount(electronicFence.getElectronicFenceId()); - } - - if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { - deviceCount = hwElectronicFenceMapper.selectDeviceCountByMonitorUnit(electronicFence.getElectronicFenceId()); - - } else if (fenceType.equals(HwDictConstants.FENCE_TYPE_SCENE)) { - deviceCount = hwElectronicFenceMapper.selectDeviceCountByScene(electronicFence.getSceneId()); - } - - if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) { - String[] areaRangeArr = areaRange.split("_"); - List points = new ArrayList(); - for (String areaR : areaRangeArr) { - String[] areaRArr = areaR.split(","); - ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint(); - p.setLongitude(Double.valueOf(areaRArr[0])); - p.setLatitude(Double.valueOf(areaRArr[1])); - points.add(p); + HwFenceArea queryFenceArea = new HwFenceArea(); + queryFenceArea.setElectronicFenceId(electronicFence.getElectronicFenceId()); + List fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea); + for (HwFenceArea fenceArea : fenceAreas) { + ElectronicFenceVo e = new ElectronicFenceVo(); + String fenceType = electronicFence.getFenceType(); + String areaShapeFlag = fenceArea.getAreaShapeFlag(); + String areaRange = fenceArea.getAreaRange(); + Integer deviceCount = 0; + if (fenceType.equals(HwDictConstants.FENCE_TYPE_DEVICE) + || fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { + deviceCount = hwElectronicFenceMapper.selectDeviceCount(electronicFence.getElectronicFenceId()); } - e.setAreaPoints(points); - } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) { - String[] areaRangeArr = areaRange.split(","); - ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint(); - p.setLongitude(Double.valueOf(areaRangeArr[0])); - p.setLatitude(Double.valueOf(areaRangeArr[1])); + if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { + deviceCount = hwElectronicFenceMapper.selectDeviceCountByMonitorUnit(electronicFence.getElectronicFenceId()); - e.setCenterPoint(p); - e.setRadius(Double.valueOf(areaRangeArr[2])); + } else if (fenceType.equals(HwDictConstants.FENCE_TYPE_SCENE)) { + deviceCount = hwElectronicFenceMapper.selectDeviceCountByScene(electronicFence.getSceneId()); + } + + if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) { + String[] areaRangeArr = areaRange.split("_"); + List points = new ArrayList(); + for (String areaR : areaRangeArr) { + String[] areaRArr = areaR.split(","); + ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint(); + p.setLongitude(Double.valueOf(areaRArr[0])); + p.setLatitude(Double.valueOf(areaRArr[1])); + points.add(p); + } + e.setAreaPoints(points); + + } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) { + String[] areaRangeArr = areaRange.split(","); + ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint(); + p.setLongitude(Double.valueOf(areaRangeArr[0])); + p.setLatitude(Double.valueOf(areaRangeArr[1])); + + e.setCenterPoint(p); + e.setRadius(Double.valueOf(areaRangeArr[2])); + } + + e.setAbnormalCount(2);//todo 异常数量获取 + e.setAreaShapeFlag(areaShapeFlag); + e.setDeviceCount(deviceCount); + electronicFenceVos.add(e); } - - e.setAbnormalCount(2);//todo 异常数量获取 - e.setAreaShapeFlag(areaShapeFlag); - e.setDeviceCount(deviceCount); - electronicFenceVos.add(e); }); return electronicFenceVos; @@ -120,9 +177,107 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { * @return 结果 */ @Override + @Transactional public int insertHwElectronicFence(HwElectronicFence hwElectronicFence) { + hwElectronicFence.setFencePushFlag("0"); + hwElectronicFence.setFenceType("3"); hwElectronicFence.setCreateTime(DateUtils.getNowDate()); - return hwElectronicFenceMapper.insertHwElectronicFence(hwElectronicFence); + int rows = hwElectronicFenceMapper.insertHwElectronicFence(hwElectronicFence); + this.batchInsertFenceArea(hwElectronicFence); + return rows; + } + + private void batchInsertFenceArea(HwElectronicFence hwElectronicFence) { + Long electronicFenceId = hwElectronicFence.getElectronicFenceId(); + String polygonAreaListStr = hwElectronicFence.getPolygonAreaListStr(); + String circleAreaListStr = hwElectronicFence.getCircleAreaListStr(); + List fenceAreaList = new ArrayList<>(); + if (polygonAreaListStr != null) { + JSONArray polygonAreaJsonArray = JSON.parseArray(polygonAreaListStr); + Map polygonAreaJsonMap = new HashMap<>(); + for (Object polygonAreaObj : polygonAreaJsonArray) { + JSONObject polygonAreaJson = (JSONObject) polygonAreaObj; + Integer polygonAreaIndex = polygonAreaJson.getInteger("index"); + JSONArray polygonAreaArr = polygonAreaJsonMap.get(polygonAreaIndex); + if (polygonAreaArr == null) { + polygonAreaArr = new JSONArray(); + polygonAreaArr.add(polygonAreaJson); + polygonAreaJsonMap.put(polygonAreaIndex, polygonAreaArr); + } else { + polygonAreaArr.add(polygonAreaJson); + } + } + + //每个key有一个区域,多个点 + for (Map.Entry entry : polygonAreaJsonMap.entrySet()) { + JSONArray polygonPointList = entry.getValue(); + StringBuilder areaRange = new StringBuilder(); + int i = 0; + for (Object polygonPointObj : polygonPointList) { + JSONObject polygonPointJson = (JSONObject) polygonPointObj; + if (i > 0) { + areaRange.append("_"); + } else { + i++; + } + areaRange.append(polygonPointJson.getString("longitude")).append(",").append(polygonPointJson.getString("latitude")); + } + HwFenceArea polygonArea = new HwFenceArea(); + polygonArea.setElectronicFenceId(electronicFenceId); + polygonArea.setAreaShapeFlag(HwDictConstants.AREA_SHAPE_FLAG_POLYGN); + polygonArea.setAreaRange(areaRange.toString()); + fenceAreaList.add(polygonArea); + } + } + if (circleAreaListStr != null) { + JSONArray circleAreaJsonArray = JSON.parseArray(circleAreaListStr); + Map circleAreaJsonMap = new HashMap<>(); + for (Object circleAreaObj : circleAreaJsonArray) { + JSONObject circleAreaJson = (JSONObject) circleAreaObj; + Integer circleAreaIndex = circleAreaJson.getInteger("index"); + JSONArray circleAreaArr = circleAreaJsonMap.get(circleAreaIndex); + if (circleAreaArr == null) { + circleAreaArr = new JSONArray(); + circleAreaArr.add(circleAreaJson); + circleAreaJsonMap.put(circleAreaIndex, circleAreaArr); + } else { + circleAreaArr.add(circleAreaJson); + } + } + + //每个key有一个区域,多个点 + for (Map.Entry entry : circleAreaJsonMap.entrySet()) { + JSONArray circlePointList = entry.getValue(); + StringBuilder areaRange = new StringBuilder(); + int j = 0; + for (Object circlePointObj : circlePointList) { + JSONObject circlePointJson = (JSONObject) circlePointObj; + if (j > 0) { + areaRange.append(","); + } else { + j++; + } + JSONArray centerPointArr = circlePointJson.getJSONArray("center"); + BigDecimal longitude = (BigDecimal) centerPointArr.get(0); + BigDecimal latitude = (BigDecimal) centerPointArr.get(1); + areaRange.append(longitude).append(",") + .append(latitude).append(",") + .append(circlePointJson.getString("radius")); + } + HwFenceArea polygonArea = new HwFenceArea(); + polygonArea.setElectronicFenceId(electronicFenceId); + polygonArea.setAreaShapeFlag(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA); + polygonArea.setAreaRange(areaRange.toString()); + fenceAreaList.add(polygonArea); + } + + } + + if (!fenceAreaList.isEmpty()) { + for (HwFenceArea area : fenceAreaList) { + hwFenceAreaMapper.insertHwFenceArea(area); + } + } } /** @@ -133,6 +288,13 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { */ @Override public int updateHwElectronicFence(HwElectronicFence hwElectronicFence) { + HwFenceArea queryFenceArea = new HwFenceArea(); + queryFenceArea.setElectronicFenceId(hwElectronicFence.getElectronicFenceId()); + List dbFenceAreaList = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea); + for (HwFenceArea dbFenceArea : dbFenceAreaList) { + hwFenceAreaMapper.deleteHwFenceAreaByFenceAreaId(dbFenceArea.getFenceAreaId()); + } + this.batchInsertFenceArea(hwElectronicFence); hwElectronicFence.setUpdateTime(DateUtils.getNowDate()); return hwElectronicFenceMapper.updateHwElectronicFence(hwElectronicFence); } @@ -158,4 +320,18 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { public int deleteHwElectronicFenceByElectronicFenceId(Long electronicFenceId) { return hwElectronicFenceMapper.deleteHwElectronicFenceByElectronicFenceId(electronicFenceId); } + + + /** + * 查询电子围栏列表Join场景 + * + * @param hwElectronicFence 电子围栏 + * @return 电子围栏 + */ + @Override + @DataScope(tenantAlias = "hef") + public List selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence) { + return hwElectronicFenceMapper.selectHwElectronicFenceJoinList(hwElectronicFence); + } + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java index 16abf40..ed47593 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java @@ -1,5 +1,28 @@ package com.ruoyi.business.service.impl; +import com.ruoyi.business.domain.HwAlarmInfo; +import com.ruoyi.business.domain.HwDevice; +import com.ruoyi.business.domain.HwMonitorUnit; +import com.ruoyi.business.domain.VO.*; +import com.ruoyi.business.mapper.HwAlarmInfoMapper; +import com.ruoyi.business.mapper.HwDeviceMapper; +import com.ruoyi.business.mapper.HwElectronicFenceMapper; +import com.ruoyi.business.mapper.HwMonitorUnitMapper; +import com.ruoyi.business.service.IHwMonitorUnitService; +import com.ruoyi.common.core.constant.TdEngineConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.NumberUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.datascope.annotation.DataScope; +import com.ruoyi.tdengine.api.RemoteTdEngineService; +import com.ruoyi.tdengine.api.domain.DeviceStatus; +import com.ruoyi.tdengine.api.domain.TdSelectDto; +import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -8,26 +31,6 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; -import com.ruoyi.business.domain.HwDevice; -import com.ruoyi.business.domain.VO.*; -import com.ruoyi.business.mapper.HwDeviceMapper; -import com.ruoyi.business.mapper.HwElectronicFenceMapper; -import com.ruoyi.common.core.constant.TdEngineConstants; -import com.ruoyi.common.core.domain.R; -import com.ruoyi.common.core.utils.DateUtils; -import com.ruoyi.common.core.utils.StringUtils; -import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.system.api.domain.SysUser; -import com.ruoyi.system.api.model.LoginUser; -import com.ruoyi.tdengine.api.RemoteTdEngineService; -import com.ruoyi.tdengine.api.domain.DeviceStatus; -import com.ruoyi.tdengine.api.domain.TdSelectDto; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.business.mapper.HwMonitorUnitMapper; -import com.ruoyi.business.domain.HwMonitorUnit; -import com.ruoyi.business.service.IHwMonitorUnitService; - /** * 监控单元Service业务层处理 * @@ -35,8 +38,7 @@ import com.ruoyi.business.service.IHwMonitorUnitService; * @date 2023-08-31 */ @Service -public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService -{ +public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService { @Autowired private HwMonitorUnitMapper hwMonitorUnitMapper; @Autowired @@ -45,9 +47,8 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService private RemoteTdEngineService remoteTdEgineService; @Autowired private HwDeviceMapper hwDeviceMapper; - - - + @Autowired + private HwAlarmInfoMapper hwAlarmInfoMapper; /** * 查询监控单元 @@ -56,106 +57,106 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService * @return 监控单元 */ @Override - public HwMonitorUnit selectHwMonitorUnitByMonitorUnitId(Long monitorUnitId) - { + public HwMonitorUnit selectHwMonitorUnitByMonitorUnitId(Long monitorUnitId) { return hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId(monitorUnitId); } + /** * 查询区域数量站场景区总数百分比 - * */ + */ @Override public List selectMonitorPercentage() { +// HwMonitorUnit queryMonitorUnit = new HwMonitorUnit(); +// List list = hwMonitorUnitMapper.selectHwMonitorUnitListJoinScene(queryMonitorUnit); +// Map> monitorUnitMap = list.stream() +// .collect(Collectors.groupingBy(HwMonitorUnit::getSceneId)); +// List monitorUnitVoList = new ArrayList<>(); +// +// +// Set keys = monitorUnitMap.keySet(); +// for(Long key:keys){ +// Integer value = monitorUnitMap.get(key); +// System.out.println(key+"\t"+value); +// } List list = hwMonitorUnitMapper.selectMonitorPercentage(); List hwScenes = hwMonitorUnitMapper.selectSceneNameById(); - int count = hwScenes.size(); - if (list.size()<=hwScenes.size()) { - count = list.size(); - } - for (int i = 0; i < count; i++) { - for (int j = 0;j { + for (int i = 0; i < hwScenes.size(); i++) { + if (l.getSceneId().equals(hwScenes.get(i).getSceneId())) { + l.setSceneName(hwScenes.get(i).getSceneName()); } } - } + }); + Integer value = 0; // Integer sums = 0; - if (list.size()>5){ - for (int i = 4; i < list.size(); i++){ - if (list.get(i).sum==null){ - list.get(i).sum = 0; - } - value = value+list.get(i).sum; - } - } - for (int i = 0; i < list.size();i++){ - if (list.get(i).sum==null){ +// if (list.size() > 5) { +// for (int i = 4; i < list.size(); i++) {//这是剩下的总数 +// if (list.get(i).sum == null) { +// list.get(i).sum = 0; +// } +// value = value + list.get(i).sum; +// } +// } + for (int i = 0; i < list.size(); i++) { + if (list.get(i).sum == null) { list.get(i).sum = 0; } - sums = sums+list.get(i).sum; + sums = sums + list.get(i).sum; } - for (int i=0;i alarmInfos = hwAlarmInfoMapper.selectHwAlarmInfoList(queryAlarmInfo); + Integer alarmInfoSize = alarmInfos == null ? 0 : alarmInfos.size(); + hwMonitorUnitVo.setErr(alarmInfoSize); } - HwMonitorUnitVo hwMonitorUnitVo = new HwMonitorUnitVo(); - hwMonitorUnitVo.setSceneName("其他"); - hwMonitorUnitVo.setSum(value); - if (list.size()>5){ - list.add(5,hwMonitorUnitVo); - return list.subList(0,5); - } - else { - return list; - } +// HwMonitorUnitVo hwMonitorUnitVo = new HwMonitorUnitVo(); +// hwMonitorUnitVo.setSceneName("其他"); +// hwMonitorUnitVo.setSum(value); + +// if (list.size() > 5) { +// list.add(5, hwMonitorUnitVo); +// return list.subList(0, 5); +// } else { +// return list; +// } + return list; } //获取总的设备数量与监控单元数量 @Override - public AllNumsVo selectAllNums() { + public AllNumsVo selectAllNums(Long sceneId) { //监控单元 - String monitor = hwMonitorUnitMapper.selectSubSetNums(); - String integer = hwMonitorUnitMapper.selectDeviceNums(); - System.out.println(monitor+" dsaas "+integer); - Integer monitor1 = 0; - Integer monitor2 = 0; - + Integer monitor = hwMonitorUnitMapper.selectSubSetNums(sceneId) == null ? 0 + : hwMonitorUnitMapper.selectSubSetNums(sceneId); + Integer integer = hwMonitorUnitMapper.selectDeviceNums(sceneId) == null ? 0 + : hwMonitorUnitMapper.selectDeviceNums(sceneId); AllNumsVo vo = new AllNumsVo(); - if (monitor == null){ - monitor1 = 0; - } - else { - monitor1 = Integer.valueOf(monitor); - } - if (integer == null){ - monitor2 = 0; - } - else { - monitor2 = Integer.valueOf(integer); - } - vo.setSubSum(monitor1); - vo.setSum(monitor2); - - + vo.setSubSum(monitor); + vo.setSum(integer); return vo; } - - @Override - public List selectSenceAllNums() { - List allNumsVos = hwMonitorUnitMapper.selectAllNums(); - List allNums = hwMonitorUnitMapper.selectsum(); - for (int i=0;i< allNums.size();i++){ - for (int j=0;j< allNums.size();j++){ - if (allNums.get(i).getSceneId().equals(allNumsVos.get(i).getSceneId())){ - allNums.get(i).setSubSum(allNumsVos.get(i).getSubSum()); - } - } - } - return allNums; - } +// @Override +// public List selectSenceAllNums() { +// List allNumsVos = hwMonitorUnitMapper.selectAllNums(); +// List allNums = hwMonitorUnitMapper.selectsum(); +// for (int i = 0; i < allNums.size(); i++) { +// for (int j = 0; j < allNums.size(); j++) { +// if (allNums.get(i).getSceneId().equals(allNumsVos.get(i).getSceneId())) { +// allNums.get(i).setSubSum(allNumsVos.get(i).getSubSum()); +// } +// } +// } +// return allNums; +// } @Override public List selectLimitSubMonitorUnit() { @@ -165,8 +166,8 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService } @Override - public List selectAlarmStats() { - return hwMonitorUnitMapper.selectAlarmStats(); + public List selectAlarmStats(Long sceneId) { + return hwMonitorUnitMapper.selectAlarmStats(sceneId); } @@ -177,155 +178,72 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService * @return 监控单元 */ @Override - public List selectHwMonitorUnitList(HwMonitorUnit hwMonitorUnit) - { + public List selectHwMonitorUnitList(HwMonitorUnit hwMonitorUnit) { return hwMonitorUnitMapper.selectHwMonitorUnitList(hwMonitorUnit); } @Override public SubDeviceSumVo selectSubDeviceSum(Long sceneId) { - int SubSum = hwMonitorUnitMapper.selectSubDeviceSum(sceneId); - List hwDevices = hwDeviceMapper.selectDeviceNum(sceneId); - int onlineDevice = 0; - for (int i = 0;i longs = hwMonitorUnitMapper.selectEleInScene(sceneId); - return null; - } - @Override public HwMonitorUnit selectHwmonitorUnitSub(Long monitorUnitId) { - return hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId(monitorUnitId); + return hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId(monitorUnitId); } + //todo SysDeptServiceImpl类中的递归方法recursionFn(以实现) @Override - // 加一个begintime参数,endtime参数 stream时间戳 从开始时间0点开始,结束时间23.59.59结束 - public Map selectTdengine(String beginTime, String endTime, Long sceneId) { - DeviceStatus queryDeviceStatus = new DeviceStatus(); - - Map params = queryDeviceStatus.getParams(); - DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); - System.out.println(ofPattern); - LocalDate parse = LocalDate.parse(beginTime, ofPattern); - long begintime = parse.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli(); - - DateTimeFormatter ofPattern1 = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); - LocalDate parse1 = LocalDate.parse(endTime, ofPattern); - long endtime = LocalDateTime.of(parse1, LocalTime.MAX).toInstant(ZoneOffset.of("+8")).toEpochMilli(); - - params.put("beginTime",begintime); - params.put("endTime", endtime); - queryDeviceStatus.setParams(params); - if (sceneId != null) { - queryDeviceStatus.setSceneId(sceneId); + public List selectTreeList(List hwMonitorUnits) { + List returnList = new ArrayList<>(); + List tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList()); + List treeList = new ArrayList<>(); + for (HwMonitorUnit hwMonitorUnit : hwMonitorUnits) { + if (!tempList.contains(hwMonitorUnit.getParentId())) + recursionFn(hwMonitorUnits, hwMonitorUnit); + returnList.add(hwMonitorUnit); } - - int sum = 0; - int values[] = new int[10]; - Map valuesMap = new HashMap<>(); - //todo 使用id(以解决) - //map key时间戳,value List 对象 - R r = remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus); - Map> deviceStatusMap = (Map>) r.getData(); - List list = (List) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus); - Set longs = deviceStatusMap.keySet(); - for (Object key:longs){ - List deviceStatuses = deviceStatusMap.get(key); - for (int i=0;i>> selectLatestDataByTags(Long monitorUnitId) { -// - R>> latestDataByTags = new R>>(); - List hwDevices = hwDeviceMapper.selectDeviceByMonitorId(monitorUnitId); - TdSelectDto tdSelectDto = new TdSelectDto(); - for (int i = 0; i < hwDevices.size(); i++){ - tdSelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); - tdSelectDto.setTableName(TdEngineConstants.getDeviceDataTableName(hwDevices.get(i).getDeviceId())); - tdSelectDto.setTagsName(hwDevices.get(i).getDeviceCode()); - - latestDataByTags = remoteTdEgineService.getLatestDataByTags(tdSelectDto); - } - return latestDataByTags; - } - -//todo SysDeptServiceImpl类中的递归方法recursionFn(以实现) -@Override -public List selectTreeList(List hwMonitorUnits) { - List returnList = new ArrayList<>(); - List tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList()); - List treeList = new ArrayList<>(); - for (HwMonitorUnit hwMonitorUnit:hwMonitorUnits){ - if (!tempList.contains(hwMonitorUnit.getParentId())) - recursionFn(hwMonitorUnits,hwMonitorUnit); - returnList.add(hwMonitorUnit); - } - for (int i = 0; i < returnList.size(); i++){ - if (returnList.get(i).getParentId()==null){ - treeList.add(returnList.get(i)); - } - } - return treeList; -} - private void recursionFn(List list, HwMonitorUnit t) - { + private void recursionFn(List list, HwMonitorUnit t) { // 得到子节点列表 List childList = getChildList(list, t); t.setChild(childList); - for (HwMonitorUnit tChild : childList) - { - if (hasChild(list, tChild)) - { + for (HwMonitorUnit tChild : childList) { + if (hasChild(list, tChild)) { recursionFn(list, tChild); } } } - private List getChildList(List list, HwMonitorUnit t) - { + + private List getChildList(List list, HwMonitorUnit t) { List tlist = new ArrayList(); Iterator it = list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { HwMonitorUnit n = (HwMonitorUnit) it.next(); - if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMonitorUnitId().longValue()) - { + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMonitorUnitId().longValue()) { tlist.add(n); } } return tlist; } - private boolean hasChild(List list, HwMonitorUnit t) - { + + private boolean hasChild(List list, HwMonitorUnit t) { return getChildList(list, t).size() > 0 ? true : false; } @@ -336,32 +254,10 @@ public List selectTreeList(List hwMonitorUnits) { * @return 结果 */ @Override - public int insertHwMonitorUnit(HwMonitorUnit hwMonitorUnit) - { - //少一个离线报警规则 todo - //根据父级监控单元id查询是否关联了设备,若关联则不能添加 - if ( - hwMonitorUnitMapper.selectDeviceRelevancyMontiorUnit(hwMonitorUnit.getParentId())==0 - && hwMonitorUnitMapper.selectElectronicFenceRelevancyMonitorUnit(hwMonitorUnit.getParentId())==0 - ){ //如果是无父级的监控单元,后台赋null,前端赋null会报错 - if (hwMonitorUnit.getParentId()==0){ - hwMonitorUnit.setParentId(null); - } - //如果该监控单元拥有父级监控单元,则场景继承其父级监控单元 - else if (hwMonitorUnit.getParentId()!=0&&hwMonitorUnit.getParentId()!=null){ - hwMonitorUnit.setSceneId( - hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId( - hwMonitorUnit.getParentId()).getSceneId()); - } - - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser sysUser = loginUser.getSysUser(); - hwMonitorUnit.setTenantId(sysUser.getTenantId()); - - hwMonitorUnit.setCreateTime(DateUtils.getNowDate()); - return hwMonitorUnitMapper.insertHwMonitorUnit(hwMonitorUnit); - } - return 0; + public int insertHwMonitorUnit(HwMonitorUnit hwMonitorUnit) { + this.checkRelatedDevices(hwMonitorUnit); + hwMonitorUnit.setCreateTime(DateUtils.getNowDate()); + return hwMonitorUnitMapper.insertHwMonitorUnit(hwMonitorUnit); } /** @@ -371,8 +267,8 @@ public List selectTreeList(List hwMonitorUnits) { * @return 结果 */ @Override - public int updateHwMonitorUnit(HwMonitorUnit hwMonitorUnit) - { + public int updateHwMonitorUnit(HwMonitorUnit hwMonitorUnit) { + this.checkRelatedDevices(hwMonitorUnit); hwMonitorUnit.setUpdateTime(DateUtils.getNowDate()); return hwMonitorUnitMapper.updateHwMonitorUnit(hwMonitorUnit); } @@ -384,18 +280,7 @@ public List selectTreeList(List hwMonitorUnits) { * @return 结果 */ @Override - public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds) - { - //先查询是否有子集,如果有返回error 如果没有则逻辑删除 - for (Long monitorUnitId : monitorUnitIds){ - if (hwMonitorUnitMapper.selectIsParent(monitorUnitId)!=0){ - return 0; - } - else{ - hwMonitorUnitMapper.deleteHwMonitorUnitByMonitorUnitId(monitorUnitId); - return 1; - } - } + public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds) { return hwMonitorUnitMapper.deleteHwMonitorUnitByMonitorUnitIds(monitorUnitIds); } @@ -406,38 +291,118 @@ public List selectTreeList(List hwMonitorUnits) { * @return 结果 */ @Override - public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId) - { + public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId) { return hwMonitorUnitMapper.deleteHwMonitorUnitByMonitorUnitId(monitorUnitId); } - @Override - public int getMonitorIsRelevancy(Long monitorUnitId) { - if (hwMonitorUnitMapper.selectDeviceRelevancyMontiorUnit(monitorUnitId)==0 - && hwMonitorUnitMapper.selectElectronicFenceRelevancyMonitorUnit(monitorUnitId)==0 - ){ - return 1; - } - return 0; - } -} -//remoteTdEngineSevice.getOnlineDevicesGroupByDay方法获取 -// 参数实例: -// // params.put("beginTime", beginTime); -//// params.put("endTime", endTime); -//// queryDeviceStatus.setParams(params); -//// if (sceneId != null) { -//// queryDeviceStatus.setSceneId(sceneId); -//// } -// -// 这是IDEA参数传的参数Content-Type: application/json -// { -// "params": { "beginTime":1666666666666,"endTime":1766666666666 } -// -// } -// -// 如果在IDEA测试可以{ -// "params": {"databaseName":"db_scene_1","superTableName":"st_ds_1", -// "beginTime":1666666666666,"endTime":1766666666666 } -// } + /** + * 查询监控单元树结构信息 + * + * @param hwMonitorUnit 监控单元信息 + * @return 监控单元树信息集合 + */ + @Override + @DataScope(tenantAlias = "hmu") + public List selectMonitorTreeList(HwMonitorUnit hwMonitorUnit) { + List hwMonitorUnits = this.selectHwMonitorUnitList(hwMonitorUnit); + return buildMonitorUnitTreeSelect(hwMonitorUnits); + } + + /** + * 构建前端所需要下拉树结构 + * + * @param hwMonitorUnits 监控单元列表 + * @return 下拉树结构列表 + */ + @Override + public List buildMonitorUnitTreeSelect(List hwMonitorUnits) { + List monitorUnitTrees = buildMonitorUnitTree(hwMonitorUnits); + return monitorUnitTrees.stream().map(TreeSelectVo::new).collect(Collectors.toList()); + } + + /** + * 构建前端所需要树结构 + * + * @param hwMonitorUnits 监控单元列表 + * @return 树结构列表 + */ + @Override + public List buildMonitorUnitTree(List hwMonitorUnits) { + List returnList = new ArrayList(); + List tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList()); + for (HwMonitorUnit monitorUnit : hwMonitorUnits) { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(monitorUnit.getParentId())) { + recursionFn1(hwMonitorUnits, monitorUnit); + returnList.add(monitorUnit); + } + } + if (returnList.isEmpty()) { + returnList = hwMonitorUnits; + } + return returnList; + + } + + /** + * 递归列表 + */ + private void recursionFn1(List list, HwMonitorUnit t) { + // 得到子节点列表 + List childList = getChildList1(list, t); + t.setChildren(childList); + for (HwMonitorUnit tChild : childList) { + if (hasChild1(list, tChild)) { + recursionFn1(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList1(List list, HwMonitorUnit t) { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) { + HwMonitorUnit n = (HwMonitorUnit) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMonitorUnitId().longValue()) { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild1(List list, HwMonitorUnit t) { + return getChildList1(list, t).size() > 0 ? true : false; + } + + + /** + * 查询监控单元列表,Join监控单元类型,租户和场景 + * + * @param hwMonitorUnit 监控单元 + * @return 监控单元 + */ + @Override + @DataScope(tenantAlias = "hmu") + public List selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit) { + return hwMonitorUnitMapper.selectHwMonitorUnitJoinList(hwMonitorUnit); + } + + private void checkRelatedDevices(HwMonitorUnit hwMonitorUnit) { + HwDevice queryDevice = new HwDevice(); + if (hwMonitorUnit.getParentId() != null) { + queryDevice.setMonitorUnitId(hwMonitorUnit.getParentId()); + List devices = hwDeviceMapper.selectHwDeviceList(queryDevice); + if (devices != null && !devices.isEmpty()) { + throw new ServiceException("此父级单元已关联设备,请重新选择"); + } + } + } + +} diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java index 12a4920..e553497 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java @@ -4,9 +4,7 @@ import java.util.List; import com.ruoyi.business.domain.VO.HwMonitorUnitVo; import com.ruoyi.common.core.utils.DateUtils; -import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.system.api.domain.SysUser; -import com.ruoyi.system.api.model.LoginUser; +import com.ruoyi.common.datascope.annotation.DataScope; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.business.mapper.HwMonitorUnitTypeMapper; @@ -44,13 +42,9 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService * @return 监控单元类型 */ @Override + @DataScope(tenantAlias = "hmut") public List selectHwMonitorUnitTypeList(HwMonitorUnitType hwMonitorUnitType) { - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser sysUser = loginUser.getSysUser(); - if (!sysUser.getUserName().equals("admin")){ - hwMonitorUnitType.setTenantId(sysUser.getTenantId()); - } return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeList(hwMonitorUnitType); } @@ -64,12 +58,6 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService @Override public int insertHwMonitorUnitType(HwMonitorUnitType hwMonitorUnitType) { - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser sysUser = loginUser.getSysUser(); - hwMonitorUnitType.setMonitorUnitTypeStatus("1"); - hwMonitorUnitType.setCommonFlag("1"); - hwMonitorUnitType.setTenantId(sysUser.getTenantId()); - hwMonitorUnitType.setCreateBy(sysUser.getNickName()); hwMonitorUnitType.setCreateTime(DateUtils.getNowDate()); return hwMonitorUnitTypeMapper.insertHwMonitorUnitType(hwMonitorUnitType); } @@ -83,9 +71,6 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService @Override public int updateHwMonitorUnitType(HwMonitorUnitType hwMonitorUnitType) { - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser sysUser = loginUser.getSysUser(); - hwMonitorUnitType.setCreateBy(sysUser.getNickName()); hwMonitorUnitType.setUpdateTime(DateUtils.getNowDate()); return hwMonitorUnitTypeMapper.updateHwMonitorUnitType(hwMonitorUnitType); } @@ -99,12 +84,6 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService @Override public int deleteHwMonitorUnitTypeByMonitorUnitTypeIds(Long[] monitorUnitTypeIds) { - for (Long monitorUnitTypeId : monitorUnitTypeIds){ - if (hwMonitorUnitTypeMapper.getNumsHwMonitorUnitTypeByMonitorUnitTypeId(monitorUnitTypeId)!=0){ - return 0; - } - } - return hwMonitorUnitTypeMapper.deleteHwMonitorUnitTypeByMonitorUnitTypeIds(monitorUnitTypeIds); } @@ -117,11 +96,30 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService @Override public int deleteHwMonitorUnitTypeByMonitorUnitTypeId(Long monitorUnitTypeId) { - if (hwMonitorUnitTypeMapper.getNumsHwMonitorUnitTypeByMonitorUnitTypeId(monitorUnitTypeId)!=0){ - System.out.println(hwMonitorUnitTypeMapper.getNumsHwMonitorUnitTypeByMonitorUnitTypeId(monitorUnitTypeId)); - return 0; - } - return hwMonitorUnitTypeMapper.deleteHwMonitorUnitTypeByMonitorUnitTypeId(monitorUnitTypeId); } + + /** + * 查询监控单元类型列表供编辑页面使用,不过滤权限,设置条件查询 + * + * @param hwMonitorUnitType 监控单元类型 + * @return 监控单元类型集合 + */ + public List selectHwMonitorUnitTypeList4Select(HwMonitorUnitType hwMonitorUnitType){ + return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeList(hwMonitorUnitType); + } + + /** + * 查询监控单元类型列表,Join租户和场景 + * + * @param hwMonitorUnitType 监控单元类型 + * @return 监控单元类型 + */ + @Override + @DataScope(tenantAlias = "hmut") + public List selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType) + { + return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType); + } + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwTenantServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwTenantServiceImpl.java index 4c1ec82..5c856e3 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwTenantServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwTenantServiceImpl.java @@ -10,19 +10,19 @@ import com.ruoyi.business.service.IHwTenantService; /** * 租户信息Service业务层处理 - * + * * @author xins * @date 2023-09-04 */ @Service -public class HwTenantServiceImpl implements IHwTenantService +public class HwTenantServiceImpl implements IHwTenantService { @Autowired private HwTenantMapper hwTenantMapper; /** * 查询租户信息 - * + * * @param tenantId 租户信息主键 * @return 租户信息 */ @@ -34,7 +34,7 @@ public class HwTenantServiceImpl implements IHwTenantService /** * 查询租户信息列表 - * + * * @param hwTenant 租户信息 * @return 租户信息 */ @@ -46,7 +46,7 @@ public class HwTenantServiceImpl implements IHwTenantService /** * 新增租户信息 - * + * * @param hwTenant 租户信息 * @return 结果 */ @@ -59,7 +59,7 @@ public class HwTenantServiceImpl implements IHwTenantService /** * 修改租户信息 - * + * * @param hwTenant 租户信息 * @return 结果 */ @@ -72,27 +72,25 @@ public class HwTenantServiceImpl implements IHwTenantService /** * 批量删除租户信息 - * + * * @param tenantIds 需要删除的租户信息主键 * @return 结果 */ @Override public int deleteHwTenantByTenantIds(Long[] tenantIds) { - return hwTenantMapper.deleteHwTenantByTenantIds(tenantIds); } /** * 删除租户信息信息 - * + * * @param tenantId 租户信息主键 * @return 结果 */ @Override public int deleteHwTenantByTenantId(Long tenantId) { - return hwTenantMapper.deleteHwTenantByTenantId(tenantId); } } diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml index d5abd95..f7c5fc9 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml @@ -3,18 +3,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + - - @@ -24,12 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - + @@ -43,123 +37,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select electronic_fence_id, electronic_fence_name, scene_id, fence_type, effective_time_flag, time_zone, effective_time, trigger_status, area_shape_flag, area_range, fence_push_flag, fence_push_content, fence_recover_content, remark, create_by, create_time, update_by, update_time, fence_field from hw_electronic_fence + select electronic_fence_id, electronic_fence_name, tenant_id, scene_id, fence_type, effective_time_flag, time_zone, effective_time, trigger_status, fence_push_flag, fence_push_content, fence_recover_content, remark, create_by, create_time, update_by, update_time, fence_field from hw_electronic_fence - - - - - - - - - - - - - + - + insert into hw_electronic_fence electronic_fence_name, + tenant_id, scene_id, fence_type, effective_time_flag, time_zone, effective_time, trigger_status, - area_shape_flag, - area_range, fence_push_flag, fence_push_content, fence_recover_content, @@ -172,14 +89,13 @@ GROUP BY #{electronicFenceName}, + #{tenantId}, #{sceneId}, #{fenceType}, #{effectiveTimeFlag}, #{timeZone}, #{effectiveTime}, #{triggerStatus}, - #{areaShapeFlag}, - #{areaRange}, #{fencePushFlag}, #{fencePushContent}, #{fenceRecoverContent}, @@ -196,14 +112,13 @@ GROUP BY update hw_electronic_fence electronic_fence_name = #{electronicFenceName}, + tenant_id = #{tenantId}, scene_id = #{sceneId}, fence_type = #{fenceType}, effective_time_flag = #{effectiveTimeFlag}, time_zone = #{timeZone}, effective_time = #{effectiveTime}, trigger_status = #{triggerStatus}, - area_shape_flag = #{areaShapeFlag}, - area_range = #{areaRange}, fence_push_flag = #{fencePushFlag}, fence_push_content = #{fencePushContent}, fence_recover_content = #{fenceRecoverContent}, @@ -222,30 +137,52 @@ GROUP BY - delete from hw_electronic_fence where electronic_fence_id in + delete from hw_electronic_fence where electronic_fence_id in + + #{electronicFenceId} + + + + + delete from hw_fence_target where electronic_fence_id in #{electronicFenceId} - + select hef.electronic_fence_id,hef.electronic_fence_name,hef.fence_type,hef.trigger_status, + hs.scene_name + from hw_electronic_fence hef + left join hw_scene hs on hef.scene_id = hs.scene_id + + and hef.electronic_fence_name like concat('%', #{electronicFenceName}, '%') + and hef.tenant_id = #{tenantId} + and hef.scene_id = #{sceneId} + and hef.fence_type = #{fenceType} + and hef.effective_time_flag = #{effectiveTimeFlag} + and hef.time_zone = #{timeZone} + and hef.effective_time = #{effectiveTime} + and hef.trigger_status = #{triggerStatus} + and hef.fence_push_flag = #{fencePushFlag} + and hef.fence_push_content = #{fencePushContent} + and hef.fence_recover_content = #{fenceRecoverContent} + and hef.fence_field = #{fenceField} + + ${params.tenantDataScope} + - - - - - - - - + \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml index 185bfe2..c46770a 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml @@ -1,13 +1,12 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - @@ -21,6 +20,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -58,66 +61,78 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 + select monitor_unit_id, monitor_unit_name, scene_id, parent_id, monitor_unit_type_id, area_id, monitor_address, monitor_pic, preserve_time, remark, monitor_unit_status, create_by, create_time, update_by, update_time, monitor_unit_field from hw_monitor_unit hmu + + + select hmu.monitor_unit_id, hmu.monitor_unit_name, hmu.scene_id, hmu.parent_id, + hmu.monitor_unit_type_id, hmu.area_id, hmu.monitor_address, hmu.monitor_pic, + hmu.preserve_time, hmu.monitor_unit_status, hc.scene_name + from hw_monitor_unit hmu left join hw_scene hc on hmu.scene_id = hc.scene_id + + + + + ${params.tenantDataScope} + + - - + + - - select count(*)from hw_monitor_unit - where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null) + select count(*)from hw_monitor_unit + where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null) + and scene_id = #{sceneId} - select count(*) as sum from hw_device -where device_status = '1' + where device_status = '1' + and scene_id = #{sceneId} - + - + - + - + select scene_id,scene_name from hw_scene - + - + - + - + - + + select count(*) from hw_device where monitor_unit_id = (select target_id from hw_fence_target where target_type='2' and electronic_fence_id = #{electronicFenceId}) + insert into hw_monitor_unit monitor_unit_name, - scene_id, tenant_id, + scene_id, parent_id, monitor_unit_type_id, area_id, @@ -203,11 +218,11 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw update_by, update_time, monitor_unit_field, - + #{monitorUnitName}, - #{sceneId}, #{tenantId}, + #{sceneId}, #{parentId}, #{monitorUnitTypeId}, #{areaId}, @@ -221,7 +236,7 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw #{updateBy}, #{updateTime}, #{monitorUnitField}, - + @@ -229,7 +244,6 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw monitor_unit_name = #{monitorUnitName}, scene_id = #{sceneId}, - scene_id = #{tenantId}, parent_id = #{parentId}, monitor_unit_type_id = #{monitorUnitTypeId}, area_id = #{areaId}, @@ -248,23 +262,52 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw - UPDATE hw_monitor_unit SET monitor_unit_status='9' where monitor_unit_id= #{monitorUnitId} + delete from hw_monitor_unit where monitor_unit_id = #{monitorUnitId} - UPDATE hw_monitor_unit SET monitor_unit_status='9' where monitor_unit_id = + delete from hw_monitor_unit where monitor_unit_id in #{monitorUnitId} - - - + + + hmu.monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null) + and monitor_unit_name like concat('%', #{monitorUnitName}, '%') + and scene_id = #{sceneId} + and parent_id = #{parentId} + and monitor_unit_type_id = #{monitorUnitTypeId} + and area_id = #{areaId} + and monitor_address = #{monitorAddress} + and monitor_pic = #{monitorPic} + and preserve_time = #{preserveTime} + and monitor_unit_status = #{monitorUnitStatus} + and monitor_unit_field = #{monitorUnitField} + - + + + \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml index 95d8266..d3fad2d 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml @@ -12,7 +12,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - @@ -20,10 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - select monitor_unit_type_id, monitor_unit_type_name, vitual_flag, monitor_unit_type_status, language_code, common_flag, scene_id,tenant_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 from hw_monitor_unit_type - - insert into hw_monitor_unit_type @@ -59,8 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" monitor_unit_type_status, language_code, common_flag, + tenant_id, scene_id, - tenant_id, remark, create_by, create_time, @@ -75,8 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{monitorUnitTypeStatus}, #{languageCode}, #{commonFlag}, + #{tenantId}, #{sceneId}, - #{tenantId}, #{remark}, #{createBy}, #{createTime}, @@ -96,7 +92,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" language_code = #{languageCode}, common_flag = #{commonFlag}, scene_id = #{sceneId}, - tenant_id = #{tenantId}, remark = #{remark}, create_by = #{createBy}, create_time = #{createTime}, @@ -109,17 +104,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update hw_monitor_unit_type set monitor_unit_type_status = '9' where monitor_unit_type_id = #{monitorUnitTypeId} + delete from hw_monitor_unit_type where monitor_unit_type_id = #{monitorUnitTypeId} - update hw_monitor_unit_type set monitor_unit_type_status = '9' where monitor_unit_type_id in + delete from hw_monitor_unit_type where monitor_unit_type_id in #{monitorUnitTypeId} - + select hmut.*,ht.tenant_name,hs.scene_name from hw_monitor_unit_type hmut + left join hw_tenant ht on hmut.tenant_id = ht.tenant_id + left join hw_scene hs on hmut.scene_id = hs.scene_id + + and hmut.monitor_unit_type_name like concat('%', #{monitorUnitTypeName}, '%') + and hmut.vitual_flag = #{vitualFlag} + and hmut.monitor_unit_type_status = #{monitorUnitTypeStatus} + and hmut.language_code = #{languageCode} + and hmut.common_flag = #{commonFlag} + and hmut.scene_id = #{sceneId} + and hmut.tenant_id = #{tenantId} + and hmut.unit_type_icon = #{unitTypeIcon} + and hmut.unit_type_field = #{unitTypeField} + + ${params.tenantDataScope} + + diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml index 983242d..280cd55 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml @@ -54,28 +54,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select scene_id, scene_name, tenant_id, scene_mode_id, scene_pic, default_flag, scene_status, auth_mode, mode_account, mode_key, mode_secret, preserve_time, test_preserve_time, remark, create_by, create_time, update_by, update_time, scene_environment, scene_field from hw_scene + select scene_id, scene_name, tenant_id, scene_mode_id, scene_pic, default_flag, scene_status, auth_mode, mode_account, mode_key, mode_secret, preserve_time, test_preserve_time, remark, create_by, create_time, update_by, update_time, scene_environment, scene_field from hw_scene hs where tenant_id = #{tenantId} + order by update_time desc - select scene_id,scene_name from hw_scene where tenant_id = #{tenantId} - diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index a33ae6a..7bd3d01 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -1,13 +1,5 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.SpringUtils; @@ -16,6 +8,7 @@ import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.SysRole; import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleMenu; import com.ruoyi.system.domain.SysUserRole; @@ -24,6 +17,11 @@ import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMenuMapper; import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.service.ISysRoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; /** * 角色 业务层处理 @@ -134,12 +132,10 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public boolean checkRoleNameUnique(SysRole role) - { + public boolean checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -152,12 +148,10 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public boolean checkRoleKeyUnique(SysRole role) - { + public boolean checkRoleKeyUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -169,10 +163,8 @@ public class SysRoleServiceImpl implements ISysRoleService { * @param role 角色信息 */ @Override - public void checkRoleAllowed(SysRole role) - { - if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) - { + public void checkRoleAllowed(SysRole role) { + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { throw new ServiceException("不允许操作超级管理员角色"); } } @@ -183,15 +175,12 @@ public class SysRoleServiceImpl implements ISysRoleService { * @param roleId 角色id */ @Override - public void checkRoleDataScope(Long roleId) - { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) - { + public void checkRoleDataScope(Long roleId) { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) { SysRole role = new SysRole(); role.setRoleId(roleId); List roles = SpringUtils.getAopProxy(this).selectRoleList(role); - if (StringUtils.isEmpty(roles)) - { + if (StringUtils.isEmpty(roles)) { throw new ServiceException("没有权限访问角色数据!"); } } @@ -204,8 +193,7 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public int countUserRoleByRoleId(Long roleId) - { + public int countUserRoleByRoleId(Long roleId) { return userRoleMapper.countUserRoleByRoleId(roleId); } @@ -217,8 +205,7 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public int insertRole(SysRole role) - { + public int insertRole(SysRole role) { // 新增角色信息 roleMapper.insertRole(role); return insertRoleMenu(role); @@ -232,8 +219,7 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public int updateRole(SysRole role) - { + public int updateRole(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与菜单关联 @@ -248,8 +234,7 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public int updateRoleStatus(SysRole role) - { + public int updateRoleStatus(SysRole role) { return roleMapper.updateRole(role); } @@ -261,8 +246,7 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public int authDataScope(SysRole role) - { + public int authDataScope(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与部门关联 @@ -276,20 +260,17 @@ public class SysRoleServiceImpl implements ISysRoleService { * * @param role 角色对象 */ - public int insertRoleMenu(SysRole role) - { + public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List list = new ArrayList(); - for (Long menuId : role.getMenuIds()) - { + for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; @@ -300,20 +281,17 @@ public class SysRoleServiceImpl implements ISysRoleService { * * @param role 角色对象 */ - public int insertRoleDept(SysRole role) - { + public int insertRoleDept(SysRole role) { int rows = 1; // 新增角色与部门(数据权限)管理 List list = new ArrayList(); - for (Long deptId : role.getDeptIds()) - { + for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); rd.setDeptId(deptId); list.add(rd); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleDeptMapper.batchRoleDept(list); } return rows; @@ -327,8 +305,7 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleById(Long roleId) - { + public int deleteRoleById(Long roleId) { // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(roleId); // 删除角色与部门关联 @@ -344,15 +321,12 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleByIds(Long[] roleIds) - { - for (Long roleId : roleIds) - { + public int deleteRoleByIds(Long[] roleIds) { + for (Long roleId : roleIds) { checkRoleAllowed(new SysRole(roleId)); checkRoleDataScope(roleId); SysRole role = selectRoleById(roleId); - if (countUserRoleByRoleId(roleId) > 0) - { + if (countUserRoleByRoleId(roleId) > 0) { throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } @@ -370,38 +344,34 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public int deleteAuthUser(SysUserRole userRole) - { + public int deleteAuthUser(SysUserRole userRole) { return userRoleMapper.deleteUserRoleInfo(userRole); } /** * 批量取消授权用户角色 * - * @param roleId 角色ID + * @param roleId 角色ID * @param userIds 需要取消授权的用户数据ID * @return 结果 */ @Override - public int deleteAuthUsers(Long roleId, Long[] userIds) - { + public int deleteAuthUsers(Long roleId, Long[] userIds) { return userRoleMapper.deleteUserRoleInfos(roleId, userIds); } /** * 批量选择授权用户角色 * - * @param roleId 角色ID + * @param roleId 角色ID * @param userIds 需要授权的用户数据ID * @return 结果 */ @Override - public int insertAuthUsers(Long roleId, Long[] userIds) - { + public int insertAuthUsers(Long roleId, Long[] userIds) { // 新增用户与角色管理 List list = new ArrayList(); - for (Long userId : userIds) - { + for (Long userId : userIds) { SysUserRole ur = new SysUserRole(); ur.setUserId(userId); ur.setRoleId(roleId); @@ -409,4 +379,23 @@ public class SysRoleServiceImpl implements ISysRoleService { } return userRoleMapper.batchUserRole(list); } + + /** + * 根据查询条件查询角色列表 + * + * @return 角色列表 + */ + @Override + public List selectRoleAll(SysRole querySysRole) { + if(querySysRole ==null){ + querySysRole = new SysRole(); + } + if (querySysRole.getTenantId() == null) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + querySysRole.setTenantId(user.getTenantId()); + } + + return roleMapper.selectAddedUserRoleList(querySysRole); + } } diff --git a/ruoyi-ui/src/api/business/electronicFence.js b/ruoyi-ui/src/api/business/electronicFence.js index 5a70cc2..b6a28ab 100644 --- a/ruoyi-ui/src/api/business/electronicFence.js +++ b/ruoyi-ui/src/api/business/electronicFence.js @@ -42,3 +42,21 @@ export function delElectronicFence(electronicFenceId) { method: 'delete' }) } + +// 查询场景信息列表供查询页面选择使用(例如下拉列表) +export function getScenes(query) { + return request({ + url: '/business/electronicFence/getScenes', + method: 'get', + params: query + }) +} + +// 查询场景信息列表供编辑页面选择使用(例如下拉列表) +export function getEditedScenes(query) { + return request({ + url: '/business/electronicFence/getEditedScenes', + method: 'get', + params: query + }) +} diff --git a/ruoyi-ui/src/api/business/scene.js b/ruoyi-ui/src/api/business/scene.js index 5c89883..682d5e8 100644 --- a/ruoyi-ui/src/api/business/scene.js +++ b/ruoyi-ui/src/api/business/scene.js @@ -53,3 +53,22 @@ export function getScenes(query) { }) } + +// 查询租户信息列表供选择使用(例如下拉列表) +export function getTenants(query) { + return request({ + url: '/business/scene/getTenants', + method: 'get', + params: query + }) +} + +// 查询场景类型信息列表供选择使用(例如下拉列表) +export function getSceneModes(query) { + return request({ + url: '/business/scene/getSceneModes', + method: 'get', + params: query + }) +} + diff --git a/ruoyi-ui/src/assets/board/equipment/icon.png b/ruoyi-ui/src/assets/board/equipment/icon.png index e69de29..5de951d 100644 Binary files a/ruoyi-ui/src/assets/board/equipment/icon.png and b/ruoyi-ui/src/assets/board/equipment/icon.png differ diff --git a/ruoyi-ui/src/assets/board/equipment/iconBg.png b/ruoyi-ui/src/assets/board/equipment/iconBg.png index e69de29..987361f 100644 Binary files a/ruoyi-ui/src/assets/board/equipment/iconBg.png and b/ruoyi-ui/src/assets/board/equipment/iconBg.png differ diff --git a/ruoyi-ui/src/assets/board/equipment/item.png b/ruoyi-ui/src/assets/board/equipment/item.png index e69de29..f49cca2 100644 Binary files a/ruoyi-ui/src/assets/board/equipment/item.png and b/ruoyi-ui/src/assets/board/equipment/item.png differ diff --git a/ruoyi-ui/src/assets/board/equipment/right.png b/ruoyi-ui/src/assets/board/equipment/right.png index e69de29..56ad201 100644 Binary files a/ruoyi-ui/src/assets/board/equipment/right.png and b/ruoyi-ui/src/assets/board/equipment/right.png differ diff --git a/ruoyi-ui/src/assets/board/equipmentMonitoring/bg.jpg b/ruoyi-ui/src/assets/board/equipmentMonitoring/bg.jpg index e69de29..b49a5de 100644 Binary files a/ruoyi-ui/src/assets/board/equipmentMonitoring/bg.jpg and b/ruoyi-ui/src/assets/board/equipmentMonitoring/bg.jpg differ diff --git a/ruoyi-ui/src/assets/board/equipmentMonitoring/item.png b/ruoyi-ui/src/assets/board/equipmentMonitoring/item.png index e69de29..f715f75 100644 Binary files a/ruoyi-ui/src/assets/board/equipmentMonitoring/item.png and b/ruoyi-ui/src/assets/board/equipmentMonitoring/item.png differ diff --git a/ruoyi-ui/src/assets/board/index/container.png b/ruoyi-ui/src/assets/board/index/container.png index e69de29..5de951d 100644 Binary files a/ruoyi-ui/src/assets/board/index/container.png and b/ruoyi-ui/src/assets/board/index/container.png differ diff --git a/ruoyi-ui/src/assets/board/senso/iconBg.png b/ruoyi-ui/src/assets/board/senso/iconBg.png index e69de29..987361f 100644 Binary files a/ruoyi-ui/src/assets/board/senso/iconBg.png and b/ruoyi-ui/src/assets/board/senso/iconBg.png differ diff --git a/ruoyi-ui/src/assets/board/senso/iconBottom.png b/ruoyi-ui/src/assets/board/senso/iconBottom.png index e69de29..9915ec9 100644 Binary files a/ruoyi-ui/src/assets/board/senso/iconBottom.png and b/ruoyi-ui/src/assets/board/senso/iconBottom.png differ diff --git a/ruoyi-ui/src/assets/board/senso/itemBg.png b/ruoyi-ui/src/assets/board/senso/itemBg.png index e69de29..56ad201 100644 Binary files a/ruoyi-ui/src/assets/board/senso/itemBg.png and b/ruoyi-ui/src/assets/board/senso/itemBg.png differ diff --git a/ruoyi-ui/src/components/RuoYi/Git/index.vue b/ruoyi-ui/src/components/RuoYi/Git/index.vue index 4edb068..d1c3f8e 100644 --- a/ruoyi-ui/src/components/RuoYi/Git/index.vue +++ b/ruoyi-ui/src/components/RuoYi/Git/index.vue @@ -14,7 +14,7 @@ export default { }, methods: { goto() { - window.open(this.url) + this.$router.push({path: "/board/index"}); } } } diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index 39b3dad..6fff6a2 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -8,13 +8,9 @@