袁强 1 month ago
parent
commit
3d1239ea10
  1. 26
      dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java
  2. 2
      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. 3
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  6. 34
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  7. 61
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  8. 118
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml
  9. 9
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/DeviceEntity.java
  10. 8
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java
  11. 1
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SDKDeviceService.java
  12. 4
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/controller/WaylineJobController.java
  13. 25
      dk-modules/system/src/main/java/org/dromara/system/config/ProjectTablePrefixConfig.java
  14. 3
      dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java
  15. 8
      dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
  16. 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;
}

2
dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java

@ -172,7 +172,7 @@ public class BusinessAlertController extends BaseController {
/**
* 查询实时流预警
*/
@SaCheckPermission("business:alertAi:list")
// @SaCheckPermission("business:alertAi:list")
@Operation(summary ="查询实时流预警",description = "查询实时流预警")
@GetMapping("/ai/verify/alert")
public R<List<BusinessAlertVo>> listAiVerifyAlert(BusinessAlertVo vo) {

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));
}
@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.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<BusinessAlert, Busin
@DataPermission(
@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(
@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(
@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(
@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(
@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(
@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>> 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>> 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);
@ -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);
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<Map<String,Object>> countStreetRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList);
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, @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);
@ -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<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);

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);
List<StatObj> countPostAllAlert(BusinessAlertBo businessAlertBo);
}

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

@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo;
import org.dromara.business.config.ProjectTablePrefixConfig;
import org.dromara.business.domain.BusinessAlert;
import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.vo.BusinessAlertVo;
@ -35,6 +36,7 @@ import org.dromara.system.api.domain.vo.RemoteUserVo;
import org.dromara.workflow.api.RemoteWorkflowService;
import org.dromara.workflow.api.domain.RemoteStartProcess;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
@ -68,6 +70,8 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
@DubboReference
RemoteLabelPostService remoteLablePostService;
@Autowired
private ProjectTablePrefixConfig ptPrefix;
/**
* 新增预警任务
@ -216,7 +220,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return new TableDataInfo<>();
}
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper);
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper, ptPrefix);
try {
page.getRecords().forEach(businessAlertVo->{
@ -253,7 +257,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper);
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper, ptPrefix);
try {
page.getRecords().forEach(businessAlertVo->{
@ -291,7 +295,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.eq("t.handle_type",BusinessStatusEnum.FINISH.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertFinish(pageQuery.build(), wrapper);
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertFinish(pageQuery.build(), wrapper, ptPrefix);
try {
page.getRecords().forEach(businessAlertVo->{
@ -329,7 +333,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
Page<BusinessAlert> page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper);
Page<BusinessAlert> page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper, ptPrefix);
List<BusinessAlert> records = page.getRecords();
if (CollUtil.isNotEmpty(records)) {
@ -370,11 +374,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return new TableDataInfo<>();
}
String tableWorkflow = ptPrefix.getTableWorkflow(); // eg: "dk_workflow"
wrapper.notIn("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus());
wrapper.apply(" EXISTS(select * from dk_workflow.flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)");
// wrapper.apply(" EXISTS(select * from w_dk_workflow.flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)");
wrapper.apply(" EXISTS(select * from "+tableWorkflow+".flow_his_task ht where ht.approver ='" + LoginHelper.getUserId() + "' and ht.instance_id = t.instanceId)");
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertHandle(pageQuery.build(), wrapper);
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertHandle(pageQuery.build(), wrapper, ptPrefix);
try {
page.getRecords().forEach(businessAlertVo->{
@ -489,7 +495,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
//查看的是总览的预警信息
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
List<BusinessAlert> businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
List<BusinessAlert> businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix);
businessAlerts.forEach(businessAlertVo->{
if (businessAlertVo.getBusinessType() == 2){
@ -513,7 +519,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
Map<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->{
if (businessAlertVo.getBusinessType() == 2){
@ -553,7 +559,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
//查看的是总览的预警信息
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));
result.putAll(listMap);
return result;
@ -566,7 +572,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return result;
}
businessAlertBo.setAiLabelEnList(postVoList.stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<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));
result.putAll(listMap);
return result;
@ -603,7 +609,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime, ptPrefix);
alertList.forEach(businessAlertVo->{
if (businessAlertVo.getBusinessType() == 2){
@ -654,7 +660,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return infoMap;
}
businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<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));
infoMap.putAll(listMap);
return infoMap;
@ -768,7 +774,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
return this.baseMapper.listTodoAlert(wrapper);
return this.baseMapper.listTodoAlert(wrapper, ptPrefix);
}
/**
@ -784,7 +790,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.in("t.approver", remoteWorkflowService.getPermissions());
wrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
List<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();
try {

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.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<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());
}
//如果有则使用这个查询
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());
}
@ -159,7 +163,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//排除自己如果没有下级则默认使用下边的逻辑查询
if (ObjectUtil.isEmpty(remoteDeptVoList)) {
List<Map<String, Object>> mapList = baseMapper.listOneDepartAlertStatus(businessAlertBo);
List<Map<String, Object>> mapList = baseMapper.listOneDepartAlertStatus(businessAlertBo, ptPrefix);
return mapList.stream()
.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()
.map(map -> new StatObj(
@ -494,6 +498,41 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
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
@ -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<>();
@ -603,7 +642,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
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<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<>();
@ -616,7 +655,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------街道处理效率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<>();
@ -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<>();
@ -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<>();
@ -750,13 +789,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
//-------------------------------------------------------事件高发区--------------------------------------------
//事件高发区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"));
//-------------------------------------------------------处理效率--------------------------------------------
//处理效率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"));

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

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

9
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/DeviceEntity.java

@ -92,4 +92,13 @@ public class DeviceEntity implements Serializable {
@TableField(value = "pro_id")
private Integer proId;
@TableField(value = "latitude")
private Float latitude;
@TableField(value = "longitude")
private Float longitude;
@TableField(value = "height")
private Float height;
}

8
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java

@ -423,13 +423,16 @@ public class DeviceServiceImpl implements IDeviceService {
.firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE)
.videoId(dockVideoId)
.proId(ObjectUtil.isNotEmpty(entity.getProId())?entity.getProId():null)
.latitude(entity.getLatitude())
.longitude(entity.getLongitude())
.height(entity.getHeight())
.thingVersion(entity.getVersion()).build();
} catch (CloudSDKException e) {
log.error(e.getLocalizedMessage() + "Entity: {}", entity);
}
DeviceDTO deviceDTO = builder.build();
if(deviceDTO.getDomain() != null && deviceDTO.getDomain().getDomain() == 3 && deviceDTO.getLatitude() != null){
Optional<OsdDockDrone> deviceOsd = deviceRedisService.getDeviceOsd(entity.getDeviceSn(), OsdDockDrone.class);
Optional<OsdDock> deviceOsd = deviceRedisService.getDeviceOsd(entity.getDeviceSn(), OsdDock.class);
if(!deviceOsd.isEmpty()){
deviceDTO.setLatitude(deviceOsd.get().getLatitude());
deviceDTO.setLongitude(deviceOsd.get().getLongitude());
@ -748,6 +751,9 @@ public class DeviceServiceImpl implements IDeviceService {
.compatibleStatus(dto.getFirmwareStatus() == null ? null :
DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != dto.getFirmwareStatus())
.deviceDesc(dto.getDeviceDesc())
.latitude(dto.getLatitude())
.longitude(dto.getLongitude())
.height(dto.getHeight())
.proId(dto.getProId() == null ? null : dto.getProId())
.build();
}

1
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SDKDeviceService.java

@ -167,6 +167,7 @@ public class SDKDeviceService extends AbstractDeviceService {
&& ((deviceOpt.get().getLatitude() == null && deviceOpt.get().getLongitude() == null)) || (request.getData().getLatitude() != deviceOpt.get().getLatitude() && request.getData().getLongitude() != deviceOpt.get().getLongitude())){
deviceOpt.get().setLatitude(request.getData().getLatitude());
deviceOpt.get().setLongitude(request.getData().getLongitude());
deviceOpt.get().setHeight(request.getData().getHeight());
deviceRedisService.setDeviceOnline(deviceOpt.get());
deviceService.updateDevice(deviceOpt.get());
}

4
dk-modules/sample/src/main/java/org/dromara/sample/wayline/controller/WaylineJobController.java

@ -133,8 +133,8 @@ public class WaylineJobController {
public HttpResultResponse getJobIdByDeviceSn(@PathVariable(name = "workspace_id") String workspaceId,
@RequestParam(name = "device_sn") String deviceSn, HttpServletRequest req, HttpServletResponse rsp) {
Optional<EventsReceiver<FlighttaskProgress>> runningWaylineJob = waylineRedisService.getRunningWaylineJob(deviceSn);
if(runningWaylineJob.isEmpty())HttpResultResponse.error("不存在");
return HttpResultResponse.success(runningWaylineJob.get().getOutput().getExt().getFlightId()==null?runningWaylineJob.get().getOutput().getExt().getFlightId():null);
if(runningWaylineJob.isEmpty())return HttpResultResponse.error("不存在");
return HttpResultResponse.success(runningWaylineJob.get().getOutput().getExt().getFlightId()!=null?runningWaylineJob.get().getOutput().getExt().getFlightId():null);
}
@GetMapping("/{workspace_id}/getJobFileUrlByDeviceSn")

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.core.mapper.BaseMapperPlus;
import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.system.config.ProjectTablePrefixConfig;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.vo.SysDeptVo;
import org.apache.ibatis.annotations.Param;
@ -72,5 +73,5 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
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.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.constant.CacheNames;
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.satoken.utils.LoginHelper;
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.SysRole;
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.SysUserMapper;
import org.dromara.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@ -52,6 +55,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
private final SysRoleMapper roleMapper;
private final SysUserMapper userMapper;
@Autowired
private ProjectTablePrefixConfig ptPrefix;
/**
* 查询部门管理数据
*
@ -383,7 +389,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
@Override
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
</select>
<!-- w_dk_cloud-->
<select id="listTreeDept" resultType="org.dromara.system.domain.vo.SysDeptVo">
WITH RECURSIVE warning_summary AS (
SELECT
sd1.*
FROM
dk_cloud.sys_dept sd1
${tbPrefix.tableCloud}.sys_dept sd1
WHERE
dept_id = #{deptId}
UNION ALL
SELECT
d.*
FROM
dk_cloud.sys_dept d
${tbPrefix.tableCloud}.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE
d.del_flag = '0'

Loading…
Cancel
Save