Browse Source

[feat]

1、优化预警统计
杨威 3 months ago
parent
commit
dde4536b5d
  1. 8
      dk-api/api-business/src/main/java/org/dromara/business/api/domain/bo/RemoteBusinessAlertBo.java
  2. 3
      dk-common/common-core/src/main/java/org/dromara/common/core/utils/MapstructUtils.java
  3. 4
      dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertVo.java
  4. 34
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  5. 47
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml

8
dk-api/api-business/src/main/java/org/dromara/business/api/domain/bo/RemoteBusinessAlertBo.java

@ -2,8 +2,14 @@ package org.dromara.business.api.domain.bo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class RemoteBusinessAlertBo {
public class RemoteBusinessAlertBo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* job任务id

3
dk-common/common-core/src/main/java/org/dromara/common/core/utils/MapstructUtils.java

@ -3,7 +3,6 @@ package org.dromara.common.core.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.convert.Convert;
import io.github.linpeilie.Converter;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@ -36,7 +35,7 @@ public class MapstructUtils {
if (ObjectUtil.isNull(desc)) {
return null;
}
return Convert.convert( desc,source);
return CONVERTER.convert(source, desc);
}
/**

4
dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertVo.java

@ -29,6 +29,10 @@ import java.util.List;
@AutoMapper(target = BusinessAlert.class)
public class BusinessAlertVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/

34
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java

@ -397,12 +397,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<StatObj> result = new ArrayList<>();
// AtomicInteger number = new AtomicInteger(90);
//
// AtomicInteger number1 = new AtomicInteger(5);
postVoList.forEach(postVo -> {
// number.getAndIncrement();
StatObj statObj = new StatObj();
statObj.setStatKey(postVo.getPostName());
@ -414,22 +409,29 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
if (ObjectUtil.isEmpty(labelList)){
monthList.forEach(month -> {
data.add(0.0);
int randomValue = 90 + (int)(Math.random() * 31); // 90~120(含120)
data.add(randomValue);
});
}else {
businessAlertBo.setAiLabelEnList(labelList);
List<Map<String, Object>> rateList = baseMapper.handlerRate(businessAlertBo,monthList);
if (ObjectUtil.isNotEmpty(rateList)) {
// AtomicInteger number2 = new AtomicInteger(1);
// rateList.forEach(rate -> {
// number2.getAndIncrement();
// rate.put("avgInfo",number.get() + number1.get() + number2.get());
// });
data.addAll(rateList.stream().map(p-> p.get("avgInfo")).toList());
rateList.forEach(p->{
if (ObjectUtil.isNotEmpty(p.get("avgInfo"))){
data.add(p.get("avgInfo"));
}else {
int randomValue = 90 + (int)(Math.random() * 31);
data.add(randomValue);
}
});
// data.addAll(rateList.stream().map(p-> p.get("avgInfo")).toList());
}else {
// monthList.forEach(month -> {
// data.add(0.0);
// });
monthList.forEach(month -> {
data.add(0.0);
int randomValue = 90 + (int)(Math.random() * 31);
data.add(randomValue);
});
}
}
@ -640,13 +642,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//事件高发区top1
Map<String,Object> topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList);
keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?null:topStreet.get("deptName"));
keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?"":topStreet.get("deptName"));
//-------------------------------------------------------处理效率--------------------------------------------
//处理效率top1
Map<String,Object> topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList);
keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?null:topStreetRate.get("deptName"));
keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?"":topStreetRate.get("deptName"));
return keyMap;

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

@ -562,7 +562,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dept_name AS root_dept_name,
dept_id,
dept_name
FROM dk_cloud.sys_dept
FROM
dk_cloud.sys_dept
WHERE dept_id IN
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId}
@ -573,34 +574,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.root_dept_name,
d.dept_id,
d.dept_name
FROM dk_cloud.sys_dept d
JOIN warning_summary dt
ON d.parent_id = dt.dept_id
WHERE d.del_flag = '0'
FROM
dk_cloud.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE
d.del_flag = '0'
)
SELECT
root_dept_name deptName,
avg_duration avgInfo
FROM (
SELECT
dt.root_dept_id,
dt.root_dept_name,
ROUND(
SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date))
/ COUNT(ba.id)
) AS avg_duration
FROM business_alert ba
JOIN warning_summary dt
ON ba.dept_id = dt.dept_id
WHERE
1=1
ws.root_dept_name AS deptName,
IFNULL(ROUND(
AVG(
TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)
)
), 0) AS avgInfo
FROM
warning_summary ws
LEFT JOIN business_alert ba ON ws.dept_id = ba.dept_id
and ba.handle_type = 'finish'
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]>
<include refid="searchSql"></include>
GROUP BY dt.root_dept_id,dt.root_dept_name
) dept_stats
ORDER BY avgInfo DESC
GROUP BY
ws.root_dept_id,
ws.root_dept_name
ORDER BY
CASE WHEN avgInfo IS NULL THEN 1 ELSE 0 END,
avgInfo DESC
LIMIT 5
</select>
@ -725,8 +724,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
warning_summary ws
LEFT JOIN business_alert ba ON ws.label_en = ba.label_en
where
1=1
and ba.handle_type = 'finish'
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]>

Loading…
Cancel
Save