Browse Source

Merge remote-tracking branch 'origin/dev' into dev

pull/6/head
吴远 1 month ago
parent
commit
f1cdcf7e55
  1. 26
      dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java
  2. 18
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java
  3. 6
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  4. 38
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java
  5. 7
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java
  6. 3
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  7. 97
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  8. 61
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  9. 118
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml
  10. 4
      dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/MegaphoneController.java
  11. 25
      dk-modules/system/src/main/java/org/dromara/system/config/ProjectTablePrefixConfig.java
  12. 3
      dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java
  13. 8
      dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
  14. 5
      dk-modules/system/src/main/resources/mapper/system/SysDeptMapper.xml

26
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;
}

18
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.MinioUntil;
import org.dromara.business.utils.constants.MinIOConstants; import org.dromara.business.utils.constants.MinIOConstants;
import org.dromara.common.core.domain.R; 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.annotation.Log;
import org.dromara.common.log.enums.BusinessType; import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
@ -106,11 +107,11 @@ public class BusinessAlertController extends BaseController {
*/ */
@Operation(summary ="ai实时流预警保存-用于演示",description = "ai实时流预警保存-用于演示") @Operation(summary ="ai实时流预警保存-用于演示",description = "ai实时流预警保存-用于演示")
@PostMapping("/saveAlert") @PostMapping("/saveAlert")
public R saveAlert(@RequestBody BusinessAlertVo vo) { public R<BusinessAlert> saveAlert(@RequestBody BusinessAlertVo vo) {
vo.setBusinessType(2); vo.setBusinessType(2);
vo.setHandleType("verify"); vo.setHandleType("verify");
BusinessAlert businessAlert = businessAlertService.addBusinessAlert(vo); BusinessAlert businessAlert = businessAlertService.addBusinessAlert(vo);
return R.ok(); return R.ok(businessAlert);
} }
/** /**
@ -118,8 +119,13 @@ public class BusinessAlertController extends BaseController {
*/ */
@Operation(summary ="预警推送-实时预警模块专用",description = "预警推送-实时预警模块专用") @Operation(summary ="预警推送-实时预警模块专用",description = "预警推送-实时预警模块专用")
@GetMapping("/pushAlert") @GetMapping("/pushAlert")
public R pushAlert(Long alertId) { public R pushAlert(Long alertId,String deptId,String deptName) {
BusinessAlert businessAlert= businessAlertService.getBusinessAlert(alertId); 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(); RemoteStartProcess startProcess = new RemoteStartProcess();
startProcess.setBusinessId(String.valueOf(businessAlert.getId())); startProcess.setBusinessId(String.valueOf(businessAlert.getId()));
startProcess.setFlowCode("alertChz"); startProcess.setFlowCode("alertChz");
@ -169,11 +175,11 @@ public class BusinessAlertController extends BaseController {
/** /**
* 查询实时流预警 * 查询实时流预警
*/ */
@SaCheckPermission("business:alertAi:list") // @SaCheckPermission("business:alertAi:list")
@Operation(summary ="查询实时流预警",description = "查询实时流预警") @Operation(summary ="查询实时流预警",description = "查询实时流预警")
@GetMapping("/ai/verify/alert") @GetMapping("/ai/verify/alert")
public R<List<BusinessAlertVo>> listAiVerifyAlert(BusinessAlertVo vo) { public R<TableDataInfo<BusinessAlertVo>> listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery) {
return R.ok(businessAlertService.listAiVerifyAlert(vo)); return R.ok(businessAlertService.listAiVerifyAlert(vo,pageQuery));
} }

6
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)); return R.ok(statisticsService.countPostAlert(businessAlertBo));
} }
@Operation(summary="各大类全部预警数", description="各大类全部预警数")
@GetMapping(value = "/post/count/all")
public R<List<StatObj>> countPostAll(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.countPostAllAlert(businessAlertBo));
}
/** /**
* 出警效率 * 出警效率

38
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.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.dromara.business.config.ProjectTablePrefixConfig;
import org.dromara.business.domain.BusinessAlert; import org.dromara.business.domain.BusinessAlert;
import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.vo.BusinessAlertVo; import org.dromara.business.domain.vo.BusinessAlertVo;
@ -24,12 +25,12 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
@DataPermission( @DataPermission(
@DataColumn(key = "deptName", value = "t.dept_id") @DataColumn(key = "deptName", value = "t.dept_id")
) )
Page<BusinessAlert> pageBusinessAlert(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew); Page<BusinessAlert> pageBusinessAlert(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness
@DataPermission( @DataPermission(
@DataColumn(key = "deptName", value = "t.dept_id") @DataColumn(key = "deptName", value = "t.dept_id")
) )
Page<BusinessAlert> pageBusinessAlertHandle(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew); Page<BusinessAlert> pageBusinessAlertHandle(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow
/** /**
* 处理中 * 处理中
@ -40,34 +41,34 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
@DataPermission( @DataPermission(
@DataColumn(key = "deptName", value = "t.dept_id") @DataColumn(key = "deptName", value = "t.dept_id")
) )
Page<BusinessAlert> pageAlertTodo(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew); Page<BusinessAlert> pageAlertTodo(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow
@DataPermission( @DataPermission(
@DataColumn(key = "deptName", value = "t.dept_id") @DataColumn(key = "deptName", value = "t.dept_id")
) )
Page<BusinessAlert> pageBusinessAlertCancel(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew); Page<BusinessAlert> pageBusinessAlertCancel(@Param("page") Page<BusinessAlert> page,@Param("ew") QueryWrapper<BusinessAlert> ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow
@DataPermission( @DataPermission(
@DataColumn(key = "deptName", value = "t.dept_id") @DataColumn(key = "deptName", value = "t.dept_id")
) )
Page<BusinessAlert> pageBusinessAlertFinish(@Param("page") Page<BusinessAlert> page, @Param("ew") QueryWrapper<BusinessAlert> wrapper); Page<BusinessAlert> pageBusinessAlertFinish(@Param("page") Page<BusinessAlert> page, @Param("ew") QueryWrapper<BusinessAlert> wrapper, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness
@DataPermission( @DataPermission(
@DataColumn(key = "deptName", value = "t.dept_id") @DataColumn(key = "deptName", value = "t.dept_id")
) )
List<BusinessAlert> listTodoAlert(@Param("ew") QueryWrapper<BusinessAlert> ew); List<BusinessAlert> listTodoAlert(@Param("ew") QueryWrapper<BusinessAlert> ew, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness, @Param("tableWorkflow") String tableWorkflow
List<Map<String, Object>> listMonthAlert(@Param("param") BusinessAlertBo businessAlertBo); List<Map<String, Object>> listMonthAlert(@Param("param") BusinessAlertBo businessAlertBo);
List<Map<String, Object>> listDepartAlert(@Param("param") BusinessAlertBo businessAlertBo); List<Map<String, Object>> listDepartAlert(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
List<Map<String, Object>> listMonthAlertStatus(@Param("param")BusinessAlertBo businessAlertBo); List<Map<String, Object>> listMonthAlertStatus(@Param("param")BusinessAlertBo businessAlertBo);
List<Map<String, Object>> listDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo); List<Map<String, Object>> listDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
List<Map<String, Object>> countAlertCompare(@Param("param")BusinessAlertBo businessAlertBo); List<Map<String, Object>> countAlertCompare(@Param("param")BusinessAlertBo businessAlertBo);
@ -89,21 +90,22 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
List<Map<String, Object>> handlerRate(@Param("param") BusinessAlertBo businessAlertBo,@Param("months") List<String> months); List<Map<String, Object>> handlerRate(@Param("param") BusinessAlertBo businessAlertBo,@Param("months") List<String> months);
Map<String, Object> countPastYearAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); Map<String, Object> countPastYearAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
Map<String, Object> countTotalAlert(@Param("param") BusinessAlertBo businessAlertBo);
List<Map<String, Object>> countAiLabel(@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, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
List<Map<String,Object>> countStreetAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList); List<Map<String,Object>> countStreetAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
List<BusinessAlert> listAlert(@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, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness
List<BusinessAlertVo> heatList(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); List<BusinessAlertVo> heatList(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableBusiness") String tableBusiness
List<Map<String,Object>> countStreetRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList); List<Map<String,Object>> countStreetRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
Map<String, Object> streetRateTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList); Map<String, Object> streetRateTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
Map<String, Object> streetTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList); Map<String, Object> streetTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);//@Param("tableCloud") String tableCloud
List<Map<String, Object>> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime); List<Map<String, Object>> 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<BusinessAlertVo> alertVoList); void batchUpdateDept(@Param("list") List<BusinessAlertVo> alertVoList);
@ -112,9 +114,9 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
List<BusinessAlert> listHandleHistory(@Param("lng") String lng, @Param("lat") String lat,@Param("createTime") String createTime); List<BusinessAlert> listHandleHistory(@Param("lng") String lng, @Param("lat") String lat,@Param("createTime") String createTime);
List<Map<String, Object>> listOneDepartAlert(@Param("param") BusinessAlertBo businessAlertBo); List<Map<String, Object>> listOneDepartAlert(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix); //@Param("tableCloud") String tableCloud
List<Map<String, Object>> listOneDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo); List<Map<String, Object>> listOneDepartAlertStatus(@Param("param") BusinessAlertBo businessAlertBo, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix); //@Param("tableCloud") String tableCloud
Integer selectCurrentAlertCount(@Param("currentDate") String currentDate); Integer selectCurrentAlertCount(@Param("currentDate") String currentDate);

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

@ -36,6 +36,8 @@ public interface IBusinessAlertService {
* @return 是否新增成功 * @return 是否新增成功
*/ */
BusinessAlert addBusinessAlert(BusinessAlertVo param); BusinessAlert addBusinessAlert(BusinessAlertVo param);
//用于演示
BusinessAlert addAlert(BusinessAlert param);
void addBusinessAlertList(List<BusinessAlertVo> alertVoList); void addBusinessAlertList(List<BusinessAlertVo> alertVoList);
@ -94,7 +96,10 @@ public interface IBusinessAlertService {
List<BusinessAlert> listHandleHistory(String lng, String lat, String createTime); List<BusinessAlert> listHandleHistory(String lng, String lat, String createTime);
Boolean transferAlert(BusinessAlertVo vo); Boolean transferAlert(BusinessAlertVo vo);
BusinessAlert getBusinessAlert(Long alertId); BusinessAlert getBusinessAlert(Long alertId);
List<BusinessAlertVo> listAiVerifyAlert(BusinessAlertVo vo); Boolean updateBusinessAlert(BusinessAlert businessAlert);
TableDataInfo<BusinessAlertVo> listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery);
} }

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

@ -38,4 +38,7 @@ public interface IBusinessAlertStatisticsService {
Map<String, Object> listAppAlertCount(BusinessAlertBo businessAlertBo); Map<String, Object> listAppAlertCount(BusinessAlertBo businessAlertBo);
List<StatObj> countPostAllAlert(BusinessAlertBo businessAlertBo);
} }

97
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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo; import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo; 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.BusinessAlert;
import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.vo.BusinessAlertVo; 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.RemoteWorkflowService;
import org.dromara.workflow.api.domain.RemoteStartProcess; import org.dromara.workflow.api.domain.RemoteStartProcess;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -68,6 +71,8 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
@DubboReference @DubboReference
RemoteLabelPostService remoteLablePostService; RemoteLabelPostService remoteLablePostService;
@Autowired
private ProjectTablePrefixConfig ptPrefix;
/** /**
* 新增预警任务 * 新增预警任务
@ -79,8 +84,24 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
public BusinessAlert addBusinessAlert(BusinessAlertVo param) { public BusinessAlert addBusinessAlert(BusinessAlertVo param) {
BusinessAlert alert = MapstructUtils.convert(param, BusinessAlert.class); BusinessAlert alert = MapstructUtils.convert(param, BusinessAlert.class);
alert.setCreateTime(new Date()); alert.setCreateTime(new Date());
alert.setCaseNumber(param.getCaseNumber()); alert.setJobName(alert.getLabelCn()+ DateUtils.getTime());
alert.setJobName(alert.getDeptName()+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); this.baseMapper.insert(alert);
return alert; return alert;
} }
@ -216,7 +237,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return new TableDataInfo<>(); return new TableDataInfo<>();
} }
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper); Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper, ptPrefix);
try { try {
page.getRecords().forEach(businessAlertVo->{ page.getRecords().forEach(businessAlertVo->{
@ -253,7 +274,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus()); wrapper.in("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper); Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper, ptPrefix);
try { try {
page.getRecords().forEach(businessAlertVo->{ page.getRecords().forEach(businessAlertVo->{
@ -291,7 +312,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.eq("t.handle_type",BusinessStatusEnum.FINISH.getStatus()); wrapper.eq("t.handle_type",BusinessStatusEnum.FINISH.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertFinish(pageQuery.build(), wrapper); Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertFinish(pageQuery.build(), wrapper, ptPrefix);
try { try {
page.getRecords().forEach(businessAlertVo->{ page.getRecords().forEach(businessAlertVo->{
@ -329,7 +350,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.approver", remoteWorkflowService.getPermissions()); wrapper.in("t.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper); Page<BusinessAlert> page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper, ptPrefix);
List<BusinessAlert> records = page.getRecords(); List<BusinessAlert> records = page.getRecords();
if (CollUtil.isNotEmpty(records)) { if (CollUtil.isNotEmpty(records)) {
@ -370,11 +391,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return new TableDataInfo<>(); return new TableDataInfo<>();
} }
String tableWorkflow = ptPrefix.getTableWorkflow(); // eg: "dk_workflow"
wrapper.notIn("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus()); wrapper.notIn("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus());
wrapper.apply(" EXISTS(select * from dk_workflow.flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)"); // 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<BusinessAlert> page = this.baseMapper.pageBusinessAlertHandle(pageQuery.build(), wrapper); Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertHandle(pageQuery.build(), wrapper, ptPrefix);
try { try {
page.getRecords().forEach(businessAlertVo->{ page.getRecords().forEach(businessAlertVo->{
@ -489,7 +512,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
//查看的是总览的预警信息 //查看的是总览的预警信息
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) { if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
List<BusinessAlert> businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); List<BusinessAlert> businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix);
businessAlerts.forEach(businessAlertVo->{ businessAlerts.forEach(businessAlertVo->{
if (businessAlertVo.getBusinessType() == 2){ if (businessAlertVo.getBusinessType() == 2){
@ -513,7 +536,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
Map<String,Object> handlerMap = new HashMap<>(); Map<String,Object> handlerMap = new HashMap<>();
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix);
alertList.forEach(businessAlertVo->{ alertList.forEach(businessAlertVo->{
if (businessAlertVo.getBusinessType() == 2){ if (businessAlertVo.getBusinessType() == 2){
@ -553,7 +576,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
//查看的是总览的预警信息 //查看的是总览的预警信息
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) { if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
List<BusinessAlertVo> businessAlerts = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime()); List<BusinessAlertVo> businessAlerts = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime(), ptPrefix);
Map<String, List<BusinessAlertVo>> listMap = businessAlerts.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn)); Map<String, List<BusinessAlertVo>> listMap = businessAlerts.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn));
result.putAll(listMap); result.putAll(listMap);
return result; return result;
@ -566,7 +589,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return result; return result;
} }
businessAlertBo.setAiLabelEnList(postVoList.stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); businessAlertBo.setAiLabelEnList(postVoList.stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<BusinessAlertVo> alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime()); List<BusinessAlertVo> alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime(), ptPrefix);
Map<String, List<BusinessAlertVo>> listMap = alertList.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn)); Map<String, List<BusinessAlertVo>> listMap = alertList.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn));
result.putAll(listMap); result.putAll(listMap);
return result; return result;
@ -603,7 +626,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix);
alertList.forEach(businessAlertVo->{ alertList.forEach(businessAlertVo->{
if (businessAlertVo.getBusinessType() == 2){ if (businessAlertVo.getBusinessType() == 2){
@ -654,7 +677,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return infoMap; return infoMap;
} }
businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<BusinessAlertVo> alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime()); List<BusinessAlertVo> alertList = this.baseMapper.heatList(businessAlertBo, businessAlertBo.getStartTime(), businessAlertBo.getEndTime(), ptPrefix);
Map<String, List<BusinessAlertVo>> listMap = alertList.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn)); Map<String, List<BusinessAlertVo>> listMap = alertList.stream().collect(Collectors.groupingBy(BusinessAlertVo::getLabelCn));
infoMap.putAll(listMap); infoMap.putAll(listMap);
return infoMap; return infoMap;
@ -668,9 +691,14 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return this.baseMapper.selectVoList(wrapper); return this.baseMapper.selectVoList(wrapper);
} }
/**
* 查询实时流待验证预警
* @param vo
* @param pageQuery
* @return
*/
@Override @Override
public List<BusinessAlertVo> listAiVerifyAlert(BusinessAlertVo vo) { public TableDataInfo<BusinessAlertVo> listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery) {
LambdaQueryWrapper<BusinessAlert> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BusinessAlert> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BusinessAlert::getHandleType, BusinessStatusEnum.VERIFY.getStatus()); wrapper.eq(BusinessAlert::getHandleType, BusinessStatusEnum.VERIFY.getStatus());
wrapper.eq(BusinessAlert::getBusinessType, vo.getBusinessType()); wrapper.eq(BusinessAlert::getBusinessType, vo.getBusinessType());
@ -678,14 +706,20 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.eq(BusinessAlert::getDeptId, vo.getDeptId()); wrapper.eq(BusinessAlert::getDeptId, vo.getDeptId());
} }
List<BusinessAlertVo> businessAlertVos = this.baseMapper.selectVoList(wrapper); if (ObjectUtil.isNotEmpty(vo.getJobName())){
businessAlertVos.forEach(businessAlertVo->{ wrapper.like(BusinessAlert::getJobName, vo.getJobName());
}
wrapper.orderByDesc(BusinessAlert::getCreateTime);
IPage<BusinessAlertVo> businessAlertVos = this.baseMapper.selectVoPage(pageQuery.build(), wrapper);
businessAlertVos.getRecords().forEach(businessAlertVo->{
URL url = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, businessAlertVo.getImages(), 3600); URL url = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, businessAlertVo.getImages(), 3600);
businessAlertVo.setImages(url.toString()); businessAlertVo.setImages(url.toString());
}); });
return businessAlertVos; return TableDataInfo.build(businessAlertVos);
} }
@Override @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<String> getLastSixDays() { public static List<String> getLastSixDays() {
List<String> days = new ArrayList<>(7); List<String> days = new ArrayList<>(7);
@ -768,7 +818,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.approver", remoteWorkflowService.getPermissions()); wrapper.in("t.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); 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.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
List<BusinessAlert> businessAlerts = this.baseMapper.listTodoAlert(wrapper); List<BusinessAlert> businessAlerts = this.baseMapper.listTodoAlert(wrapper, ptPrefix);
BusinessAlert businessAlert = businessAlerts.stream().filter(p -> p.getId().equals(alertId)).findFirst().get(); BusinessAlert businessAlert = businessAlerts.stream().filter(p -> p.getId().equals(alertId)).findFirst().get();
try { try {
@ -859,6 +909,11 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return baseMapper.selectById(alertId); return baseMapper.selectById(alertId);
} }
@Override
public Boolean updateBusinessAlert(BusinessAlert businessAlert) {
return baseMapper.updateById(businessAlert) > 0;
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(getLastSixDays()); System.out.println(getLastSixDays());

61
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.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.business.config.ProjectTablePrefixConfig;
import org.dromara.business.domain.BusinessAlert; import org.dromara.business.domain.BusinessAlert;
import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.model.StatObj; import org.dromara.business.domain.model.StatObj;
@ -72,6 +73,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
private final IBusinessAlertService businessAlertService; private final IBusinessAlertService businessAlertService;
@Autowired
private ProjectTablePrefixConfig ptPrefix;
/** /**
* 按照月份分类预警数量 * 按照月份分类预警数量
* @param businessAlertBo * @param businessAlertBo
@ -111,12 +115,12 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
.collect(Collectors.toList()); .collect(Collectors.toList());
//排除自己如果没有下级则默认使用下边的逻辑查询 //排除自己如果没有下级则默认使用下边的逻辑查询
if (ObjectUtil.isEmpty(remoteDeptVoList)) { if (ObjectUtil.isEmpty(remoteDeptVoList)) {
List<Map<String, Object>> mapList = baseMapper.listOneDepartAlert(businessAlertBo); List<Map<String, Object>> 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()); return mapList.stream().map(data -> new StatObj(data.get("deptName") + "", Long.parseLong(data.get("total") + ""),"deptId",data.get("deptId"))).collect(Collectors.toList());
} }
//如果有则使用这个查询 //如果有则使用这个查询
List<Map<String, Object>> mapList = baseMapper.listDepartAlert(businessAlertBo); List<Map<String, Object>> 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()); 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)) { if (ObjectUtil.isEmpty(remoteDeptVoList)) {
List<Map<String, Object>> mapList = baseMapper.listOneDepartAlertStatus(businessAlertBo); List<Map<String, Object>> mapList = baseMapper.listOneDepartAlertStatus(businessAlertBo, ptPrefix);
return mapList.stream() return mapList.stream()
.map(map -> new StatObj( .map(map -> new StatObj(
@ -176,7 +180,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
} }
//如果有下级则使用下方方法 //如果有下级则使用下方方法
List<Map<String, Object>> mapList = baseMapper.listDepartAlertStatus(businessAlertBo); List<Map<String, Object>> mapList = baseMapper.listDepartAlertStatus(businessAlertBo, ptPrefix);
return mapList.stream() return mapList.stream()
.map(map -> new StatObj( .map(map -> new StatObj(
@ -494,6 +498,41 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
return result; return result;
} }
@Override
public List<StatObj> countPostAllAlert(BusinessAlertBo businessAlertBo) {
//构建查询数据权限
createPermissions(businessAlertBo);
//查询所有的职能岗位
List<RemotePostVo> postVoList = remotePostService.listPost();
postVoList = postVoList.stream().filter(item -> StrUtil.equals("0",item.getStatus())).toList();//剔除禁用规则
List<StatObj> result = new ArrayList<>();
if (ObjectUtil.isEmpty(postVoList)) {
return ListUtil.empty();
}
postVoList.forEach(postVo -> {
List<String> labelList = getAiLabel(postVo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList());
Map<String, Object> 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 * @param businessAlertBo
@ -585,7 +624,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------识别类型事件情况-------------------------------------------- //-------------------------------------------------------识别类型事件情况--------------------------------------------
List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime, ptPrefix);
List<StatObj> labelStatObj = new ArrayList<>(); List<StatObj> labelStatObj = new ArrayList<>();
@ -603,7 +642,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List<RemoteDeptVo> streetList = remoteDeptService.selectListByParentId(String.valueOf(deptId)); List<RemoteDeptVo> streetList = remoteDeptService.selectListByParentId(String.valueOf(deptId));
List<Long> deptIdList = streetList.stream().filter(p-> p.getParentId().equals(deptId)).map(RemoteDeptVo::getDeptId).distinct().toList(); List<Long> deptIdList = streetList.stream().filter(p-> p.getParentId().equals(deptId)).map(RemoteDeptVo::getDeptId).distinct().toList();
List<Map<String,Object>> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList); List<Map<String,Object>> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix);
List<StatObj> top5StatObj = new ArrayList<>(); List<StatObj> top5StatObj = new ArrayList<>();
@ -616,7 +655,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------街道处理效率Top5-------------------------------------------- //-------------------------------------------------------街道处理效率Top5--------------------------------------------
List<Map<String,Object>> streetRateTop5Map = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime,deptIdList); List<Map<String,Object>> streetRateTop5Map = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix);
List<StatObj> streetRateTop5StatObj = new ArrayList<>(); List<StatObj> streetRateTop5StatObj = new ArrayList<>();
@ -630,7 +669,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------识别类型事件处理情况-------------------------------------------- //-------------------------------------------------------识别类型事件处理情况--------------------------------------------
//识别类型事件处理情况 //识别类型事件处理情况
List<Map<String,Object>> labelRateMap = this.baseMapper.countLabelRateAlert(businessAlertBo,startTime,endTime); List<Map<String,Object>> labelRateMap = this.baseMapper.countLabelRateAlert(businessAlertBo,startTime,endTime, ptPrefix);
List<StatObj> labelRateStatObj = new ArrayList<>(); List<StatObj> labelRateStatObj = new ArrayList<>();
@ -736,7 +775,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
} }
List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime, ptPrefix);
List<StatObj> incidentHandlerStatStat = new ArrayList<>(); List<StatObj> incidentHandlerStatStat = new ArrayList<>();
@ -750,13 +789,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------事件高发区-------------------------------------------- //-------------------------------------------------------事件高发区--------------------------------------------
//事件高发区top1 //事件高发区top1
Map<String,Object> topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList); Map<String,Object> topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix);
keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?"":topStreet.get("deptName")); keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?"":topStreet.get("deptName"));
//-------------------------------------------------------处理效率-------------------------------------------- //-------------------------------------------------------处理效率--------------------------------------------
//处理效率top1 //处理效率top1
Map<String,Object> topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList); Map<String,Object> topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList, ptPrefix);
keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?"":topStreetRate.get("deptName")); keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?"":topStreetRate.get("deptName"));

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

@ -30,20 +30,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</sql> </sql>
<!-- w_dk_business-->
<select id="pageBusinessAlert" resultType="org.dromara.business.domain.BusinessAlert"> <select id="pageBusinessAlert" resultType="org.dromara.business.domain.BusinessAlert">
select t.* from (select select t.* from (select
ba.* ba.*
from dk_business.business_alert ba) t from ${tbPrefix.tableBusiness}.business_alert ba) t
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>
<!-- w_dk_business-->
<select id="pageBusinessAlertFinish" resultType="org.dromara.business.domain.BusinessAlert"> <select id="pageBusinessAlertFinish" resultType="org.dromara.business.domain.BusinessAlert">
select t.* from (select select t.* from (select
ba.* ba.*
from dk_business.business_alert ba) t from ${tbPrefix.tableBusiness}.business_alert ba) t
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>
<!-- w_dk_business-->
<!-- w_dk_workflow-->
<select id="pageBusinessAlertCancel" resultType="org.dromara.business.domain.BusinessAlert"> <select id="pageBusinessAlertCancel" resultType="org.dromara.business.domain.BusinessAlert">
select t.* from ( select t.* from (
select select
@ -51,12 +55,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.flow_status flowStatus, b.flow_status flowStatus,
b.business_id businessId, b.business_id businessId,
b.id instanceId b.id instanceId
from dk_business.business_alert ba from ${tbPrefix.tableBusiness}.business_alert ba
inner join dk_workflow.flow_instance b on ba.id = b.business_id inner join ${tbPrefix.tableWorkflow}.flow_instance b on ba.id = b.business_id
) t ) t
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>
<!-- w_dk_business-->
<!-- w_dk_workflow-->
<select id="pageBusinessAlertHandle" resultType="org.dromara.business.domain.BusinessAlert"> <select id="pageBusinessAlertHandle" resultType="org.dromara.business.domain.BusinessAlert">
select t.* from ( select t.* from (
select select
@ -64,15 +70,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.flow_status flowStatus, b.flow_status flowStatus,
b.business_id businessId, b.business_id businessId,
b.id instanceId b.id instanceId
from dk_business.business_alert ba from ${tbPrefix.tableBusiness}.business_alert ba
inner join dk_workflow.flow_instance b on ba.id = b.business_id inner join ${tbPrefix.tableWorkflow}.flow_instance b on ba.id = b.business_id
where where
b.del_flag = '0' b.del_flag = '0'
) t ) t
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>
<!-- w_dk_business-->
<!-- w_dk_workflow-->
<select id="pageAlertTodo" resultType="org.dromara.business.domain.BusinessAlert"> <select id="pageAlertTodo" resultType="org.dromara.business.domain.BusinessAlert">
select t.* from ( select t.* from (
select select
@ -85,16 +92,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.node_type, a.node_type,
fnData.buttonPermission, fnData.buttonPermission,
fnData.permissions fnData.permissions
from dk_business.business_alert ba from ${tbPrefix.tableBusiness}.business_alert ba
inner join dk_workflow.flow_instance b on ba.id = b.business_id inner join ${tbPrefix.tableWorkflow}.flow_instance b on ba.id = b.business_id
left join dk_workflow.flow_task a on a.instance_id = b.id left join ${tbPrefix.tableWorkflow}.flow_task a on a.instance_id = b.id
left join dk_workflow.flow_user uu on uu.associated = a.id left join ${tbPrefix.tableWorkflow}.flow_user uu on uu.associated = a.id
left join dk_workflow.flow_definition c on a.definition_id = c.id left join ${tbPrefix.tableWorkflow}.flow_definition c on a.definition_id = c.id
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
SELECT SELECT
JSON_UNQUOTE(JSON_EXTRACT(fn.ext, '$[0].value')) AS buttonPermission, JSON_UNQUOTE(JSON_EXTRACT(fn.ext, '$[0].value')) AS buttonPermission,
fn.permissions fn.permissions
FROM dk_workflow.flow_node fn FROM ${tbPrefix.tableWorkflow}.flow_node fn
WHERE WHERE
fn.node_code = b.node_code fn.node_code = b.node_code
and fn.definition_id = c.id and fn.definition_id = c.id
@ -159,6 +166,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="searchSql"></include> <include refid="searchSql"></include>
</select> </select>
<!-- w_dk_cloud-->
<select id="listDepartAlert" resultType="java.util.Map"> <select id="listDepartAlert" resultType="java.util.Map">
WITH RECURSIVE sub_depts AS ( WITH RECURSIVE sub_depts AS (
SELECT SELECT
@ -167,13 +175,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id, parent_id,
tenant_id tenant_id
FROM FROM
dk_cloud.sys_dept ${tbPrefix.tableCloud}.sys_dept
<where> <where>
<if test="param.deptId != null and param.deptId != ''"> <if test="param.deptId != null and param.deptId != ''">
parent_id = #{param.deptId} parent_id = #{param.deptId}
</if> </if>
<if test="param.deptId == null or param.deptId == ''"> <if test="param.deptId == null or param.deptId == ''">
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') parent_id in (select dsd.dept_id from ${tbPrefix.tableCloud}.sys_dept dsd where dsd.parent_id = '0')
</if> </if>
</where> </where>
UNION ALL UNION ALL
@ -184,7 +192,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.parent_id, d.parent_id,
d.tenant_id d.tenant_id
FROM FROM
dk_cloud.sys_dept d ${tbPrefix.tableCloud}.sys_dept d
INNER JOIN sub_depts st ON d.parent_id = st.dept_id INNER JOIN sub_depts st ON d.parent_id = st.dept_id
), ),
-- 获取直接子部门(用于最终显示) -- 获取直接子部门(用于最终显示)
@ -195,13 +203,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id, parent_id,
tenant_id tenant_id
FROM FROM
dk_cloud.sys_dept ${tbPrefix.tableCloud}.sys_dept
<where> <where>
<if test="param.deptId != null and param.deptId != ''"> <if test="param.deptId != null and param.deptId != ''">
parent_id = #{param.deptId} parent_id = #{param.deptId}
</if> </if>
<if test="param.deptId == null or param.deptId == ''"> <if test="param.deptId == null or param.deptId == ''">
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') parent_id in (select dsd.dept_id from ${tbPrefix.tableCloud}.sys_dept dsd where dsd.parent_id = '0')
</if> </if>
</where> </where>
), ),
@ -248,6 +256,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY m.dateMonth ORDER BY m.dateMonth
</select> </select>
<!-- w_dk_cloud-->
<select id="listDepartAlertStatus" resultType="java.util.Map"> <select id="listDepartAlertStatus" resultType="java.util.Map">
WITH RECURSIVE sub_depts AS ( WITH RECURSIVE sub_depts AS (
SELECT SELECT
@ -256,13 +265,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id, parent_id,
tenant_id tenant_id
FROM FROM
dk_cloud.sys_dept ${tbPrefix.tableCloud}.sys_dept
<where> <where>
<if test="param.deptId != null and param.deptId != ''"> <if test="param.deptId != null and param.deptId != ''">
parent_id = #{param.deptId} parent_id = #{param.deptId}
</if> </if>
<if test="param.deptId == null or param.deptId == ''"> <if test="param.deptId == null or param.deptId == ''">
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') parent_id in (select dsd.dept_id from ${tbPrefix.tableCloud}.sys_dept dsd where dsd.parent_id = '0')
</if> </if>
</where> </where>
UNION ALL UNION ALL
@ -273,7 +282,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.parent_id, d.parent_id,
d.tenant_id d.tenant_id
FROM FROM
dk_cloud.sys_dept d ${tbPrefix.tableCloud}.sys_dept d
INNER JOIN sub_depts st ON d.parent_id = st.dept_id INNER JOIN sub_depts st ON d.parent_id = st.dept_id
), ),
-- 获取直接子部门(用于最终显示) -- 获取直接子部门(用于最终显示)
@ -284,13 +293,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id, parent_id,
tenant_id tenant_id
FROM FROM
dk_cloud.sys_dept ${tbPrefix.tableCloud}.sys_dept
<where> <where>
<if test="param.deptId != null and param.deptId != ''"> <if test="param.deptId != null and param.deptId != ''">
parent_id = #{param.deptId} parent_id = #{param.deptId}
</if> </if>
<if test="param.deptId == null or param.deptId == ''"> <if test="param.deptId == null or param.deptId == ''">
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') parent_id in (select dsd.dept_id from ${tbPrefix.tableCloud}.sys_dept dsd where dsd.parent_id = '0')
</if> </if>
</where> </where>
), ),
@ -515,10 +524,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="searchSql"></include> <include refid="searchSql"></include>
</select> </select>
<select id="countTotalAlert" 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
<include refid="searchSql"></include>
</select>
<!-- w_dk_cloud-->
<select id="countAiLabel" resultType="java.util.Map"> <select id="countAiLabel" resultType="java.util.Map">
WITH warning_summary AS ( WITH warning_summary AS (
SELECT al.label_cn, al.label_en SELECT al.label_cn, al.label_en
FROM dk_cloud.ai_label al where al.label_en in FROM ${tbPrefix.tableCloud}.ai_label al where al.label_en in
<foreach collection="param.aiLabelEnList" item="item" open="(" close=")" separator=","> <foreach collection="param.aiLabelEnList" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
@ -543,6 +562,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ws.label_en ws.label_en
</select> </select>
<!-- w_dk_cloud-->
<select id="countStreetAlert" resultType="java.util.Map"> <select id="countStreetAlert" resultType="java.util.Map">
WITH RECURSIVE warning_summary AS ( WITH RECURSIVE warning_summary AS (
SELECT SELECT
@ -551,7 +571,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dept_id, dept_id,
dept_name dept_name
FROM FROM
dk_cloud.sys_dept ${tbPrefix.tableCloud}.sys_dept
WHERE dept_id IN WHERE dept_id IN
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")"> <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
@ -563,7 +583,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.dept_id, d.dept_id,
d.dept_name d.dept_name
FROM FROM
dk_cloud.sys_dept d ${tbPrefix.tableCloud}.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE WHERE
d.del_flag = '0' d.del_flag = '0'
@ -586,6 +606,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 5 LIMIT 5
</select> </select>
<!-- w_dk_business-->
<select id="listAlert" resultType="org.dromara.business.domain.BusinessAlert"> <select id="listAlert" resultType="org.dromara.business.domain.BusinessAlert">
select select
ba.label_en labelEn, ba.label_en labelEn,
@ -596,7 +617,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ba.business_type businessType, ba.business_type businessType,
ba.lat, ba.lat,
ba.lng ba.lng
from dk_business.business_alert ba from ${tbPrefix.tableBusiness}.business_alert ba
where 1=1 where 1=1
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') >= #{startTime} ]]> and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]> and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]>
@ -604,6 +625,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by ba.create_time desc order by ba.create_time desc
</select> </select>
<!-- w_dk_cloud-->
<select id="countStreetRateAlert" resultType="java.util.Map"> <select id="countStreetRateAlert" resultType="java.util.Map">
WITH RECURSIVE warning_summary AS ( WITH RECURSIVE warning_summary AS (
SELECT SELECT
@ -612,7 +634,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dept_id, dept_id,
dept_name dept_name
FROM FROM
dk_cloud.sys_dept ${tbPrefix.tableCloud}.sys_dept
WHERE dept_id IN WHERE dept_id IN
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")"> <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
@ -624,7 +646,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.dept_id, d.dept_id,
d.dept_name d.dept_name
FROM FROM
dk_cloud.sys_dept d ${tbPrefix.tableCloud}.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE WHERE
d.del_flag = '0' d.del_flag = '0'
@ -652,6 +674,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 5 LIMIT 5
</select> </select>
<!-- w_dk_cloud-->
<select id="streetRateTopAlert" resultType="java.util.Map"> <select id="streetRateTopAlert" resultType="java.util.Map">
WITH RECURSIVE warning_summary AS ( WITH RECURSIVE warning_summary AS (
SELECT SELECT
@ -659,7 +682,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dept_name AS root_dept_name, dept_name AS root_dept_name,
dept_id, dept_id,
dept_name dept_name
FROM dk_cloud.sys_dept FROM ${tbPrefix.tableCloud}.sys_dept
WHERE dept_id IN WHERE dept_id IN
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")"> <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
@ -670,7 +693,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.root_dept_name, dt.root_dept_name,
d.dept_id, d.dept_id,
d.dept_name d.dept_name
FROM dk_cloud.sys_dept d FROM ${tbPrefix.tableCloud}.sys_dept d
JOIN warning_summary dt JOIN warning_summary dt
ON d.parent_id = dt.dept_id ON d.parent_id = dt.dept_id
WHERE d.del_flag = '0' WHERE d.del_flag = '0'
@ -702,6 +725,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 1 LIMIT 1
</select> </select>
<!-- w_dk_cloud-->
<select id="streetTopAlert" resultType="java.util.Map"> <select id="streetTopAlert" resultType="java.util.Map">
WITH RECURSIVE warning_summary AS ( WITH RECURSIVE warning_summary AS (
SELECT SELECT
@ -709,7 +733,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dept_name AS root_dept_name, dept_name AS root_dept_name,
dept_id, dept_id,
dept_name dept_name
FROM dk_cloud.sys_dept FROM ${tbPrefix.tableCloud}.sys_dept
WHERE dept_id IN WHERE dept_id IN
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")"> <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
@ -720,7 +744,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.root_dept_name, dt.root_dept_name,
d.dept_id, d.dept_id,
d.dept_name d.dept_name
FROM dk_cloud.sys_dept d FROM ${tbPrefix.tableCloud}.sys_dept d
JOIN warning_summary dt JOIN warning_summary dt
ON d.parent_id = dt.dept_id ON d.parent_id = dt.dept_id
WHERE d.del_flag = '0' WHERE d.del_flag = '0'
@ -748,14 +772,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 1; LIMIT 1;
</select> </select>
<!-- w_dk_cloud-->
<select id="countLabelRateAlert" resultType="java.util.Map"> <select id="countLabelRateAlert" resultType="java.util.Map">
WITH warning_summary AS ( WITH warning_summary AS (
SELECT SELECT
al.label_cn, al.label_cn,
al.label_en al.label_en
FROM FROM
dk_cloud.ai_label al ${tbPrefix.tableCloud}.ai_label al
WHERE WHERE
al.label_en IN al.label_en IN
<foreach collection="param.aiLabelEnList" item="item" open="(" close=")" separator=","> <foreach collection="param.aiLabelEnList" item="item" open="(" close=")" separator=",">
@ -812,6 +836,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="searchSql"></include> <include refid="searchSql"></include>
</select> </select>
<!-- w_dk_business-->
<!-- w_dk_workflow-->
<select id="listTodoAlert" resultType="org.dromara.business.domain.BusinessAlert"> <select id="listTodoAlert" resultType="org.dromara.business.domain.BusinessAlert">
select t.* from ( select t.* from (
select select
@ -824,16 +850,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.node_type, a.node_type,
fnData.buttonPermission, fnData.buttonPermission,
fnData.permissions fnData.permissions
from dk_business.business_alert ba from ${tbPrefix.tableBusiness}.business_alert ba
inner join dk_workflow.flow_instance b on ba.id = b.business_id inner join ${tbPrefix.tableWorkflow}.flow_instance b on ba.id = b.business_id
left join dk_workflow.flow_task a on a.instance_id = b.id left join ${tbPrefix.tableWorkflow}.flow_task a on a.instance_id = b.id
left join dk_workflow.flow_user uu on uu.associated = a.id left join ${tbPrefix.tableWorkflow}.flow_user uu on uu.associated = a.id
left join dk_workflow.flow_definition c on a.definition_id = c.id left join ${tbPrefix.tableWorkflow}.flow_definition c on a.definition_id = c.id
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
SELECT SELECT
JSON_UNQUOTE(JSON_EXTRACT(fn.ext, '$[0].value')) AS buttonPermission, JSON_UNQUOTE(JSON_EXTRACT(fn.ext, '$[0].value')) AS buttonPermission,
fn.permissions fn.permissions
FROM dk_workflow.flow_node fn FROM ${tbPrefix.tableWorkflow}.flow_node fn
WHERE WHERE
fn.node_code = b.node_code fn.node_code = b.node_code
and fn.definition_id = c.id and fn.definition_id = c.id
@ -858,19 +884,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY create_time desc ORDER BY create_time desc
</select> </select>
<!-- w_dk_cloud-->
<select id="listOneDepartAlert" resultType="java.util.Map"> <select id="listOneDepartAlert" resultType="java.util.Map">
SELECT SELECT
dc.dept_id AS deptId, dc.dept_id AS deptId,
dc.dept_name AS deptName, dc.dept_name AS deptName,
COALESCE(COUNT(ba.id), 0) AS total COALESCE(COUNT(ba.id), 0) AS total
FROM FROM
(select dept_id,dept_name from dk_cloud.sys_dept sd where sd.dept_id = #{param.deptId}) dc (select dept_id,dept_name from ${tbPrefix.tableCloud}.sys_dept sd where sd.dept_id = #{param.deptId}) dc
LEFT JOIN business_alert ba ON ba.dept_id = dc.dept_id LEFT JOIN business_alert ba ON ba.dept_id = dc.dept_id
<include refid="searchSql"></include> <include refid="searchSql"></include>
GROUP BY GROUP BY
dc.dept_id,dc.dept_name dc.dept_id,dc.dept_name
</select> </select>
<!-- w_dk_cloud-->
<select id="listOneDepartAlertStatus" resultType="java.util.Map"> <select id="listOneDepartAlertStatus" resultType="java.util.Map">
SELECT SELECT
dc.dept_id AS deptId, dc.dept_id AS deptId,
@ -880,12 +908,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL(SUM(ba.handle_type = 'finish'), 0) AS finishCount, IFNULL(SUM(ba.handle_type = 'finish'), 0) AS finishCount,
IFNULL(SUM(ba.handle_type = 'cancel'), 0) AS cancelCount IFNULL(SUM(ba.handle_type = 'cancel'), 0) AS cancelCount
FROM FROM
(select dept_id,dept_name from dk_cloud.sys_dept sd where sd.dept_id = #{param.deptId}) dc (select dept_id,dept_name from ${tbPrefix.tableCloud}.sys_dept sd where sd.dept_id = #{param.deptId}) dc
LEFT JOIN business_alert ba ON ba.dept_id = dc.dept_id LEFT JOIN business_alert ba ON ba.dept_id = dc.dept_id
<include refid="searchSql"></include> <include refid="searchSql"></include>
GROUP BY GROUP BY
dc.dept_id,dc.dept_name dc.dept_id,dc.dept_name
</select> </select>
<!-- w_dk_business-->
<select id="heatList" resultType="org.dromara.business.domain.vo.BusinessAlertVo"> <select id="heatList" resultType="org.dromara.business.domain.vo.BusinessAlertVo">
SELECT SELECT
temp.label_en AS labelEn, temp.label_en AS labelEn,
@ -899,7 +929,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ba.label_en, ba.label_en,
ba.label_cn ba.label_cn
FROM FROM
dk_business.business_alert ba ${tbPrefix.tableBusiness}.business_alert ba
GROUP BY GROUP BY
ba.label_en, ba.label_cn ba.label_en, ba.label_cn
) temp ) temp

4
dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/MegaphoneController.java

@ -303,6 +303,8 @@ public class MegaphoneController {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("labelEn",type); map.put("labelEn",type);
map.put("deviceSn",objectMap.get("deviceSn")); map.put("deviceSn",objectMap.get("deviceSn"));
map.put("jobId",objectMap.get("jobId"));
map.put("jobName",objectMap.get("jobName"));
StreamTypeDTO param1 = Convert.convert(StreamTypeDTO.class, map); StreamTypeDTO param1 = Convert.convert(StreamTypeDTO.class, map);
gatewayPublish.publish(topTow,new CommonTopicRequest<>() gatewayPublish.publish(topTow,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(param1)),1); .setData(Objects.requireNonNull(param1)),1);
@ -347,6 +349,8 @@ public class MegaphoneController {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("labelEn",type); map.put("labelEn",type);
map.put("deviceSn",objectMap.get("deviceSn")); map.put("deviceSn",objectMap.get("deviceSn"));
map.put("jobId",objectMap.get("jobId"));
map.put("jobName",objectMap.get("jobName"));
StreamTypeDTO param1 = Convert.convert(StreamTypeDTO.class, map); StreamTypeDTO param1 = Convert.convert(StreamTypeDTO.class, map);
gatewayPublish.publish(topTow,new CommonTopicRequest<>() gatewayPublish.publish(topTow,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(param1)),1); .setData(Objects.requireNonNull(param1)),1);

25
dk-modules/system/src/main/java/org/dromara/system/config/ProjectTablePrefixConfig.java

@ -0,0 +1,25 @@
package org.dromara.system.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* 系统-表名配置
* 多个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;
}

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

@ -8,6 +8,7 @@ import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission; import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.common.mybatis.helper.DataBaseHelper; import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.system.config.ProjectTablePrefixConfig;
import org.dromara.system.domain.SysDept; import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.vo.SysDeptVo; import org.dromara.system.domain.vo.SysDeptVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -72,5 +73,5 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
List<Map<String,Object>> getNamePathList(); List<Map<String,Object>> getNamePathList();
List<SysDeptVo> listTreeDept(@Param("deptId") Long deptId); List<SysDeptVo> listTreeDept(@Param("deptId") Long deptId, @Param("tbPrefix") ProjectTablePrefixConfig tbPrefix);
} }

8
dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java

@ -8,6 +8,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.core.constant.CacheNames; import org.dromara.common.core.constant.CacheNames;
import org.dromara.common.core.constant.SystemConstants; import org.dromara.common.core.constant.SystemConstants;
@ -21,6 +22,7 @@ import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.common.redis.utils.CacheUtils; import org.dromara.common.redis.utils.CacheUtils;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.domain.vo.RemoteDeptVo; import org.dromara.system.api.domain.vo.RemoteDeptVo;
import org.dromara.system.config.ProjectTablePrefixConfig;
import org.dromara.system.domain.SysDept; import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.SysRole; import org.dromara.system.domain.SysRole;
import org.dromara.system.domain.SysUser; import org.dromara.system.domain.SysUser;
@ -30,6 +32,7 @@ import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysRoleMapper; import org.dromara.system.mapper.SysRoleMapper;
import org.dromara.system.mapper.SysUserMapper; import org.dromara.system.mapper.SysUserMapper;
import org.dromara.system.service.ISysDeptService; import org.dromara.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -52,6 +55,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
private final SysRoleMapper roleMapper; private final SysRoleMapper roleMapper;
private final SysUserMapper userMapper; private final SysUserMapper userMapper;
@Autowired
private ProjectTablePrefixConfig ptPrefix;
/** /**
* 查询部门管理数据 * 查询部门管理数据
* *
@ -383,7 +389,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
@Override @Override
public List<SysDeptVo> listTreeDept(Long deptId) { public List<SysDeptVo> listTreeDept(Long deptId) {
return baseMapper.listTreeDept(deptId); return baseMapper.listTreeDept(deptId, ptPrefix); //.getTableCloud()
} }
} }

5
dk-modules/system/src/main/resources/mapper/system/SysDeptMapper.xml

@ -84,19 +84,20 @@
deptId deptId
</select> </select>
<!-- w_dk_cloud-->
<select id="listTreeDept" resultType="org.dromara.system.domain.vo.SysDeptVo"> <select id="listTreeDept" resultType="org.dromara.system.domain.vo.SysDeptVo">
WITH RECURSIVE warning_summary AS ( WITH RECURSIVE warning_summary AS (
SELECT SELECT
sd1.* sd1.*
FROM FROM
dk_cloud.sys_dept sd1 ${tbPrefix.tableCloud}.sys_dept sd1
WHERE WHERE
dept_id = #{deptId} dept_id = #{deptId}
UNION ALL UNION ALL
SELECT SELECT
d.* d.*
FROM FROM
dk_cloud.sys_dept d ${tbPrefix.tableCloud}.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE WHERE
d.del_flag = '0' d.del_flag = '0'

Loading…
Cancel
Save