Ver código fonte

新增运行日志

zmj 5 dias atrás
pai
commit
24478ecfb1

+ 104 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/RobotOpsSysLogController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.web.controller.base;
+
+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.base.domain.RobotOpsSysLog;
+import com.ruoyi.base.service.IRobotOpsSysLogService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 运行日志Controller
+ *
+ * @author ruoyi
+ * @date 2026-05-18
+ */
+@RestController
+@RequestMapping("/base/sysLog")
+public class RobotOpsSysLogController extends BaseController
+{
+    @Autowired
+    private IRobotOpsSysLogService robotOpsSysLogService;
+
+    /**
+     * 查询运行日志列表
+     */
+    @PreAuthorize("@ss.hasPermi('base:sysLog:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(RobotOpsSysLog robotOpsSysLog)
+    {
+        startPage();
+        List<RobotOpsSysLog> list = robotOpsSysLogService.selectRobotOpsSysLogList(robotOpsSysLog);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出运行日志列表
+     */
+    @PreAuthorize("@ss.hasPermi('base:sysLog:export')")
+    @Log(title = "运行日志", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, RobotOpsSysLog robotOpsSysLog)
+    {
+        List<RobotOpsSysLog> list = robotOpsSysLogService.selectRobotOpsSysLogList(robotOpsSysLog);
+        ExcelUtil<RobotOpsSysLog> util = new ExcelUtil<RobotOpsSysLog>(RobotOpsSysLog.class);
+        util.exportExcel(response, list, "运行日志数据");
+    }
+
+    /**
+     * 获取运行日志详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('base:sysLog:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(robotOpsSysLogService.selectRobotOpsSysLogById(id));
+    }
+
+    /**
+     * 新增运行日志
+     */
+    @PreAuthorize("@ss.hasPermi('base:sysLog:add')")
+    @Log(title = "运行日志", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody RobotOpsSysLog robotOpsSysLog)
+    {
+        return toAjax(robotOpsSysLogService.insertRobotOpsSysLog(robotOpsSysLog));
+    }
+
+    /**
+     * 修改运行日志
+     */
+    @PreAuthorize("@ss.hasPermi('base:sysLog:edit')")
+    @Log(title = "运行日志", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody RobotOpsSysLog robotOpsSysLog)
+    {
+        return toAjax(robotOpsSysLogService.updateRobotOpsSysLog(robotOpsSysLog));
+    }
+
+    /**
+     * 删除运行日志
+     */
+    @PreAuthorize("@ss.hasPermi('base:sysLog:remove')")
+    @Log(title = "运行日志", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(robotOpsSysLogService.deleteRobotOpsSysLogByIds(ids));
+    }
+}

+ 193 - 0
ruoyi-system/src/main/java/com/ruoyi/base/domain/RobotOpsSysLog.java

@@ -0,0 +1,193 @@
+package com.ruoyi.base.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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;
+
+/**
+ * 运行日志对象 robot_ops_sys_log
+ * 
+ * @author ruoyi
+ * @date 2026-05-18
+ */
+public class RobotOpsSysLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    private Long id;
+
+    /** 机器人编号 */
+    @Excel(name = "机器人编号")
+    private String robotCode;
+
+    /** 日志时间,设备侧或服务侧日志发生时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "日志时间,设备侧或服务侧日志发生时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date logTime;
+
+    /** 日志接收时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "日志接收时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date receiveTime;
+
+    /** 日志类型 */
+    @Excel(name = "日志类型")
+    private String logType;
+
+    /** 日志级别 */
+    @Excel(name = "日志级别")
+    private String logLevel;
+
+    /** 模块名称,如 screen、audio、camera、network、ota */
+    @Excel(name = "模块名称,如 screen、audio、camera、network、ota")
+    private String moduleName;
+
+    /** 日志摘要 */
+    @Excel(name = "日志摘要")
+    private String contentSummary;
+
+    /** 日志内容 */
+    @Excel(name = "日志内容")
+    private String content;
+
+    /** 结果状态 */
+    @Excel(name = "结果状态")
+    private String resultStatus;
+
+    /** 链路追踪ID */
+    @Excel(name = "链路追踪ID")
+    private String traceId;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+
+    public void setRobotCode(String robotCode) 
+    {
+        this.robotCode = robotCode;
+    }
+
+    public String getRobotCode() 
+    {
+        return robotCode;
+    }
+
+    public void setLogTime(Date logTime) 
+    {
+        this.logTime = logTime;
+    }
+
+    public Date getLogTime() 
+    {
+        return logTime;
+    }
+
+    public void setReceiveTime(Date receiveTime) 
+    {
+        this.receiveTime = receiveTime;
+    }
+
+    public Date getReceiveTime() 
+    {
+        return receiveTime;
+    }
+
+    public void setLogType(String logType) 
+    {
+        this.logType = logType;
+    }
+
+    public String getLogType() 
+    {
+        return logType;
+    }
+
+    public void setLogLevel(String logLevel) 
+    {
+        this.logLevel = logLevel;
+    }
+
+    public String getLogLevel() 
+    {
+        return logLevel;
+    }
+
+    public void setModuleName(String moduleName) 
+    {
+        this.moduleName = moduleName;
+    }
+
+    public String getModuleName() 
+    {
+        return moduleName;
+    }
+
+    public void setContentSummary(String contentSummary) 
+    {
+        this.contentSummary = contentSummary;
+    }
+
+    public String getContentSummary() 
+    {
+        return contentSummary;
+    }
+
+    public void setContent(String content) 
+    {
+        this.content = content;
+    }
+
+    public String getContent() 
+    {
+        return content;
+    }
+
+    public void setResultStatus(String resultStatus) 
+    {
+        this.resultStatus = resultStatus;
+    }
+
+    public String getResultStatus() 
+    {
+        return resultStatus;
+    }
+
+    public void setTraceId(String traceId) 
+    {
+        this.traceId = traceId;
+    }
+
+    public String getTraceId() 
+    {
+        return traceId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("robotCode", getRobotCode())
+            .append("logTime", getLogTime())
+            .append("receiveTime", getReceiveTime())
+            .append("logType", getLogType())
+            .append("logLevel", getLogLevel())
+            .append("moduleName", getModuleName())
+            .append("contentSummary", getContentSummary())
+            .append("content", getContent())
+            .append("resultStatus", getResultStatus())
+            .append("traceId", getTraceId())
+            .append("remark", getRemark())
+            .append("createTime", getCreateTime())
+            .toString();
+    }
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/base/mapper/RobotOpsSysLogMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.base.mapper;
+
+import java.util.List;
+import com.ruoyi.base.domain.RobotOpsSysLog;
+
+/**
+ * 运行日志Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2026-05-18
+ */
+public interface RobotOpsSysLogMapper 
+{
+    /**
+     * 查询运行日志
+     * 
+     * @param id 运行日志主键
+     * @return 运行日志
+     */
+    public RobotOpsSysLog selectRobotOpsSysLogById(Long id);
+
+    /**
+     * 查询运行日志列表
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 运行日志集合
+     */
+    public List<RobotOpsSysLog> selectRobotOpsSysLogList(RobotOpsSysLog robotOpsSysLog);
+
+    /**
+     * 新增运行日志
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 结果
+     */
+    public int insertRobotOpsSysLog(RobotOpsSysLog robotOpsSysLog);
+
+    /**
+     * 修改运行日志
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 结果
+     */
+    public int updateRobotOpsSysLog(RobotOpsSysLog robotOpsSysLog);
+
+    /**
+     * 删除运行日志
+     * 
+     * @param id 运行日志主键
+     * @return 结果
+     */
+    public int deleteRobotOpsSysLogById(Long id);
+
+    /**
+     * 批量删除运行日志
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteRobotOpsSysLogByIds(Long[] ids);
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/base/service/IRobotOpsSysLogService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.base.service;
+
+import java.util.List;
+import com.ruoyi.base.domain.RobotOpsSysLog;
+
+/**
+ * 运行日志Service接口
+ * 
+ * @author ruoyi
+ * @date 2026-05-18
+ */
+public interface IRobotOpsSysLogService 
+{
+    /**
+     * 查询运行日志
+     * 
+     * @param id 运行日志主键
+     * @return 运行日志
+     */
+    public RobotOpsSysLog selectRobotOpsSysLogById(Long id);
+
+    /**
+     * 查询运行日志列表
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 运行日志集合
+     */
+    public List<RobotOpsSysLog> selectRobotOpsSysLogList(RobotOpsSysLog robotOpsSysLog);
+
+    /**
+     * 新增运行日志
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 结果
+     */
+    public int insertRobotOpsSysLog(RobotOpsSysLog robotOpsSysLog);
+
+    /**
+     * 修改运行日志
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 结果
+     */
+    public int updateRobotOpsSysLog(RobotOpsSysLog robotOpsSysLog);
+
+    /**
+     * 批量删除运行日志
+     * 
+     * @param ids 需要删除的运行日志主键集合
+     * @return 结果
+     */
+    public int deleteRobotOpsSysLogByIds(Long[] ids);
+
+    /**
+     * 删除运行日志信息
+     * 
+     * @param id 运行日志主键
+     * @return 结果
+     */
+    public int deleteRobotOpsSysLogById(Long id);
+}

+ 95 - 0
ruoyi-system/src/main/java/com/ruoyi/base/service/impl/RobotOpsSysLogServiceImpl.java

@@ -0,0 +1,95 @@
+package com.ruoyi.base.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.base.mapper.RobotOpsSysLogMapper;
+import com.ruoyi.base.domain.RobotOpsSysLog;
+import com.ruoyi.base.service.IRobotOpsSysLogService;
+
+/**
+ * 运行日志Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2026-05-18
+ */
+@Service
+public class RobotOpsSysLogServiceImpl implements IRobotOpsSysLogService 
+{
+    @Autowired
+    private RobotOpsSysLogMapper robotOpsSysLogMapper;
+
+    /**
+     * 查询运行日志
+     * 
+     * @param id 运行日志主键
+     * @return 运行日志
+     */
+    @Override
+    public RobotOpsSysLog selectRobotOpsSysLogById(Long id)
+    {
+        return robotOpsSysLogMapper.selectRobotOpsSysLogById(id);
+    }
+
+    /**
+     * 查询运行日志列表
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 运行日志
+     */
+    @Override
+    public List<RobotOpsSysLog> selectRobotOpsSysLogList(RobotOpsSysLog robotOpsSysLog)
+    {
+        return robotOpsSysLogMapper.selectRobotOpsSysLogList(robotOpsSysLog);
+    }
+
+    /**
+     * 新增运行日志
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 结果
+     */
+    @Override
+    public int insertRobotOpsSysLog(RobotOpsSysLog robotOpsSysLog)
+    {
+        robotOpsSysLog.setCreateTime(DateUtils.getNowDate());
+        return robotOpsSysLogMapper.insertRobotOpsSysLog(robotOpsSysLog);
+    }
+
+    /**
+     * 修改运行日志
+     * 
+     * @param robotOpsSysLog 运行日志
+     * @return 结果
+     */
+    @Override
+    public int updateRobotOpsSysLog(RobotOpsSysLog robotOpsSysLog)
+    {
+        return robotOpsSysLogMapper.updateRobotOpsSysLog(robotOpsSysLog);
+    }
+
+    /**
+     * 批量删除运行日志
+     * 
+     * @param ids 需要删除的运行日志主键
+     * @return 结果
+     */
+    @Override
+    public int deleteRobotOpsSysLogByIds(Long[] ids)
+    {
+        return robotOpsSysLogMapper.deleteRobotOpsSysLogByIds(ids);
+    }
+
+    /**
+     * 删除运行日志信息
+     * 
+     * @param id 运行日志主键
+     * @return 结果
+     */
+    @Override
+    public int deleteRobotOpsSysLogById(Long id)
+    {
+        return robotOpsSysLogMapper.deleteRobotOpsSysLogById(id);
+    }
+}

+ 109 - 0
ruoyi-system/src/main/resources/mapper/base/RobotOpsSysLogMapper.xml

@@ -0,0 +1,109 @@
+<?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.base.mapper.RobotOpsSysLogMapper">
+    
+    <resultMap type="RobotOpsSysLog" id="RobotOpsSysLogResult">
+        <result property="id"    column="id"    />
+        <result property="robotCode"    column="robot_code"    />
+        <result property="logTime"    column="log_time"    />
+        <result property="receiveTime"    column="receive_time"    />
+        <result property="logType"    column="log_type"    />
+        <result property="logLevel"    column="log_level"    />
+        <result property="moduleName"    column="module_name"    />
+        <result property="contentSummary"    column="content_summary"    />
+        <result property="content"    column="content"    />
+        <result property="resultStatus"    column="result_status"    />
+        <result property="traceId"    column="trace_id"    />
+        <result property="remark"    column="remark"    />
+        <result property="createTime"    column="create_time"    />
+    </resultMap>
+
+    <sql id="selectRobotOpsSysLogVo">
+        select id, robot_code, log_time, receive_time, log_type, log_level, module_name, content_summary, content, result_status, trace_id, remark, create_time from robot_ops_sys_log
+    </sql>
+
+    <select id="selectRobotOpsSysLogList" parameterType="RobotOpsSysLog" resultMap="RobotOpsSysLogResult">
+        <include refid="selectRobotOpsSysLogVo"/>
+        <where>  
+            <if test="robotCode != null  and robotCode != ''"> and robot_code = #{robotCode}</if>
+            <if test="logTime != null "> and log_time = #{logTime}</if>
+            <if test="receiveTime != null "> and receive_time = #{receiveTime}</if>
+            <if test="logType != null  and logType != ''"> and log_type = #{logType}</if>
+            <if test="logLevel != null  and logLevel != ''"> and log_level = #{logLevel}</if>
+            <if test="moduleName != null  and moduleName != ''"> and module_name like concat('%', #{moduleName}, '%')</if>
+            <if test="contentSummary != null  and contentSummary != ''"> and content_summary = #{contentSummary}</if>
+            <if test="content != null  and content != ''"> and content = #{content}</if>
+            <if test="resultStatus != null  and resultStatus != ''"> and result_status = #{resultStatus}</if>
+            <if test="traceId != null  and traceId != ''"> and trace_id = #{traceId}</if>
+        </where>
+    </select>
+    
+    <select id="selectRobotOpsSysLogById" parameterType="Long" resultMap="RobotOpsSysLogResult">
+        <include refid="selectRobotOpsSysLogVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertRobotOpsSysLog" parameterType="RobotOpsSysLog" useGeneratedKeys="true" keyProperty="id">
+        insert into robot_ops_sys_log
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="robotCode != null">robot_code,</if>
+            <if test="logTime != null">log_time,</if>
+            <if test="receiveTime != null">receive_time,</if>
+            <if test="logType != null">log_type,</if>
+            <if test="logLevel != null">log_level,</if>
+            <if test="moduleName != null">module_name,</if>
+            <if test="contentSummary != null">content_summary,</if>
+            <if test="content != null">content,</if>
+            <if test="resultStatus != null">result_status,</if>
+            <if test="traceId != null">trace_id,</if>
+            <if test="remark != null">remark,</if>
+            <if test="createTime != null">create_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="robotCode != null">#{robotCode},</if>
+            <if test="logTime != null">#{logTime},</if>
+            <if test="receiveTime != null">#{receiveTime},</if>
+            <if test="logType != null">#{logType},</if>
+            <if test="logLevel != null">#{logLevel},</if>
+            <if test="moduleName != null">#{moduleName},</if>
+            <if test="contentSummary != null">#{contentSummary},</if>
+            <if test="content != null">#{content},</if>
+            <if test="resultStatus != null">#{resultStatus},</if>
+            <if test="traceId != null">#{traceId},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="createTime != null">#{createTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateRobotOpsSysLog" parameterType="RobotOpsSysLog">
+        update robot_ops_sys_log
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="robotCode != null">robot_code = #{robotCode},</if>
+            <if test="logTime != null">log_time = #{logTime},</if>
+            <if test="receiveTime != null">receive_time = #{receiveTime},</if>
+            <if test="logType != null">log_type = #{logType},</if>
+            <if test="logLevel != null">log_level = #{logLevel},</if>
+            <if test="moduleName != null">module_name = #{moduleName},</if>
+            <if test="contentSummary != null">content_summary = #{contentSummary},</if>
+            <if test="content != null">content = #{content},</if>
+            <if test="resultStatus != null">result_status = #{resultStatus},</if>
+            <if test="traceId != null">trace_id = #{traceId},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteRobotOpsSysLogById" parameterType="Long">
+        delete from robot_ops_sys_log where id = #{id}
+    </delete>
+
+    <delete id="deleteRobotOpsSysLogByIds" parameterType="String">
+        delete from robot_ops_sys_log where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>