Browse Source

[feat]

1、开发首页预警统计
pull/1/head
杨威 3 months ago
parent
commit
3506585aca
  1. 1
      dk-api/api-system/src/main/java/org/dromara/system/api/RemoteLabelPostService.java
  2. 8
      dk-api/api-system/src/main/java/org/dromara/system/api/domain/vo/RemotePostVo.java
  3. 30
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  4. 10
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java
  5. 3
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java
  6. 1
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  7. 105
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  8. 142
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  9. 102
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml
  10. 13
      dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteLabelPostServicelmpl.java
  11. 15
      dk-modules/system/src/main/java/org/dromara/system/dubbo/RemotePostServiceImpl.java
  12. 3
      dk-modules/system/src/main/java/org/dromara/system/mapper/AiLabelPostMapper.java
  13. 2
      dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java
  14. 2
      dk-modules/system/src/main/java/org/dromara/system/service/IAiLabelPostService.java
  15. 7
      dk-modules/system/src/main/java/org/dromara/system/service/impl/AiLablePostServiceImpl.java
  16. 4
      dk-modules/system/src/main/resources/mapper/system/AiLabelPostMapper.xml

1
dk-api/api-system/src/main/java/org/dromara/system/api/RemoteLabelPostService.java

@ -18,4 +18,5 @@ public interface RemoteLabelPostService {
* */
List<RemoteAiLabelPostVo> selectLabelByList(String postCode, Long deptId);
List<RemoteAiLabelPostVo> getAiLabelList();
}

8
dk-api/api-system/src/main/java/org/dromara/system/api/domain/vo/RemotePostVo.java

@ -2,14 +2,20 @@ package org.dromara.system.api.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
@Data
public class RemotePostVo {
@NoArgsConstructor
public class RemotePostVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 岗位ID

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

@ -4,8 +4,10 @@ import cn.hutool.core.lang.Dict;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.business.domain.BusinessAlert;
import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.model.StatObj;
import org.dromara.business.service.IBusinessAlertService;
import org.dromara.business.service.IBusinessAlertStatisticsService;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
@ -27,6 +29,8 @@ public class BusinessAlertStatisticsController extends BaseController {
private final IBusinessAlertStatisticsService statisticsService;
private final IBusinessAlertService businessAlertService;
@Operation(summary="panel看板数据", description="panel看板数据")
@GetMapping(value = "/panel/count")
@ -88,10 +92,34 @@ public class BusinessAlertStatisticsController extends BaseController {
*/
@Operation(summary="出警效率", description="出警效率")
@GetMapping(value = "/handler/rate")
public R<List<StatObj>> handlerRate(BusinessAlertBo businessAlertBo,Dict dict) {
public R<List<StatObj>> handlerRate(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.handlerRate(businessAlertBo));
}
/**
* 综治管理
* @param businessAlertBo
* @return
*/
@Operation(summary="综治管理", description="综治管理")
@GetMapping(value = "/comprehensive/manage")
public R<Map<String,Object>> comprehensiveManage(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.comprehensiveManage(businessAlertBo));
}
/**
* 预警信息
* @param businessAlertBo
* @return
*/
@Operation(summary="预警信息", description="预警信息")
@GetMapping(value = "/alert/list")
public R<List<Map<String,Object>>> listAlert(BusinessAlertBo businessAlertBo) {
return R.ok(businessAlertService.listAlert(businessAlertBo));
}
//饼图显示每个月根据部门

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

@ -78,4 +78,14 @@ 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);
Map<String, Object> countPastYearAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
List<Map<String, Object>> countAiLabel(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
Integer countStreetAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
List<BusinessAlert> listAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
Integer countStreetRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
}

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

@ -6,6 +6,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import java.util.List;
import java.util.Map;
/**
* 预警任务Service接口
@ -65,4 +66,6 @@ public interface IBusinessAlertService {
void updateAlertStatus(String businessId, String flowStatus,Boolean isIllegal,String alertType,String message,String assignName);
TableDataInfo<BusinessAlert> getInfo(BusinessAlertBo bo, PageQuery pageQuery, String alertCode);
List<Map<String,Object>> listAlert(BusinessAlertBo businessAlertBo);
}

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

@ -32,4 +32,5 @@ public interface IBusinessAlertStatisticsService {
List<StatObj> handlerRate(BusinessAlertBo businessAlertBo);
Map<String, Object> comprehensiveManage(BusinessAlertBo businessAlertBo);
}

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

@ -25,6 +25,8 @@ import org.dromara.workflow.api.RemoteWorkflowService;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@ -146,6 +148,10 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
public TableDataInfo<BusinessAlert> pageBusinessAlertAll(BusinessAlertBo bo, PageQuery pageQuery) {
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
}
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper);
return TableDataInfo.build(page);
@ -162,6 +168,10 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
bo.setHandleType(BusinessStatusEnum.INVALID.getStatus());
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
}
wrapper.in("t.flowStatus", BusinessStatusEnum.INVALID.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper);
@ -179,6 +189,11 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
@Override
public TableDataInfo<BusinessAlert> pageBusinessAlertFinish(BusinessAlertBo bo, PageQuery pageQuery) {
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
}
wrapper.notIn("t.flowStatus", BusinessStatusEnum.INVALID.getStatus());
wrapper.apply(" EXISTS(select * from dk_workflow.flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)");
@ -199,6 +214,10 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
public TableDataInfo<BusinessAlert> pageBusinessAlertTodo(BusinessAlertBo bo, PageQuery pageQuery) {
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
}
wrapper.eq("t.node_type", 1);
wrapper.in("t.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
@ -230,12 +249,17 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
private QueryWrapper<BusinessAlert> buildQueryWrapper(BusinessAlertBo bo) {
QueryWrapper<BusinessAlert> wrapper = new QueryWrapper<>();
//根据当前用户职能获取识别类型
List<RemoteAiLabelPostVo> postVoList = remoteLablePostService.selectLabelByList(bo.getPostCode(), LoginHelper.getDeptId());
if (ObjectUtil.isNotEmpty(bo.getPostCode())){
//根据当前用户职能获取识别类型
List<RemoteAiLabelPostVo> postVoList = remoteLablePostService.selectLabelByList(bo.getPostCode(), LoginHelper.getDeptId());
if (ObjectUtil.isEmpty(postVoList)) {
return null;
}
if (ObjectUtil.isNotEmpty(postVoList)) {
wrapper.in("t.label_en",StreamUtils.toList(postVoList, RemoteAiLabelPostVo::getLabelEn));
if (ObjectUtil.isNotEmpty(postVoList)) {
wrapper.in("t.label_en",StreamUtils.toList(postVoList, RemoteAiLabelPostVo::getLabelEn));
}
}
//排除状态为验证状态预警
@ -254,7 +278,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.eq("DATE_FORMAT(t.create_time, '%Y-%m-%d')", bo.getCreateTime());
}
wrapper.orderByAsc("t.create_time");
wrapper.orderByDesc("t.create_time","t.complete_date");
return wrapper;
}
@ -284,4 +308,75 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
}
return null;
}
@Override
public List<Map<String,Object>> listAlert(BusinessAlertBo businessAlertBo) {
List<Map<String,Object>> resultList = new ArrayList<>();
//生成近一周开始时间、结束时间
List<String> dayList = getLastSixDays();
String startTime = dayList.get(dayList.size() - 1);
String endTime = dayList.get(0);
//查看的是总览的预警信息
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
Map<String,Object> result = new HashMap<>();
result.put("date", startTime + "~" + endTime);
result.put("list",this.baseMapper.listAlert(businessAlertBo,startTime,endTime));
resultList.add(result);
return resultList;
}
//不是空的话查看是对应各局的
List<RemoteAiLabelPostVo> postVoList = remoteLablePostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId());
postVoList.forEach(postVo -> {
Map<String,Object> result = new HashMap<>();
businessAlertBo.setAiLabelEnList(List.of(postVo.getLabelEn()));
Map<String,Object> handlerMap = new HashMap<>();
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());
result.put("panel",handlerMap);
result.put("list",alertList);
result.put("date", startTime + "~" + endTime);
resultList.add(result);
});
return resultList;
}
public static List<String> getLastSixDays() {
List<String> days = new ArrayList<>(7);
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
for (int i = 0; i < 7; i++) {
LocalDate date = currentDate.minusDays(i);
days.add(date.format(formatter));
}
return days;
}
public static void main(String[] args) {
System.out.println(getLastSixDays());
}
}

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

@ -8,6 +8,7 @@ import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.model.StatObj;
import org.dromara.business.mapper.BusinessAlertMapper;
import org.dromara.business.service.IBusinessAlertStatisticsService;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.RemoteDeptService;
import org.dromara.system.api.RemoteLabelPostService;
@ -45,6 +46,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@DubboReference
RemotePostService remotePostService;
/**
* 按照月份分类预警数量(包含权限)
* @param businessAlertBo
@ -129,7 +131,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
public List<StatObj> countPanelAlert(BusinessAlertBo businessAlertBo) {
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()));
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
LocalDate today = LocalDate.now();
businessAlertBo.setCreateTime(today.getYear()+"-"+today.getMonthValue()+"-"+today.getDayOfMonth());
businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()));
}
List<Map<String, Object>> mapList = baseMapper.countPanelAlert(businessAlertBo);
return mapList.stream()
@ -157,12 +165,15 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
public Map<String,Object> countPanelTotalAlert(BusinessAlertBo businessAlertBo) {
Map<String,Object> result = new HashMap<>();
List<String> labelList = getAiLabel(businessAlertBo.getPostCode());
businessAlertBo.setAiLabelEnList(labelList);
//2024一直到当前年份处理预警个数
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
List<String> labelList = getAiLabel(businessAlertBo.getPostCode());
businessAlertBo.setAiLabelEnList(labelList);
}
// 1、2024一直到当前年份处理预警个数
Integer totalFinishCount = baseMapper.countFromOldToCurrent(businessAlertBo);
result.put("totalFinishCount", totalFinishCount);
//今年处理率 今年的预警总数 今年处理个数
//2、今年处理率 今年的预警总数 今年处理个数
Map<String, Object> currentYearMap = baseMapper.countCurrentAlert(businessAlertBo);
// 四舍五入保留两位小数
double yearTotal = Double.parseDouble(String.valueOf(currentYearMap.get("total")));
@ -173,7 +184,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
result.put("yearFinishCount", currentYearMap.get("finishCount"));
result.put("yearRate", currentYearAverage);
//本月处理率 本月预警总数 本月处理个数
//3、本月处理率 本月预警总数 本月处理个数
Map<String, Object> monthMap = baseMapper.countMonthAlert(businessAlertBo);
// 四舍五入保留两位小数
@ -186,6 +197,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
result.put("monthFinishCount", monthMap.get("finishCount"));
result.put("monthRate", currentMonthAverage);
//4、今日预警总数 今日处理个数 今日未处理个数
Map<String, Object> dayMap = this.baseMapper.countCurrentDayAlert(businessAlertBo);
result.put("dayTotal", dayMap.get("total"));
result.put("dayFinishCount", dayMap.get("finishCount"));
result.put("dayTodo", dayMap.get("todoCount"));
return result;
}
@ -197,8 +215,11 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
public Map<String, Object> countCurrentDayAlert(BusinessAlertBo businessAlertBo) {
Map<String,Object> result = new HashMap<>();
List<String> labelList = getAiLabel(businessAlertBo.getPostCode());
businessAlertBo.setAiLabelEnList(labelList);
if (ObjectUtil.isNotEmpty(businessAlertBo.getPostCode())){
List<String> labelList = getAiLabel(businessAlertBo.getPostCode());
businessAlertBo.setAiLabelEnList(labelList);
}
Map<String, Object> dayMap = this.baseMapper.countCurrentDayAlert(businessAlertBo);
@ -252,12 +273,11 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
postVoList.forEach(postVo -> {
List<String> labelList = getAiLabel(postVo.getPostCode());
businessAlertBo.setAiLabelEnList(labelList);
Map<String, Object> dateMap = switch (businessAlertBo.getDateType()) {
case 1 -> baseMapper.countCurrentAlert(businessAlertBo);
case 2 -> baseMapper.countMonthAlert(businessAlertBo);
case 3 -> baseMapper.countCurrentDayAlert(businessAlertBo);
default -> baseMapper.countCurrentAlert(businessAlertBo);
};
List<String> monthList = getLastSixMonths();
String startTime = monthList.get(monthList.size() - 1);
String endTime = monthList.get(0);
Map<String, Object> dateMap = baseMapper.countPastYearAlert(businessAlertBo,startTime,endTime);
result.add(new StatObj(
postVo.getPostName(),
@ -291,11 +311,20 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<StatObj> statObjs = new ArrayList<>();
postVoList.forEach(postVo -> {
List<String> labelList = getAiLabel(postVo.getPostCode());
businessAlertBo.setAiLabelEnList(labelList);
Map<String,Object> rateMap = baseMapper.handlerRate(businessAlertBo,month);
StatObj statObj1 = new StatObj();
statObj1.setStatKey(postVo.getPostName());
statObj1.setStatVal(rateMap.get("avgInfo"));
if (ObjectUtil.isEmpty(labelList)){
statObj1.setStatVal(0);
}else {
businessAlertBo.setAiLabelEnList(labelList);
Map<String,Object> rateMap = baseMapper.handlerRate(businessAlertBo,month);
statObj1.setStatKey(postVo.getPostName());
if (ObjectUtil.isNotEmpty(rateMap)) {
statObj1.setStatVal(rateMap.get("avgInfo"));
}else {
statObj1.setStatVal(0);
}
}
statObjs.add(statObj1);
});
statObj.setNextStatList(statObjs);
@ -305,6 +334,83 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
return result;
}
@Override
public Map<String, Object> comprehensiveManage(BusinessAlertBo businessAlertBo) {
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
throw new ServiceException("【postCode】 岗位编码为空!");
}
Map<String,Object> result = new HashMap<>();
List<String> aiLabelList = getAiLabel(businessAlertBo.getPostCode());
businessAlertBo.setAiLabelEnList(aiLabelList);
List<String> monthList = getLastSixMonths();
String startTime = monthList.get(monthList.size() - 1);
String endTime = monthList.get(0);
List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime);
Map<String,Object> labelMap = new HashMap<>();
labelMapList.forEach(label -> {
labelMap.put(label.get("labelCn")+ "",label.get("total"));
});
//识别类型存储
result.put("label", labelMap);
//事件高发区
Long deptId = LoginHelper.getDeptId();
//获取街道信息
List<RemoteDeptVo> streetList = remoteDeptService.selectListByParentId(String.valueOf(deptId));
Map<String,Integer> streeMap = new HashMap<>();
streetList.forEach(street -> {
businessAlertBo.setDeptId(String.valueOf(street.getDeptId()));
Integer alertCount = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime);
streeMap.put(street.getDeptName(),alertCount);
});
//降序排序,取前五个
Map<String, Integer> top5Map = streeMap.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
.limit(5)
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(e1, e2) -> e1,
LinkedHashMap::new
));
result.put("streetCount", top5Map);
//处理效率top5
Map<String,Integer> streeRateMap = new HashMap<>();
streetList.forEach(street -> {
businessAlertBo.setDeptId(String.valueOf(street.getDeptId()));
Integer alertCount = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime);
if (ObjectUtil.isEmpty(alertCount)) {
streeRateMap.put(street.getDeptName(),0);
}else {
streeRateMap.put(street.getDeptName(),alertCount);
}
});
Map<String, Integer> streeRatetop5Map = streeRateMap.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
.limit(5)
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(e1, e2) -> e1,
LinkedHashMap::new
));
result.put("handlerRate", streeRatetop5Map);
return result;
}
/**
* 获取近6个月的月份集合格式yyyy-MM
*/

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

@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
<if test="param.createTime != null and param.createTime != ''">
and DATE_FORMAT(ba.create_time,'%Y-%m') = DATE_FORMAT(#{param.createTime},'%Y-%m')
and DATE_FORMAT(ba.create_time,'%Y-%m-%d') = #{param.createTime}
</if>
<if test="param.deptIdList != null and param.deptIdList.size > 0">
and ba.dept_id in
@ -387,10 +387,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY md.dept_id, md.dateMonth
</select>
<select id="countFromOldToCurrent" resultType="java.util.Map">
<select id="countFromOldToCurrent" resultType="java.lang.Integer">
select
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount,
COUNT(DISTINCT ba.id) AS total
from business_alert ba
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y') >= '2024' ]]>
@ -401,7 +400,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countCurrentAlert" resultType="java.util.Map">
select COUNT(DISTINCT ba.id) AS total,
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount
from business_alert ba
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y') = DATE_FORMAT(now(), '%Y') ]]>
@ -411,7 +410,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countMonthAlert" resultType="java.util.Map">
select COUNT(DISTINCT ba.id) AS total,
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount,
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount
from business_alert ba
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') = DATE_FORMAT(now(), '%Y-%m') ]]>
@ -430,10 +429,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="handlerRate" resultType="java.util.Map">
select
SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)) / COUNT(*) AS avgInfo
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>
</select>
<select id="countPastYearAlert" resultType="java.util.Map">
select
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount,
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount
from business_alert ba
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') <= #{endTime} ]]>
<include refid="searchSql"></include>
</select>
<select id="countAiLabel" resultType="java.util.Map">
select
COUNT(DISTINCT ba.id) AS total,
ba.label_cn labelCn,
ba.label_en labelEn
from business_alert ba
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') = DATE_FORMAT(#{month}, '%Y-%m') ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') <= #{endTime} ]]>
<include refid="searchSql"></include>
group by ba.label_cn,ba.label_en
</select>
<select id="countStreetAlert" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT ba.id) AS total
FROM business_alert ba
WHERE 1=1
and ba.dept_id IN (
WITH RECURSIVE warning_summary AS (
SELECT dept_id
FROM dk_cloud.sys_dept
WHERE dept_id = #{param.deptId}
UNION ALL
SELECT d.dept_id
FROM dk_cloud.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE d.del_flag = '0'
)
SELECT dept_id
FROM warning_summary
)
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') <= #{endTime} ]]>
<include refid="searchSql"></include>
</select>
<select id="listAlert" resultType="org.dromara.business.domain.BusinessAlert">
select
ba.*,
b.flow_status flowStatus,
b.business_id businessId,
b.id instanceId
from dk_business.business_alert ba
left join dk_workflow.flow_instance b on ba.id = b.business_id
where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') <= #{endTime} ]]>
<include refid="searchSql"></include>
order by ba.create_time desc
</select>
<select id="countStreetRateAlert" resultType="java.lang.Integer">
select
ROUND(SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)) / COUNT(*)) AS avgInfo
from business_alert ba
WHERE 1=1
and ba.dept_id IN (
WITH RECURSIVE warning_summary AS (
SELECT dept_id
FROM dk_cloud.sys_dept
WHERE dept_id = #{param.deptId}
UNION ALL
SELECT d.dept_id
FROM dk_cloud.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE d.del_flag = '0'
)
SELECT dept_id
FROM warning_summary
)
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m') <= #{endTime} ]]>
<include refid="searchSql"></include>
</select>

13
dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteLabelPostServicelmpl.java

@ -50,4 +50,17 @@ public class RemoteLabelPostServicelmpl implements RemoteLabelPostService {
}
return new ArrayList<>();
}
@Override
public List<RemoteAiLabelPostVo> getAiLabelList() {
return aiLabelPostService.getAiLabelList().stream()
.map(aiLabel -> {
RemoteAiLabelPostVo remoteAiLabelPostVo = new RemoteAiLabelPostVo();
remoteAiLabelPostVo.setLabelId(aiLabel.getLabelId());
remoteAiLabelPostVo.setLabelEn(aiLabel.getLabelEn());
remoteAiLabelPostVo.setLabelCn(aiLabel.getLabelCn());
return remoteAiLabelPostVo;
})
.collect(Collectors.toList());
}
}

15
dk-modules/system/src/main/java/org/dromara/system/dubbo/RemotePostServiceImpl.java

@ -4,13 +4,17 @@ import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.system.api.RemotePostService;
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo;
import org.dromara.system.api.domain.vo.RemotePostVo;
import org.dromara.system.domain.bo.SysPostBo;
import org.dromara.system.domain.vo.SysPostVo;
import org.dromara.system.service.ISysPostService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@RequiredArgsConstructor
@Service
@ -23,6 +27,15 @@ public class RemotePostServiceImpl implements RemotePostService {
@Override
public List<RemotePostVo> listPost() {
List<SysPostVo> sysPostVos = sysPostService.selectPostList(new SysPostBo());
return MapstructUtils.convert(sysPostVos, RemotePostVo.class);
return sysPostVos.stream()
.map(aiLabel -> {
RemotePostVo remotePostVo = new RemotePostVo();
remotePostVo.setPostId(aiLabel.getPostId());
remotePostVo.setPostName(aiLabel.getPostName());
remotePostVo.setPostCode(aiLabel.getPostCode());
return remotePostVo;
})
.collect(Collectors.toList());
}
}

3
dk-modules/system/src/main/java/org/dromara/system/mapper/AiLabelPostMapper.java

@ -19,4 +19,7 @@ public interface AiLabelPostMapper extends BaseMapperPlus<AiLabelPost, AiLabelPo
Page<AiLabelPostVo> selectAiLabelPostPage(@Param("page") Page<?> page, @Param("ew") QueryWrapper<AiLabelPost> wrapper);
List<AiLabelPostVo> queryListByLabel(@Param("postId") Long postId);
List<AiLabelPostVo> selectAiLabelPost();
}

2
dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java

@ -55,7 +55,7 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
*/
default List<SysDept> selectListByParentId(Long parentId) {
return this.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId)
.select(SysDept::getDeptId,SysDept::getDeptName)
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
}

2
dk-modules/system/src/main/java/org/dromara/system/service/IAiLabelPostService.java

@ -73,4 +73,6 @@ public interface IAiLabelPostService {
List<AiLabelPostVo> queryListByLabel(Long postId);
Boolean insertByBatchBo(AiLabelPostBindBo aiLablePostBindBo);
List<AiLabelPostVo> getAiLabelList();
}

7
dk-modules/system/src/main/java/org/dromara/system/service/impl/AiLablePostServiceImpl.java

@ -1,5 +1,7 @@
package org.dromara.system.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -160,4 +162,9 @@ public class AiLablePostServiceImpl implements IAiLabelPostService {
}
return this.baseMapper.insertBatch(resultlist);
}
@Override
public List<AiLabelPostVo> getAiLabelList() {
return ObjectUtil.isNotEmpty(this.baseMapper.selectAiLabelPost())?this.baseMapper.selectAiLabelPost(): ListUtil.empty();
}
}

4
dk-modules/system/src/main/resources/mapper/system/AiLabelPostMapper.xml

@ -11,4 +11,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT p.*,a.label_cn ,label_en FROM ai_label_post p inner JOIN ai_label a ON p.label_id = a.label_id
where p.post_id = #{postId}
</select>
<select id="selectAiLabelPost" resultType="org.dromara.system.domain.vo.AiLabelPostVo">
SELECT *,a.label_cn ,label_en FROM ai_label_post p inner JOIN ai_label a ON p.label_id = a.label_id
</select>
</mapper>

Loading…
Cancel
Save