From 90fdcfc75fae6ef899a643bfc5c6bebfb32e74ba Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Tue, 20 May 2025 18:32:17 +0800 Subject: [PATCH 1/9] =?UTF-8?q?[feat]=E5=8E=BB=E6=8E=89ai=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=B5=81=E9=A2=84=E8=AD=A6=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/business/controller/BusinessAlertController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java index 564a09c..700674c 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java +++ b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java @@ -169,7 +169,7 @@ public class BusinessAlertController extends BaseController { /** * 查询实时流预警 */ - @SaCheckPermission("business:alertAi:list") +// @SaCheckPermission("business:alertAi:list") @Operation(summary ="查询实时流预警",description = "查询实时流预警") @GetMapping("/ai/verify/alert") public R> listAiVerifyAlert(BusinessAlertVo vo) { From 3842d0062989de343d72c5031699928624050ebf Mon Sep 17 00:00:00 2001 From: shizisheng Date: Tue, 20 May 2025 22:06:19 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=B8=8D=E5=90=8C=E9=A1=B9=E7=9B=AE-?= =?UTF-8?q?=E7=89=B9=E5=AE=9A=E6=95=B0=E6=8D=AE=E5=BA=93=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=8A=A8=E6=80=81=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8D=97=E9=80=9A=E5=B7=A5=E5=9C=B0/?= =?UTF-8?q?=E4=B8=B0=E5=8E=BF=E7=87=83=E6=B0=94=E9=A1=B9=E7=9B=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/ProjectTablePrefixConfig.java | 26 ++++ .../BusinessAlertStatisticsController.java | 6 + .../business/mapper/BusinessAlertMapper.java | 38 +++--- .../IBusinessAlertStatisticsService.java | 3 + .../impl/BusinessAlertServiceImpl.java | 34 ++--- .../BusinessAlertStatisticsServiceImpl.java | 61 +++++++-- .../mapper/business/BusinessAlertMapper.xml | 118 +++++++++++------- .../config/ProjectTablePrefixConfig.java | 25 ++++ .../dromara/system/mapper/SysDeptMapper.java | 3 +- .../service/impl/SysDeptServiceImpl.java | 8 +- .../resources/mapper/system/SysDeptMapper.xml | 5 +- 11 files changed, 236 insertions(+), 91 deletions(-) create mode 100644 dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java create mode 100644 dk-modules/system/src/main/java/org/dromara/system/config/ProjectTablePrefixConfig.java diff --git a/dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java b/dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java new file mode 100644 index 0000000..b8352f9 --- /dev/null +++ b/dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java @@ -0,0 +1,26 @@ +package org.dromara.business.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * szs + * 系统-表名配置 + * 多个profile环境中会查询不同表,需要处理拼接表名 ,比如 dk_business变成 w_dk_business + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "projecttableprefix") +public class ProjectTablePrefixConfig { + + @Value("${projectTablePrefix.tableBusiness:dk_business") + private String tableBusiness; + + @Value("${projectTablePrefix.tableCloud:dk_cloud") + private String tableCloud; + + @Value("${projectTablePrefix.tableWorkflow:dk_workflow") + private String tableWorkflow; +} diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java index f86da09..3db95c8 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java +++ b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java @@ -84,6 +84,12 @@ public class BusinessAlertStatisticsController extends BaseController { return R.ok(statisticsService.countPostAlert(businessAlertBo)); } + @Operation(summary="各大类全部预警数", description="各大类全部预警数") + @GetMapping(value = "/post/count/all") + public R> countPostAll(BusinessAlertBo businessAlertBo) { + return R.ok(statisticsService.countPostAllAlert(businessAlertBo)); + } + /** * 出警效率 diff --git a/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java b/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java index 97c2a2d..e2823c1 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java +++ b/dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java @@ -3,6 +3,7 @@ package org.dromara.business.mapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; +import org.dromara.business.config.ProjectTablePrefixConfig; import org.dromara.business.domain.BusinessAlert; import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.vo.BusinessAlertVo; @@ -24,12 +25,12 @@ public interface BusinessAlertMapper extends BaseMapperPlus pageBusinessAlert(@Param("page") Page page,@Param("ew") QueryWrapper ew); + Page pageBusinessAlert(@Param("page") Page page,@Param("ew") QueryWrapper ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness @DataPermission( @DataColumn(key = "deptName", value = "t.dept_id") ) - Page pageBusinessAlertHandle(@Param("page") Page page,@Param("ew") QueryWrapper ew); + Page pageBusinessAlertHandle(@Param("page") Page page,@Param("ew") QueryWrapper ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow /** * 处理中 @@ -40,34 +41,34 @@ public interface BusinessAlertMapper extends BaseMapperPlus pageAlertTodo(@Param("page") Page page,@Param("ew") QueryWrapper ew); + Page pageAlertTodo(@Param("page") Page page,@Param("ew") QueryWrapper ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow @DataPermission( @DataColumn(key = "deptName", value = "t.dept_id") ) - Page pageBusinessAlertCancel(@Param("page") Page page,@Param("ew") QueryWrapper ew); + Page pageBusinessAlertCancel(@Param("page") Page page,@Param("ew") QueryWrapper ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow @DataPermission( @DataColumn(key = "deptName", value = "t.dept_id") ) - Page pageBusinessAlertFinish(@Param("page") Page page, @Param("ew") QueryWrapper wrapper); + Page pageBusinessAlertFinish(@Param("page") Page page, @Param("ew") QueryWrapper wrapper, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness @DataPermission( @DataColumn(key = "deptName", value = "t.dept_id") ) - List listTodoAlert(@Param("ew") QueryWrapper ew); + List listTodoAlert(@Param("ew") QueryWrapper ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow List> listMonthAlert(@Param("param") BusinessAlertBo businessAlertBo); - List> listDepartAlert(@Param("param") BusinessAlertBo businessAlertBo); + List> listDepartAlert(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud List> listMonthAlertStatus(@Param("param")BusinessAlertBo businessAlertBo); - List> listDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo); + List> listDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud List> countAlertCompare(@Param("param")BusinessAlertBo businessAlertBo); @@ -89,21 +90,22 @@ public interface BusinessAlertMapper extends BaseMapperPlus> handlerRate(@Param("param") BusinessAlertBo businessAlertBo,@Param("months") List months); Map countPastYearAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); + Map countTotalAlert(@Param("param") BusinessAlertBo businessAlertBo); - List> countAiLabel(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); + List> countAiLabel(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud - List> countStreetAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList); + List> countStreetAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud - List listAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); + List listAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness - List heatList(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); - List> countStreetRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList); + List heatList(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness + List> countStreetRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud - Map streetRateTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList); + Map streetRateTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud - Map streetTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList); + Map streetTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud - List> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); + List> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud void batchUpdateDept(@Param("list") List alertVoList); @@ -112,9 +114,9 @@ public interface BusinessAlertMapper extends BaseMapperPlus listHandleHistory(@Param("lng") String lng, @Param("lat") String lat,@Param("createTime") String createTime); - List> listOneDepartAlert(@Param("param") BusinessAlertBo businessAlertBo); + List> listOneDepartAlert(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix); //@Param("tableCloud") String tableCloud - List> listOneDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo); + List> listOneDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix); //@Param("tableCloud") String tableCloud Integer selectCurrentAlertCount(@Param("currentDate") String currentDate); diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java index bac55f8..20ee211 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java @@ -38,4 +38,7 @@ public interface IBusinessAlertStatisticsService { Map listAppAlertCount(BusinessAlertBo businessAlertBo); + List countPostAllAlert(BusinessAlertBo businessAlertBo); + + } diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java index 7f06fac..b221084 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo; import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo; +import org.dromara.business.config.ProjectTablePrefixConfig; import org.dromara.business.domain.BusinessAlert; import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.vo.BusinessAlertVo; @@ -35,6 +36,7 @@ import org.dromara.system.api.domain.vo.RemoteUserVo; import org.dromara.workflow.api.RemoteWorkflowService; import org.dromara.workflow.api.domain.RemoteStartProcess; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.lang.reflect.Method; @@ -68,6 +70,8 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { @DubboReference RemoteLabelPostService remoteLablePostService; + @Autowired + private ProjectTablePrefixConfig ptPrefix; /** * 新增预警任务 @@ -216,7 +220,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { return new TableDataInfo<>(); } - Page page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper); + Page page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper, ptPrefix); try { page.getRecords().forEach(businessAlertVo->{ @@ -253,7 +257,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { wrapper.in("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus()); - Page page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper); + Page page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper, ptPrefix); try { page.getRecords().forEach(businessAlertVo->{ @@ -291,7 +295,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { wrapper.eq("t.handle_type",BusinessStatusEnum.FINISH.getStatus()); - Page page = this.baseMapper.pageBusinessAlertFinish(pageQuery.build(), wrapper); + Page page = this.baseMapper.pageBusinessAlertFinish(pageQuery.build(), wrapper, ptPrefix); try { page.getRecords().forEach(businessAlertVo->{ @@ -329,7 +333,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { wrapper.in("t.approver", remoteWorkflowService.getPermissions()); wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); - Page page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper); + Page page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper, ptPrefix); List records = page.getRecords(); if (CollUtil.isNotEmpty(records)) { @@ -370,11 +374,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { return new TableDataInfo<>(); } + String tableWorkflow = ptPrefix.getTableWorkflow(); // eg: "dk_workflow" 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)"); +// wrapper.apply(" EXISTS(select * from w_dk_workflow.flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)"); + wrapper.apply(" EXISTS(select * from "+tableWorkflow+".flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)"); - Page page = this.baseMapper.pageBusinessAlertHandle(pageQuery.build(), wrapper); + Page page = this.baseMapper.pageBusinessAlertHandle(pageQuery.build(), wrapper, ptPrefix); try { page.getRecords().forEach(businessAlertVo->{ @@ -489,7 +495,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { //查看的是总览的预警信息 if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) { - List businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); + List businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix); businessAlerts.forEach(businessAlertVo->{ if (businessAlertVo.getBusinessType() == 2){ @@ -513,7 +519,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { Map handlerMap = new HashMap<>(); - List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); + List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix); alertList.forEach(businessAlertVo->{ if (businessAlertVo.getBusinessType() == 2){ @@ -553,7 +559,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { //查看的是总览的预警信息 if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) { - List businessAlerts = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime()); + List businessAlerts = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime(), ptPrefix); Map> listMap = businessAlerts.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn)); result.putAll(listMap); return result; @@ -566,7 +572,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { return result; } businessAlertBo.setAiLabelEnList(postVoList.stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); - List alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime()); + List alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime(), ptPrefix); Map> listMap = alertList.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn)); result.putAll(listMap); return result; @@ -603,7 +609,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); - List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); + List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix); alertList.forEach(businessAlertVo->{ if (businessAlertVo.getBusinessType() == 2){ @@ -654,7 +660,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { return infoMap; } businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); - List alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime()); + List alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime(), ptPrefix); Map> listMap = alertList.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn)); infoMap.putAll(listMap); return infoMap; @@ -768,7 +774,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { wrapper.in("t.approver", remoteWorkflowService.getPermissions()); wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); - return this.baseMapper.listTodoAlert(wrapper); + return this.baseMapper.listTodoAlert(wrapper, ptPrefix); } /** @@ -784,7 +790,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { wrapper.in("t.approver", remoteWorkflowService.getPermissions()); wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); - List businessAlerts = this.baseMapper.listTodoAlert(wrapper); + List businessAlerts = this.baseMapper.listTodoAlert(wrapper, ptPrefix); BusinessAlert businessAlert = businessAlerts.stream().filter(p -> p.getId().equals(alertId)).findFirst().get(); try { diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index 16e7699..5e4be56 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; +import org.dromara.business.config.ProjectTablePrefixConfig; import org.dromara.business.domain.BusinessAlert; import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.model.StatObj; @@ -72,6 +73,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist private final IBusinessAlertService businessAlertService; + @Autowired + private ProjectTablePrefixConfig ptPrefix; + /** * 按照月份分类预警数量 * @param businessAlertBo @@ -111,12 +115,12 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist .collect(Collectors.toList()); //排除自己如果没有下级则默认使用下边的逻辑查询 if (ObjectUtil.isEmpty(remoteDeptVoList)) { - List> mapList = baseMapper.listOneDepartAlert(businessAlertBo); + List> mapList = baseMapper.listOneDepartAlert(businessAlertBo, ptPrefix); return mapList.stream().map(data -> new StatObj(data.get("deptName") + "", Long.parseLong(data.get("total") + ""),"deptId",data.get("deptId"))).collect(Collectors.toList()); } //如果有则使用这个查询 - List> mapList = baseMapper.listDepartAlert(businessAlertBo); + List> mapList = baseMapper.listDepartAlert(businessAlertBo, ptPrefix); return mapList.stream().map(data -> new StatObj(data.get("deptName") + "", Long.parseLong(data.get("total") + ""),"deptId",data.get("deptId"))).collect(Collectors.toList()); } @@ -159,7 +163,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //排除自己如果没有下级则默认使用下边的逻辑查询 if (ObjectUtil.isEmpty(remoteDeptVoList)) { - List> mapList = baseMapper.listOneDepartAlertStatus(businessAlertBo); + List> mapList = baseMapper.listOneDepartAlertStatus(businessAlertBo, ptPrefix); return mapList.stream() .map(map -> new StatObj( @@ -176,7 +180,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist } //如果有下级则使用下方方法 - List> mapList = baseMapper.listDepartAlertStatus(businessAlertBo); + List> mapList = baseMapper.listDepartAlertStatus(businessAlertBo, ptPrefix); return mapList.stream() .map(map -> new StatObj( @@ -494,6 +498,41 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist return result; } + @Override + public List countPostAllAlert(BusinessAlertBo businessAlertBo) { + + //构建查询数据权限 + createPermissions(businessAlertBo); + + //查询所有的职能岗位 + List postVoList = remotePostService.listPost(); + postVoList = postVoList.stream().filter(item -> StrUtil.equals("0",item.getStatus())).toList();//剔除禁用规则 + + List result = new ArrayList<>(); + if (ObjectUtil.isEmpty(postVoList)) { + return ListUtil.empty(); + } + + postVoList.forEach(postVo -> { + List labelList = getAiLabel(postVo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList()); + Map dateMap = new HashMap<>(); + if (ObjectUtil.isEmpty(labelList)) { + dateMap.put("todoCount",0); + dateMap.put("finishCount",0); + }else { + businessAlertBo.setAiLabelEnList(labelList); + dateMap = baseMapper.countTotalAlert(businessAlertBo); + } + result.add(new StatObj( + postVo.getPostName(), + dateMap.get("todoCount"), + dateMap.get("finishCount") + )); + }); + return result; + } + + /** * 出警效率 * @param businessAlertBo @@ -585,7 +624,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //-------------------------------------------------------识别类型事件情况-------------------------------------------- - List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); + List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime, ptPrefix); List labelStatObj = new ArrayList<>(); @@ -603,7 +642,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist List streetList = remoteDeptService.selectListByParentId(String.valueOf(deptId)); List deptIdList = streetList.stream().filter(p-> p.getParentId().equals(deptId)).map(RemoteDeptVo::getDeptId).distinct().toList(); - List> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList); + List> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix); List top5StatObj = new ArrayList<>(); @@ -616,7 +655,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //-------------------------------------------------------街道处理效率Top5-------------------------------------------- - List> streetRateTop5Map = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime,deptIdList); + List> streetRateTop5Map = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix); List streetRateTop5StatObj = new ArrayList<>(); @@ -630,7 +669,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //-------------------------------------------------------识别类型事件处理情况-------------------------------------------- //识别类型事件处理情况 - List> labelRateMap = this.baseMapper.countLabelRateAlert(businessAlertBo,startTime,endTime); + List> labelRateMap = this.baseMapper.countLabelRateAlert(businessAlertBo,startTime,endTime, ptPrefix); List labelRateStatObj = new ArrayList<>(); @@ -736,7 +775,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist } - List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); + List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime, ptPrefix); List incidentHandlerStatStat = new ArrayList<>(); @@ -750,13 +789,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //-------------------------------------------------------事件高发区-------------------------------------------- //事件高发区top1 - Map topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList); + Map topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix); keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?"":topStreet.get("deptName")); //-------------------------------------------------------处理效率-------------------------------------------- //处理效率top1 - Map topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList); + Map topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix); keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?"":topStreetRate.get("deptName")); diff --git a/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml b/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml index 8e7b549..dc1ab60 100644 --- a/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml +++ b/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml @@ -30,20 +30,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + - + + + + + + + + + + + + - + + + + + + + +