Commit 2736d7f8 by fz

1.任意条件触发,只处理时间条件

2.全部条件触发,只处理包含时间条件的场景
1 parent 85659d6d
...@@ -9,7 +9,5 @@ import java.util.List; ...@@ -9,7 +9,5 @@ import java.util.List;
@Mapper @Mapper
public interface SceneMapper extends CommonBaseMapper<Scene> { public interface SceneMapper extends CommonBaseMapper<Scene> {
List<Long> getSceneAnyConditionTime(int executeCycle);
List<Long> getSceneAllConditionTime(int executeCycle); List<Long> getSceneAllConditionTime(int executeCycle);
} }
\ No newline at end of file \ No newline at end of file
...@@ -9,4 +9,6 @@ import java.util.List; ...@@ -9,4 +9,6 @@ import java.util.List;
@Mapper @Mapper
public interface ScenseDataMapper extends CommonBaseMapper<ScenseData> { public interface ScenseDataMapper extends CommonBaseMapper<ScenseData> {
List<ScenseData> getScneByIds(List<Long> ids); List<ScenseData> getScneByIds(List<Long> ids);
List<ScenseData> getByAnyConditionTime(int executeCycle);
} }
\ No newline at end of file \ No newline at end of file
...@@ -28,11 +28,6 @@ ...@@ -28,11 +28,6 @@
execute_cycle, `status`, remark, create_time, update_time execute_cycle, `status`, remark, create_time, update_time
</sql> </sql>
<!-- 查询符合周期(每天+当天类型)且满足任意条件触发 -->
<select id="getSceneAnyConditionTime" resultType="long">
select sms.id from smart_scene sms INNER JOIN smart_scene_data smsd on sms.id = smsd.scene_id where sms.status = 1 and smsd.type = 1 and smsd.param_key = 'scene_condition_time' and sms.execute_cycle in (1,#{executeCycle}) and sms.condition_rule = 1
</select>
<!-- 查询符合周期(每天+当天类型)且满足全部条件触发 --> <!-- 查询符合周期(每天+当天类型)且满足全部条件触发 -->
<select id="getSceneAllConditionTime" resultType="long"> <select id="getSceneAllConditionTime" resultType="long">
select sms.id from smart_scene sms INNER JOIN smart_scene_data smsd on sms.id = smsd.scene_id where sms.status = 1 and smsd.type = 1 and smsd.param_key = 'scene_condition_time' and sms.execute_cycle in (1,#{executeCycle}) and sms.condition_rule = 2 select sms.id from smart_scene sms INNER JOIN smart_scene_data smsd on sms.id = smsd.scene_id where sms.status = 1 and smsd.type = 1 and smsd.param_key = 'scene_condition_time' and sms.execute_cycle in (1,#{executeCycle}) and sms.condition_rule = 2
......
...@@ -27,4 +27,9 @@ ...@@ -27,4 +27,9 @@
#{sceneId} #{sceneId}
</foreach> </foreach>
</select> </select>
<!-- 查询符合周期(每天+当天类型)且满足任意条件触发 -->
<select id="getByAnyConditionTime" resultMap="BaseResultMap">
select smsd.* from smart_scene sms INNER JOIN smart_scene_data smsd on sms.id = smsd.scene_id where sms.status = 1 and smsd.type = 1 and smsd.param_key = 'scene_condition_time' and sms.execute_cycle in (1,#{executeCycle}) and sms.condition_rule = 1
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -9,7 +9,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
......
...@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
...@@ -25,8 +24,7 @@ public class AnyMatchStrategy implements ConditionStrategy { ...@@ -25,8 +24,7 @@ public class AnyMatchStrategy implements ConditionStrategy {
@Override @Override
public List<ScenseData> getScenseData(int executeCycle) { public List<ScenseData> getScenseData(int executeCycle) {
//获取包含时间条件,符合周期且任意满足触发的场景对应的触发条件集合 //获取包含时间条件,符合周期且任意满足触发的场景对应的触发条件集合
List<Long> ids = sceneMapper.getSceneAnyConditionTime(executeCycle); return scenseDataMapper.getByAnyConditionTime(executeCycle);
return scenseDataMapper.getScneByIds(ids);
} }
@Override @Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!