Преглед изворни кода

优化规则引擎模块逻辑,调整空间树的过滤逻辑

james пре 2 дана
родитељ
комит
e07ca12a5b
21 измењених фајлова са 33 додато и 347 уклоњено
  1. 1 2
      service-rule/service-rule-biz/src/main/java/com/usky/rule/config/CronTaskManager.java
  2. 0 21
      service-rule/service-rule-biz/src/main/java/com/usky/rule/controller/web/BaseSpaceController.java
  3. 7 8
      service-rule/service-rule-biz/src/main/java/com/usky/rule/crons/TriggerCronTask.java
  4. 0 91
      service-rule/service-rule-biz/src/main/java/com/usky/rule/domain/BaseSpace.java
  5. 0 1
      service-rule/service-rule-biz/src/main/java/com/usky/rule/domain/RuleEngine.java
  6. 2 3
      service-rule/service-rule-biz/src/main/java/com/usky/rule/jobs/CommonJob.java
  7. 1 2
      service-rule/service-rule-biz/src/main/java/com/usky/rule/jobs/ConsumptionJob.java
  8. 0 16
      service-rule/service-rule-biz/src/main/java/com/usky/rule/mapper/BaseSpaceMapper.java
  9. 0 16
      service-rule/service-rule-biz/src/main/java/com/usky/rule/service/BaseSpaceService.java
  10. 0 20
      service-rule/service-rule-biz/src/main/java/com/usky/rule/service/impl/BaseSpaceServiceImpl.java
  11. 4 4
      service-rule/service-rule-biz/src/main/java/com/usky/rule/service/impl/RuleEngineDetailServiceImpl.java
  12. 2 24
      service-rule/service-rule-biz/src/main/java/com/usky/rule/service/impl/RuleEngineServiceImpl.java
  13. 1 1
      service-rule/service-rule-biz/src/main/java/com/usky/rule/subscribe/TriggerDeviceUtil.java
  14. 3 4
      service-rule/service-rule-biz/src/main/java/com/usky/rule/util/RuleEngineUtil.java
  15. 4 33
      service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEngineCronVO.java
  16. 4 43
      service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEngineDTO.java
  17. 0 1
      service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEnginePageRequest.java
  18. 4 32
      service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEngineVO.java
  19. 0 2
      service-rule/service-rule-biz/src/main/resources/mapper/RuleEngineCronMapper.xml
  20. 0 1
      service-rule/service-rule-biz/src/main/resources/mapper/RuleEngineMapper.xml
  21. 0 22
      service-rule/service-rule-biz/src/main/resources/mapper/rule/BaseSpaceMapper.xml

+ 1 - 2
service-rule/service-rule-biz/src/main/java/com/usky/rule/config/CronTaskManager.java

@@ -29,12 +29,11 @@ public class CronTaskManager {
     private Scheduler scheduler;
     private TriggerDeviceUtil triggerDeviceUtil;
 
-    public void addJob(String jobName, String jobGroup, String cronExpression, Class<? extends Job> jobClass, List<CronConstraint> cronConstraintList, List<DeviceConstraint> deviceConstraints, List<RuleEngineAction> actions, Long ruleEngineId, Long projectId, Long spaceId) {
+    public void addJob(String jobName, String jobGroup, String cronExpression, Class<? extends Job> jobClass, List<CronConstraint> cronConstraintList, List<DeviceConstraint> deviceConstraints, List<RuleEngineAction> actions, Long ruleEngineId, Long projectId) {
         JobDataMap jobDataMap = new JobDataMap();
         jobDataMap.put("actions", actions);
         jobDataMap.put("ruleEngineId", ruleEngineId);
         jobDataMap.put("projectId", projectId);
-        jobDataMap.put("spaceId", spaceId);
         JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName, jobGroup).usingJobData(jobDataMap).build();
         CronTrigger cronTrigger = (CronTrigger)TriggerBuilder.newTrigger().withIdentity(jobName, jobGroup).withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
 

+ 0 - 21
service-rule/service-rule-biz/src/main/java/com/usky/rule/controller/web/BaseSpaceController.java

@@ -1,21 +0,0 @@
-package com.usky.rule.controller.web;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.stereotype.Controller;
-
-/**
- * <p>
- * 空间 前端控制器
- * </p>
- *
- * @author zyj
- * @since 2026-03-17
- */
-@Controller
-@RequestMapping("/baseSpace")
-public class BaseSpaceController {
-
-}
-

+ 7 - 8
service-rule/service-rule-biz/src/main/java/com/usky/rule/crons/TriggerCronTask.java

@@ -53,7 +53,7 @@ public class TriggerCronTask implements ApplicationContextAware, InitializingBea
                 if (cronTriggers != null) {
                     cronTriggers = (List)cronTriggers.stream().filter((cronTrigger) -> CronUtil.isCronMatched(cronTrigger.getCron())).collect(Collectors.toList());
                     if (!cronTriggers.isEmpty()) {
-                        this.processCronTask(ruleEngine.getId(), ruleEngine.getProjectId(), ruleEngine.getSpaceId(), ruleEngineDetail, cronTriggers);
+                        this.processCronTask(ruleEngine.getId(), ruleEngine.getProjectId(), ruleEngineDetail, cronTriggers);
                     }
                 }
 
@@ -65,18 +65,17 @@ public class TriggerCronTask implements ApplicationContextAware, InitializingBea
 
     private void startCronTask() {
         List<RuleEngineCronVO> ruleEngineCronList = this.ruleEngineCronService.getTurnedOnCron();
-        Function<RuleEngineCronVO, String> ruleEngineCronFunction = (vo) -> vo.getRuleEngineId() + ":" + vo.getProjectId() + ":" + vo.getSpaceId();
+        Function<RuleEngineCronVO, String> ruleEngineCronFunction = (vo) -> vo.getRuleEngineId() + ":" + vo.getProjectId();
         Map<String, List<CronTrigger>> ruleEngineCronMap = (Map)ruleEngineCronList.stream().filter((cronTrigger) -> CronUtil.isCronMatched(cronTrigger.getCron())).collect(Collectors.groupingBy(ruleEngineCronFunction, Collectors.mapping((vo) -> new CronTrigger(vo.getCron()), Collectors.toList())));
         if (CollectionUtils.isNotEmpty(ruleEngineCronMap)) {
             ruleEngineCronMap.forEach((identifier, list) -> {
                 String[] idAndProjectId = identifier.split(":");
                 Long ruleEngineId = Long.valueOf(idAndProjectId[0]);
                 Long projectId = Long.valueOf(idAndProjectId[1]);
-                Long spaceId = Long.valueOf(idAndProjectId[2]);
                 String detail = this.ruleEngineService.getDetail(Long.valueOf(idAndProjectId[0]));
                 if (StringUtils.isNotEmpty(detail)) {
                     RuleEngineDetail ruleEngineDetail = (RuleEngineDetail)JsonUtil.toObject(detail, RuleEngineDetail.class);
-                    this.processCronTask(ruleEngineId, projectId, spaceId, ruleEngineDetail, list);
+                    this.processCronTask(ruleEngineId, projectId, ruleEngineDetail, list);
                 }
 
             });
@@ -118,23 +117,23 @@ public class TriggerCronTask implements ApplicationContextAware, InitializingBea
         }
     }
 
-    private void processCronTask(Long id, Long projectId, Long spaceId, RuleEngineDetail engineDetail, List<CronTrigger> cronTriggers) {
+    private void processCronTask(Long id, Long projectId, RuleEngineDetail engineDetail, List<CronTrigger> cronTriggers) {
         List<CronConstraint> cronConstraints = this.ruleEngineService.getCronConstraints(engineDetail.getConstraints());
         List<DeviceConstraint> deviceConstraints = this.ruleEngineService.getDeviceConstraints(engineDetail.getConstraints());
         List<RuleEngineAction> actions = this.ruleEngineService.getActions(engineDetail.getActions());
         if (actions != null && !actions.isEmpty()) {
-            addCronJob(id, projectId, spaceId, cronTriggers, cronConstraints, deviceConstraints, actions, this.cronTaskManager);
+            addCronJob(id, projectId, cronTriggers, cronConstraints, deviceConstraints, actions, this.cronTaskManager);
         }
 
     }
 
-    public static void addCronJob(Long ruleEngineId, Long projectId, Long spaceId, List<CronTrigger> cronTriggers, List<CronConstraint> cronConstraints, List<DeviceConstraint> deviceConstraints, List<RuleEngineAction> actions, CronTaskManager cronTaskManager) {
+    public static void addCronJob(Long ruleEngineId, Long projectId, List<CronTrigger> cronTriggers, List<CronConstraint> cronConstraints, List<DeviceConstraint> deviceConstraints, List<RuleEngineAction> actions, CronTaskManager cronTaskManager) {
         String jobGroup = RuleEngineUtil.getJobGroup(ruleEngineId);
 
         for(int i = 0; i < cronTriggers.size(); ++i) {
             CronTrigger cronTrigger = (CronTrigger)cronTriggers.get(i);
             String jobName = RuleEngineUtil.getTriggerCronJobName(i);
-            cronTaskManager.addJob(jobName, jobGroup, cronTrigger.getCron(), CommonJob.class, cronConstraints, deviceConstraints, actions, ruleEngineId, projectId, spaceId);
+            cronTaskManager.addJob(jobName, jobGroup, cronTrigger.getCron(), CommonJob.class, cronConstraints, deviceConstraints, actions, ruleEngineId, projectId);
         }
 
     }

+ 0 - 91
service-rule/service-rule-biz/src/main/java/com/usky/rule/domain/BaseSpace.java

@@ -1,91 +0,0 @@
-package com.usky.rule.domain;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
-import java.io.Serializable;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * <p>
- * 空间
- * </p>
- *
- * @author zyj
- * @since 2026-03-17
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-public class BaseSpace implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 自增ID
-     */
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 名称
-     */
-    private String name;
-
-    /**
-     * 父节点ID
-     */
-    private Long parentId;
-
-    /**
-     * 空间类型 1:项目 2:区域 3:建筑 4:楼层 5:房间
-     */
-    private Integer type;
-
-    /**
-     * 根节点ID
-     */
-    private Long rootId;
-
-    /**
-     * 节点路径
-     */
-    private String path;
-
-    /**
-     * 节点路径名称
-     */
-    private String pathName;
-
-    /**
-     * 深度
-     */
-    private Integer deep;
-
-    /**
-     * 更新人
-     */
-    private Long updatedBy;
-
-    /**
-     * 记录更新时间
-     */
-    private LocalDateTime updateTime;
-
-    /**
-     * 创建人
-     */
-    private Long createdBy;
-
-    /**
-     * 记录创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 租户号
-     */
-    private Integer tenantId;
-
-
-}

+ 0 - 1
service-rule/service-rule-biz/src/main/java/com/usky/rule/domain/RuleEngine.java

@@ -17,7 +17,6 @@ public class RuleEngine implements Serializable {
     private Long id;
     private Long projectId;
     private String name;
-    private Long spaceId;
     /** 规则状态 1:启用 0:停用 */
     private Integer status;
     private String descr;

+ 2 - 3
service-rule/service-rule-biz/src/main/java/com/usky/rule/jobs/CommonJob.java

@@ -30,15 +30,14 @@ public class CommonJob implements Job {
         JobDataMap dataMap = context.getJobDetail().getJobDataMap();
         Long ruleEngineId = (Long)dataMap.get("ruleEngineId");
         Long projectId = (Long)dataMap.get("projectId");
-        Long spaceId = (Long)dataMap.get("spaceId");
         List<RuleEngineAction> actions = (List)dataMap.get("actions");
         RuleEngineDetailLog detail = (RuleEngineDetailLog)context.get("detail");
         if (detail == null) {
             detail = CommonListener.initRuleEngineDetailLog((CronTrigger)context.getTrigger(), LocalDateTime.now());
             detail.setConstraints(new ArrayList());
         }
-        log.info("commonJob start ruleEngineId: {}, detail: {}, spaceId: {}", ruleEngineId, detail, spaceId);
+        log.info("commonJob start ruleEngineId: {}, detail: {}", ruleEngineId, detail);
 
-        this.ruleEngineUtil.performMultipleDevicesControl(ruleEngineId, true, TriggerTypeEnum.CRON.getType(), projectId, spaceId, actions, detail);
+        this.ruleEngineUtil.performMultipleDevicesControl(ruleEngineId, true, TriggerTypeEnum.CRON.getType(), projectId, actions, detail);
     }
 }

+ 1 - 2
service-rule/service-rule-biz/src/main/java/com/usky/rule/jobs/ConsumptionJob.java

@@ -77,7 +77,6 @@ public class ConsumptionJob implements Job {
             if (ruleEngine == null || ruleEngine.getStatus() == null || ruleEngine.getStatus() != 1) {
                 continue;
             }
-            Long spaceId = ruleEngine.getSpaceId();
             RuleEngineDetail ruleEngineDetail = (RuleEngineDetail) JsonUtil.toObject(ruleEngine.getDetail(), RuleEngineDetail.class);
             List<RuleEngineAction> actions = this.ruleEngineService.getActions(ruleEngineDetail.getActions());
             if (!actions.isEmpty()) {
@@ -158,7 +157,7 @@ public class ConsumptionJob implements Job {
                     if (cronOk && deviceOk) {
 
                         log.info("ConsumptionJob constraints satisfied engineId: {}, actions: {}", engineId, actions);
-                        this.ruleEngineUtil.performMultipleDevicesControl(engineId, true, TriggerTypeEnum.DEVICE.getType(), ruleEngine.getProjectId(), spaceId, actions, ruleEngineDetailLog);
+                        this.ruleEngineUtil.performMultipleDevicesControl(engineId, true, TriggerTypeEnum.DEVICE.getType(), ruleEngine.getProjectId(), actions, ruleEngineDetailLog);
                     }
                 }
             }

+ 0 - 16
service-rule/service-rule-biz/src/main/java/com/usky/rule/mapper/BaseSpaceMapper.java

@@ -1,16 +0,0 @@
-package com.usky.rule.mapper;
-
-import com.usky.rule.domain.BaseSpace;
-import com.usky.common.mybatis.core.CrudMapper;
-
-/**
- * <p>
- * 空间 Mapper 接口
- * </p>
- *
- * @author zyj
- * @since 2026-03-17
- */
-public interface BaseSpaceMapper extends CrudMapper<BaseSpace> {
-
-}

+ 0 - 16
service-rule/service-rule-biz/src/main/java/com/usky/rule/service/BaseSpaceService.java

@@ -1,16 +0,0 @@
-package com.usky.rule.service;
-
-import com.usky.rule.domain.BaseSpace;
-import com.usky.common.mybatis.core.CrudService;
-
-/**
- * <p>
- * 空间 服务类
- * </p>
- *
- * @author zyj
- * @since 2026-03-17
- */
-public interface BaseSpaceService extends CrudService<BaseSpace> {
-
-}

+ 0 - 20
service-rule/service-rule-biz/src/main/java/com/usky/rule/service/impl/BaseSpaceServiceImpl.java

@@ -1,20 +0,0 @@
-package com.usky.rule.service.impl;
-
-import com.usky.rule.domain.BaseSpace;
-import com.usky.rule.mapper.BaseSpaceMapper;
-import com.usky.rule.service.BaseSpaceService;
-import com.usky.common.mybatis.core.AbstractCrudService;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- * 空间 服务实现类
- * </p>
- *
- * @author zyj
- * @since 2026-03-17
- */
-@Service
-public class BaseSpaceServiceImpl extends AbstractCrudService<BaseSpaceMapper, BaseSpace> implements BaseSpaceService {
-
-}

+ 4 - 4
service-rule/service-rule-biz/src/main/java/com/usky/rule/service/impl/RuleEngineDetailServiceImpl.java

@@ -55,13 +55,13 @@ public class RuleEngineDetailServiceImpl implements RuleEngineDetailService {
         if (cronTriggers != null) {
             List<CronConstraint> cronConstraints = this.ruleEngineService.getCronConstraints(ruleEngineDetail.getConstraints());
             List<DeviceConstraint> deviceConstraints = this.ruleEngineService.getDeviceConstraints(ruleEngineDetail.getConstraints());
-            this.addRuleEngineJobs(dto.getId(), dto.getProjectId(), dto.getSpaceId(), actions, cronTriggers, cronConstraints, deviceConstraints);
+            this.addRuleEngineJobs(dto.getId(), dto.getProjectId(), actions, cronTriggers, cronConstraints, deviceConstraints);
         }
 
     }
 
-    private void addRuleEngineJobs(Long id, Long projectId, Long spaceId, List<RuleEngineAction> actions, List<CronTrigger> cronTriggers, List<CronConstraint> cronConstraints, List<DeviceConstraint> deviceConstraints) {
-        TriggerCronTask.addCronJob(id, projectId, spaceId, cronTriggers, cronConstraints, deviceConstraints, actions, this.cronTaskManager);
+    private void addRuleEngineJobs(Long id, Long projectId, List<RuleEngineAction> actions, List<CronTrigger> cronTriggers, List<CronConstraint> cronConstraints, List<DeviceConstraint> deviceConstraints) {
+        TriggerCronTask.addCronJob(id, projectId, cronTriggers, cronConstraints, deviceConstraints, actions, this.cronTaskManager);
     }
 
     public Boolean update(RuleEngineDTO dto) {
@@ -84,7 +84,7 @@ public class RuleEngineDetailServiceImpl implements RuleEngineDetailService {
         } else {
             List<RuleEngineAction> actions = this.ruleEngineService.getActions(ruleEngineDetail.getActions());
             if (actions != null && !actions.isEmpty()) {
-                this.ruleEngineUtil.performMultipleDevicesControl(id, false, TriggerTypeEnum.DEVICE.getType(), ruleEngine.getProjectId(), (Long)null, actions, new RuleEngineDetailLog());
+                this.ruleEngineUtil.performMultipleDevicesControl(id, false, TriggerTypeEnum.DEVICE.getType(), ruleEngine.getProjectId(), actions, new RuleEngineDetailLog());
                 return true;
             } else {
                 return true;

+ 2 - 24
service-rule/service-rule-biz/src/main/java/com/usky/rule/service/impl/RuleEngineServiceImpl.java

@@ -64,8 +64,6 @@ public class RuleEngineServiceImpl extends AbstractCrudService<RuleEngineMapper,
     @Lazy
     @Autowired
     private RuleEngineDetailService ruleEngineDetailService;
-    @Autowired
-    private BaseSpaceService baseSpaceService;
 
     public RuleEngineServiceImpl(RuleEngineCronService ruleEngineCronService, RuleEngineDeviceService ruleEngineDeviceService,
                                  @Lazy CronTaskManager cronTaskManager) {
@@ -154,44 +152,24 @@ public class RuleEngineServiceImpl extends AbstractCrudService<RuleEngineMapper,
 
     @Override
     public CommonPage<RuleEngine> pageList(RuleEnginePageRequest request) {
-        List<Long> ids = new ArrayList();
-        if (request.getSpaceId() != null) {
-            ids.add(request.getSpaceId());
-            ids.addAll(collectAllDescendantSpaceIds(request.getSpaceId()));
-        }
-
 
         IPage<RuleEngine> page = new Page<>(request.getPageNum(), request.getPageSize());
         LambdaQueryWrapper<RuleEngine> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.in(CollectionUtils.isNotEmpty(ids), RuleEngine::getSpaceId, ids)
-                .like(StringUtils.isNotBlank(request.getName()),RuleEngine::getName, request.getName())
+        queryWrapper.like(StringUtils.isNotBlank(request.getName()),RuleEngine::getName, request.getName())
                 .eq(request.getStatus() != null,RuleEngine::getStatus,request.getStatus())
                 .eq(RuleEngine::getTenantId,SecurityUtils.getTenantId())
                 .orderByDesc(RuleEngine::getId);
         page = this.page(page, queryWrapper);
 
-        if(!page.getRecords().isEmpty()){
-            List<Long> spaceIds = page.getRecords().stream().map(RuleEngine::getSpaceId).distinct().collect(Collectors.toList());
-            List<BaseSpace> spaceList = baseSpaceService.listByIds(spaceIds);
-            Map<Long, BaseSpace> spaceMap = (Map)spaceList.stream().collect(Collectors.toMap(BaseSpace::getId, (s) -> s));
-            page.getRecords().forEach((r) -> r.setSpaceName(((BaseSpace)spaceMap.get(r.getSpaceId())).getName()));
-        }
-
         return new CommonPage<>(page.getRecords(), page.getTotal(), request.getPageSize(), request.getPageNum());
 
     }
 
     @Override
     public List<RuleEngine> list(RuleEnginePageRequest request) {
-        List<Long> ids = new ArrayList();
-        if (request.getSpaceId() != null) {
-            ids.add(request.getSpaceId());
-            ids.addAll(collectAllDescendantSpaceIds(request.getSpaceId()));
-        }
 
         LambdaQueryWrapper<RuleEngine> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.in(CollectionUtils.isNotEmpty(ids), RuleEngine::getSpaceId, ids)
-                .like(StringUtils.isNotBlank(request.getName()),RuleEngine::getName, request.getName())
+        queryWrapper.like(StringUtils.isNotBlank(request.getName()),RuleEngine::getName, request.getName())
                 .eq(request.getStatus() != null,RuleEngine::getStatus,request.getStatus())
                 .eq(SecurityUtils.getTenantId() != 0 && SecurityUtils.getTenantId() != null,RuleEngine::getTenantId,SecurityUtils.getTenantId());
         List<RuleEngine> ruleEngines = this.list(queryWrapper);

+ 1 - 1
service-rule/service-rule-biz/src/main/java/com/usky/rule/subscribe/TriggerDeviceUtil.java

@@ -124,7 +124,7 @@ public class TriggerDeviceUtil {
                                         boolean deviceOk = this.meetConstraintAction(deviceConstraints, ruleEngineDetailLog);
                                         if (cronOk && deviceOk) {
                                             log.info("ruleEngineId={} constraints satisfied, executing actions", ruleEngineId);
-                                            this.ruleEngineUtil.performMultipleDevicesControl(ruleEngineId, true, TriggerTypeEnum.DEVICE.getType(), ruleEngine.getProjectId(), ruleEngine.getSpaceId(), actions, ruleEngineDetailLog);
+                                            this.ruleEngineUtil.performMultipleDevicesControl(ruleEngineId, true, TriggerTypeEnum.DEVICE.getType(), ruleEngine.getProjectId(), actions, ruleEngineDetailLog);
                                             this.clearMeetConditionCache(ruleEngineId, deviceId, meetMinuteExpressionMap);
                                             this.deviceAcqTriggerCooldownCache.startCooldown(ruleEngineId, deviceId, this.deviceAcqCooldownSeconds);
                                         } else if (!cronOk) {

+ 3 - 4
service-rule/service-rule-biz/src/main/java/com/usky/rule/util/RuleEngineUtil.java

@@ -54,7 +54,7 @@ public class RuleEngineUtil {
         return "job-" + index;
     }
 
-    public void performMultipleDevicesControl(Long ruleEngineId, boolean isAuto, String triggerType, Long projectId, Long spaceId, List<RuleEngineAction> actionList, RuleEngineDetailLog ruleEngineDetail) {
+    public void performMultipleDevicesControl(Long ruleEngineId, boolean isAuto, String triggerType, Long projectId, List<RuleEngineAction> actionList, RuleEngineDetailLog ruleEngineDetail) {
         List<BaseLog> baseLogs = new ArrayList();
         ruleEngineDetail.setActions(baseLogs);
         LocalDateTime now = LocalDateTime.now();
@@ -75,7 +75,7 @@ public class RuleEngineUtil {
                 baseLogs.add(baseLog);
                 ruleEngineLog.setTenantId(deviceControlAction.getDevices().get(0).getTenantId());
             } else if (ActionTypeEnum.ALARM_EVENT.getType().equals(ruleEngineAction.getType())) {
-                this.generateAlarmEvent(ruleEngineId, ruleEngineName, projectId, spaceId, Collections.singletonList(ruleEngineAction));
+                this.generateAlarmEvent(ruleEngineId, ruleEngineName, projectId, Collections.singletonList(ruleEngineAction));
                 deviceActionTypes.add("alarmEvent");
                 BaseLog baseLog = new BaseLog();
                 baseLog.setType(ActionTypeEnum.ALARM_EVENT.getType());
@@ -125,10 +125,9 @@ public class RuleEngineUtil {
      * @param ruleEngineId
      * @param ruleEngineName
      * @param projectId
-     * @param spaceId
      * @param actions
      */
-    public void generateAlarmEvent(Long ruleEngineId, String ruleEngineName, Long projectId, Long spaceId, List<RuleEngineAction> actions) {
+    public void generateAlarmEvent(Long ruleEngineId, String ruleEngineName, Long projectId, List<RuleEngineAction> actions) {
         for(RuleEngineAction ruleEngineAction : actions) {
             AlarmEventAction alarmEventAction = (AlarmEventAction)ruleEngineAction;
             List<AlarmSimpleVO> devices = alarmEventAction.getDevices();

+ 4 - 33
service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEngineCronVO.java

@@ -17,8 +17,6 @@ public class RuleEngineCronVO implements Serializable {
     private String cron;
     @ApiModelProperty("项目ID")
     private Long projectId;
-    @ApiModelProperty("空间ID")
-    private Long spaceId;
     @ApiModelProperty("更新人")
     private Long updatedBy;
     @ApiModelProperty("记录更新时间")
@@ -52,10 +50,6 @@ public class RuleEngineCronVO implements Serializable {
         return this.projectId;
     }
 
-    public Long getSpaceId() {
-        return this.spaceId;
-    }
-
     public Long getUpdatedBy() {
         return this.updatedBy;
     }
@@ -92,10 +86,6 @@ public class RuleEngineCronVO implements Serializable {
         this.projectId = projectId;
     }
 
-    public void setSpaceId(final Long spaceId) {
-        this.spaceId = spaceId;
-    }
-
     public void setUpdatedBy(final Long updatedBy) {
         this.updatedBy = updatedBy;
     }
@@ -162,16 +152,6 @@ public class RuleEngineCronVO implements Serializable {
                     return false;
                 }
 
-                Object this$spaceId = this.getSpaceId();
-                Object other$spaceId = other.getSpaceId();
-                if (this$spaceId == null) {
-                    if (other$spaceId != null) {
-                        return false;
-                    }
-                } else if (!this$spaceId.equals(other$spaceId)) {
-                    return false;
-                }
-
                 Object this$updatedBy = this.getUpdatedBy();
                 Object other$updatedBy = other.getUpdatedBy();
                 if (this$updatedBy == null) {
@@ -242,8 +222,6 @@ public class RuleEngineCronVO implements Serializable {
         result = result * 59 + ($ruleEngineName == null ? 43 : $ruleEngineName.hashCode());
         Object $projectId = this.getProjectId();
         result = result * 59 + ($projectId == null ? 43 : $projectId.hashCode());
-        Object $spaceId = this.getSpaceId();
-        result = result * 59 + ($spaceId == null ? 43 : $spaceId.hashCode());
         Object $updatedBy = this.getUpdatedBy();
         result = result * 59 + ($updatedBy == null ? 43 : $updatedBy.hashCode());
         Object $createdBy = this.getCreatedBy();
@@ -258,16 +236,15 @@ public class RuleEngineCronVO implements Serializable {
     }
 
     public String toString() {
-        return "RuleEngineCronVO(id=" + this.getId() + ", ruleEngineId=" + this.getRuleEngineId() + ", ruleEngineName=" + this.getRuleEngineName() + ", cron=" + this.getCron() + ", projectId=" + this.getProjectId() + ", spaceId=" + this.getSpaceId() + ", updatedBy=" + this.getUpdatedBy() + ", updateTime=" + this.getUpdateTime() + ", createdBy=" + this.getCreatedBy() + ", createTime=" + this.getCreateTime() + ")";
+        return "RuleEngineCronVO(id=" + this.getId() + ", ruleEngineId=" + this.getRuleEngineId() + ", ruleEngineName=" + this.getRuleEngineName() + ", cron=" + this.getCron() + ", projectId=" + this.getProjectId() + ", updatedBy=" + this.getUpdatedBy() + ", updateTime=" + this.getUpdateTime() + ", createdBy=" + this.getCreatedBy() + ", createTime=" + this.getCreateTime() + ")";
     }
 
-    public RuleEngineCronVO(final Long id, final Long ruleEngineId, final Long ruleEngineName, final String cron, final Long projectId, final Long spaceId, final Long updatedBy, final String updateTime, final Long createdBy, final String createTime) {
+    public RuleEngineCronVO(final Long id, final Long ruleEngineId, final Long ruleEngineName, final String cron, final Long projectId, final Long updatedBy, final String updateTime, final Long createdBy, final String createTime) {
         this.id = id;
         this.ruleEngineId = ruleEngineId;
         this.ruleEngineName = ruleEngineName;
         this.cron = cron;
         this.projectId = projectId;
-        this.spaceId = spaceId;
         this.updatedBy = updatedBy;
         this.updateTime = updateTime;
         this.createdBy = createdBy;
@@ -283,7 +260,6 @@ public class RuleEngineCronVO implements Serializable {
         private Long ruleEngineName;
         private String cron;
         private Long projectId;
-        private Long spaceId;
         private Long updatedBy;
         private String updateTime;
         private Long createdBy;
@@ -317,11 +293,6 @@ public class RuleEngineCronVO implements Serializable {
             return this;
         }
 
-        public RuleEngineCronVOBuilder spaceId(final Long spaceId) {
-            this.spaceId = spaceId;
-            return this;
-        }
-
         public RuleEngineCronVOBuilder updatedBy(final Long updatedBy) {
             this.updatedBy = updatedBy;
             return this;
@@ -343,11 +314,11 @@ public class RuleEngineCronVO implements Serializable {
         }
 
         public RuleEngineCronVO build() {
-            return new RuleEngineCronVO(this.id, this.ruleEngineId, this.ruleEngineName, this.cron, this.projectId, this.spaceId, this.updatedBy, this.updateTime, this.createdBy, this.createTime);
+            return new RuleEngineCronVO(this.id, this.ruleEngineId, this.ruleEngineName, this.cron, this.projectId, this.updatedBy, this.updateTime, this.createdBy, this.createTime);
         }
 
         public String toString() {
-            return "RuleEngineCronVO.RuleEngineCronVOBuilder(id=" + this.id + ", ruleEngineId=" + this.ruleEngineId + ", ruleEngineName=" + this.ruleEngineName + ", cron=" + this.cron + ", projectId=" + this.projectId + ", spaceId=" + this.spaceId + ", updatedBy=" + this.updatedBy + ", updateTime=" + this.updateTime + ", createdBy=" + this.createdBy + ", createTime=" + this.createTime + ")";
+            return "RuleEngineCronVO.RuleEngineCronVOBuilder(id=" + this.id + ", ruleEngineId=" + this.ruleEngineId + ", ruleEngineName=" + this.ruleEngineName + ", cron=" + this.cron + ", projectId=" + this.projectId + ", updatedBy=" + this.updatedBy + ", updateTime=" + this.updateTime + ", createdBy=" + this.createdBy + ", createTime=" + this.createTime + ")";
         }
     }
 }

+ 4 - 43
service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEngineDTO.java

@@ -26,11 +26,6 @@ public class RuleEngineDTO implements Serializable {
             groups = {GroupUpdate.class, GroupInsert.class},
             message = "名称不能为空"
     ) String name;
-    @ApiModelProperty("空间ID")
-    private @NotNull(
-            groups = {GroupInsert.class},
-            message = "空间不能为空"
-    ) Long spaceId;
     @ApiModelProperty("规则状态 1:启用 0:停用")
     private Integer status;
     @ApiModelProperty("规则描述")
@@ -61,12 +56,6 @@ public class RuleEngineDTO implements Serializable {
         return this.name;
     }
 
-    public @NotNull(
-            groups = {GroupInsert.class},
-            message = "空间不能为空"
-    ) Long getSpaceId() {
-        return this.spaceId;
-    }
 
     public Integer getStatus() {
         return this.status;
@@ -95,12 +84,6 @@ public class RuleEngineDTO implements Serializable {
         this.name = name;
     }
 
-    public void setSpaceId(final @NotNull(
-            groups = {GroupInsert.class},
-            message = "空间不能为空"
-    ) Long spaceId) {
-        this.spaceId = spaceId;
-    }
 
     public void setStatus(final Integer status) {
         this.status = status;
@@ -147,16 +130,6 @@ public class RuleEngineDTO implements Serializable {
                     return false;
                 }
 
-                Object this$spaceId = this.getSpaceId();
-                Object other$spaceId = other.getSpaceId();
-                if (this$spaceId == null) {
-                    if (other$spaceId != null) {
-                        return false;
-                    }
-                } else if (!this$spaceId.equals(other$spaceId)) {
-                    return false;
-                }
-
                 Object this$status = this.getStatus();
                 Object other$status = other.getStatus();
                 if (this$status == null) {
@@ -213,8 +186,6 @@ public class RuleEngineDTO implements Serializable {
         result = result * 59 + ($id == null ? 43 : $id.hashCode());
         Object $projectId = this.getProjectId();
         result = result * 59 + ($projectId == null ? 43 : $projectId.hashCode());
-        Object $spaceId = this.getSpaceId();
-        result = result * 59 + ($spaceId == null ? 43 : $spaceId.hashCode());
         Object $status = this.getStatus();
         result = result * 59 + ($status == null ? 43 : $status.hashCode());
         Object $name = this.getName();
@@ -227,7 +198,7 @@ public class RuleEngineDTO implements Serializable {
     }
 
     public String toString() {
-        return "RuleEngineDTO(id=" + this.getId() + ", projectId=" + this.getProjectId() + ", name=" + this.getName() + ", spaceId=" + this.getSpaceId() + ", status=" + this.getStatus() + ", descr=" + this.getDescr() + ", detail=" + this.getDetail() + ")";
+        return "RuleEngineDTO(id=" + this.getId() + ", projectId=" + this.getProjectId() + ", name=" + this.getName() + ", status=" + this.getStatus() + ", descr=" + this.getDescr() + ", detail=" + this.getDetail() + ")";
     }
 
     public RuleEngineDTO(final @NotNull(
@@ -236,11 +207,10 @@ public class RuleEngineDTO implements Serializable {
     ) Long id, final Long projectId, final String name, final @NotNull(
             groups = {GroupInsert.class},
             message = "空间不能为空"
-    ) Long spaceId, final Integer status, final String descr, final String detail) {
+    )  Integer status, final String descr, final String detail) {
         this.id = id;
         this.projectId = projectId;
         this.name = name;
-        this.spaceId = spaceId;
         this.status = status;
         this.descr = descr;
         this.detail = detail;
@@ -253,7 +223,6 @@ public class RuleEngineDTO implements Serializable {
         private Long id;
         private Long projectId;
         private String name;
-        private Long spaceId;
         private Integer status;
         private String descr;
         private String detail;
@@ -279,14 +248,6 @@ public class RuleEngineDTO implements Serializable {
             return this;
         }
 
-        public RuleEngineDTOBuilder spaceId(final @NotNull(
-                groups = {GroupInsert.class},
-                message = "空间不能为空"
-        ) Long spaceId) {
-            this.spaceId = spaceId;
-            return this;
-        }
-
         public RuleEngineDTOBuilder status(final Integer status) {
             this.status = status;
             return this;
@@ -306,11 +267,11 @@ public class RuleEngineDTO implements Serializable {
         }
 
         public RuleEngineDTO build() {
-            return new RuleEngineDTO(this.id, this.projectId, this.name, this.spaceId, this.status, this.descr, this.detail);
+            return new RuleEngineDTO(this.id, this.projectId, this.name, this.status, this.descr, this.detail);
         }
 
         public String toString() {
-            return "RuleEngineDTO.RuleEngineDTOBuilder(id=" + this.id + ", projectId=" + this.projectId + ", name=" + this.name + ", spaceId=" + this.spaceId + ", status=" + this.status + ", descr=" + this.descr + ", detail=" + this.detail + ")";
+            return "RuleEngineDTO.RuleEngineDTOBuilder(id=" + this.id + ", projectId=" + this.projectId + ", name=" + this.name + ", status=" + this.status + ", descr=" + this.descr + ", detail=" + this.detail + ")";
         }
     }
 }

+ 0 - 1
service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEnginePageRequest.java

@@ -10,7 +10,6 @@ public class RuleEnginePageRequest {
     private Integer pageNum = 1;
     private Integer pageSize = 10;
     private Long projectId;
-    private Long spaceId;
     /** 名称模糊 */
     private String name;
     /** 状态 0/1 */

+ 4 - 32
service-rule/service-rule-biz/src/main/java/com/usky/rule/vo/RuleEngineVO.java

@@ -13,8 +13,6 @@ public class RuleEngineVO implements Serializable {
     private Long projectId;
     @ApiModelProperty("名称")
     private String name;
-    @ApiModelProperty("空间ID")
-    private Long spaceId;
     @ApiModelProperty("规则状态 1:启用 0:停用")
     private Short status;
     @ApiModelProperty("规则描述")
@@ -48,10 +46,6 @@ public class RuleEngineVO implements Serializable {
         return this.name;
     }
 
-    public Long getSpaceId() {
-        return this.spaceId;
-    }
-
     public Short getStatus() {
         return this.status;
     }
@@ -96,10 +90,6 @@ public class RuleEngineVO implements Serializable {
         this.name = name;
     }
 
-    public void setSpaceId(final Long spaceId) {
-        this.spaceId = spaceId;
-    }
-
     public void setStatus(final Short status) {
         this.status = status;
     }
@@ -162,16 +152,6 @@ public class RuleEngineVO implements Serializable {
                     return false;
                 }
 
-                Object this$spaceId = this.getSpaceId();
-                Object other$spaceId = other.getSpaceId();
-                if (this$spaceId == null) {
-                    if (other$spaceId != null) {
-                        return false;
-                    }
-                } else if (!this$spaceId.equals(other$spaceId)) {
-                    return false;
-                }
-
                 Object this$status = this.getStatus();
                 Object other$status = other.getStatus();
                 if (this$status == null) {
@@ -278,8 +258,6 @@ public class RuleEngineVO implements Serializable {
         result = result * 59 + ($id == null ? 43 : $id.hashCode());
         Object $projectId = this.getProjectId();
         result = result * 59 + ($projectId == null ? 43 : $projectId.hashCode());
-        Object $spaceId = this.getSpaceId();
-        result = result * 59 + ($spaceId == null ? 43 : $spaceId.hashCode());
         Object $status = this.getStatus();
         result = result * 59 + ($status == null ? 43 : $status.hashCode());
         Object $updatedBy = this.getUpdatedBy();
@@ -302,14 +280,13 @@ public class RuleEngineVO implements Serializable {
     }
 
     public String toString() {
-        return "RuleEngineVO(id=" + this.getId() + ", projectId=" + this.getProjectId() + ", name=" + this.getName() + ", spaceId=" + this.getSpaceId() + ", status=" + this.getStatus() + ", descr=" + this.getDescr() + ", detail=" + this.getDetail() + ", updatedBy=" + this.getUpdatedBy() + ", updateTime=" + this.getUpdateTime() + ", createdBy=" + this.getCreatedBy() + ", createTime=" + this.getCreateTime() + ", spaceName=" + this.getSpaceName() + ")";
+        return "RuleEngineVO(id=" + this.getId() + ", projectId=" + this.getProjectId() + ", name=" + this.getName() + ", status=" + this.getStatus() + ", descr=" + this.getDescr() + ", detail=" + this.getDetail() + ", updatedBy=" + this.getUpdatedBy() + ", updateTime=" + this.getUpdateTime() + ", createdBy=" + this.getCreatedBy() + ", createTime=" + this.getCreateTime() + ", spaceName=" + this.getSpaceName() + ")";
     }
 
-    public RuleEngineVO(final Long id, final Long projectId, final String name, final Long spaceId, final Short status, final String descr, final String detail, final Long updatedBy, final String updateTime, final Long createdBy, final String createTime, final String spaceName) {
+    public RuleEngineVO(final Long id, final Long projectId, final String name, final Short status, final String descr, final String detail, final Long updatedBy, final String updateTime, final Long createdBy, final String createTime, final String spaceName) {
         this.id = id;
         this.projectId = projectId;
         this.name = name;
-        this.spaceId = spaceId;
         this.status = status;
         this.descr = descr;
         this.detail = detail;
@@ -355,11 +332,6 @@ public class RuleEngineVO implements Serializable {
             return this;
         }
 
-        public RuleEngineVOBuilder spaceId(final Long spaceId) {
-            this.spaceId = spaceId;
-            return this;
-        }
-
         public RuleEngineVOBuilder status(final Short status) {
             this.status = status;
             return this;
@@ -401,11 +373,11 @@ public class RuleEngineVO implements Serializable {
         }
 
         public RuleEngineVO build() {
-            return new RuleEngineVO(this.id, this.projectId, this.name, this.spaceId, this.status, this.descr, this.detail, this.updatedBy, this.updateTime, this.createdBy, this.createTime, this.spaceName);
+            return new RuleEngineVO(this.id, this.projectId, this.name, this.status, this.descr, this.detail, this.updatedBy, this.updateTime, this.createdBy, this.createTime, this.spaceName);
         }
 
         public String toString() {
-            return "RuleEngineVO.RuleEngineVOBuilder(id=" + this.id + ", projectId=" + this.projectId + ", name=" + this.name + ", spaceId=" + this.spaceId + ", status=" + this.status + ", descr=" + this.descr + ", detail=" + this.detail + ", updatedBy=" + this.updatedBy + ", updateTime=" + this.updateTime + ", createdBy=" + this.createdBy + ", createTime=" + this.createTime + ", spaceName=" + this.spaceName + ")";
+            return "RuleEngineVO.RuleEngineVOBuilder(id=" + this.id + ", projectId=" + this.projectId + ", name=" + this.name + ", status=" + this.status + ", descr=" + this.descr + ", detail=" + this.detail + ", updatedBy=" + this.updatedBy + ", updateTime=" + this.updateTime + ", createdBy=" + this.createdBy + ", createTime=" + this.createTime + ", spaceName=" + this.spaceName + ")";
         }
     }
 }

+ 0 - 2
service-rule/service-rule-biz/src/main/resources/mapper/RuleEngineCronMapper.xml

@@ -23,9 +23,7 @@
         <result column="rule_engine_id" property="ruleEngineId"/>
         <result column="cron" property="cron"/>
         <result column="project_id" property="projectId"/>
-        <result column="space_id" property="spaceId"/>
         <result column="name" property="ruleEngineName"/>
-        <result column="detail" property="detail"/>
     </resultMap>
     <select id="getTurnedOnCron" resultMap="TurnedOnCronVO">
         SELECT rec.id, rec.rule_engine_id, rec.cron, re.project_id, re.space_id, re.name, re.detail

+ 0 - 1
service-rule/service-rule-biz/src/main/resources/mapper/RuleEngineMapper.xml

@@ -5,7 +5,6 @@
         <id column="id" property="id"/>
         <result column="project_id" property="projectId"/>
         <result column="name" property="name"/>
-        <result column="space_id" property="spaceId"/>
         <result column="status" property="status"/>
         <result column="descr" property="descr"/>
         <result column="detail" property="detail"/>

+ 0 - 22
service-rule/service-rule-biz/src/main/resources/mapper/rule/BaseSpaceMapper.xml

@@ -1,22 +0,0 @@
-<?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">
-<mapper namespace="com.usky.rule.mapper.BaseSpaceMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.usky.rule.domain.BaseSpace">
-        <id column="id" property="id" />
-        <result column="name" property="name" />
-        <result column="parent_id" property="parentId" />
-        <result column="type" property="type" />
-        <result column="root_id" property="rootId" />
-        <result column="path" property="path" />
-        <result column="path_name" property="pathName" />
-        <result column="deep" property="deep" />
-        <result column="updated_by" property="updatedBy" />
-        <result column="update_time" property="updateTime" />
-        <result column="created_by" property="createdBy" />
-        <result column="create_time" property="createTime" />
-        <result column="tenant_id" property="tenantId" />
-    </resultMap>
-
-</mapper>