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..fe48643 --- /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/BusinessAlertController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java index 564a09c..48dc808 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 @@ -15,6 +15,7 @@ import org.dromara.business.service.IBusinessAlertService; import org.dromara.business.utils.MinioUntil; import org.dromara.business.utils.constants.MinIOConstants; import org.dromara.common.core.domain.R; +import org.dromara.common.core.utils.DateUtils; import org.dromara.common.log.annotation.Log; import org.dromara.common.log.enums.BusinessType; import org.dromara.common.mybatis.core.page.PageQuery; @@ -106,11 +107,11 @@ public class BusinessAlertController extends BaseController { */ @Operation(summary ="ai实时流预警保存-用于演示",description = "ai实时流预警保存-用于演示") @PostMapping("/saveAlert") - public R saveAlert(@RequestBody BusinessAlertVo vo) { + public R saveAlert(@RequestBody BusinessAlertVo vo) { vo.setBusinessType(2); vo.setHandleType("verify"); BusinessAlert businessAlert = businessAlertService.addBusinessAlert(vo); - return R.ok(); + return R.ok(businessAlert); } /** @@ -118,8 +119,13 @@ public class BusinessAlertController extends BaseController { */ @Operation(summary ="预警推送-实时预警模块专用",description = "预警推送-实时预警模块专用") @GetMapping("/pushAlert") - public R pushAlert(Long alertId) { + public R pushAlert(Long alertId,String deptId,String deptName) { BusinessAlert businessAlert= businessAlertService.getBusinessAlert(alertId); + businessAlert.setDeptName(deptName); + businessAlert.setDeptId(deptId); + businessAlert.setCreateTime(new Date()); + //businessAlert.setJobName(deptName + businessAlert.getLabelCn() + DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",businessAlert.getCreateTime())); + businessAlertService.updateBusinessAlert(businessAlert); RemoteStartProcess startProcess = new RemoteStartProcess(); startProcess.setBusinessId(String.valueOf(businessAlert.getId())); startProcess.setFlowCode("alertChz"); @@ -169,11 +175,11 @@ 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) { - return R.ok(businessAlertService.listAiVerifyAlert(vo)); + public R> listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery) { + return R.ok(businessAlertService.listAiVerifyAlert(vo,pageQuery)); } 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/IBusinessAlertService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java index 5f7992b..2a82765 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java @@ -36,6 +36,8 @@ public interface IBusinessAlertService { * @return 是否新增成功 */ BusinessAlert addBusinessAlert(BusinessAlertVo param); + //用于演示 + BusinessAlert addAlert(BusinessAlert param); void addBusinessAlertList(List alertVoList); @@ -94,7 +96,10 @@ public interface IBusinessAlertService { List listHandleHistory(String lng, String lat, String createTime); Boolean transferAlert(BusinessAlertVo vo); + BusinessAlert getBusinessAlert(Long alertId); - List listAiVerifyAlert(BusinessAlertVo vo); + Boolean updateBusinessAlert(BusinessAlert businessAlert); + + TableDataInfo listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery); } 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..2f664e6 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 @@ -6,12 +6,14 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; 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 +37,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 +71,8 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { @DubboReference RemoteLabelPostService remoteLablePostService; + @Autowired + private ProjectTablePrefixConfig ptPrefix; /** * 新增预警任务 @@ -79,8 +84,24 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { public BusinessAlert addBusinessAlert(BusinessAlertVo param) { BusinessAlert alert = MapstructUtils.convert(param, BusinessAlert.class); alert.setCreateTime(new Date()); - alert.setCaseNumber(param.getCaseNumber()); - alert.setJobName(alert.getDeptName()+alert.getLabelCn()+ DateUtils.getTime()); + alert.setJobName(alert.getLabelCn()+ DateUtils.getTime()); + //创建案件号 + try { + incrementalAlertCount(alert); + } catch (Exception e) { + log.error(e.getMessage(),e); + } + this.baseMapper.insert(alert); + return alert; + } + + @Override + public BusinessAlert addAlert(BusinessAlert alert) { + alert.setCreateTime(new Date()); + if(ObjectUtil.isNull(alert.getJobName())){ + alert.setJobName(alert.getLabelCn()+ DateUtils.getTime()); + } + alert.setJobName(alert.getLabelCn()+ DateUtils.getTime()); this.baseMapper.insert(alert); return alert; } @@ -216,7 +237,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 +274,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 +312,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 +350,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 +391,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 +512,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 +536,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 +576,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 +589,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 +626,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 +677,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; @@ -668,9 +691,14 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { return this.baseMapper.selectVoList(wrapper); } - + /** + * 查询实时流待验证预警 + * @param vo + * @param pageQuery + * @return + */ @Override - public List listAiVerifyAlert(BusinessAlertVo vo) { + public TableDataInfo listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BusinessAlert::getHandleType, BusinessStatusEnum.VERIFY.getStatus()); wrapper.eq(BusinessAlert::getBusinessType, vo.getBusinessType()); @@ -678,14 +706,20 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { wrapper.eq(BusinessAlert::getDeptId, vo.getDeptId()); } - List businessAlertVos = this.baseMapper.selectVoList(wrapper); - businessAlertVos.forEach(businessAlertVo->{ + if (ObjectUtil.isNotEmpty(vo.getJobName())){ + wrapper.like(BusinessAlert::getJobName, vo.getJobName()); + } + + wrapper.orderByDesc(BusinessAlert::getCreateTime); + + IPage businessAlertVos = this.baseMapper.selectVoPage(pageQuery.build(), wrapper); + businessAlertVos.getRecords().forEach(businessAlertVo->{ URL url = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, businessAlertVo.getImages(), 3600); businessAlertVo.setImages(url.toString()); }); - return businessAlertVos; + return TableDataInfo.build(businessAlertVos); } @Override @@ -738,6 +772,22 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { }); } + /** + * 创建递归caseNumber + * @param + */ + public void incrementalAlertCount(BusinessAlert businessAlert){ + //查询当天时间有多少条预警 + Integer currentCount = this.baseMapper.selectCurrentAlertCount(DateUtils.getDate()); + //获取当天的时间戳 + String currentDate = DateUtils.getDate().replace("-",""); + + //然后0 + 个数 + 1 当前年月日 例如 202505150 total + 1 + + businessAlert.setCaseNumber(currentDate + "0" + (currentCount + 1)); + + } + public static List getLastSixDays() { List days = new ArrayList<>(7); @@ -768,7 +818,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 +834,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 { @@ -859,6 +909,11 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { return baseMapper.selectById(alertId); } + @Override + public Boolean updateBusinessAlert(BusinessAlert businessAlert) { + return baseMapper.updateById(businessAlert) > 0; + } + public static void main(String[] args) { System.out.println(getLastSixDays()); 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" + + + + + + - + + + + + + + + + + + + - + + + + + + + +