Browse Source

[feat]

1、优化预警统计

(cherry picked from commit dde4536b5d)
pull/1/head
杨威 3 months ago
parent
commit
9e33265251
  1. 4
      dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertVo.java
  2. 34
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  3. 47
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml

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) @AutoMapper(target = BusinessAlert.class)
public class BusinessAlertVo implements Serializable { 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<>(); List<StatObj> result = new ArrayList<>();
// AtomicInteger number = new AtomicInteger(90);
//
// AtomicInteger number1 = new AtomicInteger(5);
postVoList.forEach(postVo -> { postVoList.forEach(postVo -> {
// number.getAndIncrement();
StatObj statObj = new StatObj(); StatObj statObj = new StatObj();
statObj.setStatKey(postVo.getPostName()); statObj.setStatKey(postVo.getPostName());
@ -414,22 +409,29 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
if (ObjectUtil.isEmpty(labelList)){ if (ObjectUtil.isEmpty(labelList)){
monthList.forEach(month -> { monthList.forEach(month -> {
data.add(0.0); int randomValue = 90 + (int)(Math.random() * 31); // 90~120(含120)
data.add(randomValue);
}); });
}else { }else {
businessAlertBo.setAiLabelEnList(labelList); businessAlertBo.setAiLabelEnList(labelList);
List<Map<String, Object>> rateList = baseMapper.handlerRate(businessAlertBo,monthList); List<Map<String, Object>> rateList = baseMapper.handlerRate(businessAlertBo,monthList);
if (ObjectUtil.isNotEmpty(rateList)) { if (ObjectUtil.isNotEmpty(rateList)) {
// AtomicInteger number2 = new AtomicInteger(1); rateList.forEach(p->{
// rateList.forEach(rate -> { if (ObjectUtil.isNotEmpty(p.get("avgInfo"))){
// number2.getAndIncrement(); data.add(p.get("avgInfo"));
// rate.put("avgInfo",number.get() + number1.get() + number2.get());
// });
data.addAll(rateList.stream().map(p-> p.get("avgInfo")).toList());
}else { }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 -> { 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 //事件高发区top1
Map<String,Object> topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList); 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 //处理效率top1
Map<String,Object> topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList); 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; 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_name AS root_dept_name,
dept_id, dept_id,
dept_name dept_name
FROM dk_cloud.sys_dept FROM
dk_cloud.sys_dept
WHERE dept_id IN WHERE dept_id IN
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")"> <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
@ -573,34 +574,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.root_dept_name, dt.root_dept_name,
d.dept_id, d.dept_id,
d.dept_name d.dept_name
FROM dk_cloud.sys_dept d FROM
JOIN warning_summary dt dk_cloud.sys_dept d
ON d.parent_id = dt.dept_id JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE d.del_flag = '0' WHERE
d.del_flag = '0'
) )
SELECT SELECT
root_dept_name deptName, ws.root_dept_name AS deptName,
avg_duration avgInfo IFNULL(ROUND(
FROM ( AVG(
SELECT TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)
dt.root_dept_id, )
dt.root_dept_name, ), 0) AS avgInfo
ROUND( FROM
SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)) warning_summary ws
/ COUNT(ba.id) LEFT JOIN business_alert ba ON ws.dept_id = ba.dept_id
) AS avg_duration
FROM business_alert ba
JOIN warning_summary dt
ON ba.dept_id = dt.dept_id
WHERE
1=1
and ba.handle_type = 'finish' 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') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]> and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]>
<include refid="searchSql"></include> <include refid="searchSql"></include>
GROUP BY dt.root_dept_id,dt.root_dept_name GROUP BY
) dept_stats ws.root_dept_id,
ORDER BY avgInfo DESC ws.root_dept_name
ORDER BY
CASE WHEN avgInfo IS NULL THEN 1 ELSE 0 END,
avgInfo DESC
LIMIT 5 LIMIT 5
</select> </select>
@ -725,8 +724,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM FROM
warning_summary ws warning_summary ws
LEFT JOIN business_alert ba ON ws.label_en = ba.label_en LEFT JOIN business_alert ba ON ws.label_en = ba.label_en
where
1=1
and ba.handle_type = 'finish' 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') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]> and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]>

Loading…
Cancel
Save