diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java index cb267df..1bb1ff3 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java +++ b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java @@ -185,4 +185,13 @@ public class BusinessAlertStatisticsController extends BaseController { public R>> countAlertTypeCompare(BusinessAlertBo businessAlertBo) { return R.ok(statisticsService.countAlertTypeCompare(businessAlertBo)); } + + //本周、今日、本月 预警个数 + @Operation(summary="app首页统计", description="app首页统计") + @GetMapping(value = "/app/count") + public R> listAppAlertCount(BusinessAlertBo businessAlertBo) { + return R.ok(statisticsService.listAppAlertCount(businessAlertBo)); + } + + } diff --git a/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java b/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java index 51da15f..30f01ac 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java +++ b/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java @@ -94,4 +94,7 @@ public interface BusinessAlertMapper extends BaseMapperPlus> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); void batchUpdateDept(@Param("list") List alertVoList); + + + Map listAppAlertCount(@Param("param") BusinessAlertBo businessAlertBo); } diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java index bcd9748..bac55f8 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java @@ -35,4 +35,7 @@ public interface IBusinessAlertStatisticsService { Map comprehensiveManage(BusinessAlertBo businessAlertBo); Map cityComprehensiveManage(BusinessAlertBo businessAlertBo); + + Map listAppAlertCount(BusinessAlertBo businessAlertBo); + } diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index b58c20c..3fae449 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java @@ -11,6 +11,7 @@ import org.dromara.business.service.IBusinessAlertStatisticsService; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.system.api.RemoteDataScopeService; import org.dromara.system.api.RemoteDeptService; import org.dromara.system.api.RemoteLabelPostService; import org.dromara.system.api.RemotePostService; @@ -52,6 +53,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @DubboReference RemotePostService remotePostService; + @DubboReference(timeout = 30000) + RemoteDataScopeService remoteDataScopeService; /** * 按照月份分类预警数量 @@ -60,6 +63,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist */ @Override public List countMonthAlert(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); + if (ObjectUtil.isNotEmpty(businessAlertBo.getDeptId())){ List remoteDeptVoList = remoteDeptService.selectListByParentId(businessAlertBo.getDeptId()); List departIdList = remoteDeptVoList.stream().map(RemoteDeptVo::getDeptId).toList(); @@ -75,6 +81,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @Override public ListcountDepartAlert(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); @@ -85,6 +93,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @Override public List countMonthAlertStatus(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); List> mapList = baseMapper.listMonthAlertStatus(businessAlertBo); @@ -105,6 +115,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @Override public List countDepartAlertStatus(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); @@ -131,6 +143,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist */ @Override public List> countAlertStatusCompare(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setDateList(buildDateList(businessAlertBo)); return baseMapper.countAlertCompare(businessAlertBo); @@ -145,6 +159,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist public StatObj countPanelAlert(BusinessAlertBo businessAlertBo) { LocalDate today = LocalDate.now(); + //构建查询数据权限 + createPermissions(businessAlertBo); + if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){ if (ObjectUtil.isEmpty(getAiLabel(businessAlertBo.getPostCode()))){ return new StatObj(0, 0,0,0,0,0); @@ -206,6 +223,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @Override public List> countAlertTypeCompare(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setDateList(buildDateList(businessAlertBo)); return baseMapper.countAlertTypeCompare(businessAlertBo); @@ -218,6 +237,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist */ @Override public Map countPanelTotalAlert(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); Map result = new HashMap<>(); if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){ List labelList = getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()); @@ -285,6 +306,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist public Map countCurrentDayAlert(BusinessAlertBo businessAlertBo) { Map result = new HashMap<>(); + //构建查询数据权限 + createPermissions(businessAlertBo); + if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){ List labelList = getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()); @@ -314,6 +338,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @Override public List countPostDayAlert(BusinessAlertBo businessAlertBo) { List result = new ArrayList<>(); + + //构建查询数据权限 + createPermissions(businessAlertBo); + //查询所有的职能岗位 List postVoList = remotePostService.listPost(); @@ -338,6 +366,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist */ @Override public List countPostAlert(BusinessAlertBo businessAlertBo) { + + //构建查询数据权限 + createPermissions(businessAlertBo); + //查询所有的职能岗位 List postVoList = remotePostService.listPost(); @@ -388,6 +420,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist */ @Override public List handlerRate(BusinessAlertBo businessAlertBo) { + + //构建查询数据权限 + createPermissions(businessAlertBo); + //查询所有的职能岗位 List postVoList = remotePostService.listPost(); @@ -434,6 +470,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist throw new ServiceException("【postCode】 岗位编码为空!"); } + //构建查询数据权限 + createPermissions(businessAlertBo); + Map result = new HashMap<>(); List labelList = getAiLabel(businessAlertBo.getPostCode()); @@ -572,6 +611,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //-------------------------------------------------------条件构建-------------------------------------------- + //构建查询数据权限 + createPermissions(businessAlertBo); + List postVoList = remoteLabelPostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId()); Map> aiNameMap = postVoList.stream().collect(Collectors.groupingBy(RemoteAiLabelPostVo::getAiName)); @@ -639,6 +681,18 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist return keyMap; } + /** + * 获取app本周预警个数 + * @param businessAlertBo + * @return + */ + @Override + public Map listAppAlertCount(BusinessAlertBo businessAlertBo) { + //构建查询数据权限 + createPermissions(businessAlertBo); + return baseMapper.listAppAlertCount(businessAlertBo); + } + /** * 获取近6个月的月份集合(格式:yyyy-MM) */ @@ -683,4 +737,15 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist private List getAiLabel(String postCode) { return remoteLabelPostService.selectLabelByList(postCode,null); } + + private void createPermissions(BusinessAlertBo businessAlertBo) { + String roleCustom = remoteDataScopeService.getRoleCustom(LoginHelper.getLoginUser().getRoles().getFirst().getRoleId()); + if (roleCustom.equalsIgnoreCase("-1")){ + businessAlertBo.setDeptIdList(ListUtil.empty()); + }else { + businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) + .map(Long::parseLong) + .collect(Collectors.toList())); + } + } } diff --git a/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml b/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml index d5cc1e0..e4955f0 100644 --- a/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml +++ b/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml @@ -788,5 +788,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + +