Merge branch 'dev'

This commit is contained in:
wangliwen 2023-01-03 16:46:43 +08:00
commit 66d6281767
4 changed files with 91 additions and 2 deletions

View File

@ -11,5 +11,8 @@ import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity;
* @since 1.0 2023-01-03 * @since 1.0 2023-01-03
*/ */
public interface SysDateSnapshotService extends CrudService<SysDateSnapshotEntity, SysDateSnapshotDTO> { public interface SysDateSnapshotService extends CrudService<SysDateSnapshotEntity, SysDateSnapshotDTO> {
/**
* 数据快s照行为
*/
void snapshotAction(Integer type);
} }

View File

@ -6,9 +6,12 @@ import io.renren.modules.date_snapshot.dao.SysDateSnapshotDao;
import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO; import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO;
import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity;
import io.renren.modules.date_snapshot.service.SysDateSnapshotService; import io.renren.modules.date_snapshot.service.SysDateSnapshotService;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.*;
/** /**
* 运行数据快照资源数量申请数量 * 运行数据快照资源数量申请数量
@ -18,6 +21,10 @@ import java.util.Map;
*/ */
@Service @Service
public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotDao, SysDateSnapshotEntity, SysDateSnapshotDTO> implements SysDateSnapshotService { public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotDao, SysDateSnapshotEntity, SysDateSnapshotDTO> implements SysDateSnapshotService {
@Autowired
private TAbilityApplicationService tAbilityApplicationService;
@Autowired
private ResourceService resourceService;
@Override @Override
public QueryWrapper<SysDateSnapshotEntity> getWrapper(Map<String, Object> params) { public QueryWrapper<SysDateSnapshotEntity> getWrapper(Map<String, Object> params) {
@ -28,4 +35,24 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
} }
/**
* 数据快s照行为
*/
@Override
public void snapshotAction(Integer type) {
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO();
long countApply = tAbilityApplicationService.countApplyAll(); // 资源申请量
List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
add(new LinkedHashMap<String, Object>() {{
put("count", countApply);
put("type", "资源申请量");
}});
addAll((Collection<? extends Map<String, Object>>) resourceService.selectTotal()); // 资源汇聚量
}};
sysDateSnapshotDTO.setCreateDate(new Date());
sysDateSnapshotDTO.setType(type);
sysDateSnapshotDTO.setSnapshot(snapshot);
save(sysDateSnapshotDTO);
}
} }

View File

@ -0,0 +1,28 @@
package io.renren.modules.date_snapshot.task;
import io.renren.modules.date_snapshot.service.SysDateSnapshotService;
import io.renren.modules.job.task.ITask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("monthSnapshot")
public class MonthSnapshot implements ITask {
private static final Logger logger = LoggerFactory.getLogger(MonthSnapshot.class);
@Autowired
private SysDateSnapshotService sysDateSnapshotService;
/**
* 执行定时任务接口
*
* @param params 参数多参数使用JSON数据
*/
@Override
public void run(String params) {
logger.info("月快照计划");
sysDateSnapshotService.snapshotAction(2);
}
}

View File

@ -0,0 +1,31 @@
package io.renren.modules.date_snapshot.task;
import io.renren.modules.date_snapshot.service.SysDateSnapshotService;
import io.renren.modules.job.task.ITask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 周快照计划任务
*/
@Component("weeklySnapshot")
public class WeeklySnapshot implements ITask {
private static final Logger logger = LoggerFactory.getLogger(WeeklySnapshot.class);
@Autowired
private SysDateSnapshotService sysDateSnapshotService;
/**
* 执行定时任务接口
*
* @param params 参数多参数使用JSON数据
*/
@Override
public void run(String params) {
logger.info("周快照计划");
sysDateSnapshotService.snapshotAction(1);
}
}