Browse Source

[feat]

1、增加预警同级数据权限
2、开发app首页预警查询
master
杨威 2 months ago
parent
commit
5c2509196e
  1. 9
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  2. 3
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java
  3. 3
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  4. 65
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  5. 10
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml

9
dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java

@ -185,4 +185,13 @@ public class BusinessAlertStatisticsController extends BaseController {
public R<List<Map<String, Object>>> countAlertTypeCompare(BusinessAlertBo businessAlertBo) { public R<List<Map<String, Object>>> countAlertTypeCompare(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.countAlertTypeCompare(businessAlertBo)); return R.ok(statisticsService.countAlertTypeCompare(businessAlertBo));
} }
//本周、今日、本月 预警个数
@Operation(summary="app首页统计", description="app首页统计")
@GetMapping(value = "/app/count")
public R<Map<String, Object>> listAppAlertCount(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.listAppAlertCount(businessAlertBo));
}
} }

3
dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java

@ -94,4 +94,7 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
List<Map<String, Object>> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); List<Map<String, Object>> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
void batchUpdateDept(@Param("list") List<BusinessAlertVo> alertVoList); void batchUpdateDept(@Param("list") List<BusinessAlertVo> alertVoList);
Map<String, Object> listAppAlertCount(@Param("param") BusinessAlertBo businessAlertBo);
} }

3
dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java

@ -35,4 +35,7 @@ public interface IBusinessAlertStatisticsService {
Map<String, Object> comprehensiveManage(BusinessAlertBo businessAlertBo); Map<String, Object> comprehensiveManage(BusinessAlertBo businessAlertBo);
Map<String,Object> cityComprehensiveManage(BusinessAlertBo businessAlertBo); Map<String,Object> cityComprehensiveManage(BusinessAlertBo businessAlertBo);
Map<String, Object> listAppAlertCount(BusinessAlertBo businessAlertBo);
} }

65
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.core.exception.ServiceException;
import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.RemoteDataScopeService;
import org.dromara.system.api.RemoteDeptService; import org.dromara.system.api.RemoteDeptService;
import org.dromara.system.api.RemoteLabelPostService; import org.dromara.system.api.RemoteLabelPostService;
import org.dromara.system.api.RemotePostService; import org.dromara.system.api.RemotePostService;
@ -52,6 +53,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@DubboReference @DubboReference
RemotePostService remotePostService; RemotePostService remotePostService;
@DubboReference(timeout = 30000)
RemoteDataScopeService remoteDataScopeService;
/** /**
* 按照月份分类预警数量 * 按照月份分类预警数量
@ -60,6 +63,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
*/ */
@Override @Override
public List<StatObj> countMonthAlert(BusinessAlertBo businessAlertBo) { public List<StatObj> countMonthAlert(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
if (ObjectUtil.isNotEmpty(businessAlertBo.getDeptId())){ if (ObjectUtil.isNotEmpty(businessAlertBo.getDeptId())){
List<RemoteDeptVo> remoteDeptVoList = remoteDeptService.selectListByParentId(businessAlertBo.getDeptId()); List<RemoteDeptVo> remoteDeptVoList = remoteDeptService.selectListByParentId(businessAlertBo.getDeptId());
List<Long> departIdList = remoteDeptVoList.stream().map(RemoteDeptVo::getDeptId).toList(); List<Long> departIdList = remoteDeptVoList.stream().map(RemoteDeptVo::getDeptId).toList();
@ -75,6 +81,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override @Override
public List<StatObj>countDepartAlert(BusinessAlertBo businessAlertBo) { public List<StatObj>countDepartAlert(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId())); businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId()));
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()));
@ -85,6 +93,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override @Override
public List<StatObj> countMonthAlertStatus(BusinessAlertBo businessAlertBo) { public List<StatObj> countMonthAlertStatus(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()));
List<Map<String, Object>> mapList = baseMapper.listMonthAlertStatus(businessAlertBo); List<Map<String, Object>> mapList = baseMapper.listMonthAlertStatus(businessAlertBo);
@ -105,6 +115,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override @Override
public List<StatObj> countDepartAlertStatus(BusinessAlertBo businessAlertBo) { public List<StatObj> countDepartAlertStatus(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId())); businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId()));
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()));
@ -131,6 +143,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
*/ */
@Override @Override
public List<Map<String, Object>> countAlertStatusCompare(BusinessAlertBo businessAlertBo) { public List<Map<String, Object>> countAlertStatusCompare(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()));
businessAlertBo.setDateList(buildDateList(businessAlertBo)); businessAlertBo.setDateList(buildDateList(businessAlertBo));
return baseMapper.countAlertCompare(businessAlertBo); return baseMapper.countAlertCompare(businessAlertBo);
@ -145,6 +159,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
public StatObj countPanelAlert(BusinessAlertBo businessAlertBo) { public StatObj countPanelAlert(BusinessAlertBo businessAlertBo) {
LocalDate today = LocalDate.now(); LocalDate today = LocalDate.now();
//构建查询数据权限
createPermissions(businessAlertBo);
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){ if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
if (ObjectUtil.isEmpty(getAiLabel(businessAlertBo.getPostCode()))){ if (ObjectUtil.isEmpty(getAiLabel(businessAlertBo.getPostCode()))){
return new StatObj(0, 0,0,0,0,0); return new StatObj(0, 0,0,0,0,0);
@ -206,6 +223,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override @Override
public List<Map<String, Object>> countAlertTypeCompare(BusinessAlertBo businessAlertBo) { public List<Map<String, Object>> countAlertTypeCompare(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()));
businessAlertBo.setDateList(buildDateList(businessAlertBo)); businessAlertBo.setDateList(buildDateList(businessAlertBo));
return baseMapper.countAlertTypeCompare(businessAlertBo); return baseMapper.countAlertTypeCompare(businessAlertBo);
@ -218,6 +237,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
*/ */
@Override @Override
public Map<String,Object> countPanelTotalAlert(BusinessAlertBo businessAlertBo) { public Map<String,Object> countPanelTotalAlert(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){ if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
List<String> labelList = getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()); List<String> labelList = getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList());
@ -285,6 +306,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
public Map<String, Object> countCurrentDayAlert(BusinessAlertBo businessAlertBo) { public Map<String, Object> countCurrentDayAlert(BusinessAlertBo businessAlertBo) {
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
//构建查询数据权限
createPermissions(businessAlertBo);
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){ if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
List<String> labelList = getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()); List<String> labelList = getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList());
@ -314,6 +338,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override @Override
public List<StatObj> countPostDayAlert(BusinessAlertBo businessAlertBo) { public List<StatObj> countPostDayAlert(BusinessAlertBo businessAlertBo) {
List<StatObj> result = new ArrayList<>(); List<StatObj> result = new ArrayList<>();
//构建查询数据权限
createPermissions(businessAlertBo);
//查询所有的职能岗位 //查询所有的职能岗位
List<RemotePostVo> postVoList = remotePostService.listPost(); List<RemotePostVo> postVoList = remotePostService.listPost();
@ -338,6 +366,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
*/ */
@Override @Override
public List<StatObj> countPostAlert(BusinessAlertBo businessAlertBo) { public List<StatObj> countPostAlert(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
//查询所有的职能岗位 //查询所有的职能岗位
List<RemotePostVo> postVoList = remotePostService.listPost(); List<RemotePostVo> postVoList = remotePostService.listPost();
@ -388,6 +420,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
*/ */
@Override @Override
public List<StatObj> handlerRate(BusinessAlertBo businessAlertBo) { public List<StatObj> handlerRate(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
//查询所有的职能岗位 //查询所有的职能岗位
List<RemotePostVo> postVoList = remotePostService.listPost(); List<RemotePostVo> postVoList = remotePostService.listPost();
@ -434,6 +470,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
throw new ServiceException("【postCode】 岗位编码为空!"); throw new ServiceException("【postCode】 岗位编码为空!");
} }
//构建查询数据权限
createPermissions(businessAlertBo);
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
List<RemoteAiLabelPostVo> labelList = getAiLabel(businessAlertBo.getPostCode()); List<RemoteAiLabelPostVo> labelList = getAiLabel(businessAlertBo.getPostCode());
@ -572,6 +611,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------条件构建-------------------------------------------- //-------------------------------------------------------条件构建--------------------------------------------
//构建查询数据权限
createPermissions(businessAlertBo);
List<RemoteAiLabelPostVo> postVoList = remoteLabelPostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId()); List<RemoteAiLabelPostVo> postVoList = remoteLabelPostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId());
Map<String, List<RemoteAiLabelPostVo>> aiNameMap = postVoList.stream().collect(Collectors.groupingBy(RemoteAiLabelPostVo::getAiName)); Map<String, List<RemoteAiLabelPostVo>> aiNameMap = postVoList.stream().collect(Collectors.groupingBy(RemoteAiLabelPostVo::getAiName));
@ -639,6 +681,18 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
return keyMap; return keyMap;
} }
/**
* 获取app本周预警个数
* @param businessAlertBo
* @return
*/
@Override
public Map<String, Object> listAppAlertCount(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
return baseMapper.listAppAlertCount(businessAlertBo);
}
/** /**
* 获取近6个月的月份集合格式yyyy-MM * 获取近6个月的月份集合格式yyyy-MM
*/ */
@ -683,4 +737,15 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
private List<RemoteAiLabelPostVo> getAiLabel(String postCode) { private List<RemoteAiLabelPostVo> getAiLabel(String postCode) {
return remoteLabelPostService.selectLabelByList(postCode,null); 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()));
}
}
} }

10
dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml

@ -788,5 +788,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</update> </update>
<select id="listAppAlertCount" resultType="java.util.Map">
SELECT
COUNT(CASE WHEN DATE(ba.create_time) = CURDATE() THEN 1 END) AS dayCount,
COUNT(CASE WHEN YEARWEEK(ba.create_time, 1) = YEARWEEK(CURDATE(), 1) THEN 1 END) AS weekCount,
COUNT(CASE WHEN YEAR(ba.create_time) = YEAR(CURDATE()) AND MONTH(ba.create_time) = MONTH(CURDATE()) THEN 1 END) AS monthCount
FROM business_alert ba
where 1=1
<include refid="searchSql"></include>
</select>
</mapper> </mapper>

Loading…
Cancel
Save