Pārlūkot izejas kodu

Merge branch 'dev-api' into dev

tom 5 mēneši atpakaļ
vecāks
revīzija
ee99f13eb4

+ 2 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/FaultController.java

@@ -3,7 +3,7 @@ package com.ruoyi.sim.controller;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
-import com.ruoyi.sim.domain.vo.FaultNode;
+import com.ruoyi.sim.domain.vo.FaultTree;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -110,7 +110,7 @@ public class FaultController extends BaseController {
     public TableDataInfo listAllTreeViaSimType(@PathVariable(value = "simType") String simType) {
         Fault fault =new Fault();
         fault.setSimType(simType);
-        List<FaultNode> list = faultService.selectFaultListAllTree(fault);
+        List<FaultTree> list = faultService.selectFaultListAllTree(fault);
         return getDataTable(list);
     }
 }

+ 93 - 13
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/TaskController.java

@@ -1,32 +1,112 @@
 package com.ruoyi.sim.controller;
 
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.sim.domain.Major;
-import com.ruoyi.sim.service.IMajorService;
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.sim.domain.Task;
+import com.ruoyi.sim.service.ITaskService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
 
-import java.util.List;
-
-@Api("TaskController")
+/**
+ * 任务Controller
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
 @RestController
 @RequestMapping("/sim/task")
+@Api("任务Controller")
 public class TaskController extends BaseController {
-
     @Autowired
-    private IMajorService majorService;
+    private ITaskService taskService;
 
+    /**
+     * 查询任务列表
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:list')")
     @GetMapping("/list")
-    @PreAuthorize("@ss.hasPermi('sim:task:list')")
-    public TableDataInfo list(Major major) {
+    public TableDataInfo list(Task task) {
         startPage();
-        List<Major> list = majorService.selectMajorList(major);
+        List<Task> list = taskService.selectTaskList(task);
         return getDataTable(list);
     }
+
+    /**
+     * 导出任务列表
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:export')")
+    @Log(title = "任务", businessType = BusinessType.EXPORT)
+    // @PostMapping("/export")
+    public void export(HttpServletResponse response, Task task) {
+        List<Task> list = taskService.selectTaskList(task);
+        ExcelUtil<Task> util = new ExcelUtil<Task>(Task.class);
+        util.exportExcel(response, list, "任务数据");
+    }
+
+    /**
+     * 获取任务详细信息
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:query')")
+    @GetMapping(value = "/{taskId}")
+    public AjaxResult getInfo(@PathVariable("taskId") Long taskId) {
+        return success(taskService.selectTaskByTaskId(taskId));
+    }
+
+    /**
+     * 新增任务
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:add')")
+    @Log(title = "任务", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Task task) {
+        return toAjax(taskService.insertTask(task));
+    }
+
+    /**
+     * 修改任务
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:edit')")
+    @Log(title = "任务", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Task task) {
+        return toAjax(taskService.updateTask(task));
+    }
+
+    /**
+     * 删除任务
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:remove')")
+    @Log(title = "任务", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{taskIds}")
+    public AjaxResult remove(@PathVariable Long[] taskIds) {
+        return toAjax(taskService.deleteTaskByTaskIds(taskIds));
+    }
+
+    // -------------------------------- tom add  --------------------------------
+
+    /**
+     *
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:task:query')")
+    @GetMapping("/getInfoForAdd/{simType}")
+    @ApiOperation("获取空白的任务详细信息,为了新建任务")
+    public AjaxResult getInfoForAdd(@PathVariable("simType") String simType) {
+        return success(taskService.selectNewTaskViaSimType(simType));
+    }
 }

+ 98 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/TaskFaultController.java

@@ -0,0 +1,98 @@
+package com.ruoyi.sim.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.sim.domain.TaskFault;
+import com.ruoyi.sim.service.ITaskFaultService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 任务故障关联Controller
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@RestController
+@RequestMapping("/sim/task-fault")
+public class TaskFaultController extends BaseController {
+    @Autowired
+    private ITaskFaultService taskFaultService;
+
+    /**
+     * 查询任务故障关联列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:task-fault:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TaskFault taskFault) {
+        startPage();
+        List<TaskFault> list = taskFaultService.selectTaskFaultList(taskFault);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出任务故障关联列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:task-fault:export')")
+    @Log(title = "任务故障关联", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TaskFault taskFault) {
+        List<TaskFault> list = taskFaultService.selectTaskFaultList(taskFault);
+        ExcelUtil<TaskFault> util = new ExcelUtil<TaskFault>(TaskFault.class);
+        util.exportExcel(response, list, "任务故障关联数据");
+    }
+
+    /**
+     * 获取任务故障关联详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('sim:task-fault:query')")
+    @GetMapping(value = "/{relId}")
+    public AjaxResult getInfo(@PathVariable("relId") Long relId) {
+        return success(taskFaultService.selectTaskFaultByRelId(relId));
+    }
+
+    /**
+     * 新增任务故障关联
+     */
+    @PreAuthorize("@ss.hasPermi('sim:task-fault:add')")
+    @Log(title = "任务故障关联", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TaskFault taskFault) {
+        return toAjax(taskFaultService.insertTaskFault(taskFault));
+    }
+
+    /**
+     * 修改任务故障关联
+     */
+    @PreAuthorize("@ss.hasPermi('sim:task-fault:edit')")
+    @Log(title = "任务故障关联", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TaskFault taskFault) {
+        return toAjax(taskFaultService.updateTaskFault(taskFault));
+    }
+
+    /**
+     * 删除任务故障关联
+     */
+    @PreAuthorize("@ss.hasPermi('sim:task-fault:remove')")
+    @Log(title = "任务故障关联", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{relIds}")
+    public AjaxResult remove(@PathVariable Long[] relIds) {
+        return toAjax(taskFaultService.deleteTaskFaultByRelIds(relIds));
+    }
+}

+ 119 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/Task.java

@@ -0,0 +1,119 @@
+package com.ruoyi.sim.domain;
+
+import com.ruoyi.sim.domain.vo.FaultTree;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+import java.util.List;
+
+/**
+ * 任务对象 sim_task
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public class Task extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 任务ID
+     */
+    private Long taskId;
+
+    /**
+     * 模拟器型号
+     */
+    @Excel(name = "模拟器型号")
+    private String simType;
+
+    /**
+     * 任务类型
+     * 1:教师创建管理
+     * 2:考试临时数据
+     */
+    @Excel(name = "任务类型")
+    private String taskType;
+
+    /**
+     * 任务名称
+     */
+    @Excel(name = "任务名称")
+    private String name;
+
+    /**
+     * 创建教师ID/用户ID
+     */
+    @Excel(name = "创建教师ID/用户ID")
+    private Long createByUserId;
+
+    public void setTaskId(Long taskId) {
+        this.taskId = taskId;
+    }
+
+    public Long getTaskId() {
+        return taskId;
+    }
+
+    public void setSimType(String simType) {
+        this.simType = simType;
+    }
+
+    public String getSimType() {
+        return simType;
+    }
+
+    public void setTaskType(String taskType) {
+        this.taskType = taskType;
+    }
+
+    public String getTaskType() {
+        return taskType;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setCreateByUserId(Long createByUserId) {
+        this.createByUserId = createByUserId;
+    }
+
+    public Long getCreateByUserId() {
+        return createByUserId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("taskId", getTaskId())
+                .append("simType", getSimType())
+                .append("taskType", getTaskType())
+                .append("name", getName())
+                .append("createByUserId", getCreateByUserId())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
+    }
+
+    // -------------------------------- tom add  --------------------------------
+    public static final Long EMPTY_TASK_ID = 0L;
+
+    private List<FaultTree> faultTreeList;
+
+    public List<FaultTree> getFaultTreeList() {
+        return faultTreeList;
+    }
+
+    public void setFaultTreeList(List<FaultTree> faultTreeList) {
+        this.faultTreeList = faultTreeList;
+    }
+}

+ 99 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/TaskFault.java

@@ -0,0 +1,99 @@
+package com.ruoyi.sim.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 任务故障关联对象 sim_task_fault
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public class TaskFault extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * $column.columnComment
+     */
+    private Long relId;
+
+    /**
+     * $column.columnComment
+     */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private Long taskId;
+
+    /**
+     * $column.columnComment
+     */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private String faultId;
+
+    /**
+     * 7:未知
+     * 1:选中
+     * 0:没有选中
+     */
+    @Excel(name = "")
+    private String flag;
+
+    public void setRelId(Long relId) {
+        this.relId = relId;
+    }
+
+    public Long getRelId() {
+        return relId;
+    }
+
+    public void setTaskId(Long taskId) {
+        this.taskId = taskId;
+    }
+
+    public Long getTaskId() {
+        return taskId;
+    }
+
+    public void setFaultId(String faultId) {
+        this.faultId = faultId;
+    }
+
+    public String getFaultId() {
+        return faultId;
+    }
+
+    public void setFlag(String flag) {
+        this.flag = flag;
+    }
+
+    public String getFlag() {
+        return flag;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("relId", getRelId())
+                .append("taskId", getTaskId())
+                .append("faultId", getFaultId())
+                .append("flag", getFlag())
+                .append("updateTime", getUpdateTime())
+                .toString();
+    }
+
+    // -------------------------------- tom add  --------------------------------
+    public static final String UNKNOWN = "7";
+    public static final String YES = "1";
+    public static final String NO = "0";
+
+    public TaskFault() {
+    }
+
+    public TaskFault(Long relId, Long taskId, String faultId, String flag) {
+        this.relId = relId;
+        this.taskId = taskId;
+        this.faultId = faultId;
+        this.flag = flag;
+    }
+}

+ 0 - 26
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/vo/FaultNode.java

@@ -1,26 +0,0 @@
-package com.ruoyi.sim.domain.vo;
-
-import com.ruoyi.sim.domain.Fault;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-import java.util.List;
-
-public class FaultNode extends Fault {
-
-    private List<FaultNode> children;
-
-    public List<FaultNode> getChildren() {
-        return children;
-    }
-
-    public void setChildren(List<FaultNode> children) {
-        this.children = children;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this)
-                .append("children", children)
-                .toString();
-    }
-}

+ 41 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/vo/FaultTree.java

@@ -0,0 +1,41 @@
+package com.ruoyi.sim.domain.vo;
+
+import com.ruoyi.sim.domain.Fault;
+import com.ruoyi.sim.domain.TaskFault;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ *
+ */
+import java.util.List;
+
+public class FaultTree extends Fault {
+
+    private List<FaultTree> children;
+
+    private TaskFault taskFault;
+
+    public List<FaultTree> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<FaultTree> children) {
+        this.children = children;
+    }
+
+    public TaskFault getTaskFault() {
+        return taskFault;
+    }
+
+    public void setTaskFault(TaskFault taskFault) {
+        this.taskFault = taskFault;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .append("children", children)
+                .append("taskFault", taskFault)
+                .toString();
+    }
+}

+ 61 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/mapper/TaskFaultMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.mapper;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.TaskFault;
+
+/**
+ * 任务故障关联Mapper接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface TaskFaultMapper {
+    /**
+     * 查询任务故障关联
+     *
+     * @param relId 任务故障关联主键
+     * @return 任务故障关联
+     */
+    public TaskFault selectTaskFaultByRelId(Long relId);
+
+    /**
+     * 查询任务故障关联列表
+     *
+     * @param taskFault 任务故障关联
+     * @return 任务故障关联集合
+     */
+    public List<TaskFault> selectTaskFaultList(TaskFault taskFault);
+
+    /**
+     * 新增任务故障关联
+     *
+     * @param taskFault 任务故障关联
+     * @return 结果
+     */
+    public int insertTaskFault(TaskFault taskFault);
+
+    /**
+     * 修改任务故障关联
+     *
+     * @param taskFault 任务故障关联
+     * @return 结果
+     */
+    public int updateTaskFault(TaskFault taskFault);
+
+    /**
+     * 删除任务故障关联
+     *
+     * @param relId 任务故障关联主键
+     * @return 结果
+     */
+    public int deleteTaskFaultByRelId(Long relId);
+
+    /**
+     * 批量删除任务故障关联
+     *
+     * @param relIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTaskFaultByRelIds(Long[] relIds);
+}

+ 61 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/mapper/TaskMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.mapper;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Task;
+
+/**
+ * 任务Mapper接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface TaskMapper {
+    /**
+     * 查询任务
+     *
+     * @param taskId 任务主键
+     * @return 任务
+     */
+    public Task selectTaskByTaskId(Long taskId);
+
+    /**
+     * 查询任务列表
+     *
+     * @param task 任务
+     * @return 任务集合
+     */
+    public List<Task> selectTaskList(Task task);
+
+    /**
+     * 新增任务
+     *
+     * @param task 任务
+     * @return 结果
+     */
+    public int insertTask(Task task);
+
+    /**
+     * 修改任务
+     *
+     * @param task 任务
+     * @return 结果
+     */
+    public int updateTask(Task task);
+
+    /**
+     * 删除任务
+     *
+     * @param taskId 任务主键
+     * @return 结果
+     */
+    public int deleteTaskByTaskId(Long taskId);
+
+    /**
+     * 批量删除任务
+     *
+     * @param taskIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTaskByTaskIds(Long[] taskIds);
+}

+ 2 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/service/IFaultService.java

@@ -3,7 +3,7 @@ package com.ruoyi.sim.service;
 import java.util.List;
 
 import com.ruoyi.sim.domain.Fault;
-import com.ruoyi.sim.domain.vo.FaultNode;
+import com.ruoyi.sim.domain.vo.FaultTree;
 
 /**
  * 故障Service接口
@@ -68,5 +68,5 @@ public interface IFaultService {
      * @param fault 故障
      * @return 故障集合
      */
-    public List<FaultNode> selectFaultListAllTree(Fault fault);
+    public List<FaultTree> selectFaultListAllTree(Fault fault);
 }

+ 61 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/ITaskFaultService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.service;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.TaskFault;
+
+/**
+ * 任务故障关联Service接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface ITaskFaultService {
+    /**
+     * 查询任务故障关联
+     *
+     * @param relId 任务故障关联主键
+     * @return 任务故障关联
+     */
+    public TaskFault selectTaskFaultByRelId(Long relId);
+
+    /**
+     * 查询任务故障关联列表
+     *
+     * @param taskFault 任务故障关联
+     * @return 任务故障关联集合
+     */
+    public List<TaskFault> selectTaskFaultList(TaskFault taskFault);
+
+    /**
+     * 新增任务故障关联
+     *
+     * @param taskFault 任务故障关联
+     * @return 结果
+     */
+    public int insertTaskFault(TaskFault taskFault);
+
+    /**
+     * 修改任务故障关联
+     *
+     * @param taskFault 任务故障关联
+     * @return 结果
+     */
+    public int updateTaskFault(TaskFault taskFault);
+
+    /**
+     * 批量删除任务故障关联
+     *
+     * @param relIds 需要删除的任务故障关联主键集合
+     * @return 结果
+     */
+    public int deleteTaskFaultByRelIds(Long[] relIds);
+
+    /**
+     * 删除任务故障关联信息
+     *
+     * @param relId 任务故障关联主键
+     * @return 结果
+     */
+    public int deleteTaskFaultByRelId(Long relId);
+}

+ 70 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/ITaskService.java

@@ -0,0 +1,70 @@
+package com.ruoyi.sim.service;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Task;
+
+/**
+ * 任务Service接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface ITaskService {
+    /**
+     * 查询任务
+     *
+     * @param taskId 任务主键
+     * @return 任务
+     */
+    public Task selectTaskByTaskId(Long taskId);
+
+    /**
+     * 查询任务列表
+     *
+     * @param task 任务
+     * @return 任务集合
+     */
+    public List<Task> selectTaskList(Task task);
+
+    /**
+     * 新增任务
+     *
+     * @param task 任务
+     * @return 结果
+     */
+    public int insertTask(Task task);
+
+    /**
+     * 修改任务
+     *
+     * @param task 任务
+     * @return 结果
+     */
+    public int updateTask(Task task);
+
+    /**
+     * 批量删除任务
+     *
+     * @param taskIds 需要删除的任务主键集合
+     * @return 结果
+     */
+    public int deleteTaskByTaskIds(Long[] taskIds);
+
+    /**
+     * 删除任务信息
+     *
+     * @param taskId 任务主键
+     * @return 结果
+     */
+    public int deleteTaskByTaskId(Long taskId);
+
+    // -------------------------------- tom add  --------------------------------
+
+    /**
+     *
+     * @param simType
+     * @return
+     */
+    public Task selectNewTaskViaSimType(String simType);
+}

+ 11 - 8
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/FaultServiceImpl.java

@@ -4,7 +4,8 @@ import java.util.*;
 import java.util.stream.Collectors;
 
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.sim.domain.vo.FaultNode;
+import com.ruoyi.sim.domain.TaskFault;
+import com.ruoyi.sim.domain.vo.FaultTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -104,7 +105,7 @@ public class FaultServiceImpl implements IFaultService {
      * @return 故障
      */
     @Override
-    public List<FaultNode> selectFaultListAllTree(Fault fault) {
+    public List<FaultTree> selectFaultListAllTree(Fault fault) {
         //
         // fault.getParams().put(TableSupport.PAGE_NUM, 1);
         // fault.getParams().put(TableSupport.PAGE_SIZE, 100);
@@ -115,20 +116,19 @@ public class FaultServiceImpl implements IFaultService {
         log.info(Objects.requireNonNull(fault.getParams()).toString());
         log.info(Objects.requireNonNull(list.size()).toString());
 
-        List<FaultNode> tempListNode = new ArrayList<>();
+        List<FaultTree> tempListNode = new ArrayList<>();
         for (Fault source : list) {
-            FaultNode target = new FaultNode();
+            FaultTree target = new FaultTree();
             BeanUtils.copyProperties(source, target);
             tempListNode.add(target);
         }
         log.info(Objects.requireNonNull(tempListNode).toString());
-        List<FaultNode> tree = toTree(tempListNode, ROOT_FAULT_ID);
+        List<FaultTree> tree = toTree(tempListNode, ROOT_FAULT_ID);
         log.info(Objects.requireNonNull(tree).toString());
         return tree;
     }
 
     /**
-     *
      * @param simType
      * @return
      */
@@ -160,14 +160,17 @@ public class FaultServiceImpl implements IFaultService {
 //        return tree;
 //    }
 
-    private static List<FaultNode> toTree(List<FaultNode> list, String parentFaultId) {
+    private static List<FaultTree> toTree(List<FaultTree> list, String parentFaultId) {
         // todo:sort
-        List<FaultNode> tree = list
+        List<FaultTree> tree = list
                 .stream()
                 .filter(
                         parent ->
                                 parent.getParentFaultId().equals(parentFaultId))
                 .map(child -> {
+                    if (child.getTaskFault() == null) {
+                        child.setTaskFault(new TaskFault(0L, 0L, child.getFaultId(), TaskFault.UNKNOWN));
+                    }
                     child.setChildren(toTree(list, child.getFaultId()));
                     return child;
                 })

+ 89 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/TaskFaultServiceImpl.java

@@ -0,0 +1,89 @@
+package com.ruoyi.sim.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.sim.mapper.TaskFaultMapper;
+import com.ruoyi.sim.domain.TaskFault;
+import com.ruoyi.sim.service.ITaskFaultService;
+
+/**
+ * 任务故障关联Service业务层处理
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@Service
+public class TaskFaultServiceImpl implements ITaskFaultService {
+    @Autowired
+    private TaskFaultMapper taskFaultMapper;
+
+    /**
+     * 查询任务故障关联
+     *
+     * @param relId 任务故障关联主键
+     * @return 任务故障关联
+     */
+    @Override
+    public TaskFault selectTaskFaultByRelId(Long relId) {
+        return taskFaultMapper.selectTaskFaultByRelId(relId);
+    }
+
+    /**
+     * 查询任务故障关联列表
+     *
+     * @param taskFault 任务故障关联
+     * @return 任务故障关联
+     */
+    @Override
+    public List<TaskFault> selectTaskFaultList(TaskFault taskFault) {
+        return taskFaultMapper.selectTaskFaultList(taskFault);
+    }
+
+    /**
+     * 新增任务故障关联
+     *
+     * @param taskFault 任务故障关联
+     * @return 结果
+     */
+    @Override
+    public int insertTaskFault(TaskFault taskFault) {
+        return taskFaultMapper.insertTaskFault(taskFault);
+    }
+
+    /**
+     * 修改任务故障关联
+     *
+     * @param taskFault 任务故障关联
+     * @return 结果
+     */
+    @Override
+    public int updateTaskFault(TaskFault taskFault) {
+        taskFault.setUpdateTime(DateUtils.getNowDate());
+        return taskFaultMapper.updateTaskFault(taskFault);
+    }
+
+    /**
+     * 批量删除任务故障关联
+     *
+     * @param relIds 需要删除的任务故障关联主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTaskFaultByRelIds(Long[] relIds) {
+        return taskFaultMapper.deleteTaskFaultByRelIds(relIds);
+    }
+
+    /**
+     * 删除任务故障关联信息
+     *
+     * @param relId 任务故障关联主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTaskFaultByRelId(Long relId) {
+        return taskFaultMapper.deleteTaskFaultByRelId(relId);
+    }
+}

+ 117 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/TaskServiceImpl.java

@@ -0,0 +1,117 @@
+package com.ruoyi.sim.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.sim.domain.Fault;
+import com.ruoyi.sim.domain.vo.FaultTree;
+import com.ruoyi.sim.service.IFaultService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.sim.mapper.TaskMapper;
+import com.ruoyi.sim.domain.Task;
+import com.ruoyi.sim.service.ITaskService;
+
+/**
+ * 任务Service业务层处理
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@Service
+public class TaskServiceImpl implements ITaskService {
+    @Autowired
+    private TaskMapper taskMapper;
+
+    /**
+     * 查询任务
+     *
+     * @param taskId 任务主键
+     * @return 任务
+     */
+    @Override
+    public Task selectTaskByTaskId(Long taskId) {
+        return taskMapper.selectTaskByTaskId(taskId);
+    }
+
+    /**
+     * 查询任务列表
+     *
+     * @param task 任务
+     * @return 任务
+     */
+    @Override
+    public List<Task> selectTaskList(Task task) {
+        return taskMapper.selectTaskList(task);
+    }
+
+    /**
+     * 新增任务
+     *
+     * @param task 任务
+     * @return 结果
+     */
+    @Override
+    public int insertTask(Task task) {
+        task.setCreateTime(DateUtils.getNowDate());
+        return taskMapper.insertTask(task);
+    }
+
+    /**
+     * 修改任务
+     *
+     * @param task 任务
+     * @return 结果
+     */
+    @Override
+    public int updateTask(Task task) {
+        task.setUpdateTime(DateUtils.getNowDate());
+        return taskMapper.updateTask(task);
+    }
+
+    /**
+     * 批量删除任务
+     *
+     * @param taskIds 需要删除的任务主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTaskByTaskIds(Long[] taskIds) {
+        return taskMapper.deleteTaskByTaskIds(taskIds);
+    }
+
+    /**
+     * 删除任务信息
+     *
+     * @param taskId 任务主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTaskByTaskId(Long taskId) {
+        return taskMapper.deleteTaskByTaskId(taskId);
+    }
+
+    // -------------------------------- tom add  --------------------------------
+    @Autowired
+    private IFaultService faultService;
+
+    /**
+     * 为了新建,返回一个带tree结构的数据对象。
+     *
+     * @return 任务
+     */
+    public Task selectNewTaskViaSimType(String simType) {
+        // check
+
+        //
+        Task t = new Task();
+        // fa 构建用于查询的对象。
+        Fault fa = new Fault();
+        fa.setSimType(simType);
+        //
+        List<FaultTree> ftList = faultService.selectFaultListAllTree(fa);
+        t.setTaskId(Task.EMPTY_TASK_ID);
+        t.setFaultTreeList(ftList);
+        return t;
+    }
+}

+ 73 - 0
ruoyi-sim/src/main/resources/mapper/sim/TaskFaultMapper.xml

@@ -0,0 +1,73 @@
+<?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.ruoyi.sim.mapper.TaskFaultMapper">
+
+    <resultMap type="TaskFault" id="TaskFaultResult">
+        <result property="relId" column="rel_id"/>
+        <result property="taskId" column="task_id"/>
+        <result property="faultId" column="fault_id"/>
+        <result property="flag" column="flag"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectTaskFaultVo">
+        select rel_id, task_id, fault_id, flag, update_time
+        from sim_task_fault
+    </sql>
+
+    <select id="selectTaskFaultList" parameterType="TaskFault" resultMap="TaskFaultResult">
+        <include refid="selectTaskFaultVo"/>
+        <where>
+            <if test="taskId != null ">and task_id = #{taskId}</if>
+            <if test="faultId != null  and faultId != ''">and fault_id = #{faultId}</if>
+            <if test="flag != null  and flag != ''">and flag = #{flag}</if>
+        </where>
+    </select>
+
+    <select id="selectTaskFaultByRelId" parameterType="Long" resultMap="TaskFaultResult">
+        <include refid="selectTaskFaultVo"/>
+        where rel_id = #{relId}
+    </select>
+
+    <insert id="insertTaskFault" parameterType="TaskFault" useGeneratedKeys="true" keyProperty="relId">
+        insert into sim_task_fault
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="taskId != null">task_id,</if>
+            <if test="faultId != null and faultId != ''">fault_id,</if>
+            <if test="flag != null and flag != ''">flag,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="taskId != null">#{taskId},</if>
+            <if test="faultId != null and faultId != ''">#{faultId},</if>
+            <if test="flag != null and flag != ''">#{flag},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTaskFault" parameterType="TaskFault">
+        update sim_task_fault
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="taskId != null">task_id = #{taskId},</if>
+            <if test="faultId != null and faultId != ''">fault_id = #{faultId},</if>
+            <if test="flag != null and flag != ''">flag = #{flag},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where rel_id = #{relId}
+    </update>
+
+    <delete id="deleteTaskFaultByRelId" parameterType="Long">
+        delete
+        from sim_task_fault
+        where rel_id = #{relId}
+    </delete>
+
+    <delete id="deleteTaskFaultByRelIds" parameterType="String">
+        delete from sim_task_fault where rel_id in
+        <foreach item="relId" collection="array" open="(" separator="," close=")">
+            #{relId}
+        </foreach>
+    </delete>
+</mapper>

+ 105 - 0
ruoyi-sim/src/main/resources/mapper/sim/TaskMapper.xml

@@ -0,0 +1,105 @@
+<?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.ruoyi.sim.mapper.TaskMapper">
+
+    <resultMap type="Task" id="TaskResult">
+        <result property="taskId" column="task_id"/>
+        <result property="simType" column="sim_type"/>
+        <result property="taskType" column="task_type"/>
+        <result property="name" column="name"/>
+        <result property="createByUserId" column="create_by_user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <sql id="selectTaskVo">
+        select task_id,
+               sim_type,
+               task_type,
+               name,
+               create_by_user_id,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from sim_task
+    </sql>
+
+    <select id="selectTaskList" parameterType="Task" resultMap="TaskResult">
+        <include refid="selectTaskVo"/>
+        <where>
+            <if test="simType != null  and simType != ''">and sim_type = #{simType}</if>
+            <if test="taskType != null  and taskType != ''">and task_type = #{taskType}</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="createByUserId != null ">and create_by_user_id = #{createByUserId}</if>
+        </where>
+    </select>
+
+    <select id="selectTaskByTaskId" parameterType="Long" resultMap="TaskResult">
+        <include refid="selectTaskVo"/>
+        where task_id = #{taskId}
+    </select>
+
+    <insert id="insertTask" parameterType="Task">
+        insert into sim_task
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="taskId != null">task_id,</if>
+            <if test="simType != null">sim_type,</if>
+            <if test="taskType != null">task_type,</if>
+            <if test="name != null">name,</if>
+            <if test="createByUserId != null">create_by_user_id,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="taskId != null">#{taskId},</if>
+            <if test="simType != null">#{simType},</if>
+            <if test="taskType != null">#{taskType},</if>
+            <if test="name != null">#{name},</if>
+            <if test="createByUserId != null">#{createByUserId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTask" parameterType="Task">
+        update sim_task
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="simType != null">sim_type = #{simType},</if>
+            <if test="taskType != null">task_type = #{taskType},</if>
+            <if test="name != null">name = #{name},</if>
+            <if test="createByUserId != null">create_by_user_id = #{createByUserId},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where task_id = #{taskId}
+    </update>
+
+    <delete id="deleteTaskByTaskId" parameterType="Long">
+        delete
+        from sim_task
+        where task_id = #{taskId}
+    </delete>
+
+    <delete id="deleteTaskByTaskIds" parameterType="String">
+        delete from sim_task where task_id in
+        <foreach item="taskId" collection="array" open="(" separator="," close=")">
+            #{taskId}
+        </foreach>
+    </delete>
+</mapper>