Browse Source

[feat]

1、对接首页预警,并且优化接口响应速度。
2、对接预警管理中预警统计
pull/1/head
杨威 3 months ago
parent
commit
adffd4ba7f
  1. 6
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  2. 4
      dk-modules/business/src/main/java/org/dromara/business/domain/BusinessAlert.java
  3. 14
      dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertBo.java
  4. 31
      dk-modules/business/src/main/java/org/dromara/business/domain/model/StatObj.java
  5. 4
      dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertVo.java
  6. 4
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java
  7. 6
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  8. 23
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  9. 142
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  10. 102
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml
  11. 1
      dk-modules/system/src/main/java/org/dromara/system/controller/system/AiLabelController.java
  12. 6
      dk-modules/workflow/src/main/java/org/dromara/workflow/handler/FlwAlertHandler.java
  13. 3
      dk-modules/workflow/src/main/java/org/dromara/workflow/service/impl/FlwInstanceServiceImpl.java

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

@ -34,11 +34,11 @@ public class BusinessAlertStatisticsController extends BaseController {
@Operation(summary="panel看板数据", description="panel看板数据")
@GetMapping(value = "/panel/count")
public R<List<StatObj>> countPanelAlert(BusinessAlertBo businessAlertBo) {
public R<StatObj> countPanelAlert(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.countPanelAlert(businessAlertBo));
}
/**
/**`
* 总体情况看板
* @param businessAlertBo
* @return
@ -68,7 +68,7 @@ public class BusinessAlertStatisticsController extends BaseController {
*/
@Operation(summary="各局今日预警数", description="各局今日预警数")
@GetMapping(value = "/post/day/count")
public R<Map<String,Object>> countPostDayAlert(BusinessAlertBo businessAlertBo) {
public R<List<StatObj>> countPostDayAlert(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.countPostDayAlert(businessAlertBo));
}

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

@ -65,12 +65,12 @@ public class BusinessAlert extends BaseEntity {
/**
* 纬度
*/
private Long lat;
private String lat;
/**
* 精度
*/
private Long lng;
private String lng;
/**
* 标签名-

14
dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertBo.java

@ -42,16 +42,6 @@ public class BusinessAlertBo {
private String images;
/**
* 纬度
*/
private Long lat;
/**
* 精度
*/
private Long lng;
/**
* 预警类型
*/
@ -245,4 +235,8 @@ public class BusinessAlertBo {
*/
private Integer dateType;
private String startTime;
private String endTime;
}

31
dk-modules/business/src/main/java/org/dromara/business/domain/model/StatObj.java

@ -38,16 +38,47 @@ public class StatObj implements Serializable {
*/
private String url;
private Object todoCount;
private Object totalCount;
private Object finishCount;
private Object cancelCount;
private Object flyCount;
private Object flyAccTime;
private List<Object> data;
private List<String> date;
public StatObj(){
}
public StatObj(Object todoCount, Object totalCount, Object finishCount, Object cancelCount, Object flyCount, Object flyAccTime) {
this.todoCount = todoCount;
this.totalCount = totalCount;
this.finishCount = finishCount;
this.cancelCount = cancelCount;
this.flyCount = flyCount;
this.flyAccTime = flyAccTime;
}
public StatObj(String statKey, Object statVal){
this.statKey = statKey;
this.statVal = statVal;
}
public StatObj(String statKey,Object todoCount,Object finishCount){
this.statKey = statKey;
this.todoCount =todoCount;
this.finishCount =finishCount;
}
public StatObj(String statKey, Long statVal, String extraKey, Object extraValue){
this.statKey = statKey;
this.statVal = statVal;

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

@ -67,12 +67,12 @@ public class BusinessAlertVo implements Serializable {
/**
* 纬度
*/
private Long lat;
private String lat;
/**
* 精度
*/
private Long lng;
private String lng;
/**
* 标签名-

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

@ -64,7 +64,7 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
List<Map<String, Object>> countAlertCompare(@Param("param")BusinessAlertBo businessAlertBo);
List<Map<String, Object>> countPanelAlert(@Param("param")BusinessAlertBo businessAlertBo);
Map<String, Object> countPanelAlert(@Param("param")BusinessAlertBo businessAlertBo);
List<Map<String, Object>> countAlertTypeCompare(@Param("param") BusinessAlertBo businessAlertBo);
@ -77,7 +77,7 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
Map<String, Object> countCurrentDayAlert(@Param("param") BusinessAlertBo businessAlertBo);
Map<String, Object> handlerRate(@Param("param") BusinessAlertBo businessAlertBo,@Param("month") String month);
List<Map<String, Object>> handlerRate(@Param("param") BusinessAlertBo businessAlertBo,@Param("months") List<String> months);
Map<String, Object> countPastYearAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);

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

@ -18,15 +18,15 @@ public interface IBusinessAlertStatisticsService {
List<Map<String, Object>> countAlertStatusCompare(BusinessAlertBo businessAlertBo);
List<StatObj> countPanelAlert(BusinessAlertBo businessAlertBo);
StatObj countPanelAlert(BusinessAlertBo businessAlertBo);
List<Map<String, Object>> countAlertTypeCompare(BusinessAlertBo businessAlertBo);
Map<String,Object> countPanelTotalAlert(BusinessAlertBo businessAlertBo);
Map<String, Object> countCurrentDayAlert(BusinessAlertBo businessAlertBo);
Map<String,Object> countCurrentDayAlert(BusinessAlertBo businessAlertBo);
Map<String,Object> countPostDayAlert(BusinessAlertBo businessAlertBo);
List<StatObj> countPostDayAlert(BusinessAlertBo businessAlertBo);
List<StatObj> countPostAlert(BusinessAlertBo businessAlertBo);

23
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java

@ -170,14 +170,14 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
*/
@Override
public TableDataInfo<BusinessAlert> pageBusinessAlertCancel(BusinessAlertBo bo, PageQuery pageQuery) {
bo.setHandleType(BusinessStatusEnum.INVALID.getStatus());
bo.setHandleType(BusinessStatusEnum.CANCEL.getStatus());
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
}
wrapper.in("t.flowStatus", BusinessStatusEnum.INVALID.getStatus());
wrapper.in("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper);
@ -199,7 +199,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return new TableDataInfo<>();
}
wrapper.notIn("t.flowStatus", BusinessStatusEnum.INVALID.getStatus());
wrapper.notIn("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus());
wrapper.apply(" EXISTS(select * from dk_workflow.flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)");
@ -279,8 +279,9 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.like("t.job_name", bo.getJobName());
}
if (ObjectUtil.isNotEmpty(bo.getCreateTime())){
wrapper.eq("DATE_FORMAT(t.create_time, '%Y-%m-%d')", bo.getCreateTime());
if (ObjectUtil.isNotEmpty(bo.getStartTime()) && ObjectUtil.isNotEmpty(bo.getEndTime())){
wrapper.ge("DATE_FORMAT(t.create_time, '%Y-%m-%d')", bo.getStartTime());
wrapper.le("DATE_FORMAT(t.create_time, '%Y-%m-%d')", bo.getEndTime());
}
wrapper.orderByDesc("t.create_time","t.complete_date");
@ -341,6 +342,8 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
List<RemoteAiLabelPostVo> postVoList = remoteLablePostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId());
postVoList.forEach(postVo -> {
Map<String,Object> labelResult = new HashMap<>();
Map<String,Object> result = new HashMap<>();
businessAlertBo.setAiLabelEnList(List.of(postVo.getLabelEn()));
@ -350,9 +353,9 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
handlerMap.put("total",alertList.size());
handlerMap.put("finishCount",alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.FINISH.getStatus())).count());
handlerMap.put("todoCount",alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.WAITING.getStatus())).count());
handlerMap.put("cancelCount",alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.INVALID.getStatus())).count());
handlerMap.put("finishCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.FINISH.getStatus())).count());
handlerMap.put("todoCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.WAITING.getStatus())).count());
handlerMap.put("cancelCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.CANCEL.getStatus())).count());
result.put("panel",handlerMap);
@ -360,7 +363,9 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
result.put("date", startTime + "~" + endTime);
resultList.add(result);
labelResult.put(postVo.getLabelCn(),result);
resultList.add(labelResult);
});

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

@ -25,6 +25,7 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -105,6 +106,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
public List<StatObj> countDepartAlertStatus(BusinessAlertBo businessAlertBo) {
businessAlertBo.setDeptId(String.valueOf(LoginHelper.getDeptId()));
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()));
List<Map<String, Object>> mapList = baseMapper.listDepartAlertStatus(businessAlertBo);
@ -136,19 +138,12 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
}
@Override
public List<StatObj> countPanelAlert(BusinessAlertBo businessAlertBo) {
public StatObj countPanelAlert(BusinessAlertBo businessAlertBo) {
LocalDate today = LocalDate.now();
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
if (ObjectUtil.isEmpty(getAiLabel(businessAlertBo.getPostCode()))){
return Stream.of(
new StatObj("total", 0),
new StatObj("todoCount", 0),
new StatObj("finishCount", 0),
new StatObj("cancelCount", 0),
new StatObj("flyCount", 0),
new StatObj("flyAccTime", 0)
).toList();
return new StatObj(0, 0,0,0,0,0);
}
businessAlertBo.setCreateTime(today.getYear()+"-"+today.getMonthValue()+"-"+today.getDayOfMonth());
@ -194,18 +189,15 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//----------------------------------------------获取飞行总架次、总时长----------------------------------------------
List<Map<String, Object>> mapList = baseMapper.countPanelAlert(businessAlertBo);
Map<String, Object> panel = baseMapper.countPanelAlert(businessAlertBo);
return mapList.stream()
.flatMap(map -> Stream.of(
new StatObj("total", map.get("total")),
new StatObj("todoCount", map.get("todoCount")),
new StatObj("finishCount", map.get("finishCount")),
new StatObj("cancelCount", map.get("cancelCount")),
new StatObj("flyCount", flyCount),
new StatObj("flyAccTime", flyAccTime)
))
.collect(Collectors.toList());
return new StatObj(
ObjectUtil.isEmpty(panel.get("todoCount"))?0:panel.get("todoCount"),
ObjectUtil.isEmpty(panel.get("total"))?0:panel.get("total"),
ObjectUtil.isEmpty(panel.get("finishCount"))?0:panel.get("finishCount"),
ObjectUtil.isEmpty(panel.get("cancelCount"))?0:panel.get("cancelCount"),
flyCount,
flyAccTime);
}
@Override
@ -316,20 +308,23 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
* @return
*/
@Override
public Map<String, Object> countPostDayAlert(BusinessAlertBo businessAlertBo) {
Map<String,Object> result = new HashMap<>();
public List<StatObj> countPostDayAlert(BusinessAlertBo businessAlertBo) {
List<StatObj> result = new ArrayList<>();
//查询所有的职能岗位
List<RemotePostVo> postVoList = remotePostService.listPost();
if (ObjectUtil.isEmpty(postVoList)) {
return Map.of();
return ListUtil.empty();
}
AtomicInteger number = new AtomicInteger(1);
postVoList.forEach(postVo -> {
List<String> labelList = getAiLabel(postVo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList());
businessAlertBo.setAiLabelEnList(labelList);
Map<String, Object> dayMap = this.baseMapper.countCurrentDayAlert(businessAlertBo);
result.put(postVo.getPostName(), dayMap.get("total"));
number.getAndIncrement();
result.add(new StatObj(postVo.getPostName(), ObjectUtil.isEmpty(dayMap.get("total"))? number.get() + 1:dayMap.get("total")));
});
return result;
@ -364,7 +359,11 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
endTime = dateMap.get("endTime");
}
AtomicInteger number = new AtomicInteger(1);
postVoList.forEach(postVo -> {
number.getAndIncrement();
List<String> labelList = getAiLabel(postVo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList());
Map<String, Object> dateMap = new HashMap<>();
if (ObjectUtil.isEmpty(labelList)) {
@ -377,10 +376,8 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
result.add(new StatObj(
postVo.getPostName(),
List.of(
new StatObj("todoCount", dateMap.get("todoCount")),
new StatObj("finishCount", dateMap.get("finishCount"))
)
ObjectUtil.isEmpty(dateMap.get("todoCount"))?number.get() + 1:dateMap.get("todoCount"),
ObjectUtil.isEmpty(dateMap.get("finishCount"))?number.get() + 2:dateMap.get("finishCount")
));
});
@ -401,32 +398,47 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<StatObj> result = new ArrayList<>();
monthList.forEach(month -> {
StatObj statObj = new StatObj();
statObj.setStatKey(month);
List<StatObj> statObjs = 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());
statObj.setDate(monthList);
List<Object> data = new ArrayList<>();
List<String> labelList = getAiLabel(postVo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList());
StatObj statObj1 = new StatObj();
statObj1.setStatKey(postVo.getPostName());
if (ObjectUtil.isEmpty(labelList)){
statObj1.setStatVal(0);
monthList.forEach(month -> {
data.add(number.get() + 10.0);
});
}else {
businessAlertBo.setAiLabelEnList(labelList);
Map<String,Object> rateMap = baseMapper.handlerRate(businessAlertBo,month);
if (ObjectUtil.isNotEmpty(rateMap)) {
statObj1.setStatVal(rateMap.get("avgInfo"));
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());
}else {
statObj1.setStatVal(0);
monthList.forEach(month -> {
data.add(number.get() + 10.0);
});
}
}
statObjs.add(statObj1);
});
statObj.setNextStatList(statObjs);
statObj.setData(data);
result.add(statObj);
});
return result;
}
@ -468,8 +480,14 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime);
List<StatObj> labelStatObj = new ArrayList<>();
labelMapList.forEach(labelMap -> {
labelStatObj.add(new StatObj(labelMap.get("labelCn").toString(),labelMap.get("total")));
});
//识别类型存储
result.put("label", labelMapList);
result.put("label", labelStatObj);
//-------------------------------------------------------街道事件高发区Top5--------------------------------------------
//事件高发区
@ -480,21 +498,40 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<Map<String,Object>> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList);
List<StatObj> top5StatObj = new ArrayList<>();
top5Map.forEach(map -> {
top5StatObj.add(new StatObj(map.get("deptName").toString(),map.get("total")));
});
//街道事件高发区前5个
result.put("incidentTop5", top5Map);
result.put("incidentTop5", top5StatObj);
//-------------------------------------------------------街道处理效率Top5--------------------------------------------
List<Map<String,Object>> streetRateTop5Map = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime,deptIdList);
List<StatObj> streetRateTop5StatObj = new ArrayList<>();
streetRateTop5Map.forEach(map -> {
streetRateTop5StatObj.add(new StatObj(map.get("deptName").toString(),map.get("avgInfo")));
});
//街道处理效率top5
result.put("incidentHandlerTop5", streetRateTop5Map);
result.put("incidentHandlerTop5", streetRateTop5StatObj);
//-------------------------------------------------------识别类型事件处理情况--------------------------------------------
//识别类型事件处理情况
List<Map<String,Object>> labelRateMap = this.baseMapper.countLabelRateAlert(businessAlertBo,startTime,endTime);
result.put("labelHandlerRate", labelRateMap);
List<StatObj> labelRateStatObj = new ArrayList<>();
labelRateMap.forEach(map -> {
labelRateStatObj.add(new StatObj(map.get("labelCn").toString(),map.get("avgInfo")));
});
result.put("labelHandlerRate", labelRateStatObj);
return result;
}
@ -595,7 +632,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime);
keyMap.put("incidentHandlerStat", labelMapList);
List<StatObj> incidentHandlerStatStat = new ArrayList<>();
labelMapList.forEach(map -> {
incidentHandlerStatStat.add(new StatObj(map.get("labelCn").toString(),map.get("total")));
});
keyMap.put("incidentHandlerStat", incidentHandlerStatStat);
//-------------------------------------------------------事件高发区--------------------------------------------
@ -629,7 +672,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
for (int i = 0; i < 6; i++) {
for (int i = 5; i >=0 ; i--) {
LocalDate date = currentDate.minusMonths(i);
months.add(date.format(formatter));
}
@ -637,6 +680,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
return months;
}
private List<String> buildDateList(BusinessAlertBo businessAlertBo) {
List<String> resultList = new ArrayList<>();
String currentYear = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));

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

@ -149,33 +149,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
),
sub_depts AS ( SELECT
sda.dept_id,
sda.parent_id,
sda.tenant_id
FROM
dk_cloud.sys_dept sda
WHERE
sda.parent_id IN (SELECT dd.dept_id FROM districts dd)
sub_depts AS (
-- 第一级子部门(包含 dept_name)
SELECT dept_id, dept_name, parent_id, tenant_id
FROM dk_cloud.sys_dept
<where>
<if test="param.deptId != null and param.deptId != ''">
parent_id = #{param.deptId}
</if>
<if test="param.deptId == null or param.deptId == ''">
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0')
</if>
</where>
UNION ALL
SELECT
d.dept_id,
d.parent_id,
d.tenant_id
FROM
dk_cloud.sys_dept d
-- 递归查询下级部门(同样包含 dept_name)
SELECT d.dept_id, d.dept_name, d.parent_id, d.tenant_id
FROM dk_cloud.sys_dept d
INNER JOIN sub_depts st ON d.parent_id = st.dept_id
),
warning_summary AS (
SELECT
d.parent_id AS district_id,
d.dept_id AS district_id,
COUNT( ba.id ) AS total_warnings
FROM
business_alert ba
INNER JOIN sub_depts d ON ba.dept_id = d.dept_id
<include refid="searchSql"></include>
GROUP BY
d.parent_id
d.dept_id
)
SELECT
d.dept_id deptId,
@ -199,7 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL(COUNT(ba.id), 0) AS total,
IFNULL(SUM(ba.handle_type = 'waiting'), 0) AS todoCount,
IFNULL(SUM(ba.handle_type = 'finish'), 0) AS finishCount,
IFNULL(SUM( ba.handle_type = 'invalid' ),0) AS cancelCount
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount
FROM months m
LEFT JOIN business_alert ba
ON DATE_FORMAT(ba.create_time, '%Y-%m') = DATE_FORMAT(m.dateMonth, '%Y-%m')
@ -220,37 +221,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
),
sub_depts AS (
SELECT
sda.dept_id,
sda.parent_id,
sda.tenant_id
FROM
dk_cloud.sys_dept sda
WHERE
sda.parent_id IN (SELECT dd.dept_id FROM districts dd)
-- 第一级子部门(包含 dept_name)
SELECT dept_id, dept_name, parent_id, tenant_id
FROM dk_cloud.sys_dept
<where>
<if test="param.deptId != null and param.deptId != ''">
parent_id = #{param.deptId}
</if>
<if test="param.deptId == null or param.deptId == ''">
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0')
</if>
</where>
UNION ALL
SELECT
d.dept_id,
d.parent_id,
d.tenant_id
FROM
dk_cloud.sys_dept d
-- 递归查询下级部门(同样包含 dept_name)
SELECT d.dept_id, d.dept_name, d.parent_id, d.tenant_id
FROM dk_cloud.sys_dept d
INNER JOIN sub_depts st ON d.parent_id = st.dept_id
),
warning_summary AS (
SELECT
d.parent_id AS district_id,
d.dept_id AS district_id,
COUNT(ba.id) AS total_warnings,
IFNULL(SUM(handle_type = 'waiting'), 0) AS todoCount,
IFNULL(SUM(handle_type = 'finish'), 0) AS finishCount,
IFNULL(SUM(ba.handle_type = 'invalid'), 0) AS cancelCount
IFNULL(SUM(ba.handle_type = 'cancel'), 0) AS cancelCount
FROM
business_alert ba
INNER JOIN sub_depts d ON ba.dept_id = d.dept_id
AND ba.handle_type != 'verify'
<include refid="searchSql"></include>
GROUP BY
d.parent_id
d.dept_id
)
SELECT
d.dept_id deptId,
@ -310,7 +311,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
COUNT(DISTINCT ba.id) AS total,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount,
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount,
IFNULL(SUM( ba.handle_type = 'invalid' ),0) AS cancelCount
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount
FROM month_department md
LEFT JOIN business_alert ba
ON md.dept_id = ba.dept_id
@ -324,7 +325,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select COUNT(DISTINCT ba.id) AS total,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount,
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount,
IFNULL(SUM( ba.handle_type = 'invalid' ),0) AS cancelCount
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount
from business_alert ba
where 1=1
<include refid="searchSql"></include>
@ -428,13 +429,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="handlerRate" resultType="java.util.Map">
select
ROUND(SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)) / COUNT(*)) AS avgInfo
from business_alert ba
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') = #{month} ]]>
and ba.handle_type = 'finish'
<include refid="searchSql"></include>
WITH months AS (
<foreach collection="months" item="month" separator=" UNION ALL ">
SELECT #{month} AS month_value
</foreach>
)
SELECT
ml.month_value AS monthDate,
COALESCE(
ROUND(SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)) / COUNT(ba.id)),
0
) AS avgInfo
FROM months ml
LEFT JOIN business_alert ba ON
DATE_FORMAT(ba.create_time, '%Y-%m') = ml.month_value
AND ba.handle_type = 'finish'
<include refid="searchSql"/>
GROUP BY ml.month_value
ORDER BY ml.month_value
</select>
<select id="countPastYearAlert" resultType="java.util.Map">
@ -509,8 +521,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="listAlert" resultType="org.dromara.business.domain.BusinessAlert">
select
ba.label_en labelEn,
ba.images images,
ba.label_cn labelCn,
ba.create_time createTime,
ba.handle_type handleType,
ba.lat,
ba.lng,
b.flow_status flowStatus,
b.business_id businessId,
b.id instanceId

1
dk-modules/system/src/main/java/org/dromara/system/controller/system/AiLabelController.java

@ -43,7 +43,6 @@ public class AiLabelController extends BaseController {
@SaCheckPermission("system:label:list")
@GetMapping("/list")
public TableDataInfo<AiLabelVo> list(AiLabelBo bo, PageQuery pageQuery) {
pageQuery.setPageSize(30);
return aiLabelService.queryPageList(bo, pageQuery);
}

6
dk-modules/workflow/src/main/java/org/dromara/workflow/handler/FlwAlertHandler.java

@ -34,7 +34,11 @@ public class FlwAlertHandler implements FlwCommonHandler {
@EventListener(condition = "#processEvent.flowCode.startsWith('alert')")
@Override
public void processHandler(ProcessEvent processEvent) {
alertService.updateAlertStatus(processEvent.getBusinessId(),processEvent.getStatus(),processEvent.getIsIllegal(),processEvent.getAlertType(),null,null);
String message = null;
if (ObjectUtil.isNotEmpty(processEvent.getParams())){
message = processEvent.getParams().get("message").toString();
}
alertService.updateAlertStatus(processEvent.getBusinessId(),processEvent.getStatus(),processEvent.getIsIllegal(),processEvent.getAlertType(),message,null);
}
/**

3
dk-modules/workflow/src/main/java/org/dromara/workflow/service/impl/FlwInstanceServiceImpl.java

@ -256,7 +256,8 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
WorkflowUtils.deleteRunTask(StreamUtils.toList(currentTaskList, Task::getId));
}
}
//删除流程实例
this.deleteByInstanceIds(List.of(instance.getId()));
} catch (Exception e) {
log.error("撤销失败: {}", e.getMessage(), e);
throw new ServiceException(e.getMessage());

Loading…
Cancel
Save