This commit is contained in:
wangliwen 2023-01-04 11:41:14 +08:00
parent 1b593637f3
commit 4286d50872
5 changed files with 61 additions and 22 deletions

View File

@ -25,6 +25,7 @@ public interface SysDateSnapshotService extends CrudService<SysDateSnapshotEntit
/**
* 能力上架统计快照行为
*
* @param type
*/
void snapshotResourceAction(Integer type);

View File

@ -75,7 +75,9 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
@Override
public void snapshotApplyAction(Integer type) {
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO();
List<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据
List<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{
put("snapshot", true);
}}); // 能力上架统计原始数据
List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
addAll(resultList);
}};
@ -93,7 +95,9 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
@Override
public void snapshotResourceAction(Integer type) {
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO();
List<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据
List<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{
put("snapshot", true);
}}); // 能力上架统计原始数据
List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
addAll(resultList);
}};

View File

@ -8,11 +8,18 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component("monthSnapshot")
public class MonthSnapshot implements ITask {
private static final Logger logger = LoggerFactory.getLogger(MonthSnapshot.class);
private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors();
private static final ExecutorService executor = Executors.newWorkStealingPool(CPUNUM);
@Autowired
private SysDateSnapshotService sysDateSnapshotService;
@ -24,8 +31,14 @@ public class MonthSnapshot implements ITask {
@Override
public void run(String params) {
logger.info("月快照计划");
sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag());
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag());
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_MONTH.getFlag());
executor.execute(() -> {
sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag());
});
executor.execute(() -> {
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag());
});
executor.execute(() -> {
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_MONTH.getFlag());
});
}
}

View File

@ -8,6 +8,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 周快照计划任务
@ -15,6 +18,9 @@ import org.springframework.stereotype.Component;
@Component("weeklySnapshot")
public class WeeklySnapshot implements ITask {
private static final Logger logger = LoggerFactory.getLogger(WeeklySnapshot.class);
private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors();
private static final ExecutorService executor = Executors.newWorkStealingPool(CPUNUM);
@Autowired
private SysDateSnapshotService sysDateSnapshotService;
@ -27,8 +33,14 @@ public class WeeklySnapshot implements ITask {
@Override
public void run(String params) {
logger.info("周快照计划");
sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag());
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag());
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_WEEKLY.getFlag());
executor.execute(() -> {
sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag());
});
executor.execute(() -> {
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag());
});
executor.execute(() -> {
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_WEEKLY.getFlag());
});
}
}

View File

@ -2328,13 +2328,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectApplyDeptDetailTypeCountList(Map params) {
UserDetail user = SecurityUser.getUser();
SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId());
if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) {
logger.info("管理员区域");
} else if (user.getDeptId() != null) {
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域
logger.error("区域管理员只出本部门区域:{}", sysDeptDTO.getDistrict());
if (params.containsKey("snapshot")) {
logger.info("快照获取");
} else {
UserDetail user = SecurityUser.getUser();
SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId());
if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) {
logger.info("管理员区域");
} else if (user.getDeptId() != null) {
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域
logger.error("区域管理员只出本部门区域:{}", sysDeptDTO.getDistrict());
}
}
if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) { // 部门精准查
@ -2654,14 +2658,19 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectDeptDetailTypeCountList(Map params) {
UserDetail user = SecurityUser.getUser();
SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId());
if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) {
logger.info("管理员区域");
} else if (user.getDeptId() != null) {
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域
logger.error("区域管理员只出本部门区域:{}", sysDeptDTO.getDistrict());
if (params.containsKey("snapshot")) {
logger.info("快照获取");
} else {
UserDetail user = SecurityUser.getUser();
SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId());
if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) {
logger.info("管理员区域");
} else if (user.getDeptId() != null) {
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域
logger.error("区域管理员只出本部门区域:{}", sysDeptDTO.getDistrict());
}
}
if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())
|| params.containsKey("region") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("region").toString())
) {