diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SnapshotType.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SnapshotType.java new file mode 100644 index 00000000..0882070b --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SnapshotType.java @@ -0,0 +1,70 @@ +package io.renren.modules.date_snapshot.entity; + + +import java.util.Arrays; + +/** + * 快照任务 枚举 + */ +public enum SnapshotType { + + /** + * 运营数据每周快照 + */ + DATA_WEEKLY(1, "运营数据每周快照"), + /** + * 运营数据每月快照 + */ + DATA_MONTH(2, "运营数据每月快照"), + /** + * 能力使用周快照 + */ + APPLY_WEEKLY(3, "能力使用周快照"), + /** + * 能力使用月快照 + */ + APPLY_MONTH(4, "能力使用月快照"), + /** + * 能力上架周快照 + */ + RESOURCE_WEEKLY(5, "能力上架周快照"), + /** + * 能力使用月快照 + */ + RESOURCE_MONTH(6, "能力使用月快照"), + + /** + * 未知 + */ + UN(99, "未知"); + + private int flag; + private String tip; + + SnapshotType(int flag, String tip) { + this.flag = flag; + this.tip = tip; + } + + public static SnapshotType getByFlag(int flag) { + SnapshotType[] index = SnapshotType.values(); + return Arrays.asList(index).stream().filter(index_ -> index_.flag == flag).findAny().orElse(SnapshotType.UN); + } + + + public int getFlag() { + return flag; + } + + public void setFlag(int flag) { + this.flag = flag; + } + + public String getTip() { + return tip; + } + + public void setTip(String tip) { + this.tip = tip; + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java index 9f0044f5..b04635ec 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java @@ -24,7 +24,7 @@ public class SysDateSnapshotEntity extends BaseEntity implements Serializable { private static final long serialVersionUID = 1L; /** - * 数据快照类型(1:每周快照 2:每月快照) + * 数据快照类型(1:每周快照 2:每月快照 3:能力使用周快照 4:能力使用月快照 5:能力上架周快照 6:能力使用月快照) */ private Integer type; /** diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java index bfcaf009..c0b0baa0 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java @@ -12,7 +12,20 @@ import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; */ public interface SysDateSnapshotService extends CrudService { /** - * 数据快s照行为 + * 数据快照行为 */ void snapshotAction(Integer type); + + /** + * 能力申请快照行为 + * + * @param type + */ + void snapshotApplyAction(Integer type); + + /** + * 能力上架统计快照行为 + * @param type + */ + void snapshotResourceAction(Integer type); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java index 9382deb2..ce81f989 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java @@ -40,7 +40,7 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl> resultList = (List>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据 + List> snapshot = new ArrayList>() {{ + addAll(resultList); + }}; + sysDateSnapshotDTO.setCreateDate(new Date()); + sysDateSnapshotDTO.setType(type); + sysDateSnapshotDTO.setSnapshot(snapshot); + save(sysDateSnapshotDTO); + } + + /** + * 能力上架统计快照行为 + * + * @param type + */ + @Override + public void snapshotResourceAction(Integer type) { + SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO(); + List> resultList = (List>) resourceService.selectDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据 + List> snapshot = new ArrayList>() {{ + addAll(resultList); + }}; + sysDateSnapshotDTO.setCreateDate(new Date()); + sysDateSnapshotDTO.setType(type); + sysDateSnapshotDTO.setSnapshot(snapshot); + save(sysDateSnapshotDTO); + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java index e2ea404c..5d01d01f 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java @@ -1,5 +1,6 @@ package io.renren.modules.date_snapshot.task; +import io.renren.modules.date_snapshot.entity.SnapshotType; import io.renren.modules.date_snapshot.service.SysDateSnapshotService; import io.renren.modules.job.task.ITask; import org.slf4j.Logger; @@ -23,6 +24,8 @@ public class MonthSnapshot implements ITask { @Override public void run(String params) { logger.info("月快照计划"); - sysDateSnapshotService.snapshotAction(2); + sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag()); + sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag()); + sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_MONTH.getFlag()); } } diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java index 2724ac9c..3b0d25be 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java @@ -1,5 +1,6 @@ package io.renren.modules.date_snapshot.task; +import io.renren.modules.date_snapshot.entity.SnapshotType; import io.renren.modules.date_snapshot.service.SysDateSnapshotService; import io.renren.modules.job.task.ITask; import org.slf4j.Logger; @@ -26,6 +27,8 @@ public class WeeklySnapshot implements ITask { @Override public void run(String params) { logger.info("周快照计划"); - sysDateSnapshotService.snapshotAction(1); + sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag()); + sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag()); + sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_WEEKLY.getFlag()); } } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index be3461f5..cdfc7e4e 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -2627,6 +2627,13 @@ public class ResourceServiceImpl extends CrudServiceImpl { + if (!index.containsKey("hys")) { + index.put("hys", 0); // 填充会议室为0 + } + return index; + }).collect(Collectors.toList()); + Integer total = 0; for (Integer count : countMap.values()) { total += count; @@ -2634,6 +2641,7 @@ public class ResourceServiceImpl extends CrudServiceImpl count = new HashMap<>(); count.put("name", "总计"); + if (!cloud) { // 不统计云资源时 count.put("yzy", "0"); count.put("ysp", "0");