Compare commits

...

3 Commits

Author SHA1 Message Date
wangliwen ab5806c2d9 Merge branch 'master' into docker_package 2023-01-04 11:41:27 +08:00
wangliwen 0ff8cbe7b1 Merge branch 'dev' 2023-01-04 11:41:21 +08:00
wangliwen 4286d50872 npe 2023-01-04 11:41:14 +08:00
5 changed files with 61 additions and 22 deletions

View File

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

View File

@ -75,7 +75,9 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
@Override @Override
public void snapshotApplyAction(Integer type) { public void snapshotApplyAction(Integer type) {
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO(); 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>>() {{ List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
addAll(resultList); addAll(resultList);
}}; }};
@ -93,7 +95,9 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
@Override @Override
public void snapshotResourceAction(Integer type) { public void snapshotResourceAction(Integer type) {
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO(); 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>>() {{ List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
addAll(resultList); addAll(resultList);
}}; }};

View File

@ -8,11 +8,18 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component("monthSnapshot") @Component("monthSnapshot")
public class MonthSnapshot implements ITask { public class MonthSnapshot implements ITask {
private static final Logger logger = LoggerFactory.getLogger(MonthSnapshot.class); 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 @Autowired
private SysDateSnapshotService sysDateSnapshotService; private SysDateSnapshotService sysDateSnapshotService;
@ -24,8 +31,14 @@ public class MonthSnapshot implements ITask {
@Override @Override
public void run(String params) { public void run(String params) {
logger.info("月快照计划"); logger.info("月快照计划");
sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag()); executor.execute(() -> {
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag()); sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag());
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; 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") @Component("weeklySnapshot")
public class WeeklySnapshot implements ITask { public class WeeklySnapshot implements ITask {
private static final Logger logger = LoggerFactory.getLogger(WeeklySnapshot.class); 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 @Autowired
private SysDateSnapshotService sysDateSnapshotService; private SysDateSnapshotService sysDateSnapshotService;
@ -27,8 +33,14 @@ public class WeeklySnapshot implements ITask {
@Override @Override
public void run(String params) { public void run(String params) {
logger.info("周快照计划"); logger.info("周快照计划");
sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag()); executor.execute(() -> {
sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag()); sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag());
sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_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 @Override
public Object selectApplyDeptDetailTypeCountList(Map params) { public Object selectApplyDeptDetailTypeCountList(Map params) {
UserDetail user = SecurityUser.getUser(); if (params.containsKey("snapshot")) {
SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId()); logger.info("快照获取");
if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) { } else {
logger.info("管理员区域"); UserDetail user = SecurityUser.getUser();
} else if (user.getDeptId() != null) { SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId());
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) {
logger.error("区域管理员只出本部门区域:{}", sysDeptDTO.getDistrict()); 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())) { // 部门精准查 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 @Override
public Object selectDeptDetailTypeCountList(Map params) { public Object selectDeptDetailTypeCountList(Map params) {
UserDetail user = SecurityUser.getUser(); if (params.containsKey("snapshot")) {
SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId()); logger.info("快照获取");
if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) { } else {
logger.info("管理员区域"); UserDetail user = SecurityUser.getUser();
} else if (user.getDeptId() != null) { SysDeptDTO sysDeptDTO = deptService.get(user.getDeptId());
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 if (user.getSuperAdmin() == SuperAdminEnum.YES.value() || bigDataDeptName.equals(sysDeptDTO.getName())) {
logger.error("区域管理员只出本部门区域:{}", sysDeptDTO.getDistrict()); 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()) 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()) || params.containsKey("region") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("region").toString())
) { ) {