Compare commits

..

2 Commits

Author SHA1 Message Date
wangliwen 790b9e98e5 Merge branch 'dev' 2023-01-04 11:22:02 +08:00
wangliwen 1b593637f3 周快照、月快照 2023-01-04 11:21:54 +08:00
7 changed files with 138 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -24,7 +24,7 @@ public class SysDateSnapshotEntity extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 数据快照类型1每周快照 2每月快照 * 数据快照类型1每周快照 2每月快照 3:能力使用周快照 4能力使用月快照 5能力上架周快照 6能力使用月快照
*/ */
private Integer type; private Integer type;
/** /**

View File

@ -12,7 +12,20 @@ import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity;
*/ */
public interface SysDateSnapshotService extends CrudService<SysDateSnapshotEntity, SysDateSnapshotDTO> { public interface SysDateSnapshotService extends CrudService<SysDateSnapshotEntity, SysDateSnapshotDTO> {
/** /**
* 数据快s照行为 * 数据快照行为
*/ */
void snapshotAction(Integer type); void snapshotAction(Integer type);
/**
* 能力申请快照行为
*
* @param type
*/
void snapshotApplyAction(Integer type);
/**
* 能力上架统计快照行为
* @param type
*/
void snapshotResourceAction(Integer type);
} }

View File

@ -40,7 +40,7 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
/** /**
* 数据快s照行为 * 数据快照行为
*/ */
@Override @Override
public void snapshotAction(Integer type) { public void snapshotAction(Integer type) {
@ -66,4 +66,40 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
sysDateSnapshotDTO.setSnapshot(snapshot); sysDateSnapshotDTO.setSnapshot(snapshot);
save(sysDateSnapshotDTO); save(sysDateSnapshotDTO);
} }
/**
* 能力申请快照行为
*
* @param type
*/
@Override
public void snapshotApplyAction(Integer type) {
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO();
List<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据
List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
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<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据
List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
addAll(resultList);
}};
sysDateSnapshotDTO.setCreateDate(new Date());
sysDateSnapshotDTO.setType(type);
sysDateSnapshotDTO.setSnapshot(snapshot);
save(sysDateSnapshotDTO);
}
} }

View File

@ -1,5 +1,6 @@
package io.renren.modules.date_snapshot.task; 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.date_snapshot.service.SysDateSnapshotService;
import io.renren.modules.job.task.ITask; import io.renren.modules.job.task.ITask;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -23,6 +24,8 @@ public class MonthSnapshot implements ITask {
@Override @Override
public void run(String params) { public void run(String params) {
logger.info("月快照计划"); logger.info("月快照计划");
sysDateSnapshotService.snapshotAction(2); sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag());
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag());
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_MONTH.getFlag());
} }
} }

View File

@ -1,5 +1,6 @@
package io.renren.modules.date_snapshot.task; 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.date_snapshot.service.SysDateSnapshotService;
import io.renren.modules.job.task.ITask; import io.renren.modules.job.task.ITask;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -26,6 +27,8 @@ public class WeeklySnapshot implements ITask {
@Override @Override
public void run(String params) { public void run(String params) {
logger.info("周快照计划"); logger.info("周快照计划");
sysDateSnapshotService.snapshotAction(1); sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag());
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag());
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_WEEKLY.getFlag());
} }
} }

View File

@ -2627,6 +2627,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultList.addAll(temp); resultList.addAll(temp);
} }
resultList = resultList.stream().map(index -> {
if (!index.containsKey("hys")) {
index.put("hys", 0); // 填充会议室为0
}
return index;
}).collect(Collectors.toList());
Integer total = 0; Integer total = 0;
for (Integer count : countMap.values()) { for (Integer count : countMap.values()) {
total += count; total += count;
@ -2634,6 +2641,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
countMap.put("count", total); countMap.put("count", total);
HashMap<String, Object> count = new HashMap<>(); HashMap<String, Object> count = new HashMap<>();
count.put("name", "总计"); count.put("name", "总计");
if (!cloud) { // 不统计云资源时 if (!cloud) { // 不统计云资源时
count.put("yzy", "0"); count.put("yzy", "0");
count.put("ysp", "0"); count.put("ysp", "0");