diff --git a/db/0pigxx_boot.sql b/db/0pigxx_boot.sql index 12985c7c5..1063c2beb 100644 --- a/db/0pigxx_boot.sql +++ b/db/0pigxx_boot.sql @@ -1171,7 +1171,7 @@ DROP TABLE IF EXISTS `sys_schedule`; CREATE TABLE `sys_schedule` ( `id` bigint(20) NOT NULL COMMENT 'id', `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标题', - `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型', + `schedule_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型', `state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '状态', `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '内容', `time` time DEFAULT NULL COMMENT '时间', diff --git a/db/2pigxx.sql b/db/2pigxx.sql index 32ab955c9..bf8a24cda 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -1135,7 +1135,7 @@ DROP TABLE IF EXISTS `sys_schedule`; CREATE TABLE `sys_schedule` ( `id` bigint(20) NOT NULL COMMENT 'id', `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标题', - `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型', + `schedule_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日程类型', `state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '状态', `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '内容', `time` time DEFAULT NULL COMMENT '时间', diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java index 702c6da5f..e0492340e 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java @@ -27,6 +27,7 @@ import com.pig4cloud.pigx.common.core.sensitive.SensitiveTypeEnum; import com.pig4cloud.pigx.common.core.util.TenantTable; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.experimental.FieldNameConstants; import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -42,6 +43,7 @@ import java.time.LocalDateTime; */ @Data @TenantTable +@FieldNameConstants @Schema(description = "日志") public class SysLog implements Serializable { diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysScheduleEntity.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysScheduleEntity.java index 4abb96cbe..72a96ea8b 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysScheduleEntity.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysScheduleEntity.java @@ -41,85 +41,86 @@ import java.time.LocalTime; @Schema(description = "日程") public class SysScheduleEntity extends Model { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * id - */ - @TableId(type = IdType.ASSIGN_ID) - @Schema(description = "id") - private Long id; + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "id") + private Long id; - /** - * 标题 - */ - @Schema(description = "标题") - private String title; + /** + * 标题 + */ + @Schema(description = "标题") + private String title; - /** - * 日程类型 - */ - @Schema(description = "日程类型") - private String type; + /** + * 日程类型 + */ + @Schema(description = "日程类型") + @TableField("schedule_type") + private String type; - /** - * 状态 - */ - @Schema(description = "状态") - private String state; + /** + * 状态 + */ + @Schema(description = "状态") + private String state; - /** - * 内容 - */ - @Schema(description = "内容") - private String content; + /** + * 内容 + */ + @Schema(description = "内容") + private String content; - /** - * 时间 - */ - @Schema(description = "时间") - private LocalTime time; + /** + * 时间 + */ + @Schema(description = "时间") + private LocalTime time; - /** - * 日期 - */ - @Schema(description = "日期") - private LocalDate date; + /** + * 日期 + */ + @Schema(description = "日期") + private LocalDate date; - /** - * 创建人 - */ - @Schema(description = "创建人") - @TableField(fill = FieldFill.INSERT) - private String createBy; + /** + * 创建人 + */ + @Schema(description = "创建人") + @TableField(fill = FieldFill.INSERT) + private String createBy; - /** - * 创建时间 - */ - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createTime; + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; - /** - * 修改人 - */ - @Schema(description = "修改人") - @TableField(fill = FieldFill.INSERT_UPDATE) - private String updateBy; + /** + * 修改人 + */ + @Schema(description = "修改人") + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updateBy; - /** - * 更新时间 - */ - @Schema(description = "更新时间") - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateTime; + /** + * 更新时间 + */ + @Schema(description = "更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; - /** - * 删除标记 - */ - @TableLogic - @Schema(description = "删除标记") - @TableField(fill = FieldFill.INSERT) - private String delFlag; + /** + * 删除标记 + */ + @TableLogic + @Schema(description = "删除标记") + @TableField(fill = FieldFill.INSERT) + private String delFlag; } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java index 8bbb4357f..985fd1d2a 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java @@ -37,10 +37,4 @@ import java.util.Map; @Mapper public interface SysLogMapper extends PigxBaseMapper { - /** - * 通过日志类型统计日志总数 返回一个包含日志类型和日志总数的列表 - * @return List> - */ - List> selectLogSumByType(); - } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java index 2df39874f..393f0b5db 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java @@ -19,6 +19,8 @@ package com.pig4cloud.pigx.admin.service.impl; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -113,7 +115,24 @@ public class SysLogServiceImpl extends ServiceImpl impleme */ @Override public List> getLogSum() { - return baseMapper.selectLogSumByType(); + // 查询createTime 最近 30天的数据 + List sysLogList = baseMapper + .selectList(Wrappers.lambdaQuery().ge(SysLog::getCreateTime, LocalDateTime.now().minusDays(30))); + return sysLogList.stream() + .collect(Collectors.groupingBy(log -> DateUtil.format(log.getCreateTime(), DatePattern.NORM_DATE_PATTERN))) + .entrySet() + .stream() + .map(entry -> { + Map map = entry.getValue() + .stream() + .collect(Collectors.groupingBy(SysLog::getLogType)) + .entrySet() + .stream() + .collect(Collectors.toMap(Map.Entry::getKey, value -> value.getValue().size())); + map.put(SysLog.Fields.createTime, entry.getKey()); + return map; + }) + .collect(Collectors.toList()); } } diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml index 810437e0a..d5c8c830f 100644 --- a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml @@ -21,18 +21,4 @@ -