Browse Source

添加Fault相关。

tom 5 months ago
parent
commit
e51c674f7f

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

@@ -0,0 +1,100 @@
+package com.ruoyi.sim.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.ApiOperation;
+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.Fault;
+import com.ruoyi.sim.service.IFaultService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 故障Controller
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@RestController
+@RequestMapping("/sim/fault")
+public class FaultController extends BaseController {
+    @Autowired
+    private IFaultService faultService;
+
+    /**
+     * 查询故障列表
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:fault:list')")
+    @GetMapping("/list")
+    @ApiOperation("查询故障列表")
+    public TableDataInfo list(Fault fault) {
+        startPage();
+        List<Fault> list = faultService.selectFaultList(fault);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出故障列表
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:fault:export')")
+    @Log(title = "故障", businessType = BusinessType.EXPORT)
+    // @PostMapping("/export")
+    public void export(HttpServletResponse response, Fault fault) {
+        List<Fault> list = faultService.selectFaultList(fault);
+        ExcelUtil<Fault> util = new ExcelUtil<Fault>(Fault.class);
+        util.exportExcel(response, list, "故障数据");
+    }
+
+    /**
+     * 获取故障详细信息
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:fault:query')")
+    @GetMapping(value = "/{faultId}")
+    public AjaxResult getInfo(@PathVariable("faultId") String faultId) {
+        return success(faultService.selectFaultByFaultId(faultId));
+    }
+
+    /**
+     * 新增故障
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:fault:add')")
+    @Log(title = "故障", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Fault fault) {
+        return toAjax(faultService.insertFault(fault));
+    }
+
+    /**
+     * 修改故障
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:fault:edit')")
+    @Log(title = "故障", businessType = BusinessType.UPDATE)
+    // @PutMapping
+    public AjaxResult edit(@RequestBody Fault fault) {
+        return toAjax(faultService.updateFault(fault));
+    }
+
+    /**
+     * 删除故障
+     */
+    // @PreAuthorize("@ss.hasPermi('sim:fault:remove')")
+    @Log(title = "故障", businessType = BusinessType.DELETE)
+    // @DeleteMapping("/{faultIds}")
+    public AjaxResult remove(@PathVariable String[] faultIds) {
+        return toAjax(faultService.deleteFaultByFaultIds(faultIds));
+    }
+}

+ 148 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/Fault.java

@@ -0,0 +1,148 @@
+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_fault
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public class Fault extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 故障ID
+     */
+    private String faultId;
+
+    /**
+     * $column.columnComment
+     */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private String parentFaultId;
+
+    /** 模拟器类型
+     */
+    @Excel(name = "模拟器类型")
+    private String simType;
+
+    /** 故障类型:
+     1:故障现象
+     2:故障现象的可能原因
+     3:故障部位
+     4:故障部位的排除方法
+     5:修复结论 */
+    @Excel(name = "故障类型")
+    private String faultType;
+
+    /**
+     * 互斥的故障ID
+     */
+    @Excel(name = "互斥的故障ID")
+    private String conflictFaultId;
+
+    /**
+     * 名称
+     */
+    @Excel(name = "名称")
+    private String name;
+
+    /**
+     * 通信报文
+     */
+    @Excel(name = "通信报文")
+    private String simMsg;
+
+    /**
+     * 显示顺序
+     */
+    @Excel(name = "显示顺序")
+    private Integer orderNum;
+
+    public void setFaultId(String faultId) {
+        this.faultId = faultId;
+    }
+
+    public String getFaultId() {
+        return faultId;
+    }
+
+    public void setParentFaultId(String parentFaultId) {
+        this.parentFaultId = parentFaultId;
+    }
+
+    public String getParentFaultId() {
+        return parentFaultId;
+    }
+
+    public void setSimType(String simType) {
+        this.simType = simType;
+    }
+
+    public String getSimType() {
+        return simType;
+    }
+
+    public void setFaultType(String faultType) {
+        this.faultType = faultType;
+    }
+
+    public String getFaultType() {
+        return faultType;
+    }
+
+    public void setConflictFaultId(String conflictFaultId) {
+        this.conflictFaultId = conflictFaultId;
+    }
+
+    public String getConflictFaultId() {
+        return conflictFaultId;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setSimMsg(String simMsg) {
+        this.simMsg = simMsg;
+    }
+
+    public String getSimMsg() {
+        return simMsg;
+    }
+
+    public void setOrderNum(Integer orderNum) {
+        this.orderNum = orderNum;
+    }
+
+    public Integer getOrderNum() {
+        return orderNum;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("faultId", getFaultId())
+                .append("parentFaultId", getParentFaultId())
+                .append("simType", getSimType())
+                .append("faultType", getFaultType())
+                .append("conflictFaultId", getConflictFaultId())
+                .append("name", getName())
+                .append("simMsg", getSimMsg())
+                .append("orderNum", getOrderNum())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
+    }
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.mapper;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Fault;
+
+/**
+ * 故障Mapper接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface FaultMapper {
+    /**
+     * 查询故障
+     *
+     * @param faultId 故障主键
+     * @return 故障
+     */
+    public Fault selectFaultByFaultId(String faultId);
+
+    /**
+     * 查询故障列表
+     *
+     * @param fault 故障
+     * @return 故障集合
+     */
+    public List<Fault> selectFaultList(Fault fault);
+
+    /**
+     * 新增故障
+     *
+     * @param fault 故障
+     * @return 结果
+     */
+    public int insertFault(Fault fault);
+
+    /**
+     * 修改故障
+     *
+     * @param fault 故障
+     * @return 结果
+     */
+    public int updateFault(Fault fault);
+
+    /**
+     * 删除故障
+     *
+     * @param faultId 故障主键
+     * @return 结果
+     */
+    public int deleteFaultByFaultId(String faultId);
+
+    /**
+     * 批量删除故障
+     *
+     * @param faultIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteFaultByFaultIds(String[] faultIds);
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.service;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Fault;
+
+/**
+ * 故障Service接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface IFaultService {
+    /**
+     * 查询故障
+     *
+     * @param faultId 故障主键
+     * @return 故障
+     */
+    public Fault selectFaultByFaultId(String faultId);
+
+    /**
+     * 查询故障列表
+     *
+     * @param fault 故障
+     * @return 故障集合
+     */
+    public List<Fault> selectFaultList(Fault fault);
+
+    /**
+     * 新增故障
+     *
+     * @param fault 故障
+     * @return 结果
+     */
+    public int insertFault(Fault fault);
+
+    /**
+     * 修改故障
+     *
+     * @param fault 故障
+     * @return 结果
+     */
+    public int updateFault(Fault fault);
+
+    /**
+     * 批量删除故障
+     *
+     * @param faultIds 需要删除的故障主键集合
+     * @return 结果
+     */
+    public int deleteFaultByFaultIds(String[] faultIds);
+
+    /**
+     * 删除故障信息
+     *
+     * @param faultId 故障主键
+     * @return 结果
+     */
+    public int deleteFaultByFaultId(String faultId);
+}

+ 90 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/FaultServiceImpl.java

@@ -0,0 +1,90 @@
+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.FaultMapper;
+import com.ruoyi.sim.domain.Fault;
+import com.ruoyi.sim.service.IFaultService;
+
+/**
+ * 故障Service业务层处理
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@Service
+public class FaultServiceImpl implements IFaultService {
+    @Autowired
+    private FaultMapper faultMapper;
+
+    /**
+     * 查询故障
+     *
+     * @param faultId 故障主键
+     * @return 故障
+     */
+    @Override
+    public Fault selectFaultByFaultId(String faultId) {
+        return faultMapper.selectFaultByFaultId(faultId);
+    }
+
+    /**
+     * 查询故障列表
+     *
+     * @param fault 故障
+     * @return 故障
+     */
+    @Override
+    public List<Fault> selectFaultList(Fault fault) {
+        return faultMapper.selectFaultList(fault);
+    }
+
+    /**
+     * 新增故障
+     *
+     * @param fault 故障
+     * @return 结果
+     */
+    @Override
+    public int insertFault(Fault fault) {
+        fault.setCreateTime(DateUtils.getNowDate());
+        return faultMapper.insertFault(fault);
+    }
+
+    /**
+     * 修改故障
+     *
+     * @param fault 故障
+     * @return 结果
+     */
+    @Override
+    public int updateFault(Fault fault) {
+        fault.setUpdateTime(DateUtils.getNowDate());
+        return faultMapper.updateFault(fault);
+    }
+
+    /**
+     * 批量删除故障
+     *
+     * @param faultIds 需要删除的故障主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFaultByFaultIds(String[] faultIds) {
+        return faultMapper.deleteFaultByFaultIds(faultIds);
+    }
+
+    /**
+     * 删除故障信息
+     *
+     * @param faultId 故障主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFaultByFaultId(String faultId) {
+        return faultMapper.deleteFaultByFaultId(faultId);
+    }
+}

+ 124 - 0
ruoyi-sim/src/main/resources/mapper/sim/FaultMapper.xml

@@ -0,0 +1,124 @@
+<?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.FaultMapper">
+
+    <resultMap type="Fault" id="FaultResult">
+        <result property="faultId" column="fault_id"/>
+        <result property="parentFaultId" column="parent_fault_id"/>
+        <result property="simType" column="sim_type"/>
+        <result property="faultType" column="fault_type"/>
+        <result property="conflictFaultId" column="conflict_fault_id"/>
+        <result property="name" column="name"/>
+        <result property="simMsg" column="sim_msg"/>
+        <result property="orderNum" column="order_num"/>
+        <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="selectFaultVo">
+        select fault_id,
+               parent_fault_id,
+               sim_type,
+               fault_type,
+               conflict_fault_id,
+               name,
+               sim_msg,
+               order_num,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from sim_fault
+    </sql>
+
+    <select id="selectFaultList" parameterType="Fault" resultMap="FaultResult">
+        <include refid="selectFaultVo"/>
+        <where>
+            <if test="parentFaultId != null  and parentFaultId != ''">and parent_fault_id = #{parentFaultId}</if>
+            <if test="simType != null  and simType != ''">and sim_type = #{simType}</if>
+            <if test="faultType != null  and faultType != ''">and fault_type = #{faultType}</if>
+            <if test="conflictFaultId != null  and conflictFaultId != ''">and conflict_fault_id = #{conflictFaultId}
+            </if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="simMsg != null  and simMsg != ''">and sim_msg = #{simMsg}</if>
+            <if test="orderNum != null ">and order_num = #{orderNum}</if>
+        </where>
+    </select>
+
+    <select id="selectFaultByFaultId" parameterType="String" resultMap="FaultResult">
+        <include refid="selectFaultVo"/>
+        where fault_id = #{faultId}
+    </select>
+
+    <insert id="insertFault" parameterType="Fault">
+        insert into sim_fault
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="faultId != null">fault_id,</if>
+            <if test="parentFaultId != null and parentFaultId != ''">parent_fault_id,</if>
+            <if test="simType != null and simType != ''">sim_type,</if>
+            <if test="faultType != null">fault_type,</if>
+            <if test="conflictFaultId != null">conflict_fault_id,</if>
+            <if test="name != null">name,</if>
+            <if test="simMsg != null">sim_msg,</if>
+            <if test="orderNum != null">order_num,</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="faultId != null">#{faultId},</if>
+            <if test="parentFaultId != null and parentFaultId != ''">#{parentFaultId},</if>
+            <if test="simType != null and simType != ''">#{simType},</if>
+            <if test="faultType != null">#{faultType},</if>
+            <if test="conflictFaultId != null">#{conflictFaultId},</if>
+            <if test="name != null">#{name},</if>
+            <if test="simMsg != null">#{simMsg},</if>
+            <if test="orderNum != null">#{orderNum},</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="updateFault" parameterType="Fault">
+        update sim_fault
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="parentFaultId != null and parentFaultId != ''">parent_fault_id = #{parentFaultId},</if>
+            <if test="simType != null and simType != ''">sim_type = #{simType},</if>
+            <if test="faultType != null">fault_type = #{faultType},</if>
+            <if test="conflictFaultId != null">conflict_fault_id = #{conflictFaultId},</if>
+            <if test="name != null">name = #{name},</if>
+            <if test="simMsg != null">sim_msg = #{simMsg},</if>
+            <if test="orderNum != null">order_num = #{orderNum},</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 fault_id = #{faultId}
+    </update>
+
+    <delete id="deleteFaultByFaultId" parameterType="String">
+        delete
+        from sim_fault
+        where fault_id = #{faultId}
+    </delete>
+
+    <delete id="deleteFaultByFaultIds" parameterType="String">
+        delete from sim_fault where fault_id in
+        <foreach item="faultId" collection="array" open="(" separator="," close=")">
+            #{faultId}
+        </foreach>
+    </delete>
+</mapper>