tom 5 месяцев назад
Родитель
Сommit
16fedfbf10

+ 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));
+    }
+}

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

@@ -0,0 +1,84 @@
+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();
+    }
+}

+ 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/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);
+}

+ 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);
+    }
+}

+ 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>