Browse Source

导出登录日志时长格式修改

yangyue 1 year ago
parent
commit
4d13489597

+ 19 - 0
duty-service/src/main/java/cn/com/taiji/duty/controller/DutyLoginLogController.java

@@ -24,6 +24,7 @@ import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Objects;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -100,6 +101,24 @@ public class DutyLoginLogController {
             }
         }
         List<DutyLoginLog> list = loginLogService.queryList(vo);
+        list.forEach(loginLog -> {
+            if (loginLog.getDuration() != null) {
+                String result="";
+                long hours = TimeUnit.SECONDS.toHours(loginLog.getDuration());
+                long minutes = TimeUnit.SECONDS.toMinutes(loginLog.getDuration()) % 60;
+                long seconds = loginLog.getDuration() % 60;
+                if(hours!=0){
+                    result+=hours+"时";
+                }
+                if(minutes!=0){
+                    result+=minutes+"分";
+                }
+                if(seconds!=0){
+                    result+=seconds+"秒";
+                }
+                loginLog.setDurationValue(result);
+            }
+        });
         DutyOperLog operLog = new DutyOperLog();
         operLog.setOperModule("8");
         operLog.setOperType("3");

+ 7 - 1
duty-service/src/main/java/cn/com/taiji/duty/model/DutyLoginLog.java

@@ -95,11 +95,17 @@ public class DutyLoginLog implements Serializable {
 	private String browser;
 
 	/** 时长 */
-	@ExcelProperty(value = "时长",index =7)
+	@ExcelIgnore
 	@ApiModelProperty("时长")
 	@TableField("duration")
 	private Long duration;
 
+	/** 时长 */
+	@ExcelProperty(value = "时长",index =7)
+	@ApiModelProperty("时长")
+	@TableField(exist = false)
+	private String durationValue;
+
 	/** token */
 	@ExcelIgnore
 	@ApiModelProperty("token")