若依微服务1.3.0

1、电子围栏
2、设备管理
3、设备模型
4、监控单元
5、场景
6、监控单元类型
7、租户
8、路由配置
9、场景获取with路由信息for监控平台
dev 1.3.0
xins 1 year ago
parent 678261d878
commit e12fe302a7

@ -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();
}
}

@ -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<Long, String> 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);
}
}

@ -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;
}
}

@ -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<HwElectronicFence> list = hwElectronicFenceService.selectHwElectronicFenceList(hwElectronicFence);
List<HwElectronicFence> 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));
}
}

@ -250,9 +250,9 @@ public class HwMonitorPlatformController extends BaseController {
JSONObject returnObj = new JSONObject();
List<Map<String, Object>> latestDataMaps = hwMonitorPlatformService.selectLatestDataByTags(deviceLatestData);
List<DeviceDataColumnVo> 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);
}

@ -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;
@Autowired
private IHwMonitorUnitTypeService monitorUnitTypeService;
/**
*
*/
@RequiresPermissions("business:monitorUnit:list")
@GetMapping("/list")
public TableDataInfo list(HwMonitorUnit hwMonitorUnit)
public AjaxResult list(HwMonitorUnit hwMonitorUnit)
{
// startPage();
List<HwMonitorUnit> list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
return getDataTable(list);
List<HwMonitorUnit> 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<HwMonitorUnit> list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
List<HwMonitorUnit> list = hwMonitorUnitService.selectHwMonitorUnitJoinList(hwMonitorUnit);
ExcelUtil<HwMonitorUnit> util = new ExcelUtil<HwMonitorUnit>(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));
}
/**
* id
* */
@GetMapping("/getMonitorIsRelevancy")
public String getMonitorIsRelevancy(Long monitorUnitId){
//如果关联设备 不能作为父级监控单元
if (hwMonitorUnitService.getMonitorIsRelevancy(monitorUnitId)==0){
return "y";
}
return "n";
@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));
}
/**
*
*/
@RequiresPermissions("business:monitorUnit:list")
@GetMapping("/getEditedMonitorUnits")
public AjaxResult getEditedMonitorUnits(HwMonitorUnit hwMonitorUnit)
{
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getSysUser();
hwMonitorUnit.setTenantId(user.getTenantId());
List<HwMonitorUnit> list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
return success(list);
}
}

@ -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<HwMonitorUnitType> list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeList(hwMonitorUnitType);
List<HwMonitorUnitType> 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<HwMonitorUnitType> list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeList(hwMonitorUnitType);
List<HwMonitorUnitType> list = hwMonitorUnitTypeService.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType);
ExcelUtil<HwMonitorUnitType> util = new ExcelUtil<HwMonitorUnitType>(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));
}
}

@ -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<HwSceneVo> list = hwSceneService.selectHwSceneList2(hwScene);
List<HwSceneVo> list = hwSceneService.selectHwSceneJoinList(hwScene);
return getDataTable(list);
}
/**
* id
* */
@GetMapping("/sceneIdAndName")
public TableDataInfo sceneIdAndName()
{
HwSceneVo hwScene = new HwSceneVo();
List<HwSceneVo> 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()));
}
}

@ -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));
}
/**
*

@ -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<HwFenceTarget> 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())

@ -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,23 +65,30 @@ public class HwMonitorUnit extends BaseEntity
@Excel(name = "预留字段")
private String monitorUnitField;
private Long tenantId;
private String sceneName;
private String monitorUnitTypeName;
private String tenantName;
private List<HwMonitorUnit> child = new ArrayList<HwMonitorUnit>();
/** 子部门 */
private List<HwMonitorUnit> children = new ArrayList<HwMonitorUnit>();
public List<HwMonitorUnit> getChild() {
return child;
}
public Long getTenantId() {
return tenantId;
public void setChild(List<HwMonitorUnit> child) {
this.child = child;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
public List<HwMonitorUnit> getChildren() {
return children;
}
public void setChild(List<HwMonitorUnit> child) {
this.child = child;
public void setChildren(List<HwMonitorUnit> children) {
this.children = children;
}
public void setMonitorUnitId(Long 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();
}
}

@ -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,97 +51,116 @@ public class HwMonitorUnitType extends BaseEntity
@Excel(name = "预留字段")
private String unitTypeField;
private String sceneName;
private String tenantName;
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public void setMonitorUnitTypeId(Long monitorUnitTypeId)
public void setMonitorUnitTypeId(Long monitorUnitTypeId)
{
this.monitorUnitTypeId = monitorUnitTypeId;
}
public Long getMonitorUnitTypeId()
public Long getMonitorUnitTypeId()
{
return monitorUnitTypeId;
}
public void setMonitorUnitTypeName(String monitorUnitTypeName)
public void setMonitorUnitTypeName(String monitorUnitTypeName)
{
this.monitorUnitTypeName = monitorUnitTypeName;
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
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();
}
}

@ -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)

@ -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;
}

@ -81,4 +81,12 @@ public interface HwElectronicFenceMapper
public int selectDeviceCountByMonitorUnit(Long electronicFenceId);
public int selectDeviceCountByScene(Long sceneId);
/**
* Join
*
* @param hwElectronicFence
* @return
*/
public List<HwElectronicFence> selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence);
}

@ -33,20 +33,20 @@ public interface HwMonitorUnitMapper
public List<AllNumsVo> selectsum();
//查询id与name的结果集
List<HwMonitorUnitVo> selectSceneNameById();
String selectSubSetNums();
Integer selectSubSetNums(Long sceneId);
/**
*
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit();
Integer selectReleatedDeviceIdNums(Long deviceCode);
String selectDeviceNums();
Integer selectDeviceNums(Long sceneId);
Integer selectSubDeviceSum(Long sceneId);
/**
*
* */
public List<AlarmStatsVo> selectAlarmStats();
public List<AlarmStatsVo> 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<HwMonitorUnit> selectHwMonitorUnitListJoinScene(HwMonitorUnit hwMonitorUnit);
/**
*
*
* @param hwMonitorUnit
* @return
*/
public List<HwMonitorUnit> selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit);
//查询设备是否关联了该监控单元
Integer selectDeviceRelevancyMontiorUnit(Long monitorUnitId);
//查询电子围栏是否关联了该监控单元
Integer selectElectronicFenceRelevancyMonitorUnit(Long monitorUnitId);
}
}

@ -63,5 +63,7 @@ public interface HwMonitorUnitTypeMapper
*/
public int deleteHwMonitorUnitTypeByMonitorUnitTypeIds(Long[] monitorUnitTypeIds);
public int getNumsHwMonitorUnitTypeByMonitorUnitTypeId(Long monitorUnitTypeId);
public List<HwMonitorUnitType> selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType);
}

@ -22,7 +22,6 @@ public interface HwSceneMapper
public List<HwScene> selectHwSceneBySceneModeId(Long sceneModeId);
public List<HwScene> selectHwSceneByTenantId0(Long tenantId);
public List<HwScene> selectHwSceneByTenantIdNot0(Long tenantId);
List<HwSceneVo> selectHwSceneVoListByTenantId(Long tenantId);
/**

@ -65,4 +65,13 @@ public interface IHwElectronicFenceService
* @return
*/
public int deleteHwElectronicFenceByElectronicFenceId(Long electronicFenceId);
/**
* Join
*
* @param hwElectronicFence
* @return
*/
public List<HwElectronicFence> selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence);
}

@ -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<AllNumsVo> selectSenceAllNums();
public AllNumsVo selectAllNums(Long sceneId);
// public List<AllNumsVo> selectSenceAllNums();
/**
*
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit();
/**
*
* */
/**
*
* */
public List<AlarmStatsVo> selectAlarmStats();
public List<AlarmStatsVo> 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<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId);
/**
*
*
* @return*/
public R<Map<String, Map<String, Object>>> selectLatestDataByTags(Long monitorUnitId);
/**
/**
*
*
* @param hwMonitorUnit
@ -114,9 +107,36 @@ public interface IHwMonitorUnitService
public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId);
/**
*
*
* @param hwMonitorUnit
* @return
*/
public List<TreeSelectVo> selectMonitorTreeList(HwMonitorUnit hwMonitorUnit);
/**
* id
* */
int getMonitorIsRelevancy(Long monitorUnitId);
}
*
*
* @param hwMonitorUnits
* @return
*/
public List<TreeSelectVo> buildMonitorUnitTreeSelect(List<HwMonitorUnit> hwMonitorUnits);
/**
*
*
* @param hwMonitorUnits
* @return
*/
public List<HwMonitorUnit> buildMonitorUnitTree(List<HwMonitorUnit> hwMonitorUnits);
/**
* ,Join
*
* @param hwMonitorUnit
* @return
*/
public List<HwMonitorUnit> selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit);
}

@ -23,8 +23,6 @@ public interface IHwSceneService
public List<HwScene> selectHwSceneBySceneModeId(Long sceneModeId);
//场景选择
List<HwScene> selectHwSceneByTenantId(Long tenantId);
/**
*
*
@ -32,8 +30,7 @@ public interface IHwSceneService
* @return
*/
public List<HwScene> selectHwSceneList(HwScene hwScene);
public List<HwSceneVo> selectHwSceneList2(HwSceneVo hwScene);
public List<HwSceneVo> selectHwSceneJoinList(HwSceneVo hwScene);
/**
*
@ -66,4 +63,12 @@ public interface IHwSceneService
* @return
*/
public int deleteHwSceneBySceneId(Long sceneId);
/**
* 使
*
* @param hwScene
* @return
*/
public List<HwScene> selectHwSceneList4Select(HwScene hwScene);
}

@ -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<TdField> 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<TdField> 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<TdField> getTdTagsFields(HwDevice hwDevice) {
List<TdField> 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());

@ -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<HwFenceArea> 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<HwElectronicFence> 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());
}
HwFenceArea queryFenceArea = new HwFenceArea();
queryFenceArea.setElectronicFenceId(electronicFence.getElectronicFenceId());
List<HwFenceArea> 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());
}
if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) {
deviceCount = hwElectronicFenceMapper.selectDeviceCountByMonitorUnit(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());
}
} 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<ElectronicFenceVo.AreaPoint> points = new ArrayList<ElectronicFenceVo.AreaPoint>();
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);
if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) {
String[] areaRangeArr = areaRange.split("_");
List<ElectronicFenceVo.AreaPoint> points = new ArrayList<ElectronicFenceVo.AreaPoint>();
for (String areaR : areaRangeArr) {
String[] areaRArr = areaR.split(",");
} else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) {
String[] areaRangeArr = areaRange.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);
p.setLongitude(Double.valueOf(areaRangeArr[0]));
p.setLatitude(Double.valueOf(areaRangeArr[1]));
} 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.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<HwFenceArea> fenceAreaList = new ArrayList<>();
if (polygonAreaListStr != null) {
JSONArray polygonAreaJsonArray = JSON.parseArray(polygonAreaListStr);
Map<Integer, JSONArray> 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<Integer, JSONArray> 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<Integer, JSONArray> 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<Integer, JSONArray> 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<HwFenceArea> 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<HwElectronicFence> selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence) {
return hwElectronicFenceMapper.selectHwElectronicFenceJoinList(hwElectronicFence);
}
}

@ -1,32 +1,35 @@
package com.ruoyi.business.service.impl;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
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.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 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 com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.service.IHwMonitorUnitService;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* 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<HwMonitorUnitVo> selectMonitorPercentage() {
// HwMonitorUnit queryMonitorUnit = new HwMonitorUnit();
// List<HwMonitorUnit> list = hwMonitorUnitMapper.selectHwMonitorUnitListJoinScene(queryMonitorUnit);
// Map<Long, List<HwMonitorUnit>> monitorUnitMap = list.stream()
// .collect(Collectors.groupingBy(HwMonitorUnit::getSceneId));
// List<HwMonitorUnitVo> monitorUnitVoList = new ArrayList<>();
//
//
// Set<Long> keys = monitorUnitMap.keySet();
// for(Long key:keys){
// Integer value = monitorUnitMap.get(key);
// System.out.println(key+"\t"+value);
// }
List<HwMonitorUnitVo> list = hwMonitorUnitMapper.selectMonitorPercentage();
List<HwMonitorUnitVo> 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<count;j++){
if (list.get(i).getSceneId().equals(hwScenes.get(i).getSceneId())){
list.get(i).setSceneName(hwScenes.get(i).getSceneName());
list.stream().forEach(l -> {
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<list.size();i++){
list.get(i).setPercentage((double) (list.get(i).getSum()/sums));
for (int i = 0; i < list.size(); i++) {
HwMonitorUnitVo hwMonitorUnitVo = list.get(i);
hwMonitorUnitVo.setPercentage(NumberUtils.getPercentage(list.get(i).getSum(), sums));
Long sceneId = hwMonitorUnitVo.getSceneId();
HwAlarmInfo queryAlarmInfo = new HwAlarmInfo();
queryAlarmInfo.setSceneId(sceneId);
List<HwAlarmInfo> 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<AllNumsVo> selectSenceAllNums() {
List<AllNumsVo> allNumsVos = hwMonitorUnitMapper.selectAllNums();
List<AllNumsVo> 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<AllNumsVo> selectSenceAllNums() {
// List<AllNumsVo> allNumsVos = hwMonitorUnitMapper.selectAllNums();
// List<AllNumsVo> 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<HwMonitorUnit> selectLimitSubMonitorUnit() {
@ -165,8 +166,8 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
}
@Override
public List<AlarmStatsVo> selectAlarmStats() {
return hwMonitorUnitMapper.selectAlarmStats();
public List<AlarmStatsVo> selectAlarmStats(Long sceneId) {
return hwMonitorUnitMapper.selectAlarmStats(sceneId);
}
@ -177,155 +178,72 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
* @return
*/
@Override
public List<HwMonitorUnit> selectHwMonitorUnitList(HwMonitorUnit hwMonitorUnit)
{
public List<HwMonitorUnit> selectHwMonitorUnitList(HwMonitorUnit hwMonitorUnit) {
return hwMonitorUnitMapper.selectHwMonitorUnitList(hwMonitorUnit);
}
@Override
public SubDeviceSumVo selectSubDeviceSum(Long sceneId) {
int SubSum = hwMonitorUnitMapper.selectSubDeviceSum(sceneId);
List<HwDevice> hwDevices = hwDeviceMapper.selectDeviceNum(sceneId);
int onlineDevice = 0;
for (int i = 0;i<hwDevices.size();i++){
if (hwDevices.get(i).getActiveStatus().equals("1")&&hwDevices.get(i).getDeviceStatus().equals("1")){
onlineDevice = onlineDevice+1;
}
}
AllNumsVo numsVo = selectAllNums(sceneId);
int onlineDeviceNum = hwDeviceMapper.getOnlineDeviceNum(sceneId);
SubDeviceSumVo subDeviceSumVo = new SubDeviceSumVo();
subDeviceSumVo.setSubSum(String.valueOf(SubSum));
subDeviceSumVo.setDeviceNum(String.valueOf(hwDevices.size()));
subDeviceSumVo.setOnlineDeviceNum(String.valueOf(onlineDevice));
subDeviceSumVo.setSubSum(numsVo.getSubSum());//监控单元数量
subDeviceSumVo.setDeviceNum(numsVo.getSum());//设备数量
subDeviceSumVo.setOnlineDeviceNum(onlineDeviceNum);//在线设备数量
return subDeviceSumVo;
}
//todo 电子围栏
@Override
public Integer selectElectronicNum(Long sceneId) {
List<Long> 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<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId) {
DeviceStatus queryDeviceStatus = new DeviceStatus();
Map<String, Object> 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<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
List<HwMonitorUnit> 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<Object,Integer> valuesMap = new HashMap<>();
//todo 使用id(以解决)
//map key时间戳value List<DeviceStatus> 对象
R<?> r = remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Map<Long, List<DeviceStatus>> deviceStatusMap = (Map<Long, List<DeviceStatus>>) r.getData();
List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Set<Long> longs = deviceStatusMap.keySet();
for (Object key:longs){
List<DeviceStatus> deviceStatuses = deviceStatusMap.get(key);
for (int i=0;i<deviceStatuses.size();i++){
if (deviceStatuses.get(i).getDeviceType()==1){
sum=sum+hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
}
else {
sum = sum+1;
}
valuesMap.put(key,sum);
for (int i = 0; i < returnList.size(); i++) {
if (returnList.get(i).getParentId() == null) {
treeList.add(returnList.get(i));
}
}
return valuesMap;
//设备类型==网关 根据releated_device_id = 网关设备设备id查询个数
//网关子设备数+非网关设备数getDeviceType()=1
return treeList;
}
@Override
public R<Map<String, Map<String, Object>>> selectLatestDataByTags(Long monitorUnitId) {
//
R<Map<String, Map<String, Object>>> latestDataByTags = new R<Map<String,Map<String, Object>>>();
List<HwDevice> 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<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
List<HwMonitorUnit> 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<HwMonitorUnit> list, HwMonitorUnit t)
{
private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t) {
// 得到子节点列表
List<HwMonitorUnit> 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<HwMonitorUnit> getChildList(List<HwMonitorUnit> list, HwMonitorUnit t)
{
private List<HwMonitorUnit> getChildList(List<HwMonitorUnit> list, HwMonitorUnit t) {
List<HwMonitorUnit> tlist = new ArrayList<HwMonitorUnit>();
Iterator<HwMonitorUnit> 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<HwMonitorUnit> list, HwMonitorUnit t)
{
private boolean hasChild(List<HwMonitorUnit> list, HwMonitorUnit t) {
return getChildList(list, t).size() > 0 ? true : false;
}
@ -336,32 +254,10 @@ public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> 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<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> 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<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> 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<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
* @return
*/
@Override
public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId)
{
public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId) {
return hwMonitorUnitMapper.deleteHwMonitorUnitByMonitorUnitId(monitorUnitId);
}
/**
*
*
* @param hwMonitorUnit
* @return
*/
@Override
public int getMonitorIsRelevancy(Long monitorUnitId) {
if (hwMonitorUnitMapper.selectDeviceRelevancyMontiorUnit(monitorUnitId)==0
&& hwMonitorUnitMapper.selectElectronicFenceRelevancyMonitorUnit(monitorUnitId)==0
){
return 1;
@DataScope(tenantAlias = "hmu")
public List<TreeSelectVo> selectMonitorTreeList(HwMonitorUnit hwMonitorUnit) {
List<HwMonitorUnit> hwMonitorUnits = this.selectHwMonitorUnitList(hwMonitorUnit);
return buildMonitorUnitTreeSelect(hwMonitorUnits);
}
/**
*
*
* @param hwMonitorUnits
* @return
*/
@Override
public List<TreeSelectVo> buildMonitorUnitTreeSelect(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> monitorUnitTrees = buildMonitorUnitTree(hwMonitorUnits);
return monitorUnitTrees.stream().map(TreeSelectVo::new).collect(Collectors.toList());
}
/**
*
*
* @param hwMonitorUnits
* @return
*/
@Override
public List<HwMonitorUnit> buildMonitorUnitTree(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<HwMonitorUnit>();
List<Long> 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 0;
return returnList;
}
}
//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 }
// }
/**
*
*/
private void recursionFn1(List<HwMonitorUnit> list, HwMonitorUnit t) {
// 得到子节点列表
List<HwMonitorUnit> childList = getChildList1(list, t);
t.setChildren(childList);
for (HwMonitorUnit tChild : childList) {
if (hasChild1(list, tChild)) {
recursionFn1(list, tChild);
}
}
}
/**
*
*/
private List<HwMonitorUnit> getChildList1(List<HwMonitorUnit> list, HwMonitorUnit t) {
List<HwMonitorUnit> tlist = new ArrayList<HwMonitorUnit>();
Iterator<HwMonitorUnit> 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<HwMonitorUnit> list, HwMonitorUnit t) {
return getChildList1(list, t).size() > 0 ? true : false;
}
/**
* ,Join
*
* @param hwMonitorUnit
* @return
*/
@Override
@DataScope(tenantAlias = "hmu")
public List<HwMonitorUnit> 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<HwDevice> devices = hwDeviceMapper.selectHwDeviceList(queryDevice);
if (devices != null && !devices.isEmpty()) {
throw new ServiceException("此父级单元已关联设备,请重新选择");
}
}
}
}

@ -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<HwMonitorUnitType> 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<HwMonitorUnitType> selectHwMonitorUnitTypeList4Select(HwMonitorUnitType hwMonitorUnitType){
return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeList(hwMonitorUnitType);
}
/**
* ,Join
*
* @param hwMonitorUnitType
* @return
*/
@Override
@DataScope(tenantAlias = "hmut")
public List<HwMonitorUnitType> selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType)
{
return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType);
}
}

@ -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);
}
}

@ -3,18 +3,17 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwElectronicFenceMapper">
<resultMap type="HwElectronicFence" id="HwElectronicFenceResult">
<result property="electronicFenceId" column="electronic_fence_id" />
<result property="electronicFenceName" column="electronic_fence_name" />
<result property="tenantId" column="tenant_id" />
<result property="sceneId" column="scene_id" />
<result property="fenceType" column="fence_type" />
<result property="effectiveTimeFlag" column="effective_time_flag" />
<result property="timeZone" column="time_zone" />
<result property="effectiveTime" column="effective_time" />
<result property="triggerStatus" column="trigger_status" />
<result property="areaShapeFlag" column="area_shape_flag" />
<result property="areaRange" column="area_range" />
<result property="fencePushFlag" column="fence_push_flag" />
<result property="fencePushContent" column="fence_push_content" />
<result property="fenceRecoverContent" column="fence_recover_content" />
@ -24,12 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="fenceField" column="fence_field" />
</resultMap>
<resultMap id="EleMonitorDeviceSumVoResult" type="EleMonitorDeviceSumVo">
<result property="sceneId" column="scene_id" />
<result property="monitorUnitId" column="monitor_unit_id"/>
<result property="electronicFenceId" column="electronic_fence_id"/>
<result property="sum" column="sum"/>
<result property="sceneName" column="scene_name" />
</resultMap>
<resultMap id="HwElectronicFenceHwFenceTargetResult" type="HwElectronicFence" extends="HwElectronicFenceResult">
@ -43,123 +37,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectHwElectronicFenceVo">
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
</sql>
<!-- 根据场景查询电子围栏信息-->
<select id="selectElectronicByScene" resultMap="HwElectronicFenceResult">
<include refid="selectHwElectronicFenceVo"/>
<where>
<if test="sceneId !=null and sceneId !=''">and scene_id = #{sceneId}</if>
</where>
</select>
<!--根据传入场景查询电子围栏的类型-->
<select id="selectEleTypeBySceneId" parameterType="List" resultType="Integer">
SELECT DISTINCT
target_type
FROM
hw_fence_target
WHERE
electronic_fence_id = (
SELECT
electronic_fence_id
FROM
hw_electronic_fence
WHERE
scene_id = #{sceneId}
)
</select>
<!-- 查询监控单元下拥有总的设备量 新增电子围栏id分层-->
<select id="selectSumsFromMonitor" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
SELECT
monitor_unit_id,b.electronic_fence_id,
count(*) AS sum
FROM
hw_device AS a
LEFT JOIN (
SELECT
b.target_id,b.electronic_fence_id
FROM
hw_electronic_fence AS a
LEFT JOIN hw_fence_target AS b ON a.electronic_fence_id = b.target_id
WHERE
a.scene_id = #{sceneId}
AND a.fence_type = '2'
) AS b ON a.monitor_unit_id = b.target_id
GROUP BY
monitor_unit_id,b.electronic_fence_id
</select>
<!-- //查询该场景下拥有电子围栏的设备的数量并按电子围栏分组 todo 获取target里的数量 已发布 -->
<select id="selectSumsFromMonitorByElectronicFence" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
select electronic_fence_id,count(*)as sum from hw_fence_target where electronic_fence_id = ( SELECT electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}
)GROUP BY electronic_fence_id
</select>
<select id="selectDevicesFromEleBySceneId" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
SELECT
d.electronic_fence_id,
count(*) AS sum
FROM
hw_device AS c
LEFT JOIN hw_fence_target AS d ON c.device_id = d.target_id
WHERE
device_id = (
SELECT
target_id
FROM
hw_fence_target AS a
LEFT JOIN ( SELECT * FROM hw_electronic_fence WHERE scene_id = #{sceneId} AND fence_type = '1' ) AS b ON a.electronic_fence_id = b.electronic_fence_id
)
GROUP BY
d.electronic_fence_id
</select>
<!---->
<select id="selectEleOnlyMonitorBySceneId" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
select b.electronic_fence_id,count(*) from hw_device as a
left join hw_fence_target as b on a.device_id = b.target_id
where a.scene_id = #{sceneId} and a.device_status ='1' group by b.electronic_fence_id
</select>
<select id="selectEleOnlyScene" parameterType="Long" resultType="Integer">
select count(*) from hw_device where scene_id = #{sceneId} where device_status = '1'
</select>
<select id="selectHwElectronicFenceList" parameterType="HwElectronicFence" resultMap="HwElectronicFenceResult">
<include refid="selectHwElectronicFenceVo"/>
<where>
<where>
<if test="electronicFenceName != null and electronicFenceName != ''"> and electronic_fence_name like concat('%', #{electronicFenceName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="fenceType != null and fenceType != ''"> and fence_type = #{fenceType}</if>
<if test="effectiveTimeFlag != null and effectiveTimeFlag != ''"> and effective_time_flag = #{effectiveTimeFlag}</if>
<if test="timeZone != null and timeZone != ''"> and time_zone = #{timeZone}</if>
<if test="effectiveTime != null and effectiveTime != ''"> and effective_time = #{effectiveTime}</if>
<if test="triggerStatus != null and triggerStatus != ''"> and trigger_status = #{triggerStatus}</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''"> and area_shape_flag = #{areaShapeFlag}</if>
<if test="areaRange != null and areaRange != ''"> and area_range = #{areaRange}</if>
<if test="fencePushFlag != null and fencePushFlag != ''"> and fence_push_flag = #{fencePushFlag}</if>
<if test="fencePushContent != null and fencePushContent != ''"> and fence_push_content = #{fencePushContent}</if>
<if test="fenceRecoverContent != null and fenceRecoverContent != ''"> and fence_recover_content = #{fenceRecoverContent}</if>
<if test="fenceField != null and fenceField != ''"> and fence_field = #{fenceField}</if>
</where>
</select>
<select id="selectHwElectronicFenceByElectronicFenceId" parameterType="Long" resultMap="HwElectronicFenceHwFenceTargetResult">
select a.electronic_fence_id, a.electronic_fence_name, a.scene_id, a.fence_type, a.effective_time_flag, a.time_zone, a.effective_time, a.trigger_status, a.area_shape_flag, a.area_range, a.fence_push_flag, a.fence_push_content, a.fence_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.fence_field,
b.electronic_fence_id as sub_electronic_fence_id, b.target_type as sub_target_type, b.target_id as sub_target_id
select a.electronic_fence_id, a.electronic_fence_name, a.tenant_id, a.scene_id, a.fence_type, a.effective_time_flag, a.time_zone, a.effective_time, a.trigger_status, a.fence_push_flag, a.fence_push_content, a.fence_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.fence_field,
b.electronic_fence_id as sub_electronic_fence_id, b.target_type as sub_target_type, b.target_id as sub_target_id
from hw_electronic_fence a
left join hw_fence_target b on b.electronic_fence_id = a.electronic_fence_id
left join hw_fence_target b on b.electronic_fence_id = a.electronic_fence_id
where a.electronic_fence_id = #{electronicFenceId}
</select>
<insert id="insertHwElectronicFence" parameterType="HwElectronicFence" useGeneratedKeys="true" keyProperty="electronicFenceId">
insert into hw_electronic_fence
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="electronicFenceName != null and electronicFenceName != ''">electronic_fence_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="fenceType != null and fenceType != ''">fence_type,</if>
<if test="effectiveTimeFlag != null and effectiveTimeFlag != ''">effective_time_flag,</if>
<if test="timeZone != null">time_zone,</if>
<if test="effectiveTime != null and effectiveTime != ''">effective_time,</if>
<if test="triggerStatus != null and triggerStatus != ''">trigger_status,</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">area_shape_flag,</if>
<if test="areaRange != null">area_range,</if>
<if test="fencePushFlag != null and fencePushFlag != ''">fence_push_flag,</if>
<if test="fencePushContent != null">fence_push_content,</if>
<if test="fenceRecoverContent != null">fence_recover_content,</if>
@ -172,14 +89,13 @@ GROUP BY
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="electronicFenceName != null and electronicFenceName != ''">#{electronicFenceName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="fenceType != null and fenceType != ''">#{fenceType},</if>
<if test="effectiveTimeFlag != null and effectiveTimeFlag != ''">#{effectiveTimeFlag},</if>
<if test="timeZone != null">#{timeZone},</if>
<if test="effectiveTime != null and effectiveTime != ''">#{effectiveTime},</if>
<if test="triggerStatus != null and triggerStatus != ''">#{triggerStatus},</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">#{areaShapeFlag},</if>
<if test="areaRange != null">#{areaRange},</if>
<if test="fencePushFlag != null and fencePushFlag != ''">#{fencePushFlag},</if>
<if test="fencePushContent != null">#{fencePushContent},</if>
<if test="fenceRecoverContent != null">#{fenceRecoverContent},</if>
@ -196,14 +112,13 @@ GROUP BY
update hw_electronic_fence
<trim prefix="SET" suffixOverrides=",">
<if test="electronicFenceName != null and electronicFenceName != ''">electronic_fence_name = #{electronicFenceName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="fenceType != null and fenceType != ''">fence_type = #{fenceType},</if>
<if test="effectiveTimeFlag != null and effectiveTimeFlag != ''">effective_time_flag = #{effectiveTimeFlag},</if>
<if test="timeZone != null">time_zone = #{timeZone},</if>
<if test="effectiveTime != null and effectiveTime != ''">effective_time = #{effectiveTime},</if>
<if test="triggerStatus != null and triggerStatus != ''">trigger_status = #{triggerStatus},</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">area_shape_flag = #{areaShapeFlag},</if>
<if test="areaRange != null">area_range = #{areaRange},</if>
<if test="fencePushFlag != null and fencePushFlag != ''">fence_push_flag = #{fencePushFlag},</if>
<if test="fencePushContent != null">fence_push_content = #{fencePushContent},</if>
<if test="fenceRecoverContent != null">fence_recover_content = #{fenceRecoverContent},</if>
@ -222,30 +137,52 @@ GROUP BY
</delete>
<delete id="deleteHwElectronicFenceByElectronicFenceIds" parameterType="String">
delete from hw_electronic_fence where electronic_fence_id in
delete from hw_electronic_fence where electronic_fence_id in
<foreach item="electronicFenceId" collection="array" open="(" separator="," close=")">
#{electronicFenceId}
</foreach>
</delete>
<delete id="deleteHwFenceTargetByElectronicFenceIds" parameterType="String">
delete from hw_fence_target where electronic_fence_id in
<foreach item="electronicFenceId" collection="array" open="(" separator="," close=")">
#{electronicFenceId}
</foreach>
</delete>
<select id="selectDeviceCount" parameterType="Long">
select count(*) as count
from hw_fence_target a where a.electronic_fence_id = #{electronicFenceId}
</select>
<delete id="deleteHwFenceTargetByElectronicFenceId" parameterType="Long">
delete from hw_fence_target where electronic_fence_id = #{electronicFenceId}
</delete>
<select id="selectDeviceCountByMonitorUnit" parameterType="Long">
select count(*) as count
from hw_device hd where hd.device_status=1 and exists (select 1 from hw_fence_target a
where hd.monitor_unit_id = a.target_id
and a.electronic_fence_id = #{electronicFenceId})
</select>
<insert id="batchHwFenceTarget">
insert into hw_fence_target( electronic_fence_id, target_type, target_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.electronicFenceId}, #{item.targetType}, #{item.targetId})
</foreach>
</insert>
<select id="selectDeviceCountByScene" parameterType="Long">
select count(*) as count
from hw_device hd where hd.device_status=1 and hd.scene_id = #{sceneId}
<select id="selectHwElectronicFenceJoinList" parameterType="HwElectronicFence" resultMap="HwElectronicFenceResult">
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
<where>
<if test="electronicFenceName != null and electronicFenceName != ''"> and hef.electronic_fence_name like concat('%', #{electronicFenceName}, '%')</if>
<if test="tenantId != null "> and hef.tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and hef.scene_id = #{sceneId}</if>
<if test="fenceType != null and fenceType != ''"> and hef.fence_type = #{fenceType}</if>
<if test="effectiveTimeFlag != null and effectiveTimeFlag != ''"> and hef.effective_time_flag = #{effectiveTimeFlag}</if>
<if test="timeZone != null and timeZone != ''"> and hef.time_zone = #{timeZone}</if>
<if test="effectiveTime != null and effectiveTime != ''"> and hef.effective_time = #{effectiveTime}</if>
<if test="triggerStatus != null and triggerStatus != ''"> and hef.trigger_status = #{triggerStatus}</if>
<if test="fencePushFlag != null and fencePushFlag != ''"> and hef.fence_push_flag = #{fencePushFlag}</if>
<if test="fencePushContent != null and fencePushContent != ''"> and hef.fence_push_content = #{fencePushContent}</if>
<if test="fenceRecoverContent != null and fenceRecoverContent != ''"> and hef.fence_recover_content = #{fenceRecoverContent}</if>
<if test="fenceField != null and fenceField != ''"> and hef.fence_field = #{fenceField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
</mapper>
</mapper>

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwMonitorUnitMapper">
<resultMap type="HwMonitorUnit" id="HwMonitorUnitResult">
<result property="monitorUnitId" column="monitor_unit_id" />
<result property="monitorUnitName" column="monitor_unit_name" />
<result property="sceneId" column="scene_id" />
<result property="tenantId" column="tenant_id" />
<result property="parentId" column="parent_id" />
<result property="monitorUnitTypeId" column="monitor_unit_type_id" />
<result property="areaId" column="area_id" />
@ -21,6 +20,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="monitorUnitField" column="monitor_unit_field" />
<result property="sceneName" column="scene_name" />
<result property="monitorUnitTypeName" column="monitor_unit_type_name" />
<result property="tenantName" column="tenant_name" />
</resultMap>
<resultMap type="HwMonitorUnitVo" id="HwMonitorUnitVoResult" >
<result property="sceneName" column="scene_name"/>
@ -58,66 +61,78 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectHwMonitorUnitVo">
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
</sql>
<sql id="selectHwMonitorUnitJoinScene">
select hmu.monitor_unit_id, hmu.monitor_unit_name, hmu.scene_id, hmu.parent_id,
hmu.monitor_unit_type_id, hmu.area_id, hmu.monitor_address, hmu.monitor_pic,
hmu.preserve_time, hmu.monitor_unit_status, hc.scene_name
from hw_monitor_unit hmu left join hw_scene hc on hmu.scene_id = hc.scene_id
</sql>
<select id="selectHaveEleDevice" parameterType="Long" resultMap="MonitorUnitNumVoResult">
SELECT monitor_unit_id,count(*) as num from hw_device where monitor_unit_id
= (select monitor_unit_id from hw_monitor_unit where monitor_unit_id =
(select target_id from hw_fence_target where target_type = '2'and
electronic_fence_id = (select electronic_fence_id from hw_electronic_fence
where scene_id = #{sceneId}) )) GROUP BY monitor_unit_id
= (select monitor_unit_id from hw_monitor_unit where monitor_unit_id =
(select target_id from hw_fence_target where target_type = '2'and
electronic_fence_id = (select electronic_fence_id from hw_electronic_fence
where scene_id = #{sceneId}) )) GROUP BY monitor_unit_id
</select>
<select id="selectMonitorUnitHaveEle" parameterType="Long" resultMap="MonitorUnitNumVoResult">
select monitor_unit_id,count(*) as num from hw_device where
monitor_unit_id = (select target_id from hw_fence_target where
target_type = '2'and electronic_fence_id =
(select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}) )
monitor_unit_id = (select target_id from hw_fence_target where
target_type = '2'and electronic_fence_id =
(select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}) )
GROUP BY monitor_unit_id
</select>
<select id="selectHwMonitorUnitList" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
<where>
<if test="monitorUnitName != null and monitorUnitName != ''"> and monitor_unit_name like concat('%', #{monitorUnitName}, '%')</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="monitorUnitTypeId != null "> and monitor_unit_type_id = #{monitorUnitTypeId}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="monitorAddress != null and monitorAddress != ''"> and monitor_address = #{monitorAddress}</if>
<if test="monitorPic != null and monitorPic != ''"> and monitor_pic = #{monitorPic}</if>
<if test="preserveTime != null "> and preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus==monitorUnitStatus"> and monitor_unit_status = '1'</if>
<if test="monitorUnitStatus != null "> and monitor_unit_status = #{monitorUnitStatus}</if>
<if test="monitorUnitField != null and monitorUnitField != ''"> and monitor_unit_field = #{monitorUnitField}</if>
</where>
</select>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
<select id="selectHwMonitorUnitByMonitorUnitId" parameterType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
</select>
<!--查询最子集监控单元以场景进行分组-->
<select id="selectHwMonitorUnitByMonitorUnitId" parameterType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
</select>
<!--查询最子集监控单元以场景进行分组-->
<select id="selectAllNums" resultMap="AllNumsVoResult">
select scene_id,count(*) as sub_sum from
(select monitor_unit_id,scene_id from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp
(select monitor_unit_id,scene_id from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id
</select>
<select id="selectSubSetNums" resultType="String">
<select id="selectSubSetNums" resultType="Integer">
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)
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select>
<select id="selectDeviceNums" resultType="String">
<select id="selectDeviceNums" resultType="Integer">
select count(*) as sum from hw_device
where device_status = '1'
where device_status = '1'
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select>
<!-- 通过场景分组,查询设备数量 todo 已解决 -->
<!-- 通过场景分组,查询设备数量 todo 已解决 -->
<select id="selectsum" resultMap="AllNumsVoResult">
select scene_id,count(*) as sum from hw_device
where device_status = '1'GROUP BY scene_id
select scene_id,count(*) as sum from hw_device
where device_status = '1'GROUP BY scene_id
</select>
<!-- 通过id查询子集并返回-->
<!-- 通过id查询子集并返回-->
<select id="selectHwMonitorUnitByParent" parameterType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where parent_id = #{monitorUnitId}
@ -126,11 +141,11 @@ where device_status = '1'GROUP BY scene_id
select count(*) from hw_device where releated_device_id = #{deviceId}
</select>
<!-- 查询该监控单元是否为最小单元-->
<!-- 查询该监控单元是否为最小单元-->
<select id="selectHwMonitorUnitIsParent" parameterType="Long" resultType="String">
SELECT count(*) from hw_monitor_unit where parent_id = #{monitorUnitId} GROUP BY parent_id
SELECT count(*) from hw_monitor_unit where parent_id = #{monitorUnitId} GROUP BY parent_id
</select>
<!-- todo 查询最小单元详细信息根据主键 byid 已解决-->
<!-- todo 查询最小单元详细信息根据主键 byid 已解决-->
<select id="selectHwmonitorUnitSub" resultType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
@ -139,57 +154,57 @@ where device_status = '1'GROUP BY scene_id
<select id="selectSceneNameById" resultMap="HwMonitorUnitVoResult">
select scene_id,scene_name from hw_scene
</select>
<!-- 分页查询在impl实现分页-->
<!-- 分页查询在impl实现分页-->
<select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult">
select * from hw_monitor_unit where monitor_unit_id
not in (select parent_id from hw_monitor_unit where parent_id is not null)
not in (select parent_id from hw_monitor_unit where parent_id is not null)
</select>
<!-- 查询最子集监控单元使用sceneid进行分组-->
<!-- 查询最子集监控单元使用sceneid进行分组-->
<select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult">
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id order by sum desc
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id order by sum desc
</select>
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
<select id="selectAlarmStats" resultMap="AlarmStatsResult">
select b.monitor_unit_id,b.monitor_unit_name,sum from
(select monitor_unit_id,count(*)as sum from hw_alarm_info GROUP BY monitor_unit_id
)as a left join hw_monitor_unit b on a.monitor_unit_id = b.monitor_unit_id order BY sum
select b.monitor_unit_id,b.monitor_unit_name,sum from
(select monitor_unit_id,count(*)as sum from hw_alarm_info where scene_id = #{sceneId} GROUP BY monitor_unit_id
)as a left join hw_monitor_unit b on a.monitor_unit_id = b.monitor_unit_id order BY sum
</select>
<!-- sub_sum 最子集监控单元数量device_num 设备数量 online_device_num在线设备数量 todo 传一个sceneid 监控单元和设备数量拆开查询 设备拿全部在后端判断 orderby 主键 -->
<!-- sub_sum 最子集监控单元数量device_num 设备数量 online_device_num在线设备数量 todo 传一个sceneid 监控单元和设备数量拆开查询 设备拿全部在后端判断 orderby 主键 -->
<select id="selectSubDeviceSum" parameterType="Long" resultType="Integer">
select count(*) from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp where scene_id = #{sceneId}
select count(*) from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp where scene_id = #{sceneId}
</select>
<!-- 先查询监控单元/设备的总量与报警未处理数量再通过场景id与电子围栏相连接-->
<!-- 先查询监控单元/设备的总量与报警未处理数量再通过场景id与电子围栏相连接-->
<select id="selectElectronicNum" resultMap="ElectronicNumVoResult">
select a.electronic_fence_id,a.electronic_fence_name,a.area_shape_flag,a.area_range,a.fence_type,b.num,b.alarm_num
from hw_electronic_fence as a left join ( select scene_id,count(*)as num,count(case when handle_status = '0' then 1 end ) as alarm_num from hw_alarm_info GROUP BY scene_id) as b on a.scene_id = b.scene_id
</select>
<select id="selectEleInScene" parameterType="Long" resultType="List">
select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}
select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}
</select>
<select id="selectEleType2" parameterType="Long" resultType="String">
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})
</select>
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})
</select>
<select id="selectEleType3" parameterType="Long" resultType="String">
select count(*) from hw_device where scene_id = #{sceneId}
</select>
<select id="selectDeviceType2Nums" parameterType="Long" resultType="Integer">
select count(*) from hw_device
where scene_id = #{sceneId}and device_type = '2' GROUP BY device_id
select count(*) from hw_device
where scene_id = #{sceneId}and device_type = '2' GROUP BY device_id
</select>
<insert id="insertHwMonitorUnit" parameterType="HwMonitorUnit" useGeneratedKeys="true" keyProperty="monitorUnitId">
insert into hw_monitor_unit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="monitorUnitName != null and monitorUnitName != ''">monitor_unit_name,</if>
<if test="sceneId != null">scene_id,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="monitorUnitTypeId != null">monitor_unit_type_id,</if>
<if test="areaId != null">area_id,</if>
@ -203,11 +218,11 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="monitorUnitField != null">monitor_unit_field,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="monitorUnitName != null and monitorUnitName != ''">#{monitorUnitName},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="monitorUnitTypeId != null">#{monitorUnitTypeId},</if>
<if test="areaId != null">#{areaId},</if>
@ -221,7 +236,7 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="monitorUnitField != null">#{monitorUnitField},</if>
</trim>
</trim>
</insert>
<update id="updateHwMonitorUnit" parameterType="HwMonitorUnit">
@ -229,7 +244,6 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
<trim prefix="SET" suffixOverrides=",">
<if test="monitorUnitName != null and monitorUnitName != ''">monitor_unit_name = #{monitorUnitName},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="tenantId != null">scene_id = #{tenantId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="monitorUnitTypeId != null">monitor_unit_type_id = #{monitorUnitTypeId},</if>
<if test="areaId != null">area_id = #{areaId},</if>
@ -248,23 +262,52 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
</update>
<delete id="deleteHwMonitorUnitByMonitorUnitId" parameterType="Long">
UPDATE hw_monitor_unit SET monitor_unit_status='9' where monitor_unit_id= #{monitorUnitId}
delete from hw_monitor_unit where monitor_unit_id = #{monitorUnitId}
</delete>
<delete id="deleteHwMonitorUnitByMonitorUnitIds" parameterType="String">
UPDATE hw_monitor_unit SET monitor_unit_status='9' where monitor_unit_id =
delete from hw_monitor_unit where monitor_unit_id in
<foreach item="monitorUnitId" collection="array" open="(" separator="," close=")">
#{monitorUnitId}
</foreach>
</delete>
<select id="selectIsParent" parameterType="Long" resultType="Integer">
select count(*) from hw_monitor_unit where parent_id = #{monitorUnitId}
</select>
<select id="selectDeviceRelevancyMontiorUnit" parameterType="Long" resultType="Integer" >
SELECT count(*) from hw_device where monitor_unit_id = #{monitorUnitId}
<select id="selectHwMonitorUnitListJoinScene" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitJoinScene"/>
<where>
hmu.monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
<if test="monitorUnitName != null and monitorUnitName != ''"> and monitor_unit_name like concat('%', #{monitorUnitName}, '%')</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="monitorUnitTypeId != null "> and monitor_unit_type_id = #{monitorUnitTypeId}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="monitorAddress != null and monitorAddress != ''"> and monitor_address = #{monitorAddress}</if>
<if test="monitorPic != null and monitorPic != ''"> and monitor_pic = #{monitorPic}</if>
<if test="preserveTime != null "> and preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and monitor_unit_status = #{monitorUnitStatus}</if>
<if test="monitorUnitField != null and monitorUnitField != ''"> and monitor_unit_field = #{monitorUnitField}</if>
</where>
</select>
<select id="selectElectronicFenceRelevancyMonitorUnit" parameterType="Long" resultType="Integer" >
SELECT count(*) from hw_fence_target where target_type = '2' and target_id = #{monitorUnitId}
<select id="selectHwMonitorUnitJoinList" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
select hmu.*,hmut.monitor_unit_type_name,ht.tenant_name,hs.scene_name from hw_monitor_unit hmu
left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id
left join hw_tenant ht on hmu.tenant_id = ht.tenant_id
left join hw_scene hs on hmu.scene_id = hs.scene_id
<where>
<if test="monitorUnitName != null and monitorUnitName != ''"> and monitor_unit_name like concat('%', #{monitorUnitName}, '%')</if>
<if test="sceneId != null "> and hmu.scene_id = #{sceneId}</if>
<if test="tenantId != null "> and hmu.tenant_id = #{tenantId}</if>
<if test="parentId != null "> and hmu.parent_id = #{parentId}</if>
<if test="monitorUnitTypeId != null "> and hmu.monitor_unit_type_id = #{monitorUnitTypeId}</if>
<if test="areaId != null "> and hmu.area_id = #{areaId}</if>
<if test="monitorAddress != null and monitorAddress != ''"> and hmu.monitor_address = #{monitorAddress}</if>
<if test="preserveTime != null "> and hmu.preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and hmu.monitor_unit_status = #{monitorUnitStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
</mapper>
</mapper>

@ -12,7 +12,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="languageCode" column="language_code" />
<result property="commonFlag" column="common_flag" />
<result property="sceneId" column="scene_id" />
<result property="tenantId" column="tenant_id" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -20,10 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="unitTypeIcon" column="unit_type_icon" />
<result property="unitTypeField" column="unit_type_field" />
<result property="sceneName" column="scene_name" />
<result property="tenantName" column="tenant_name" />
</resultMap>
<sql id="selectHwMonitorUnitTypeVo">
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
</sql>
<select id="selectHwMonitorUnitTypeByMonitorUnitTypeId" parameterType="Long" resultMap="HwMonitorUnitTypeResult">
@ -32,7 +33,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectHwMonitorUnitTypeList" parameterType="HwMonitorUnitType" resultMap="HwMonitorUnitTypeResult">
<include refid="selectHwMonitorUnitTypeVo"/>
<where>
<if test="monitorUnitTypeName != null and monitorUnitTypeName != ''"> and monitor_unit_type_name like concat('%', #{monitorUnitTypeName}, '%')</if>
<if test="vitualFlag != null and vitualFlag != ''"> and vitual_flag = #{vitualFlag}</if>
@ -40,17 +40,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="languageCode != null and languageCode != ''"> and language_code = #{languageCode}</if>
<if test="commonFlag != null and commonFlag != ''"> and common_flag = #{commonFlag}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="unitTypeIcon != null and unitTypeIcon != ''"> and unit_type_icon = #{unitTypeIcon}</if>
<if test="unitTypeField != null and unitTypeField != ''"> and unit_type_field = #{unitTypeField}</if>
<if test="monitorUnitTypeStatus == null"> and monitor_unit_type_status = '1'</if>
</where>
</select>
<insert id="insertHwMonitorUnitType" parameterType="HwMonitorUnitType" useGeneratedKeys="true" keyProperty="monitorUnitTypeId">
insert into hw_monitor_unit_type
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -59,8 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="monitorUnitTypeStatus != null and monitorUnitTypeStatus != ''">monitor_unit_type_status,</if>
<if test="languageCode != null">language_code,</if>
<if test="commonFlag != null and commonFlag != ''">common_flag,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="tenantId != null ">tenant_id,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
@ -75,8 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="monitorUnitTypeStatus != null and monitorUnitTypeStatus != ''">#{monitorUnitTypeStatus},</if>
<if test="languageCode != null">#{languageCode},</if>
<if test="commonFlag != null and commonFlag != ''">#{commonFlag},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="tenantId != null ">#{tenantId},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
@ -96,7 +92,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="languageCode != null">language_code = #{languageCode},</if>
<if test="commonFlag != null and commonFlag != ''">common_flag = #{commonFlag},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="tenantId != null ">tenant_id = #{tenantId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@ -109,17 +104,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteHwMonitorUnitTypeByMonitorUnitTypeId" parameterType="Long">
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}
</delete>
<delete id="deleteHwMonitorUnitTypeByMonitorUnitTypeIds" parameterType="String">
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
<foreach item="monitorUnitTypeId" collection="array" open="(" separator="," close=")">
#{monitorUnitTypeId}
</foreach>
</delete>
<select id="getNumsHwMonitorUnitTypeByMonitorUnitTypeId" parameterType="Long" resultType="int">
select count(*) from hw_monitor_unit where monitor_unit_type_id = #{monitorUnitTypeId}
<select id="selectHwMonitorUnitTypeJoinList" parameterType="HwMonitorUnitType" resultMap="HwMonitorUnitTypeResult">
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
<where>
<if test="monitorUnitTypeName != null and monitorUnitTypeName != ''"> and hmut.monitor_unit_type_name like concat('%', #{monitorUnitTypeName}, '%')</if>
<if test="vitualFlag != null and vitualFlag != ''"> and hmut.vitual_flag = #{vitualFlag}</if>
<if test="monitorUnitTypeStatus != null and monitorUnitTypeStatus != ''"> and hmut.monitor_unit_type_status = #{monitorUnitTypeStatus}</if>
<if test="languageCode != null and languageCode != ''"> and hmut.language_code = #{languageCode}</if>
<if test="commonFlag != null and commonFlag != ''"> and hmut.common_flag = #{commonFlag}</if>
<if test="sceneId != null "> and hmut.scene_id = #{sceneId}</if>
<if test="tenantId != null "> and hmut.tenant_id = #{tenantId}</if>
<if test="unitTypeIcon != null and unitTypeIcon != ''"> and hmut.unit_type_icon = #{unitTypeIcon}</if>
<if test="unitTypeField != null and unitTypeField != ''"> and hmut.unit_type_field = #{unitTypeField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
</mapper>

@ -54,28 +54,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectHwSceneVo">
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
</sql>
<select id="selectHwSceneVoList" parameterType="HwSceneVo" resultMap="HwSceneVoResult">
select a.*,b.tenant_name,c.scene_mode_name from hw_scene as a
left join hw_tenant as b on a.tenant_id = b.tenant_id
left join hw_scene_mode as c on a.scene_mode_id = c.scene_mode_id
where a.scene_status = '1'
<where>
<if test="sceneName != null and sceneName != ''"> and a.scene_name like concat('%', #{sceneName}, '%')</if>
<if test="contactName != null and contactName != ''"> and b.contact_name like concat('%', #{contactName}, '%')</if>
<if test="contactPhone != null and contactPhone != ''"> and b.contact_phone like concat('%', #{contactPhone}, '%')</if>
<if test="sceneModeId != null and sceneModeId != ''"> and a.scene_mode_id = #{sceneModeId}</if>
<if test="defaultFlag != null and defaultFlag != ''"> and a.default_flag = #{defaultFlag}</if>
<if test="tenantId != null and tenantId != ''"> and a.tenant_id = #{tenantId}</if>
<if test="tenantId != null"> and a.tenant_id = #{tenantId}</if>
</where>
order by a.scene_id desc
</select>
<select id="selectHwSceneList" parameterType="HwScene" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
<where>
<if test="sceneName != null and sceneName != ''"> and scene_name like concat('%', #{sceneName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
<if test="sceneModeId != null "> and scene_mode_id = #{sceneModeId}</if>
<if test="scenePic != null and scenePic != ''"> and scene_pic = #{scenePic}</if>
<if test="defaultFlag != null and defaultFlag != ''"> and default_flag = #{defaultFlag}</if>
@ -88,7 +88,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="testPreserveTime != null "> and test_preserve_time = #{testPreserveTime}</if>
<if test="sceneEnvironment != null and sceneEnvironment != ''"> and scene_environment = #{sceneEnvironment}</if>
<if test="sceneField != null and sceneField != ''"> and scene_field = #{sceneField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by scene_id desc
</select>
<select id="selectHwSceneByTenantId0" parameterType="Long" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
@ -97,6 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwSceneByTenantIdNot0" parameterType="Long" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
where tenant_id = #{tenantId}
order by update_time desc
</select>
<select id="selectHwSceneBySceneId" parameterType="Long" resultMap="HwSceneResult">
@ -188,13 +192,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteHwSceneBySceneIds" parameterType="String">
update hw_scene set scene_status = '9' where scene_id in
update hw_scene set scene_status = '9' where scene_id = in
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
#{sceneId}
</foreach>
</delete>
<select id="selectHwSceneVoListByTenantId" parameterType="Long" resultMap="HwSceneVoResult">
select scene_id,scene_name from hw_scene where tenant_id = #{tenantId}
</select>
</mapper>

@ -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<SysRole> 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<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
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<SysRoleDept> list = new ArrayList<SysRoleDept>();
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<SysUserRole> list = new ArrayList<SysUserRole>();
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<SysRole> 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);
}
}

@ -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
})
}

@ -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
})
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 17 KiB

@ -14,7 +14,7 @@ export default {
},
methods: {
goto() {
window.open(this.url)
this.$router.push({path: "/board/index"});
}
}
}

@ -8,13 +8,9 @@
<div class="right-menu">
<template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" />
<el-tooltip content="源码地址" effect="dark" placement="bottom">
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip content="文档地址" effect="dark" placement="bottom">
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
<el-tooltip content="监控平台" effect="dark" placement="bottom">
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
</el-tooltip>
<screenfull id="screenfull" class="right-menu-item hover-effect" />

@ -17,89 +17,81 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-input
v-model="queryParams.sceneId"
placeholder="请输入所属场景"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属监控单元" prop="monitorUnitId">
<el-input
v-model="queryParams.monitorUnitId"
placeholder="请输入所属监控单元"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="设备类型" prop="networkingMode">
<el-select v-model="queryParams.deviceType" placeholder="请选择设备类型" clearable>
<el-option
v-for="dict in dict.type.hw_device_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="queryParams.sceneId" placeholder="请选择" @input="sceneChange">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
<el-form-item label="接入协议" prop="accessProtocol">
<el-input
v-model="queryParams.accessProtocol"
placeholder="请输入接入协议"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数据格式" prop="dataFormat">
<el-input
v-model="queryParams.dataFormat"
placeholder="请输入数据格式"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="监控单元" prop="monitorUnitId">
<treeselect v-model="queryParams.monitorUnitId" :options="editedMonitorUnits" :show-count="true"
placeholder="请选择所属监控单元" :normalizer="normalizer" :flat="true" clearable style="width: 200px;"/>
</el-form-item>
<el-form-item label="设备模型" prop="deviceModeId">
<el-input
v-model="queryParams.deviceModeId"
placeholder="请输入设备模型"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="接入网关协议" prop="accessGwProtocol">
<el-input
v-model="queryParams.accessGwProtocol"
placeholder="请输入接入网关协议"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备激活时间" prop="activeTime">
<el-date-picker clearable
v-model="queryParams.activeTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择设备激活时间">
</el-date-picker>
<el-select v-model="queryParams.deviceModeId" placeholder="请选择" clearable>
<el-option
v-for="(editedDeviceMode, index) in editedDeviceModes"
:key="index"
:label="editedDeviceMode.deviceModeName"
:value="editedDeviceMode.deviceModeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备图片地址" prop="devicePic">
<el-input
v-model="queryParams.devicePic"
placeholder="请输入设备图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="激活状态" prop="activeStatus">
<el-select v-model="queryParams.activeStatus" placeholder="请选择" clearable>
<el-option
v-for="dict in dict.type.hw_device_active_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="网络地址" prop="ipAddress">
<el-input
v-model="queryParams.ipAddress"
placeholder="请输入网络地址"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="设备状态" prop="deviceStatus">
<el-select v-model="queryParams.deviceStatus" placeholder="请选择" clearable>
<el-option
v-for="dict in dict.type.hw_device_device_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="租户ID" prop="tenantId">
<el-input
v-model="queryParams.tenantId"
placeholder="请输入租户ID"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="在线状态" prop="onlineStatus">
<el-select v-model="queryParams.onlineStatus" placeholder="请选择" clearable>
<el-option
v-for="dict in dict.type.hw_device_online_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -118,30 +110,6 @@
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['business:device:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['business:device:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
@ -160,25 +128,42 @@
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="设备编号" align="center" prop="deviceCode"/>
<el-table-column label="设备名称" align="center" prop="deviceName"/>
<el-table-column label="所属场景" align="center" prop="sceneId"/>
<el-table-column label="所属监控单元" align="center" prop="monitorUnitId"/>
<el-table-column label="设备类型" align="center" prop="deviceType"/>
<el-table-column label="联网方式" align="center" prop="networkingMode"/>
<el-table-column label="接入协议" align="center" prop="accessProtocol"/>
<el-table-column label="数据格式" align="center" prop="dataFormat"/>
<el-table-column label="设备模型" align="center" prop="deviceModeId"/>
<el-table-column label="接入网关协议" align="center" prop="accessGwProtocol"/>
<el-table-column label="激活状态" align="center" prop="activeStatus"/>
<el-table-column label="设备状态" align="center" prop="deviceStatus"/>
<el-table-column label="设备类型" align="center" prop="deviceType">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_type" :value="scope.row.deviceType"/>
</template>
</el-table-column>
<el-table-column label="所属租户" align="center" prop="tenantName"/>
<el-table-column label="所属场景" align="center" prop="sceneName"/>
<el-table-column label="监控单元" align="center" prop="monitorUnitName"/>
<el-table-column label="设备模型" align="center" prop="deviceModeName"/>
<el-table-column label="激活状态" align="center" prop="activeStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_active_status" :value="scope.row.activeStatus"/>
</template>
</el-table-column>
<el-table-column label="设备激活时间" align="center" prop="activeTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.activeTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="设备图片地址" align="center" prop="devicePic"/>
<el-table-column label="网络地址" align="center" prop="ipAddress"/>
<el-table-column label="租户" align="center" prop="tenantId"/>
<el-table-column label="在线状态" align="center" prop="onlineStatus"/>
<el-table-column label="设备状态" align="center" prop="deviceStatus">
<template slot-scope="scope">
<el-switch
v-model="scope.row.deviceStatus"
active-value="1"
inactive-value="0"
@change="handleDeviceStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="在线状态" align="center" prop="onlineStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_online_status" :value="scope.row.onlineStatus"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -211,36 +196,43 @@
<!-- 添加或修改设备信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="设备编号" prop="deviceCode">
<el-input v-model="form.deviceCode" placeholder="请输入设备编号"/>
<el-input v-model="form.deviceCode" placeholder="请输入设备编号" maxlength="20"/>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="form.deviceName" placeholder="请输入设备名称"/>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="form.sceneId" placeholder="请选择" :input="getMonitorUnitTree()">
<el-form-item label="设备类型" prop="networkingMode">
<el-select v-model="form.deviceType" placeholder="请选择设备类型" @input="deviceTypeChange" :disabled="deviceTypeDisabled">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
v-for="dict in dict.type.hw_device_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属监控单元" prop="monitorUnitId">
<el-select v-model="form.monitorUnitId" placeholder="请选择" :disabled="disabled">
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="form.sceneId" placeholder="请选择" @input="sceneChange" :disabled="sceneDisabled">
<el-option
v-for="(monitorUnit, index) in monitorUnits"
v-for="(scene, index) in editedScenes"
:key="index"
:label="monitorUnit.monitorUnitName"
:value="monitorUnit.monitorUnitId"
:label="scene.sceneName"
:value="scene.sceneId"
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="联网方式" prop="networkingMode">
<el-form-item label="监控单元" prop="monitorUnitId">
<treeselect v-model="form.monitorUnitId" :options="editedMonitorUnits" :show-count="true"
placeholder="请选择所属监控单元" :normalizer="normalizer" :flat="true"/>
</el-form-item>
<el-form-item label="联网方式" prop="networkingMode" v-if="deviceVisible">
<el-select v-model="form.networkingMode" placeholder="请选择数据类型">
<el-option
v-for="dict in dict.type.hw_device_networking_mode"
@ -249,23 +241,49 @@
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="接入协议" prop="accessProtocol">
<el-input v-model="form.accessProtocol" placeholder="请输入接入协议"/>
</el-form-item>
<el-form-item label="数据格式" prop="dataFormat">
<el-input v-model="form.dataFormat" placeholder="请输入数据格式"/>
<el-form-item label="接入协议" prop="accessProtocol" v-if="deviceVisible">
<el-select v-model="form.accessProtocol" placeholder="请选择接入协议">
<el-option
v-for="dict in dict.type.hw_device_access_protocol"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联设备" prop="releatedDeviceId">
<el-input v-model="form.releatedDeviceId" placeholder="请输入关联设备hw_device表中国的device_id"/>
<el-form-item label="数据格式" prop="dataFormat" v-if="deviceVisible">
<el-select v-model="form.accessProtocol" placeholder="请选择数据格式">
<el-option
v-for="dict in dict.type.hw_device_data_format"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备模型" prop="deviceModeId">
<el-input v-model="form.deviceModeId" placeholder="请输入设备模型"/>
<el-form-item label="关联网关" prop="releatedDeviceId" v-if="subDeviceVisible">
<el-select v-model="form.releatedDeviceId" placeholder="请选择">
<el-option
v-for="(editedGatewayDevice, index) in editedGatewayDevices"
:key="index"
:label="editedGatewayDevice.deviceName"
:value="editedGatewayDevice.deviceId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="接入网关协议" prop="accessGwProtocol">
<el-input v-model="form.accessGwProtocol" placeholder="请输入接入网关协议"/>
<el-form-item label="设备模型" prop="deviceModeId" v-if="subDeviceVisible">
<el-select v-model="form.deviceModeId" placeholder="请选择">
<el-option
v-for="(editedDeviceMode, index) in editedDeviceModes"
:key="index"
:label="editedDeviceMode.deviceModeName"
:value="editedDeviceMode.deviceModeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="描述" prop="remark">
@ -316,7 +334,7 @@
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" v-if="confirmBtnVisible"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@ -324,11 +342,25 @@
</template>
<script>
import {listDevice, getDevice, delDevice, addDevice, updateDevice,getMonitorTree} from "@/api/business/device";
import {getScenes} from "@/api/business/scene";
import {
listDevice,
getDevice,
delDevice,
addDevice,
updateDevice,
getScenes,
getEditedScenes,
getMonitorTree,
getDeviceModes,
getGatewayDevices,
changeDeviceStatus
} from "@/api/business/device";
import {getToken} from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
components: {Treeselect},
dicts: ['hw_device_type', 'hw_device_networking_mode', 'hw_device_access_protocol', 'hw_device_data_format', 'hw_device_active_status', 'hw_device_device_status', 'hw_device_online_status'],
name: "Device",
props: {
@ -373,12 +405,38 @@ export default {
deviceList: [],
//
scenes: [],
//
monitorUnits: [],
//
editedScenes:[],
//
editedMonitorUnits: undefined,
//
editedDeviceModes: [],
//
editedGatewayDevices: [],
deviceTypeDisabled:true,
sceneDisabled:true,
subDeviceVisible: false,//
deviceVisible: false,//
DEVICE_TYPE_GATEWAY_DEVICE: "1",//
DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT: "2",//
DEVICE_TYPE_DIRECT_CONNECT_DEVICE: "3",//
DEVICE_ACCESS_PROTOCOL_MQTT: 1,//,MQTT
DEVICE_NETWORKING_MODE_WIFI: "1",// WIFI
DEVICE_DATA_FORMAT_JSON: 1,// JSON
DEVICE_STATUS_PUBLISHED: "1",//:
ACTIVE_STATUS_INACTIVE: "0",//
confirmBtnVisible : true,
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
@ -409,38 +467,25 @@ export default {
//
rules: {
deviceCode: [
{required: true, message: "设备编号不能为空", trigger: "blur"}
{required: true, message: "设备编号不能为空", trigger: "blur"},
{
pattern: /^[a-z][a-z0-9_]+$/,
message: "2-20个字符由小写字母、数字或下划线组成开头必须为小写字母",
trigger: "blur"
}
],
deviceName: [
{required: true, message: "设备名称不能为空", trigger: "blur"}
],
sceneId: [
{required: true, message: "所属场景关联hw_scene表的scene_id字段不能为空", trigger: "blur"}
{required: true, message: "所属场景不能为空", trigger: "change"}
],
deviceType: [
{required: true, message: "设备类型不能为空", trigger: "change"}
],
networkingMode: [
{required: true, message: "联网方式(1:Wi-Fi2、蜂窝(2G/3G/4G/5G),3、以太网4、其他)不能为空", trigger: "blur"}
],
accessProtocol: [
{required: true, message: "接入协议不能为空", trigger: "blur"}
],
dataFormat: [
{required: true, message: "数据格式不能为空", trigger: "blur"}
],
activeStatus: [
{required: true, message: "激活状态不能为空", trigger: "change"}
monitorUnitId: [
{required: true, message: "监控单元不能为空", trigger: "change"}
],
deviceStatus: [
{required: true, message: "设备状态不能为空", trigger: "change"}
],
tenantId: [
{required: true, message: "租户ID关联hw_tenant的tenant_id不能为空", trigger: "blur"}
],
onlineStatus: [
{required: true, message: "在线状态不能为空", trigger: "change"}
]
},
number: 0,
uploadList: [],
@ -455,9 +500,6 @@ export default {
};
},
created() {
getMonitorTree().then(response => {
alert(JSON.stringify(response.data));
});
this.getList();
getScenes().then(response => {
this.scenes = response.data;
@ -473,11 +515,18 @@ export default {
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
formatRow() {
return (row) => {
// let languages = this.languages;
// for (let i = 0; i < languages.length; i++) {
// if (languages[i].languageCode === row.languageCode) {
// return languages[i].languageName;
// }
// }
};
},
},
methods: {
getMonitorUnitTree(){
},
/** 查询设备信息列表 */
getList() {
this.loading = true;
@ -494,13 +543,15 @@ export default {
},
//
reset() {
this.subDeviceVisible = true;
this.deviceVisible = false;
this.form = {
deviceId: null,
deviceCode: null,
deviceName: null,
sceneId: null,
monitorUnitId: null,
deviceType: 2,
deviceType: "2",
networkingMode: null,
accessProtocol: null,
dataFormat: null,
@ -540,15 +591,48 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
this.deviceTypeDisabled = false;
this.sceneDisabled = false;
this.fileList = [];
this.reset();
this.open = true;
this.title = "添加设备信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
this.deviceTypeDisabled = true;
this.sceneDisabled = true;
this.reset();
this.fileList = [];
const deviceId = row.deviceId || this.ids
getDevice(deviceId).then(response => {
if(response.data.deviceStatus===this.DEVICE_STATUS_PUBLISHED){
this.confirmBtnVisible = false;
}
if (response.data.devicePic != null) {
let previewFile = {};
previewFile.url = response.data.devicePic
this.fileList.push(previewFile);
}
this.getEditedMonitorTree(response.data.sceneId);
if (response.data.deviceType === this.DEVICE_TYPE_GATEWAY_DEVICE
|| response.data.deviceType === this.DEVICE_TYPE_DIRECT_CONNECT_DEVICE) {
this.subDeviceVisible = false;
this.deviceVisible = true;
} else {
this.subDeviceVisible = true;
this.deviceVisible = false;
this.getEditedDeviceModes(response.data.sceneId);
this.getGatewayDevices(response.data.sceneId);
}
this.form = response.data;
this.open = true;
this.title = "修改设备信息";
@ -560,6 +644,31 @@ export default {
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deviceType === this.DEVICE_TYPE_GATEWAY_DEVICE || this.form.deviceType === this.DEVICE_TYPE_DIRECT_CONNECT_DEVICE) {
// if(this.form.net)
// networkingMode: [
// {required: true, message: "(1:Wi-Fi2(2G/3G/4G/5G),34)", trigger: "blur"}
// ],
// accessProtocol: [
// {required: true, message: "", trigger: "blur"}
// ],
// dataFormat: [
// {required: true, message: "", trigger: "blur"}
// ],
} else {
if (this.form.releatedDeviceId === null || this.form.releatedDeviceId === undefined
|| this.form.releatedDeviceId === '') {
this.$modal.msgWarning("请选择关联网关");
return;
}
if (this.form.deviceModeId === null || this.form.deviceModeId === undefined
|| this.form.deviceModeId === '') {
this.$modal.msgWarning("请选择设备模型");
return;
}
}
if (this.form.deviceId != null) {
updateDevice(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
@ -634,7 +743,7 @@ export default {
//
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} limit!`);
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
},
//
handleUploadSuccess(res, file) {
@ -691,7 +800,94 @@ export default {
}
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
}
},
getEditedMonitorTree(sceneId) {
getMonitorTree(sceneId).then(response => {
this.editedMonitorUnits = response.data;
});
},
getEditedDeviceModes(sceneId) {
getDeviceModes(sceneId).then(response => {
this.editedDeviceModes = response.data;
});
},
getGatewayDevices(sceneId) {
getGatewayDevices(sceneId).then(response => {
this.editedGatewayDevices = response.data;
});
},
sceneChange(sceneId) {
this.form.monitorUnitId = null;
this.queryParams.monitorUnitId = null;
this.form.deivceModeId = null;
this.queryParams.deviceModeId = null;
this.getEditedMonitorTree(sceneId);
this.getEditedDeviceModes(sceneId);
this.getGatewayDevices(sceneId);
},
deviceTypeChange(deviceType) {
if (deviceType === this.DEVICE_TYPE_GATEWAY_DEVICE || deviceType === this.DEVICE_TYPE_DIRECT_CONNECT_DEVICE) {
this.form.releatedDeviceId = null;
this.form.deviceModeId = null;
this.form.accessProtocol = this.DEVICE_ACCESS_PROTOCOL_MQTT;
this.form.networkingMode = this.DEVICE_NETWORKING_MODE_WIFI;
this.form.dataFormat = this.DEVICE_DATA_FORMAT_JSON;
this.deviceVisible = true;
this.subDeviceVisible = false;
} else {
this.form.networkingMode = null;
this.form.accessProtocol = null;
this.form.dataFormat = null;
this.subDeviceVisible = true;
this.deviceVisible = false;
}
},
monitorUnitSelect(node) {
if (node.children !== undefined) {
this.form.monitorUnitId = null;
this.$modal.msgWarning("请选择子级监控单元");
}
},
normalizer(node) {
return {
id: node.id,
label: node.label,
children: node.children,
isDisabled: node.children !== undefined
};
// if (!node.children) {
// return {
// id: node.monitorUnitId,
// label: node.monitorUnitName
// };
// }
},
//
handleDeviceStatusChange(row) {
if(row.deviceStatus==='1' && row.activeStatus === '0'){
this.$modal.msgSuccess("激活后才能修改为发布状态");
row.deviceStatus = row.deviceStatus === "0" ? "1" : "0";
return;
}
let text = row.deviceStatus === "0" ? "测试" : "发布";
this.$modal.confirm('确认要改为'+text+'状态吗?').then(function () {
return changeDeviceStatus(row.deviceId, row.deviceStatus);
}).then(() => {
this.$modal.msgSuccess("修改状态成功");
}).catch(function () {
row.deviceStatus = row.deviceStatus === "0" ? "1" : "0";
});
},
}
};
</script>

@ -9,62 +9,29 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属场景关联hw_scene表的scene_id字段" prop="sceneId">
<el-input
v-model="queryParams.sceneId"
placeholder="请输入所属场景关联hw_scene表的scene_id字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="生效时间标识" prop="effectiveTimeFlag">
<el-input
v-model="queryParams.effectiveTimeFlag"
placeholder="请输入生效时间标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="时区" prop="timeZone">
<el-input
v-model="queryParams.timeZone"
placeholder="请输入时区"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="queryParams.sceneId" placeholder="请选择" @input="sceneChange">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="格式开始时间_结束时间_状态多个用|隔开" prop="effectiveTime">
<el-input
v-model="queryParams.effectiveTime"
placeholder="请输入格式开始时间_结束时间_状态多个用|隔开"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="区域形状" prop="areaShapeFlag">
<el-input
v-model="queryParams.areaShapeFlag"
placeholder="请输入区域形状"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="报警推送标识(1、是0、否" prop="fencePushFlag">
<el-input
v-model="queryParams.fencePushFlag"
placeholder="请输入报警推送标识(1、是0、否"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="fenceField">
<el-input
v-model="queryParams.fenceField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="触发状态" prop="sceneId">
<el-select v-model="queryParams.triggerStatus" placeholder="请选择触发状态" clearable>
<el-option
v-for="dict in dict.type.hw_fence_trigger_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -119,21 +86,18 @@
<el-table v-loading="loading" :data="electronicFenceList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="电子围栏ID" align="center" prop="electronicFenceId" />
<el-table-column label="电子围栏名称" align="center" prop="electronicFenceName" />
<el-table-column label="所属场景关联hw_scene表的scene_id字段" align="center" prop="sceneId" />
<el-table-column label="规则类型" align="center" prop="fenceType" />
<el-table-column label="生效时间标识" align="center" prop="effectiveTimeFlag" />
<el-table-column label="时区" align="center" prop="timeZone" />
<el-table-column label="格式开始时间_结束时间_状态多个用|隔开" align="center" prop="effectiveTime" />
<el-table-column label="触发状态" align="center" prop="triggerStatus" />
<el-table-column label="区域形状" align="center" prop="areaShapeFlag" />
<el-table-column label="区域范围为多边形时保存格式经度_纬度多个以|隔开;为圆形时的中心点和半径,下划线隔开" align="center" prop="areaRange" />
<el-table-column label="报警推送标识(1、是0、否" align="center" prop="fencePushFlag" />
<el-table-column label="报警推送内容" align="center" prop="fencePushContent" />
<el-table-column label="恢复正常推送内容" align="center" prop="fenceRecoverContent" />
<el-table-column label="描述" align="center" prop="remark" />
<el-table-column label="预留字段" align="center" prop="fenceField" />
<el-table-column label="所属场景" align="center" prop="sceneName" />
<el-table-column label="规则类型" align="center" prop="fenceType" >
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_fence_type" :value="scope.row.fenceType"/>
</template>
</el-table-column>
<el-table-column label="触发状态" align="center" prop="triggerStatus" >
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_fence_trigger_status" :value="scope.row.triggerStatus"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -162,79 +126,16 @@
@pagination="getList"
/>
<!-- 添加或修改电子围栏对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="电子围栏名称" prop="electronicFenceName">
<el-input v-model="form.electronicFenceName" placeholder="请输入电子围栏名称" />
</el-form-item>
<el-form-item label="所属场景关联hw_scene表的scene_id字段" prop="sceneId">
<el-input v-model="form.sceneId" placeholder="请输入所属场景关联hw_scene表的scene_id字段" />
</el-form-item>
<el-form-item label="生效时间标识" prop="effectiveTimeFlag">
<el-input v-model="form.effectiveTimeFlag" placeholder="请输入生效时间标识" />
</el-form-item>
<el-form-item label="时区" prop="timeZone">
<el-input v-model="form.timeZone" placeholder="请输入时区" />
</el-form-item>
<el-form-item label="格式开始时间_结束时间_状态多个用|隔开" prop="effectiveTime">
<el-input v-model="form.effectiveTime" placeholder="请输入格式开始时间_结束时间_状态多个用|隔开" />
</el-form-item>
<el-form-item label="区域形状" prop="areaShapeFlag">
<el-input v-model="form.areaShapeFlag" placeholder="请输入区域形状" />
</el-form-item>
<el-form-item label="区域范围为多边形时保存格式经度_纬度多个以|隔开;为圆形时的中心点和半径,下划线隔开" prop="areaRange">
<el-input v-model="form.areaRange" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="报警推送标识(1、是0、否" prop="fencePushFlag">
<el-input v-model="form.fencePushFlag" placeholder="请输入报警推送标识(1、是0、否" />
</el-form-item>
<el-form-item label="报警推送内容">
<editor v-model="form.fencePushContent" :min-height="192"/>
</el-form-item>
<el-form-item label="恢复正常推送内容">
<editor v-model="form.fenceRecoverContent" :min-height="192"/>
</el-form-item>
<el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="预留字段" prop="fenceField">
<el-input v-model="form.fenceField" placeholder="请输入预留字段" />
</el-form-item>
<el-divider content-position="center">电子围栏目标信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddHwFenceTarget"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteHwFenceTarget"></el-button>
</el-col>
</el-row>
<el-table :data="hwFenceTargetList" :row-class-name="rowHwFenceTargetIndex" @selection-change="handleHwFenceTargetSelectionChange" ref="hwFenceTarget">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="目标类型" prop="targetType" width="150">
<template slot-scope="scope">
<el-select v-model="scope.row.targetType" placeholder="请选择目标类型">
<el-option label="请选择字典生成" value="" />
</el-select>
</template>
</el-table-column>
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listElectronicFence, getElectronicFence, delElectronicFence, addElectronicFence, updateElectronicFence } from "@/api/business/electronicFence";
import {getScenes} from "@/api/business/device";
export default {
name: "ElectronicFence",
dicts: ['hw_fence_trigger_status','hw_fence_type'],
data() {
return {
//
@ -255,6 +156,8 @@ export default {
electronicFenceList: [],
//
hwFenceTargetList: [],
//
scenes: [],
//
title: "",
//
@ -277,40 +180,24 @@ export default {
fenceRecoverContent: null,
fenceField: null
},
//
form: {},
//
rules: {
electronicFenceName: [
{ required: true, message: "电子围栏名称不能为空", trigger: "blur" }
],
sceneId: [
{ required: true, message: "所属场景关联hw_scene表的scene_id字段不能为空", trigger: "blur" }
],
fenceType: [
{ required: true, message: "规则类型不能为空", trigger: "change" }
],
effectiveTimeFlag: [
{ required: true, message: "生效时间标识不能为空", trigger: "blur" }
],
effectiveTime: [
{ required: true, message: "格式开始时间_结束时间_状态多个用|隔开不能为空", trigger: "blur" }
],
triggerStatus: [
{ required: true, message: "触发状态不能为空", trigger: "change" }
],
areaShapeFlag: [
{ required: true, message: "区域形状不能为空", trigger: "blur" }
],
fencePushFlag: [
{ required: true, message: "报警推送标识(1、是0、否不能为空", trigger: "blur" }
],
}
};
},
created() {
getScenes().then(response => {
this.scenes = response.data;
});
this.getList();
},
activated() {
const time = this.$route.query.t;
if (time != null && time != this.uniqueId) {
this.uniqueId = time;
this.queryParams.pageNum = Number(this.$route.query.pageNum);
this.getList();
}
},
methods: {
/** 查询电子围栏列表 */
getList() {
@ -377,30 +264,10 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
const electronicFenceId = row.electronicFenceId || this.ids
let electronicFenceName = row.electronicName;
this.$tab.openPage("修改电子围栏[" + electronicFenceName + "]", '/electronicFence/fence-edit/index/' + electronicFenceId, );
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.hwFenceTargetList = this.hwFenceTargetList;
if (this.form.electronicFenceId != null) {
updateElectronicFence(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addElectronicFence(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
let electronicFenceName = row.electronicFenceName;
this.$tab.openPage("修改电子围栏[" + electronicFenceName + "]", '/electronicFence/fence-edit/index/' + electronicFenceId);
},
/** 删除按钮操作 */
handleDelete(row) {
const electronicFenceIds = row.electronicFenceId || this.ids;

@ -9,107 +9,41 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="租户ID关联hw_tenant的tenant_id" prop="tenantId">
<el-input
v-model="queryParams.tenantId"
placeholder="请输入租户ID关联hw_tenant的tenant_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景类型关联表hw_scene_mode的scene_mode_id" prop="sceneModeId">
<el-input
v-model="queryParams.sceneModeId"
placeholder="请输入场景类型关联表hw_scene_mode的scene_mode_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景图片地址" prop="scenePic">
<el-input
v-model="queryParams.scenePic"
placeholder="请输入场景图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="所属租户" prop="tenantId">
<el-select v-model="queryParams.tenantId" placeholder="请选择">
<el-option
v-for="(tenant, index) in tenants"
:key="index"
:label="tenant.tenantName"
:value="tenant.tenantId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="defaultFlag">
<el-select v-model="queryParams.defaultFlag" placeholder="部门状态" clearable>
<el-option
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="场景类型" prop="sceneModeId">
<el-select v-model="queryParams.sceneModeId" placeholder="请选择">
<el-option
v-for="(sceneMode, index) in sceneModes"
:key="index"
:label="sceneMode.sceneModeName"
:value="sceneMode.sceneModeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="认证方式" prop="authMode">
<el-input
v-model="queryParams.authMode"
placeholder="请输入认证方式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景账号" prop="modeAccount">
<el-input
v-model="queryParams.modeAccount"
placeholder="请输入场景账号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景key" prop="modeKey">
<el-input
v-model="queryParams.modeKey"
placeholder="请输入场景key"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景secret" prop="modeSecret">
<el-input
v-model="queryParams.modeSecret"
placeholder="请输入场景secret"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="保存周期(单位默认90天" prop="preserveTime">
<el-input
v-model="queryParams.preserveTime"
placeholder="请输入保存周期(单位默认90天"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="测试环境保存周期(单位默认30天" prop="testPreserveTime">
<el-input
v-model="queryParams.testPreserveTime"
placeholder="请输入测试环境保存周期(单位默认30天"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,租户环境" prop="sceneEnvironment">
<el-input
v-model="queryParams.sceneEnvironment"
placeholder="请输入预留字段,租户环境"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="sceneField">
<el-input
v-model="queryParams.sceneField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="通用标识" prop="defaultFlag">
<el-select v-model="queryParams.defaultFlag" placeholder="请选择">
<el-option
v-for="dict in dict.type.hw_scene_default_flag"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -125,7 +59,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['business:scene:add']"
>新增</el-button>
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -136,7 +71,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['business:scene:edit']"
>修改</el-button>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -147,7 +83,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['business:scene:remove']"
>删除</el-button>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -157,29 +94,24 @@
size="mini"
@click="handleExport"
v-hasPermi="['business:scene:export']"
>导出</el-button>
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="sceneList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="场景ID" align="center" prop="sceneId" />
<el-table-column label="场景名称" align="center" prop="sceneName" />
<el-table-column label="租户ID关联hw_tenant的tenant_id" align="center" prop="tenantId" />
<el-table-column label="场景类型关联表hw_scene_mode的scene_mode_id" align="center" prop="sceneModeId" />
<el-table-column label="场景图片地址" align="center" prop="scenePic" />
<el-table-column label="是否默认" align="center" prop="defaultFlag" />
<el-table-column label="状态" align="center" prop="sceneStatus" />
<el-table-column label="认证方式" align="center" prop="authMode" />
<el-table-column label="场景账号" align="center" prop="modeAccount" />
<el-table-column label="场景key" align="center" prop="modeKey" />
<el-table-column label="场景secret" align="center" prop="modeSecret" />
<el-table-column label="保存周期(单位默认90天" align="center" prop="preserveTime" />
<el-table-column label="测试环境保存周期(单位默认30天" align="center" prop="testPreserveTime" />
<el-table-column label="场景描述" align="center" prop="remark" />
<el-table-column label="预留字段,租户环境" align="center" prop="sceneEnvironment" />
<el-table-column label="预留字段" align="center" prop="sceneField" />
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="场景ID" align="center" prop="sceneId"/>
<el-table-column label="场景名称" align="center" prop="sceneName"/>
<el-table-column label="所属租户" align="center" prop="tenantName"/>
<el-table-column label="场景类型" align="center" prop="sceneModeName"/>
<el-table-column label="是否默认" align="center" prop="defaultFlag">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_scene_default_flag" :value="scope.row.defaultFlag"/>
</template>
</el-table-column>
<el-table-column label="保存周期(天)" align="center" prop="preserveTime"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -188,14 +120,16 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['business:scene:edit']"
>修改</el-button>
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['business:scene:remove']"
>删除</el-button>
>删除
</el-button>
</template>
</el-table-column>
</el-table>
@ -210,49 +144,108 @@
<!-- 添加或修改场景信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="场景名称" prop="sceneName">
<el-input v-model="form.sceneName" placeholder="请输入场景名称" />
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-form-item label="所属租户" prop="tenantId">
<el-select v-model="form.tenantId" placeholder="请选择">
<el-option
v-for="(tenant, index) in tenants"
:key="index"
:label="tenant.tenantName"
:value="tenant.tenantId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="租户ID关联hw_tenant的tenant_id" prop="tenantId">
<el-input v-model="form.tenantId" placeholder="请输入租户ID关联hw_tenant的tenant_id" />
</el-form-item>
<el-form-item label="场景类型关联表hw_scene_mode的scene_mode_id" prop="sceneModeId">
<el-input v-model="form.sceneModeId" placeholder="请输入场景类型关联表hw_scene_mode的scene_mode_id" />
<el-form-item label="场景名称" prop="sceneName">
<el-input v-model="form.sceneName" placeholder="请输入场景名称"/>
</el-form-item>
<el-form-item label="场景图片地址" prop="scenePic">
<el-input v-model="form.scenePic" placeholder="请输入场景图片地址" />
<el-form-item label="场景类型" prop="sceneModeId">
<el-select v-model="form.sceneModeId" placeholder="请选择">
<el-option
v-for="(sceneMode, index) in sceneModes"
:key="index"
:label="sceneMode.sceneModeName"
:value="sceneMode.sceneModeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="是否默认" prop="defaultFlag">
<el-input v-model="form.defaultFlag" placeholder="请输入是否默认" />
<el-radio-group v-model="form.defaultFlag">
<el-radio
v-for="dict in dict.type.hw_scene_default_flag"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="认证方式" prop="authMode">
<el-input v-model="form.authMode" placeholder="请输入认证方式" />
<el-select v-model="form.authMode" placeholder="请选择认证方式">
<el-option
v-for="dict in dict.type.hw_scene_auth_mode"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="场景账号" prop="modeAccount">
<el-input v-model="form.modeAccount" placeholder="请输入场景账号" />
</el-form-item>
<el-form-item label="场景key" prop="modeKey">
<el-input v-model="form.modeKey" placeholder="请输入场景key" />
</el-form-item>
<el-form-item label="场景secret" prop="modeSecret">
<el-input v-model="form.modeSecret" placeholder="请输入场景secret" />
<el-input v-model="form.modeAccount" placeholder="请输入场景账号"/>
</el-form-item>
<el-form-item label="保存周期(单位默认90天" prop="preserveTime">
<el-input v-model="form.preserveTime" placeholder="请输入保存周期(单位默认90天" />
<el-form-item label="场景密码" prop="modeKey">
<el-input v-model="form.modeKey" placeholder="请输入场景key"/>
</el-form-item>
<el-form-item label="测试环境保存周期(单位默认30天" prop="testPreserveTime">
<el-input v-model="form.testPreserveTime" placeholder="请输入测试环境保存周期(单位默认30天" />
<el-form-item label="保存周期(天)" prop="preserveTime">
<el-input v-model="form.preserveTime" placeholder="请输入保存周期(单位默认90天"/>
</el-form-item>
<el-form-item label="场景描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="预留字段,租户环境" prop="sceneEnvironment">
<el-input v-model="form.sceneEnvironment" placeholder="请输入预留字段,租户环境" />
</el-form-item>
<el-form-item label="预留字段" prop="sceneField">
<el-input v-model="form.sceneField" placeholder="请输入预留字段" />
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
<el-form-item label="场景图片" prop="scenePic">
<el-upload
single
:action="uploadImgUrl"
list-type="picture-card"
:limit="limit"
:on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload"
:on-error="handleUploadError"
:on-exceed="handleExceed"
ref="imageUpload"
:on-remove="handleDeletePicture"
:show-file-list="true"
:headers="headers"
:file-list="fileList"
:on-preview="handlePictureCardPreview"
:class="{hide: this.fileList.length >= 1}"
>
<i class="el-icon-plus"></i>
</el-upload>
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传
<template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b></template>
<template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
的文件
</div>
<el-dialog
:visible.sync="dialogVisible"
title="预览"
width="800"
append-to-body
>
<img
:src="dialogImageUrl"
style="display: block; max-width: 100%; margin: 0 auto"
/>
</el-dialog>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -263,11 +256,35 @@
</template>
<script>
import { listScene, getScene, delScene, addScene, updateScene } from "@/api/business/scene";
import {listScene, getScene, delScene, addScene, updateScene, getSceneModes, getTenants} from "@/api/business/scene";
import {getToken} from "@/utils/auth";
export default {
name: "Scene",
dicts: ['sys_user_sex'],
dicts: ['hw_scene_auth_mode', 'hw_scene_default_flag'],
props: {
value: [String, Object, Array],
//
limit: {
type: Number,
default: 1,
},
// (MB)
fileSize: {
type: Number,
default: 5,
},
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ["png", "jpg", "jpeg"],
},
//
isShowTip: {
type: Boolean,
default: true
}
},
data() {
return {
//
@ -288,6 +305,9 @@ export default {
title: "",
//
open: false,
sceneModes: [],
tenants: [],
//
queryParams: {
pageNum: 1,
@ -312,39 +332,63 @@ export default {
//
rules: {
sceneName: [
{ required: true, message: "场景名称不能为空", trigger: "blur" }
{required: true, message: "场景名称不能为空", trigger: "blur"}
],
sceneModeId: [
{ required: true, message: "场景类型关联表hw_scene_mode的scene_mode_id不能为空", trigger: "blur" }
{required: true, message: "场景类型关联表hw_scene_mode的scene_mode_id不能为空", trigger: "blur"}
],
defaultFlag: [
{ required: true, message: "是否默认不能为空", trigger: "blur" }
{required: true, message: "是否默认不能为空", trigger: "blur"}
],
sceneStatus: [
{ required: true, message: "状态不能为空", trigger: "change" }
{required: true, message: "状态不能为空", trigger: "change"}
],
authMode: [
{ required: true, message: "认证方式不能为空", trigger: "blur" }
{required: true, message: "认证方式不能为空", trigger: "blur"}
],
modeKey: [
{ required: true, message: "场景key不能为空", trigger: "blur" }
{required: true, message: "场景key不能为空", trigger: "blur"}
],
modeSecret: [
{ required: true, message: "场景secret不能为空", trigger: "blur" }
{required: true, message: "场景secret不能为空", trigger: "blur"}
],
preserveTime: [
{ required: true, message: "保存周期(单位默认90天不能为空", trigger: "blur" }
{required: true, message: "保存周期(单位默认90天不能为空", trigger: "blur"}
],
testPreserveTime: [
{ required: true, message: "测试环境保存周期(单位默认30天不能为空", trigger: "blur" }
{required: true, message: "测试环境保存周期(单位默认30天不能为空", trigger: "blur"}
],
}
},
number: 0,
uploadList: [],
dialogImageUrl: "",
dialogVisible: false,
hideUpload: false,
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", //
headers: {
Authorization: "Bearer " + getToken(),
},
fileList: [],
};
},
created() {
this.getTenants();
this.getSceneModes();
this.getList();
},
methods: {
getSceneModes() {
getSceneModes().then(response => {
this.sceneModes = response.data;
});
},
getTenants() {
getTenants().then(response => {
this.tenants = response.data;
});
},
/** 查询场景信息列表 */
getList() {
this.loading = true;
@ -369,11 +413,11 @@ export default {
scenePic: null,
defaultFlag: null,
sceneStatus: null,
authMode: null,
authMode: "1",
modeAccount: null,
modeKey: null,
modeSecret: null,
preserveTime: null,
preserveTime: 90,
testPreserveTime: null,
remark: null,
createBy: null,
@ -398,7 +442,7 @@ export default {
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.sceneId)
this.single = selection.length!==1
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
@ -411,10 +455,17 @@ export default {
handleUpdate(row) {
this.reset();
const sceneId = row.sceneId || this.ids
this.fileList = [];
getScene(sceneId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改场景信息";
if (response.data.scenePic != null) {
let previewFile = {};
previewFile.url = response.data.scenePic
this.fileList.push(previewFile);
}
});
},
/** 提交按钮 */
@ -440,19 +491,121 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const sceneIds = row.sceneId || this.ids;
this.$modal.confirm('是否确认删除场景信息编号为"' + sceneIds + '"的数据项?').then(function() {
this.$modal.confirm('是否确认删除场景信息编号为"' + sceneIds + '"的数据项?').then(function () {
return delScene(sceneIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}).catch(() => {
});
},
/** 导出按钮操作 */
handleExport() {
this.download('business/scene/export', {
...this.queryParams
}, `scene_${new Date().getTime()}.xlsx`)
}
}
},
/**上传图片处理*/
// loading
handleBeforeUpload(file) {
let isImg = false;
if (this.fileType.length) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
}
isImg = this.fileType.some(type => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
} else {
isImg = file.type.indexOf("image") > -1;
}
if (!isImg) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
return false;
}
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$modal.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
this.$modal.loading("正在上传图片,请稍候...");
this.number++;
},
checkPicture(file) {
},
//
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
},
//
handleUploadSuccess(res, file) {
if (res.code === 200) {
this.uploadList.push(res.data.url);
this.uploadedSuccessfully();
} else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.imageUpload.handleRemove(file);
this.uploadedSuccessfully();
}
},
//
uploadedSuccessfully() {
if (this.number > 0 && this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
this.number = 0;
this.form.scenePic = this.fileList[0];
// this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
}
},
//
handleDeletePicture(file) {
const findex = this.fileList.map(f => f.name).indexOf(file.name);
if (findex > -1) {
this.fileList.splice(findex, 1);
// this.$emit("input", this.listToString(this.fileList));
}
this.form.scenePic = '';
},
//
handleUploadError() {
this.$modal.msgError("上传图片失败,请重试");
this.$modal.closeLoading();
},
//
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
//
listToString(list, separator) {
let strs = "";
separator = separator || ",";
for (let i in list) {
if (list[i].url) {
strs += list[i].url.replace(this.baseUrl, "") + separator;
}
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
},
},
};
</script>

Loading…
Cancel
Save