指挥系统任务创建
This commit is contained in:
@@ -155,4 +155,10 @@ public class Task {
|
||||
@JsonProperty("task_ip_num")
|
||||
@Schema(description = "任务涉及ip数量", example = "1000", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private Integer taskIpNum;
|
||||
|
||||
@JsonProperty("task_source")
|
||||
private String taskSource;
|
||||
|
||||
@JsonProperty("zh_id")
|
||||
private Long zhId;
|
||||
}
|
||||
|
||||
@@ -88,8 +88,11 @@ public class TaskController implements TaskControllerApi {
|
||||
task.setTaskCreateDepart(user.getOrgName());
|
||||
task.setAuditUserDepartCode(user.getOrgCode());
|
||||
}
|
||||
//事件类型的用户权限校验、动作逻辑性校验
|
||||
taskService.eventTypeValid(task);
|
||||
if (task.getZhId() == null || task.getZhId() == 0) {
|
||||
//事件类型的用户权限校验、动作逻辑性校验
|
||||
taskService.eventTypeValid(task);
|
||||
}
|
||||
|
||||
|
||||
//冲突性
|
||||
// taskService.chongtuValid(task);
|
||||
|
||||
@@ -18,10 +18,12 @@ import java.util.Map;
|
||||
public interface TaskMapper {
|
||||
|
||||
|
||||
void setIpTotalNum(@Param("ip_total_num")Long ipTotalNum, @Param("task_id")Long taskId) ;
|
||||
void setIpTotalNum(@Param("ip_total_num") Long ipTotalNum, @Param("task_id") Long taskId);
|
||||
|
||||
void newTask(@Param("task") Task task);
|
||||
|
||||
void newZhTask(@Param("task") Task task);
|
||||
|
||||
void newTaskStaticRuleConcat(@Param("task_id") Long taskId,
|
||||
@Param("rule_ids") List<Integer> staticRuleIds,
|
||||
@Param("status") Integer usingStatusNum);
|
||||
@@ -35,26 +37,26 @@ public interface TaskMapper {
|
||||
List<Task> queryTasks(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
|
||||
@Param("task_name") String taskName, @Param("task_creator") String taskCreator,
|
||||
@Param("audit_status") Integer auditStatus,
|
||||
@Param("task_act")String taskAct, @Param("task_auditor")String taskAuditor,
|
||||
@Param("task_source")String taskSource, @Param("rule_name")String ruleName,
|
||||
@Param("event_type")String eventType,
|
||||
@Param("task_act") String taskAct, @Param("task_auditor") String taskAuditor,
|
||||
@Param("task_source") String taskSource, @Param("rule_name") String ruleName,
|
||||
@Param("event_type") String eventType,
|
||||
@Param("create_date") String createDateStr,
|
||||
@Param("start_date")String startDateStr,
|
||||
@Param("protect_level")Integer protectLevel,
|
||||
@Param("start_date") String startDateStr,
|
||||
@Param("protect_level") Integer protectLevel,
|
||||
@Param("page") Integer page, @Param("page_size") Integer pageSize);
|
||||
|
||||
Task queryTask(@Param("task_id") Long taskId);
|
||||
|
||||
void updateTask(@Param("task") Task task);
|
||||
|
||||
void clearTaskConnectedStaticRule(@Param("task_id") Long taskId, @Param("status")Integer num);
|
||||
void clearTaskConnectedStaticRule(@Param("task_id") Long taskId, @Param("status") Integer num);
|
||||
|
||||
void clearTaskConnectedDynamicRule(@Param("task_id") Long taskId, @Param("status")Integer num);
|
||||
void clearTaskConnectedDynamicRule(@Param("task_id") Long taskId, @Param("status") Integer num);
|
||||
|
||||
void changeTaskAuditStatusWithAudior(@Param("task_id") Long taskId, @Param("audit_status") Integer auditStatus,
|
||||
@Param("auditUserName")String auditUserName,
|
||||
@Param("auditUserId")String auditUserId,
|
||||
@Param("auditUserDepart")String auditUserDepart);
|
||||
@Param("auditUserName") String auditUserName,
|
||||
@Param("auditUserId") String auditUserId,
|
||||
@Param("auditUserDepart") String auditUserDepart);
|
||||
|
||||
void changeTaskAuditStatus(@Param("task_id") Long taskId, @Param("audit_status") Integer auditStatus);
|
||||
|
||||
@@ -83,13 +85,13 @@ public interface TaskMapper {
|
||||
Integer queryTaskTotalNum(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
|
||||
@Param("task_name") String taskName, @Param("task_creator") String taskCreator,
|
||||
@Param("audit_status") Integer auditStatus,
|
||||
@Param("task_act")String taskAct, @Param("task_auditor")String taskAuditor,
|
||||
@Param("task_source")String taskSource, @Param("rule_name")String ruleName,
|
||||
@Param("task_act") String taskAct, @Param("task_auditor") String taskAuditor,
|
||||
@Param("task_source") String taskSource, @Param("rule_name") String ruleName,
|
||||
@Param("task_create_time") LocalDateTime taskCreateTime,
|
||||
@Param("event_type")String eventType,
|
||||
@Param("create_date")String createDate,
|
||||
@Param("start_date")String startDate,
|
||||
@Param("protect_level")Integer protectLevel);
|
||||
@Param("event_type") String eventType,
|
||||
@Param("create_date") String createDate,
|
||||
@Param("start_date") String startDate,
|
||||
@Param("protect_level") Integer protectLevel);
|
||||
|
||||
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
|
||||
|
||||
@@ -97,17 +99,17 @@ public interface TaskMapper {
|
||||
|
||||
List<Integer> queryAuditStatusByIds(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idsWithAuditStatusMap);
|
||||
|
||||
Boolean updateAuditInfo(@Param("ids")List<Long> ids, @Param("auditInfo")String auditInfo);
|
||||
Boolean updateAuditInfo(@Param("ids") List<Long> ids, @Param("auditInfo") String auditInfo);
|
||||
|
||||
String queryAuditInfo(Integer id);
|
||||
|
||||
void updateAuditStatusWithAuditorByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch,
|
||||
@Param("auditUserName")String auditUserName,
|
||||
@Param("auditUserId")String auditUserId,
|
||||
@Param("auditUserDepart")String auditUserDepart);
|
||||
@Param("auditUserName") String auditUserName,
|
||||
@Param("auditUserId") String auditUserId,
|
||||
@Param("auditUserDepart") String auditUserDepart);
|
||||
|
||||
void newTaskProtectObjectConcat(@Param("taskId")Long taskId,
|
||||
@Param("protectObjectIds")List<Integer> protectObjectIds);
|
||||
void newTaskProtectObjectConcat(@Param("taskId") Long taskId,
|
||||
@Param("protectObjectIds") List<Integer> protectObjectIds);
|
||||
|
||||
void deleteTaskProtectObjectConcat(Long taskId);
|
||||
|
||||
@@ -134,7 +136,7 @@ public interface TaskMapper {
|
||||
|
||||
String queryEventTypeAct(String eventType);
|
||||
|
||||
List<Task> queryAuditInfoNotification(String userId , Integer auditStatus);
|
||||
List<Task> queryAuditInfoNotification(String userId, Integer auditStatus);
|
||||
|
||||
void updateNotificationByTaskId(@Param("taskIds") List<Long> taskIdList);
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValida
|
||||
import com.realtime.protection.server.command.CommandMapper;
|
||||
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleMapper;
|
||||
import com.realtime.protection.server.rule.staticrule.StaticRuleMapper;
|
||||
import com.realtime.protection.server.v1.entity.TCommandTask;
|
||||
import com.realtime.protection.server.v1.mapper.TCommandTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -30,6 +33,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -52,6 +56,9 @@ public class TaskService {
|
||||
private final Counter counter;
|
||||
private final CommandMapper commandMapper;
|
||||
|
||||
@Autowired
|
||||
private TCommandTaskMapper tCommandTaskMapper;
|
||||
|
||||
public TaskService(TaskMapper taskMapper, StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper, DynamicRuleMapper dynamicRuleMapper, Counter counter, CommandMapper commandMapper) {
|
||||
this.taskMapper = taskMapper;
|
||||
this.staticRuleMapper = staticRuleMapper;
|
||||
@@ -84,12 +91,12 @@ public class TaskService {
|
||||
return mergedSubnets;
|
||||
}
|
||||
|
||||
public Long ipWithMaskToIpNums(List<Subnet> subnets) {
|
||||
public Long ipWithMaskToIpNums(List<Subnet> subnets) {
|
||||
|
||||
Long totalIPs = 0L;
|
||||
try {
|
||||
List<Subnet> mergedSubnets = mergeOverlappingSubnets(subnets);
|
||||
for (Subnet subnet : mergedSubnets){
|
||||
for (Subnet subnet : mergedSubnets) {
|
||||
totalIPs += Subnet.getNumberOfHosts(subnet.subnetMask);
|
||||
}
|
||||
|
||||
@@ -98,7 +105,7 @@ public class TaskService {
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
return totalIPs;
|
||||
}
|
||||
@@ -108,85 +115,120 @@ public class TaskService {
|
||||
public Long newTask(Task task) {
|
||||
|
||||
// eventTypeValid(task);
|
||||
|
||||
task.setTaskDisplayId(
|
||||
"RW-"
|
||||
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||
+ "-"
|
||||
+ String.format("%06d", counter.generateId("task")));
|
||||
|
||||
taskMapper.newTask(task);
|
||||
|
||||
List<Subnet> subnetList = new ArrayList<>();
|
||||
if (task.getStaticRuleIds() != null && !task.getStaticRuleIds().isEmpty()) {
|
||||
staticRuleMapper.queryStaticRuleByIds(task.getStaticRuleIds()).forEach(staticRuleObject -> {
|
||||
if (!staticRuleObject.getAuditStatus().equals(AuditStatusEnum.AUDITED.getNum())) {
|
||||
throw new IllegalArgumentException("部分规则审批状态错误");
|
||||
if (task.getZhId() != null && task.getZhId() != 0) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
TCommandTask tCommandTask = tCommandTaskMapper.queryById(task.getZhId());
|
||||
task.setTaskDisplayId(
|
||||
"RW-"
|
||||
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||
+ "-"
|
||||
+ String.format("%06d", counter.generateId("task")));
|
||||
task.setTaskName(tCommandTask.getTaskName());
|
||||
task.setTaskSource("指挥系统");
|
||||
try {
|
||||
if (tCommandTask.getTaskStartTime() != null) {
|
||||
task.setTaskStartTime(LocalDateTime.parse(tCommandTask.getTaskStartTime(), formatter));
|
||||
}
|
||||
if (staticRuleObject.getStaticRuleUsedTaskId() != null) {
|
||||
throw new IllegalArgumentException("部分静态规则已被其他任务使用");
|
||||
if (tCommandTask.getTaskEndTime() != null) {
|
||||
task.setTaskEndTime(LocalDateTime.parse(tCommandTask.getTaskEndTime(), formatter));
|
||||
}
|
||||
try {
|
||||
String sip = staticRuleObject.getStaticRuleSip();
|
||||
String msip;
|
||||
if (staticRuleObject.getStaticRuleMsip() != null){
|
||||
msip = staticRuleObject.getStaticRuleMsip();
|
||||
}
|
||||
else{
|
||||
msip = "255.255.255.255";
|
||||
}
|
||||
String dip = staticRuleObject.getStaticRuleDip();
|
||||
String mdip;
|
||||
if (staticRuleObject.getStaticRuleMdip() != null){
|
||||
mdip = staticRuleObject.getStaticRuleMdip();
|
||||
}
|
||||
else{
|
||||
mdip = "255.255.255.255";
|
||||
}
|
||||
if (sip != null) subnetList.add(new Subnet(sip,msip));
|
||||
if (dip != null) subnetList.add(new Subnet(dip,mdip));
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (tCommandTask.getTaskCreateTime() != null) {
|
||||
task.setTaskCreateTime(tCommandTask.getTaskCreateTime().toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime());
|
||||
}
|
||||
});
|
||||
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds(), AuditStatusEnum.USING.getNum());
|
||||
}
|
||||
|
||||
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty()) {
|
||||
dynamicRuleMapper.queryDynamicRuleByIds(task.getDynamicRuleIds()).forEach(dynamicRuleObject -> {
|
||||
if (!dynamicRuleObject.getAuditStatus().equals(AuditStatusEnum.AUDITED.getNum())) {
|
||||
throw new IllegalArgumentException("部分规则审批状态错误");
|
||||
}
|
||||
|
||||
if (dynamicRuleObject.getDynamicRuleUsedTaskId() != null) {
|
||||
throw new IllegalArgumentException("部分动态规则已被其他任务使用");
|
||||
}
|
||||
});
|
||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds(), AuditStatusEnum.USING.getNum());
|
||||
}
|
||||
if (task.getTaskType() != TaskTypeEnum.STATIC.getTaskType()) {
|
||||
if (task.getProtectObjectIds() != null && !task.getProtectObjectIds().isEmpty()) {
|
||||
//校验防护对象是否存在
|
||||
boolean ProtectObjIdValid = task.getProtectObjectIds().stream()
|
||||
.allMatch(dynamicRuleMapper::queryProtectObjectById);
|
||||
if (!ProtectObjIdValid) {
|
||||
throw new IllegalArgumentException("部分防护对象不存在");
|
||||
}
|
||||
//任务和防护对象多对多关联建立
|
||||
taskMapper.newTaskProtectObjectConcat(task.getTaskId(), task.getProtectObjectIds());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
task.setEventType(tCommandTask.getEventType());
|
||||
if ("低".equals(tCommandTask.getPriority())) {
|
||||
task.setProtectLevel(1);
|
||||
} else if ("中".equals(tCommandTask.getPriority())) {
|
||||
task.setProtectLevel(2);
|
||||
} else if ("高".equals(tCommandTask.getPriority())) {
|
||||
task.setProtectLevel(3);
|
||||
}
|
||||
taskMapper.newZhTask(task);
|
||||
tCommandTask.setTaskId(task.getTaskId());
|
||||
tCommandTaskMapper.update(tCommandTask);
|
||||
return task.getTaskId();
|
||||
} else {
|
||||
task.setTaskDisplayId(
|
||||
"RW-"
|
||||
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||
+ "-"
|
||||
+ String.format("%06d", counter.generateId("task")));
|
||||
taskMapper.newTask(task);
|
||||
|
||||
List<Subnet> subnetList = new ArrayList<>();
|
||||
if (task.getStaticRuleIds() != null && !task.getStaticRuleIds().isEmpty()) {
|
||||
staticRuleMapper.queryStaticRuleByIds(task.getStaticRuleIds()).forEach(staticRuleObject -> {
|
||||
if (!staticRuleObject.getAuditStatus().equals(AuditStatusEnum.AUDITED.getNum())) {
|
||||
throw new IllegalArgumentException("部分规则审批状态错误");
|
||||
}
|
||||
if (staticRuleObject.getStaticRuleUsedTaskId() != null) {
|
||||
throw new IllegalArgumentException("部分静态规则已被其他任务使用");
|
||||
}
|
||||
try {
|
||||
String sip = staticRuleObject.getStaticRuleSip();
|
||||
String msip;
|
||||
if (staticRuleObject.getStaticRuleMsip() != null) {
|
||||
msip = staticRuleObject.getStaticRuleMsip();
|
||||
} else {
|
||||
msip = "255.255.255.255";
|
||||
}
|
||||
String dip = staticRuleObject.getStaticRuleDip();
|
||||
String mdip;
|
||||
if (staticRuleObject.getStaticRuleMdip() != null) {
|
||||
mdip = staticRuleObject.getStaticRuleMdip();
|
||||
} else {
|
||||
mdip = "255.255.255.255";
|
||||
}
|
||||
if (sip != null) subnetList.add(new Subnet(sip, msip));
|
||||
if (dip != null) subnetList.add(new Subnet(dip, mdip));
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds(), AuditStatusEnum.USING.getNum());
|
||||
}
|
||||
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty()) {
|
||||
dynamicRuleMapper.queryDynamicRuleByIds(task.getDynamicRuleIds()).forEach(dynamicRuleObject -> {
|
||||
if (!dynamicRuleObject.getAuditStatus().equals(AuditStatusEnum.AUDITED.getNum())) {
|
||||
throw new IllegalArgumentException("部分规则审批状态错误");
|
||||
}
|
||||
|
||||
if (dynamicRuleObject.getDynamicRuleUsedTaskId() != null) {
|
||||
throw new IllegalArgumentException("部分动态规则已被其他任务使用");
|
||||
}
|
||||
});
|
||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds(), AuditStatusEnum.USING.getNum());
|
||||
}
|
||||
if (task.getTaskType() != TaskTypeEnum.STATIC.getTaskType()) {
|
||||
if (task.getProtectObjectIds() != null && !task.getProtectObjectIds().isEmpty()) {
|
||||
//校验防护对象是否存在
|
||||
boolean ProtectObjIdValid = task.getProtectObjectIds().stream()
|
||||
.allMatch(dynamicRuleMapper::queryProtectObjectById);
|
||||
if (!ProtectObjIdValid) {
|
||||
throw new IllegalArgumentException("部分防护对象不存在");
|
||||
}
|
||||
//任务和防护对象多对多关联建立
|
||||
taskMapper.newTaskProtectObjectConcat(task.getTaskId(), task.getProtectObjectIds());
|
||||
|
||||
}
|
||||
}
|
||||
Long ipTotalNum = ipWithMaskToIpNums(subnetList);
|
||||
taskMapper.setIpTotalNum(ipTotalNum, task.getTaskId());
|
||||
//todo 1、存到数据库 2、前端展示。详细信息
|
||||
insertTaskStatusLog(task.getTaskId());
|
||||
return task.getTaskId();
|
||||
}
|
||||
Long ipTotalNum = ipWithMaskToIpNums(subnetList);
|
||||
taskMapper.setIpTotalNum(ipTotalNum, task.getTaskId());
|
||||
//todo 1、存到数据库 2、前端展示。详细信息
|
||||
insertTaskStatusLog(task.getTaskId());
|
||||
return task.getTaskId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务关联的静态规则审批状态,用于任务新建/停止时候,修改审批状态为已使用/已审批,不能用于其他审批状态修改
|
||||
* @param taskId 与静态规则关联的任务ID
|
||||
*
|
||||
* @param taskId 与静态规则关联的任务ID
|
||||
* @param newAuditStatus 需要修改的审批状态
|
||||
*/
|
||||
public void updateStaticRuleAuditStatusInTask(Long taskId, AuditStatusEnum newAuditStatus) {
|
||||
@@ -249,7 +291,8 @@ public class TaskService {
|
||||
|
||||
/**
|
||||
* 更新任务关联的动态规则审批状态,用于任务新建/停止时候,修改审批状态为已使用/已审批,不能用于其他审批状态修改
|
||||
* @param taskId 与动态规则关联的任务ID
|
||||
*
|
||||
* @param taskId 与动态规则关联的任务ID
|
||||
* @param newAuditStatus 需要修改的审批状态
|
||||
*/
|
||||
public void updateDynamicRuleAuditStatusInTask(Long taskId, AuditStatusEnum newAuditStatus) {
|
||||
@@ -316,12 +359,12 @@ public class TaskService {
|
||||
Integer auditStatus,
|
||||
String taskAct, String taskAuditor,
|
||||
String taskSource, String ruleName,
|
||||
String eventType,String createDateStr, String startDateStr,
|
||||
String eventType, String createDateStr, String startDateStr,
|
||||
Integer protectLevel,
|
||||
Integer page, Integer pageSize) {
|
||||
|
||||
List<Task> tasks = taskMapper.queryTasks(taskStatus, taskType, taskName, taskCreator, auditStatus,
|
||||
taskAct, taskAuditor, taskSource, ruleName,eventType, createDateStr, startDateStr,protectLevel, page, pageSize);
|
||||
taskAct, taskAuditor, taskSource, ruleName, eventType, createDateStr, startDateStr, protectLevel, page, pageSize);
|
||||
for (Task task : tasks) {
|
||||
if (task == null) {
|
||||
continue;
|
||||
@@ -385,7 +428,7 @@ public class TaskService {
|
||||
taskMapper.newTaskStaticRuleConcat(task.getTaskId(), task.getStaticRuleIds(), AuditStatusEnum.USING.getNum());
|
||||
|
||||
if (task.getDynamicRuleIds() != null && !task.getDynamicRuleIds().isEmpty())
|
||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds(),AuditStatusEnum.USING.getNum());
|
||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds(), AuditStatusEnum.USING.getNum());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -400,7 +443,7 @@ public class TaskService {
|
||||
|
||||
|
||||
if (AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(taskAuditStatus))
|
||||
taskMapper.changeTaskAuditStatusWithAudior(taskId, taskAuditStatus, auditUserName, auditUserId, auditUserDepart);
|
||||
taskMapper.changeTaskAuditStatusWithAudior(taskId, taskAuditStatus, auditUserName, auditUserId, auditUserDepart);
|
||||
else return false;
|
||||
insertTaskStatusLog(taskId);
|
||||
|
||||
@@ -423,6 +466,7 @@ public class TaskService {
|
||||
// sendTaskStatusChangeToOtherSystem(taskId,taskAuditStatus);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean sendTaskStatusChangeToOtherSystem(Long taskId, Integer taskAuditStatus) {
|
||||
WebClient ddos_sytem = WebClient.builder()
|
||||
.baseUrl("http://10.58.72.140:8089")
|
||||
@@ -478,13 +522,14 @@ public class TaskService {
|
||||
|
||||
return success.get();
|
||||
}
|
||||
|
||||
public Boolean deleteTask(Long taskId) {
|
||||
Task task = taskMapper.queryTask(taskId);
|
||||
if (task == null) {
|
||||
return true;
|
||||
}
|
||||
if (task.getTaskStatus() == StateEnum.RUNNING.getStateNum() || task.getTaskStatus() == StateEnum.RUNNING_FAILED.getStateNum()
|
||||
|| task.getTaskStatus() == StateEnum.RUNNING_SUCCESS.getStateNum()|| task.getTaskStatus() == StateEnum.RUNNING_PARTIAL_SUCCESS.getStateNum()){
|
||||
|| task.getTaskStatus() == StateEnum.RUNNING_SUCCESS.getStateNum() || task.getTaskStatus() == StateEnum.RUNNING_PARTIAL_SUCCESS.getStateNum()) {
|
||||
throw new IllegalArgumentException("任务正在运行中,无法删除");
|
||||
}
|
||||
//有的规则被任务选择了,但任务还没有启动,此时规则的状态不是已使用,但used_task_id已经被设置
|
||||
@@ -540,10 +585,10 @@ public class TaskService {
|
||||
}
|
||||
|
||||
public Integer queryTaskTotalNum(Integer taskStatus, Integer taskType, String taskName, String taskCreator, Integer auditStatus
|
||||
,String taskAct, String taskAuditor, String taskSource, String ruleName,
|
||||
String eventType, String createDate, String startDate,Integer protectLevel) {
|
||||
, String taskAct, String taskAuditor, String taskSource, String ruleName,
|
||||
String eventType, String createDate, String startDate, Integer protectLevel) {
|
||||
return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus,
|
||||
taskAct, taskAuditor, taskSource, ruleName,null, eventType, createDate, startDate, protectLevel);
|
||||
taskAct, taskAuditor, taskSource, ruleName, null, eventType, createDate, startDate, protectLevel);
|
||||
}
|
||||
|
||||
public Boolean updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
@@ -555,7 +600,7 @@ public class TaskService {
|
||||
|
||||
int index = 0;
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
for (Map.Entry<Integer, Integer> entry : idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
Integer auditStatus = entry.getValue();
|
||||
Integer originalAuditStatus = originalAuditStatusList.get(index);
|
||||
@@ -565,7 +610,7 @@ public class TaskService {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
if (!errorIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("动态规则id无法修改为对应审核状态, errorIds: " + errorIds);
|
||||
}
|
||||
|
||||
@@ -609,7 +654,7 @@ public class TaskService {
|
||||
|
||||
int index = 0;
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
for (Map.Entry<Integer, Integer> entry : idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
Integer auditStatus = entry.getValue();
|
||||
Integer originalAuditStatus = originalAuditStatusList.get(index);
|
||||
@@ -619,7 +664,7 @@ public class TaskService {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
if (!errorIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("动态规则id无法修改为对应审核状态, errorIds: " + errorIds);
|
||||
}
|
||||
|
||||
@@ -636,11 +681,11 @@ public class TaskService {
|
||||
continue;
|
||||
}
|
||||
//mapper指的就是外层函数输入的参数,也就是WhiteListMapper
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
idWithAuditStatusBatch.clear();
|
||||
}
|
||||
if (!idWithAuditStatusBatch.isEmpty()) {
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -671,6 +716,7 @@ public class TaskService {
|
||||
taskMapper.updateTaskStatusLogExpireTime(taskId);
|
||||
taskMapper.insertTaskStatusLog(taskId);
|
||||
}
|
||||
|
||||
public void insertTaskStatusLog(Map<Integer, Integer> idWithAuditStatusBatch) {
|
||||
Set<Integer> keys = idWithAuditStatusBatch.keySet();
|
||||
ArrayList<Integer> taskIds = new ArrayList<>(keys);
|
||||
@@ -680,7 +726,7 @@ public class TaskService {
|
||||
}
|
||||
|
||||
public List<Task> queryHistory(Long id, Integer page, Integer pageSize) {
|
||||
List<Task> tasks = taskMapper.queryHistory(id, page, pageSize);
|
||||
List<Task> tasks = taskMapper.queryHistory(id, page, pageSize);
|
||||
|
||||
for (Task task : tasks) {
|
||||
if (task == null) {
|
||||
@@ -712,6 +758,7 @@ public class TaskService {
|
||||
// staticRuleMapper.updateStaticRuleStatusLogExpireTimeBatch(ids);
|
||||
staticRuleMapper.insertStaticRuleStatusLogBatch(ids);
|
||||
}
|
||||
|
||||
public void insertDynamicRuleStatusLog(Map<Integer, Integer> idWithAuditStatusBatch) {
|
||||
Set<Integer> keys = idWithAuditStatusBatch.keySet();
|
||||
ArrayList<Integer> ids = new ArrayList<>(keys);
|
||||
@@ -722,7 +769,7 @@ public class TaskService {
|
||||
}
|
||||
|
||||
public List<Long> getRunnableTasks() {
|
||||
return taskMapper.queryRunnableTasks(StateEnum.PENDING.getStateNum(),AuditStatusEnum.AUDITED.getNum());
|
||||
return taskMapper.queryRunnableTasks(StateEnum.PENDING.getStateNum(), AuditStatusEnum.AUDITED.getNum());
|
||||
}
|
||||
|
||||
public void updateTaskStartTime(Long taskId) {
|
||||
@@ -763,8 +810,8 @@ public class TaskService {
|
||||
|
||||
@Transactional
|
||||
public List<Task> auditInfoNotification(String userId) {
|
||||
List<Task> tasksNotification = taskMapper.queryAuditInfoNotification(userId,AuditStatusEnum.RETURNED.getNum());
|
||||
if (tasksNotification.isEmpty()){
|
||||
List<Task> tasksNotification = taskMapper.queryAuditInfoNotification(userId, AuditStatusEnum.RETURNED.getNum());
|
||||
if (tasksNotification.isEmpty()) {
|
||||
return tasksNotification;
|
||||
}
|
||||
List<Long> taskIdList = tasksNotification.stream().map(Task::getTaskId).toList();
|
||||
@@ -776,11 +823,11 @@ public class TaskService {
|
||||
|
||||
public void chongtuValid(Task task) {
|
||||
if (task.getTaskAct().equals("23") &&
|
||||
task.getEventType().equals("APT") &&
|
||||
task.getTaskType()==1
|
||||
){
|
||||
task.getEventType().equals("APT") &&
|
||||
task.getTaskType() == 1
|
||||
) {
|
||||
throw new IllegalArgumentException("任务冲突,任务类型:静态。任务动作:阻断+23(丢弃重定向)" +
|
||||
"事件类型:APT攻击 ,开始时间"+task.getTaskStartTime()+"结束时间:"+task.getTaskEndTime());
|
||||
"事件类型:APT攻击 ,开始时间" + task.getTaskStartTime() + "结束时间:" + task.getTaskEndTime());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -788,6 +835,7 @@ public class TaskService {
|
||||
public List<File> selectFilesByStaticRuleId(Long taskId) {
|
||||
return taskMapper.selectFilesByStaticRuleId(taskId);
|
||||
}
|
||||
|
||||
public void saveFile(File saveFile) {
|
||||
taskMapper.saveFile(saveFile);
|
||||
}
|
||||
@@ -798,7 +846,7 @@ public class TaskService {
|
||||
|
||||
|
||||
public List<Task> queryTaskStausLog(Long id, Integer page, Integer pageSize) {
|
||||
return taskMapper.queryTaskStausLog(id,page,pageSize);
|
||||
return taskMapper.queryTaskStausLog(id, page, pageSize);
|
||||
}
|
||||
|
||||
public Integer queryTaskStausLogTotalNum(Long id) {
|
||||
@@ -806,12 +854,12 @@ public class TaskService {
|
||||
}
|
||||
|
||||
public List<Long> getRunningTasks() {
|
||||
return taskMapper.queryRunningTasks(StateEnum.RUNNING.getStateNum(),StateEnum.RUNNING_SUCCESS.getStateNum(),
|
||||
StateEnum.RUNNING_PARTIAL_SUCCESS.getStateNum(),StateEnum.RUNNING_FAILED.getStateNum());
|
||||
return taskMapper.queryRunningTasks(StateEnum.RUNNING.getStateNum(), StateEnum.RUNNING_SUCCESS.getStateNum(),
|
||||
StateEnum.RUNNING_PARTIAL_SUCCESS.getStateNum(), StateEnum.RUNNING_FAILED.getStateNum());
|
||||
}
|
||||
|
||||
public void updateTaskIpTotalNum(Long ipTotalNum, Long taskId) {
|
||||
Integer taskIpNum = taskMapper.queryIpTotalNum(taskId);
|
||||
Integer taskIpNum = taskMapper.queryIpTotalNum(taskId);
|
||||
ipTotalNum = ipTotalNum + taskIpNum;
|
||||
taskMapper.setIpTotalNum(ipTotalNum, taskId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.realtime.protection.server.v1.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (TCommandTask)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-08-27 15:36:47
|
||||
*/
|
||||
public class TCommandTask implements Serializable {
|
||||
private static final long serialVersionUID = -38138465113282389L;
|
||||
/**
|
||||
* 任务id 关联任务表
|
||||
*/
|
||||
private Long taskId;
|
||||
/**
|
||||
* 指挥指令id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String taskName;
|
||||
/**
|
||||
* 处置事件类型
|
||||
*/
|
||||
private String eventType;
|
||||
/**
|
||||
* 影响的范围
|
||||
*/
|
||||
private String incidence;
|
||||
/**
|
||||
* 事件等级 字典:特别重大 重大 较大 一般
|
||||
*/
|
||||
private String eventLevel;
|
||||
/**
|
||||
* 采取的处置措施
|
||||
*/
|
||||
private String disposalMeasures;
|
||||
/**
|
||||
* 处置开始时间
|
||||
*/
|
||||
private String taskStartTime;
|
||||
/**
|
||||
* 处置结束时间 空为一直生效
|
||||
*/
|
||||
private String taskEndTime;
|
||||
/**
|
||||
* 处置优先级 字典:高 中 低
|
||||
*/
|
||||
private String priority;
|
||||
/**
|
||||
* 来函附件,暂定文件路径
|
||||
*/
|
||||
private String file;
|
||||
/**
|
||||
* 入库时间
|
||||
*/
|
||||
private Date taskCreateTime;
|
||||
/**
|
||||
* 任务创建人名称
|
||||
*/
|
||||
private String taskCreateUsername;
|
||||
/**
|
||||
* 任务创建人处室
|
||||
*/
|
||||
private String taskCreateDepart;
|
||||
/**
|
||||
* 显示ID
|
||||
*/
|
||||
private String taskDisplayId;
|
||||
|
||||
|
||||
public Long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(Long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setEventType(String eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public String getIncidence() {
|
||||
return incidence;
|
||||
}
|
||||
|
||||
public void setIncidence(String incidence) {
|
||||
this.incidence = incidence;
|
||||
}
|
||||
|
||||
public String getEventLevel() {
|
||||
return eventLevel;
|
||||
}
|
||||
|
||||
public void setEventLevel(String eventLevel) {
|
||||
this.eventLevel = eventLevel;
|
||||
}
|
||||
|
||||
public String getDisposalMeasures() {
|
||||
return disposalMeasures;
|
||||
}
|
||||
|
||||
public void setDisposalMeasures(String disposalMeasures) {
|
||||
this.disposalMeasures = disposalMeasures;
|
||||
}
|
||||
|
||||
public String getTaskStartTime() {
|
||||
return taskStartTime;
|
||||
}
|
||||
|
||||
public void setTaskStartTime(String taskStartTime) {
|
||||
this.taskStartTime = taskStartTime;
|
||||
}
|
||||
|
||||
public String getTaskEndTime() {
|
||||
return taskEndTime;
|
||||
}
|
||||
|
||||
public void setTaskEndTime(String taskEndTime) {
|
||||
this.taskEndTime = taskEndTime;
|
||||
}
|
||||
|
||||
public String getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(String priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public Date getTaskCreateTime() {
|
||||
return taskCreateTime;
|
||||
}
|
||||
|
||||
public void setTaskCreateTime(Date taskCreateTime) {
|
||||
this.taskCreateTime = taskCreateTime;
|
||||
}
|
||||
|
||||
public String getTaskCreateUsername() {
|
||||
return taskCreateUsername;
|
||||
}
|
||||
|
||||
public void setTaskCreateUsername(String taskCreateUsername) {
|
||||
this.taskCreateUsername = taskCreateUsername;
|
||||
}
|
||||
|
||||
public String getTaskCreateDepart() {
|
||||
return taskCreateDepart;
|
||||
}
|
||||
|
||||
public void setTaskCreateDepart(String taskCreateDepart) {
|
||||
this.taskCreateDepart = taskCreateDepart;
|
||||
}
|
||||
|
||||
public String getTaskDisplayId() {
|
||||
return taskDisplayId;
|
||||
}
|
||||
|
||||
public void setTaskDisplayId(String taskDisplayId) {
|
||||
this.taskDisplayId = taskDisplayId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user