1、静态任务下发指令,写入事件类型字段
2、任务新建时,就把选择规则状态设置为使用中 3、
This commit is contained in:
@@ -109,11 +109,12 @@ public class StaticRuleService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public Object deleteStaticRules(List<Integer> staticRuleIds) {
|
public Object deleteStaticRules(List<Integer> staticRuleIds) {
|
||||||
//判断当前静态规则是否能够删除---是否存在任务选择的静态规则??
|
//判断当前静态规则是否能够删除---是否存在任务选择的静态规则??
|
||||||
|
List<StaticRuleObject> staticRuleObjects = staticRuleMapper.queryStaticRuleByIds(staticRuleIds);
|
||||||
//删除静态规则
|
for (StaticRuleObject staticRuleObject : staticRuleObjects) {
|
||||||
// for (Integer id : staticRuleIds) {
|
if (Objects.equals(staticRuleObject.getAuditStatus(), AuditStatusEnum.USING.getNum())) {
|
||||||
// staticRuleMapper.deleteStaticRule(id);
|
throw new IllegalArgumentException("当前静态规则正在使用,无法删除");
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
Function<StaticRuleMapper, Function<List<Integer>, Boolean>> deleteStaticRulesFunction =
|
Function<StaticRuleMapper, Function<List<Integer>, Boolean>> deleteStaticRulesFunction =
|
||||||
mapper -> list -> {
|
mapper -> list -> {
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ public interface TaskMapper {
|
|||||||
void newTask(@Param("task") Task task);
|
void newTask(@Param("task") Task task);
|
||||||
|
|
||||||
void newTaskStaticRuleConcat(@Param("task_id") Long taskId,
|
void newTaskStaticRuleConcat(@Param("task_id") Long taskId,
|
||||||
@Param("rule_ids") List<Integer> staticRuleIds);
|
@Param("rule_ids") List<Integer> staticRuleIds,
|
||||||
|
@Param("status") Integer usingStatusNum);
|
||||||
|
|
||||||
void newTaskDynamicRuleConcat(@Param("task_id") Long taskId,
|
void newTaskDynamicRuleConcat(@Param("task_id") Long taskId,
|
||||||
@Param("rule_ids") List<Integer> dynamicRuleIds);
|
@Param("rule_ids") List<Integer> dynamicRuleIds,
|
||||||
|
@Param("status") Integer usingStatusNum);
|
||||||
|
|
||||||
void newTaskUsingCommandInfo(@Param("info") TaskCommandInfo taskCommandInfo);
|
void newTaskUsingCommandInfo(@Param("info") TaskCommandInfo taskCommandInfo);
|
||||||
|
|
||||||
@@ -40,9 +42,9 @@ public interface TaskMapper {
|
|||||||
|
|
||||||
void updateTask(@Param("task") Task task);
|
void updateTask(@Param("task") Task task);
|
||||||
|
|
||||||
void clearTaskConnectedStaticRule(@Param("task_id") Long taskId);
|
void clearTaskConnectedStaticRule(@Param("task_id") Long taskId, @Param("status")Integer num);
|
||||||
|
|
||||||
void clearTaskConnectedDynamicRule(@Param("task_id") Long taskId);
|
void clearTaskConnectedDynamicRule(@Param("task_id") Long taskId, @Param("status")Integer num);
|
||||||
|
|
||||||
void changeTaskAuditStatusWithAudior(@Param("task_id") Long taskId, @Param("audit_status") Integer auditStatus,
|
void changeTaskAuditStatusWithAudior(@Param("task_id") Long taskId, @Param("audit_status") Integer auditStatus,
|
||||||
@Param("auditUserName")String auditUserName,
|
@Param("auditUserName")String auditUserName,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class TaskService {
|
|||||||
throw new IllegalArgumentException("部分静态规则已被其他任务使用");
|
throw new IllegalArgumentException("部分静态规则已被其他任务使用");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds());
|
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds(), AuditStatusEnum.USING.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty()) {
|
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty()) {
|
||||||
@@ -89,7 +89,7 @@ public class TaskService {
|
|||||||
throw new IllegalArgumentException("部分动态规则已被其他任务使用");
|
throw new IllegalArgumentException("部分动态规则已被其他任务使用");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds());
|
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds(), AuditStatusEnum.USING.getNum());
|
||||||
}
|
}
|
||||||
if (task.getTaskType() != TaskTypeEnum.STATIC.getTaskType()) {
|
if (task.getTaskType() != TaskTypeEnum.STATIC.getTaskType()) {
|
||||||
if (task.getProtectObjectIds() != null && !task.getProtectObjectIds().isEmpty()) {
|
if (task.getProtectObjectIds() != null && !task.getProtectObjectIds().isEmpty()) {
|
||||||
@@ -300,17 +300,16 @@ public class TaskService {
|
|||||||
//更新task
|
//更新task
|
||||||
taskMapper.updateTask(task);
|
taskMapper.updateTask(task);
|
||||||
//重新关联task和protectObjects
|
//重新关联task和protectObjects
|
||||||
|
|
||||||
taskMapper.newTaskProtectObjectConcat(task.getTaskId(), task.getProtectObjectIds());
|
taskMapper.newTaskProtectObjectConcat(task.getTaskId(), task.getProtectObjectIds());
|
||||||
|
|
||||||
taskMapper.clearTaskConnectedStaticRule(task.getTaskId());
|
taskMapper.clearTaskConnectedStaticRule(task.getTaskId(), AuditStatusEnum.AUDITED.getNum());
|
||||||
taskMapper.clearTaskConnectedDynamicRule(task.getTaskId());
|
taskMapper.clearTaskConnectedDynamicRule(task.getTaskId(), AuditStatusEnum.AUDITED.getNum());
|
||||||
|
|
||||||
if (task.getStaticRuleIds() != null && !task.getStaticRuleIds().isEmpty())
|
if (task.getStaticRuleIds() != null && !task.getStaticRuleIds().isEmpty())
|
||||||
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds());
|
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds(), AuditStatusEnum.USING.getNum());
|
||||||
|
|
||||||
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty())
|
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty())
|
||||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds());
|
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds(),AuditStatusEnum.USING.getNum());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -349,11 +348,12 @@ public class TaskService {
|
|||||||
if (task == null) {
|
if (task == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//有的规则被任务选择了,但任务还没有启动,此时规则的状态不是已使用,但used_task_id已经被设置
|
||||||
|
//所以应该选择任务的时候就
|
||||||
updateStaticRuleAuditStatusInTask(taskId, AuditStatusEnum.AUDITED);
|
updateStaticRuleAuditStatusInTask(taskId, AuditStatusEnum.AUDITED);
|
||||||
updateDynamicRuleAuditStatusInTask(taskId, AuditStatusEnum.AUDITED);
|
updateDynamicRuleAuditStatusInTask(taskId, AuditStatusEnum.AUDITED);
|
||||||
taskMapper.clearTaskConnectedStaticRule(task.getTaskId());
|
taskMapper.clearTaskConnectedStaticRule(task.getTaskId(), AuditStatusEnum.AUDITED.getNum());
|
||||||
taskMapper.clearTaskConnectedDynamicRule(task.getTaskId());
|
taskMapper.clearTaskConnectedDynamicRule(task.getTaskId(), AuditStatusEnum.AUDITED.getNum());
|
||||||
|
|
||||||
commandMapper.removeCommandsByTaskId(taskId);
|
commandMapper.removeCommandsByTaskId(taskId);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<update id="newTaskStaticRuleConcat">
|
<update id="newTaskStaticRuleConcat">
|
||||||
UPDATE t_static_rule
|
UPDATE t_static_rule
|
||||||
SET static_rule_used_task_id = #{task_id}
|
SET static_rule_used_task_id = #{task_id}
|
||||||
|
static_rule_audit_status = #{status}
|
||||||
WHERE
|
WHERE
|
||||||
<if test="rule_ids != null and rule_ids.size() > 0">
|
<if test="rule_ids != null and rule_ids.size() > 0">
|
||||||
static_rule_id IN
|
static_rule_id IN
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
<update id="newTaskDynamicRuleConcat">
|
<update id="newTaskDynamicRuleConcat">
|
||||||
UPDATE t_dynamic_rule
|
UPDATE t_dynamic_rule
|
||||||
SET dynamic_rule_used_task_id = #{task_id}
|
SET dynamic_rule_used_task_id = #{task_id}
|
||||||
|
audit_status = #{status}
|
||||||
WHERE
|
WHERE
|
||||||
<if test="rule_ids != null and rule_ids.size() > 0">
|
<if test="rule_ids != null and rule_ids.size() > 0">
|
||||||
dynamic_rule_id IN
|
dynamic_rule_id IN
|
||||||
@@ -329,6 +331,7 @@
|
|||||||
<result column="static_rule_frequency" property="frequency"/>
|
<result column="static_rule_frequency" property="frequency"/>
|
||||||
<result column="task_start_time" property="startTime"/>
|
<result column="task_start_time" property="startTime"/>
|
||||||
<result column="task_end_time" property="endTime"/>
|
<result column="task_end_time" property="endTime"/>
|
||||||
|
<result column="event_type" property="eventType"/>
|
||||||
|
|
||||||
<association property="fiveTupleWithMask">
|
<association property="fiveTupleWithMask">
|
||||||
<result column="addr_type" property="addrType"/>
|
<result column="addr_type" property="addrType"/>
|
||||||
@@ -497,6 +500,7 @@
|
|||||||
|
|
||||||
t_task.task_start_time,
|
t_task.task_start_time,
|
||||||
t_task.task_end_time,
|
t_task.task_end_time,
|
||||||
|
t_task.event_type,
|
||||||
|
|
||||||
INET_NTOA(tsr.static_rule_sip) as static_rule_sip,
|
INET_NTOA(tsr.static_rule_sip) as static_rule_sip,
|
||||||
tsr.static_rule_sport,
|
tsr.static_rule_sport,
|
||||||
|
|||||||
Reference in New Issue
Block a user