Browse Source

操作日志添加耗时未加ms字段

ZJY 6 months ago
parent
commit
a6ba2b9aca

+ 7 - 0
base-modules/service-system/service-system-api/src/main/java/com/usky/system/domain/SysOperLogVO.java

@@ -69,6 +69,9 @@ public class SysOperLogVO extends BaseEntity
     /** 执行结束时间 */
     private Date endTime;
 
+    /** 执行耗时时间 */
+    private Long consumingTime;
+
     /** 执行耗时时间(带单位) */
     private String consumingTimeWithUnit;
 
@@ -240,6 +243,10 @@ public class SysOperLogVO extends BaseEntity
 
     public void setEndTime(Date endTime) {this.endTime = endTime;}
 
+    public Long getConsumingTime() {return consumingTime;}
+
+    public void setConsumingTime(Long consumingTime) {this.consumingTime = consumingTime;}
+
     public String getConsumingTimeWithUnit() {return consumingTimeWithUnit;}
 
     public void setConsumingTimeWithUnit(String consumingTimeWithUnit) {this.consumingTimeWithUnit = consumingTimeWithUnit;}

+ 8 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/domain/SysOperLog.java

@@ -92,7 +92,10 @@ public class SysOperLog extends BaseEntity
     /** 执行结束时间 */
     private Date endTime;
 
-    /** 执行耗时时间(带单位) */
+    /** 执行耗时时间 */
+    private Long consumingTime;
+
+    /** 执行耗时时间(单位:毫秒) */
     private String consumingTimeWithUnit;
 
     public String getSearchValue() {
@@ -332,6 +335,10 @@ public class SysOperLog extends BaseEntity
 
     public void setEndTime(Date endTime) { this.endTime = endTime; }
 
+    public Long getConsumingTime() { return consumingTime; }
+
+    public void setConsumingTime(Long consumingTime) { this.consumingTime = consumingTime; }
+
     public String getConsumingTimeWithUnit() { return consumingTimeWithUnit; }
 
     public void setConsumingTimeWithUnit(String consumingTimeWithUnit) { this.consumingTimeWithUnit = consumingTimeWithUnit; }

+ 6 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/vo/SysOperLogExportVO.java

@@ -68,6 +68,11 @@ public class SysOperLogExportVO {
     @Excel(name = "执行结束时间")
     private LocalDateTime endTime;
 
-    /** 执行耗时时间(带单位) */
+    /** 执行耗时时间 */
+    @Excel(name = "执行耗时时间")
+    private Long consumingTime;
+
+    /** 执行耗时时间(单位:毫秒) */
+    @Excel(name = "执行耗时时间(带单位)")
     private String consumingTimeWithUnit;
 }

+ 5 - 2
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysOperLogMapper.xml

@@ -26,11 +26,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="createBy"       column="create_by"      />
 		<result property="startTime"     column="start_time"    />
 		<result property="endTime"       column="end_time"      />
+		<result property="consumingTime"   column="consuming_time" />
 		<result property="consumingTimeWithUnit"     column="consuming_time_with_unit"    />
 	</resultMap>
 
 	<sql id="selectOperLogVo">
-        select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, start_time, end_time, consuming_time_with_unit
+        select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, start_time, end_time, consuming_time, consuming_time_with_unit
 		from sys_oper_log d
     </sql>
     
@@ -57,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="createBy != null"> create_by, </if>
 			<if test="startTime != null"> start_time, </if>
 			<if test="endTime != null"> end_time, </if>
+		    <if test="consumingTime != null"> consuming_time, </if>
 			<if test="consumingTimeWithUnit !=null"> consuming_time_with_unit, </if>
 		</trim>
 		values
@@ -81,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="createBy != null"> #{createBy},</if>
 			<if test="startTime != null"> #{startTime},</if>
 		    <if test="endTime != null"> #{endTime},</if>
+		    <if test="consumingTime != null"> #{consumingTime},</if>
 		    <if test="consumingTimeWithUnit !=null"> #{consumingTimeWithUnit},</if>
 		</trim>
 	</insert>
@@ -122,7 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 
 	<select id="selectOperLogListExport" parameterType="com.usky.system.domain.SysOperLog" resultType="com.usky.system.service.vo.SysOperLogExportVO">
-		SELECT oper_id, oper_ip, oper_name, title, (CASE business_type WHEN '0' THEN '其它' WHEN '1' THEN '新增' WHEN '2' THEN '修改' ELSE '删除' END) AS businessType, request_method, (CASE STATUS WHEN '0' THEN '成功' ELSE '失败' END) AS STATUS, oper_time, start_time, end_time, consuming_time_with_unit
+		SELECT oper_id, oper_ip, oper_name, title, (CASE business_type WHEN '0' THEN '其它' WHEN '1' THEN '新增' WHEN '2' THEN '修改' ELSE '删除' END) AS businessType, request_method, (CASE STATUS WHEN '0' THEN '成功' ELSE '失败' END) AS STATUS, oper_time, start_time, end_time, consuming_time, consuming_time_with_unit
 		FROM sys_oper_log d
 		<where>
 			<if test="title != null and title != ''">

+ 1 - 0
usky-common/usky-common-log/src/main/java/com/usky/common/log/aspect/LogAspect.java

@@ -95,6 +95,7 @@ public class LogAspect {
 
             // 将耗时转换为带有单位"ms"的字符串
             String consumingTimeWithUnit = consumingTime + "ms";
+            operLog.setConsumingTime(consumingTime); // 存储耗时
             operLog.setConsumingTimeWithUnit(consumingTimeWithUnit); // 存储带有单位的字符串
 
             // 保存数据库