Compare commits

...

74 Commits

Author SHA1 Message Date
袁强 b00159d492 Merge pull request 'dev' (#6) from dev into test 4 weeks ago
李克 b626ee65f3 推流接口 1 month ago
吴远 7fdf677a8a 取消负载控制验证 1 month ago
时子升 8e383badf3 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
时子升 f3b0e734e8 预警信息扩展-提交预警记录+文件 1 month ago
吴远 b011937260 Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
吴远 b27068b3a2 取消负载控制验证 1 month ago
时子升 343163f500 驭光算法-克隆版 1 month ago
袁强 852db5c9fc 提交:演示测试 1 month ago
吴远 210ccbec1b 取消负载控制验证 1 month ago
吴远 52c60b63b7 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
吴远 5eab033669 取消负载控制验证 1 month ago
袁强 b729f33c01 提交 1 month ago
袁强 2efece6054 提交:演示流程修改 1 month ago
吴远 94b291c967 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
吴远 f9a167cd64 取消负载控制验证 1 month ago
袁强 0f261990f8 提交:无人机自动飞行逻辑修改 1 month ago
吴远 00b94b21a7 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
吴远 edf2421452 取消负载控制验证 1 month ago
李克 7e3fbe05ba 推流接口 1 month ago
袁强 0be8b2fb90 提交 1 month ago
吴远 f1cdcf7e55 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
吴远 0f425dd451 取消负载控制验证 1 month ago
袁强 1cd95b2073 提交 1 month ago
李克 d223adbef5 推流接口 1 month ago
袁强 53856e06d8 提交 1 month ago
杨威 a30fa0eace [feat]修改实时流预警增加分页查询&修改推送逻辑增加页面选择部门提交&增加查询降序排序② 1 month ago
杨威 8659c2cfae [feat]修改实时流预警增加分页查询&修改推送逻辑增加页面选择部门提交① 1 month ago
杨威 3490a6efdf [feat]修改实时流预警增加分页查询&修改推送逻辑增加页面选择部门提交 1 month ago
袁强 3d1239ea10 Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
袁强 7748ed2f74 [bug]实时预警接口-新增部门 1 month ago
时子升 3842d00629 不同项目-特定数据库查询加入动态配置,处理南通工地/丰县燃气项目。 1 month ago
杨威 eadc252337 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
杨威 90fdcfc75f [feat]去掉ai实时流预警权限 1 month ago
吴远 344d15a734 Merge remote-tracking branch 'origin/dev' into dev 1 month ago
吴远 96233bb44e 取消负载控制验证 1 month ago
杨威 188fa5595d [feat]修改ai实时流预警推送 1 month ago
袁强 f1856400cc Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
袁强 3e713dc9ce [bug]实时预警接口 1 month ago
杨威 5a88dc5b6d Merge remote-tracking branch 'origin/dev' into dev 1 month ago
杨威 bbf2dc57d0 [feat]修改预警统计查询 1 month ago
吴远 731faee877 取消负载控制验证 1 month ago
李克 fe95340e68 推流接口 1 month ago
李克 5d7223be75 推流接口 1 month ago
李克 bfa2ea542a Merge remote-tracking branch 'origin/dev' into dev 1 month ago
李克 175de6bb82 推流接口 1 month ago
吴远 28b616b5bf Merge remote-tracking branch 'origin/dev' into dev 1 month ago
吴远 38ae466a5a 改动 1 month ago
杨威 1685c8892f [feat]增加ai实时流预警列表查询 1 month ago
袁强 3615d66873 ai预警平台推送用户 1 month ago
吴远 fcdbbd0683 Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
袁强 90d3ef685e Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
袁强 045159043f [bug]实时预警接口 1 month ago
杨威 f17a1432c1 [feat]修改生成案件号 1 month ago
吴远 3a6821b572 改动 1 month ago
吴远 08343e9e51 Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
吴远 64df39fdd2 改动 1 month ago
吴远 8e8f5cbffb Merge branch 'wuyuan' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone into dev 1 month ago
吴远 1f43d62910 改动 2 months ago
吴远 ec7d7da18f 改动 2 months ago
吴远 1cf4aa57f3 1 2 months ago
吴远 579001a1a8 Merge branch 'wuyuan' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone 2 months ago
吴远 d51c1bfb40 Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone 2 months ago
袁强 60dd87a197 Merge pull request 'test' (#3) from test into master 2 months ago
吴远 97895d4aef Merge branch 'dev' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone 2 months ago
吴远 38758ec5b7 Merge branch 'master' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone 2 months ago
吴远 6095947d8f Merge branch 'master' of http://106.13.50.125:13000/yuanqiang/dk_cloud_drone 2 months ago
吴远 fc55fa0267 改动 2 months ago
吴远 0f8f8603ba 改动 2 months ago
杨威 16b741290d [feat] 2 months ago
杨威 648fad0e8a [feat] 2 months ago
杨威 7321f972b0 [feat] 2 months ago
袁强 6e16e0a2bb 提交:图片比对修改 2 months ago
杨威 a17dc254d5 [feat] 2 months ago
  1. 3
      dk-api/api-business/src/main/java/org/dromara/business/api/RemoteBusinessAlertService.java
  2. 85
      dk-api/api-business/src/main/java/org/dromara/business/api/domain/vo/RemoteBusinessAlertConstructInfo.java
  3. 4
      dk-api/api-business/src/main/java/org/dromara/business/api/domain/vo/RemoteBusinessAlertVo.java
  4. 3
      dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/cloudapi/media/api/IHttpMediaService.java
  5. 14
      dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/cloudapi/wayline/api/IHttpWaylineService.java
  6. 3
      dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/Dock2ThingVersionEnum.java
  7. 2
      dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/Dock3ThingVersionEnum.java
  8. 2
      dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/DockThingVersionEnum.java
  9. 2
      dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/DroneThingVersionEnum.java
  10. 26
      dk-modules/business/src/main/java/org/dromara/business/config/ProjectTablePrefixConfig.java
  11. 106
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertConstructInfoController.java
  12. 78
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertController.java
  13. 7
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  14. 5
      dk-modules/business/src/main/java/org/dromara/business/domain/BusinessAlert.java
  15. 86
      dk-modules/business/src/main/java/org/dromara/business/domain/BusinessAlertConstructInfo.java
  16. 87
      dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertConstructInfoBo.java
  17. 104
      dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertConstructInfoVo.java
  18. 4
      dk-modules/business/src/main/java/org/dromara/business/dubbo/RemoteBusinessAlertServiceImpl.java
  19. 15
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertConstructInfoMapper.java
  20. 38
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java
  21. 69
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertConstructInfoService.java
  22. 10
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java
  23. 3
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  24. 138
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertConstructInfoServiceImpl.java
  25. 178
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  26. 61
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  27. 183
      dk-modules/business/src/main/java/org/dromara/business/utils/MinioUtil.java
  28. 7
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertConstructInfoMapper.xml
  29. 142
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml
  30. 2
      dk-modules/sample/src/main/java/org/dromara/sample/control/service/IControlService.java
  31. 59
      dk-modules/sample/src/main/java/org/dromara/sample/control/service/impl/ControlServiceImpl.java
  32. 2
      dk-modules/sample/src/main/java/org/dromara/sample/control/service/impl/PayloadCommandsHandler.java
  33. 1
      dk-modules/sample/src/main/java/org/dromara/sample/control/service/impl/SDKControlService.java
  34. 38
      dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java
  35. 59
      dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/MegaphoneController.java
  36. 77
      dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/SampleEngineRecordController.java
  37. 9
      dk-modules/sample/src/main/java/org/dromara/sample/manage/mapper/ISampleEngineRecordMapper.java
  38. 15
      dk-modules/sample/src/main/java/org/dromara/sample/manage/mapper/ITaskJobMapper.java
  39. 18
      dk-modules/sample/src/main/java/org/dromara/sample/manage/mapper/SampleWarningRecordMapper.java
  40. 212
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/BusinessAlertVo.java
  41. 2
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/DeviceDTO.java
  42. 2
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/DeviceQrtzDTO.java
  43. 30
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/EngineType.java
  44. 30
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/EngineTypeResponse.java
  45. 9
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/DeviceEntity.java
  46. 33
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/TaskJobEntity.java
  47. 18
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/WarningRecordEntity.java
  48. 2
      dk-modules/sample/src/main/java/org/dromara/sample/manage/model/param/DeviceQueryParam.java
  49. 4
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/IDeviceService.java
  50. 9
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/ISampleEngineRecordService.java
  51. 8
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/ISampleWarningRecordService.java
  52. 15
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/ITaskJobService.java
  53. 106
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceQrtzServiceImpl.java
  54. 46
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java
  55. 4
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/LiveStreamServiceImpl.java
  56. 14
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SDKDeviceService.java
  57. 250
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java
  58. 15
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleWarningRecordServiceImpl.java
  59. 44
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/TaskJobServiceImpl.java
  60. 14
      dk-modules/sample/src/main/java/org/dromara/sample/media/controller/FileController.java
  61. 4
      dk-modules/sample/src/main/java/org/dromara/sample/media/controller/MediaController.java
  62. 3
      dk-modules/sample/src/main/java/org/dromara/sample/media/model/MediaFileEntity.java
  63. 8
      dk-modules/sample/src/main/java/org/dromara/sample/media/service/IFileService.java
  64. 2
      dk-modules/sample/src/main/java/org/dromara/sample/media/service/IMediaService.java
  65. 43
      dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/FileServiceImpl.java
  66. 19
      dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/MediaServiceImpl.java
  67. 183
      dk-modules/sample/src/main/java/org/dromara/sample/utils/MinioUtil.java
  68. 29
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/controller/WaylineFileController.java
  69. 35
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/controller/WaylineJobController.java
  70. 2
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/dto/WaylineFileDTO.java
  71. 3
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/dto/WaylineJobDTO.java
  72. 2
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/entity/WaylineFileEntity.java
  73. 3
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/entity/WaylineJobEntity.java
  74. 9
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/IWaylineFileService.java
  75. 4
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/IWaylineJobService.java
  76. 123
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/AiCompareServiceImpl.java
  77. 20
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/FlightTaskServiceImpl.java
  78. 15
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/SDKWaylineService.java
  79. 53
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/WaylineFileServiceImpl.java
  80. 37
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/WaylineJobServiceImpl.java
  81. 6
      dk-modules/sample/src/main/resources/mapper/DeviceQrtzMapper.xml
  82. 54
      dk-modules/sample/src/main/resources/mapper/IDeviceProMapper.xml
  83. 25
      dk-modules/system/src/main/java/org/dromara/system/config/ProjectTablePrefixConfig.java
  84. 17
      dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteNoticeServiceImpl.java
  85. 3
      dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java
  86. 8
      dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
  87. 5
      dk-modules/system/src/main/resources/mapper/system/SysDeptMapper.xml

3
dk-api/api-business/src/main/java/org/dromara/business/api/RemoteBusinessAlertService.java

@ -16,8 +16,9 @@ public interface RemoteBusinessAlertService {
/**
* 生成预警待验证状态
* activeProfile :用于处理南通/丰县数据类型 default是原始处理流如果非default就会将businessType处理为2
*/
Boolean saveBusinessAlert(List<RemoteBusinessAlertVo> alertVoList);
Boolean saveBusinessAlert(List<RemoteBusinessAlertVo> alertVoList,String activeProfile);
/**
* 更新此条预警审批时候的状态
* @param businessId 业务id(预警工单)

85
dk-api/api-business/src/main/java/org/dromara/business/api/domain/vo/RemoteBusinessAlertConstructInfo.java

@ -0,0 +1,85 @@
package org.dromara.business.api.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 预警任务-施工信息对象 business_alert_construct_info
*
* @author szs
* @date 2025-05-21
*/
@Data
public class RemoteBusinessAlertConstructInfo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
private String tenantId;
/**
* 1:图片比对预警 2AI实时预警
*/
private Long businessType;
/**
* job任务id
*/
private String jobId;
/**
* 预警名称
*/
private String jobName;
/**
* 预警任务id
*/
private Long businessAlertId;
/**
* 施工名称
*/
private String constructName;
/**
* 施工单位
*/
private String constructDept;
/**
* 施工单位负责人
*/
private String constructLeader;
/**
* 联系电话
*/
private String phonenumber;
/**
* 施工地址
*/
private String address;
/**
* 所属管道
*/
private String pipeline;
/**
* 备注
*/
private String remark;
}

4
dk-api/api-business/src/main/java/org/dromara/business/api/domain/vo/RemoteBusinessAlertVo.java

@ -189,5 +189,9 @@ public class RemoteBusinessAlertVo implements Serializable {
*/
private Integer handleSource;
//预警扩展施工信息
private RemoteBusinessAlertConstructInfo remoteAlertConstructInfo;
// private Map<String,Object> infoMap;
}

3
dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/cloudapi/media/api/IHttpMediaService.java

@ -70,9 +70,10 @@ public interface IHttpMediaService {
value = "{\"code\": 0, \"message\":\"success\", \"data\": \"media/DJI_20220831151616_0004_W_Waypoint4.JPG\"}"
)})))
@PostMapping(PREFIX + "/workspaces/{workspace_id}/upload-callback")
@PostMapping(PREFIX + "/workspaces/{workspace_id}/{pro_id}/upload-callback")
HttpResultResponse<String> mediaUploadCallback(
@PathVariable(name = "workspace_id") String workspaceId,
@PathVariable(name = "pro_id") Integer proId,
@Valid @RequestBody MediaUploadCallbackRequest request,
HttpServletRequest req, HttpServletResponse rsp);

14
dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/cloudapi/wayline/api/IHttpWaylineService.java

@ -45,9 +45,21 @@ public interface IHttpWaylineService {
@Parameter(name = "workspace_id", description = "workspace_id", schema = @Schema(format = "uuid"))
})
@GetMapping(PREFIX + "/workspaces/{workspace_id}/waylines")
HttpResultResponse<PaginationData<GetWaylineListResponse>> getWaylineList(
HttpResultResponse<PaginationData<GetWaylineListResponse>> getWaylines(
@Valid @ParameterObject GetWaylineListRequest request,
@PathVariable(name = "workspace_id") String workspaceId,
@RequestParam(name = "proIds",required = false) List<Integer> proIds,
HttpServletRequest req, HttpServletResponse rsp);
@Operation(summary = "获取航线路线列表", description = "根据查询条件査询路线文件的基本数据。飞行员中的查询条件字段是固定的。",
parameters = {
@Parameter(name = "workspace_id", description = "workspace_id", schema = @Schema(format = "uuid"))
})
@GetMapping(PREFIX + "/workspaces/{workspace_id}/waylinesList")
HttpResultResponse<List<GetWaylineListResponse>> getWaylineList(
@PathVariable(name = "workspace_id") String workspaceId,
@RequestParam(name = "pro_id",required = false) Integer proId,
HttpServletRequest req, HttpServletResponse rsp);
/**

3
dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/Dock2ThingVersionEnum.java

@ -12,6 +12,7 @@ import java.util.Arrays;
*/
public enum Dock2ThingVersionEnum implements IThingVersion {
V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1),
V1_1_0("1.1.0", CloudSDKVersionEnum.V1_0_0),
@ -24,6 +25,8 @@ public enum Dock2ThingVersionEnum implements IThingVersion {
V1_2_3("1.2.3", CloudSDKVersionEnum.V1_0_3),
V1_2_4("1.2.4", CloudSDKVersionEnum.V1_0_3),
V1_3_0("1.3.0", CloudSDKVersionEnum.V1_0_3),

2
dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/Dock3ThingVersionEnum.java

@ -24,6 +24,8 @@ public enum Dock3ThingVersionEnum implements IThingVersion {
V1_2_3("1.2.3", CloudSDKVersionEnum.V1_0_3),
V1_2_4("1.2.4", CloudSDKVersionEnum.V1_0_3),
V1_3_0("1.3.0", CloudSDKVersionEnum.V1_0_3),
V1_3_1("1.3.1", CloudSDKVersionEnum.V1_0_3),

2
dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/DockThingVersionEnum.java

@ -24,6 +24,8 @@ public enum DockThingVersionEnum implements IThingVersion {
V1_2_3("1.2.3", CloudSDKVersionEnum.V1_0_3),
V1_2_4("1.2.4", CloudSDKVersionEnum.V1_0_3),
V1_3_0("1.3.0", CloudSDKVersionEnum.V1_0_3),
V1_3_1("1.3.1", CloudSDKVersionEnum.V1_0_3),

2
dk-common/common-cloudsdk/src/main/java/org/dromara/common/sdk/config/version/DroneThingVersionEnum.java

@ -27,6 +27,8 @@ public enum DroneThingVersionEnum implements IThingVersion {
V1_2_3("1.2.3", CloudSDKVersionEnum.V1_0_3),
V1_2_4("1.2.4", CloudSDKVersionEnum.V1_0_3),
V1_3_0("1.3.0", CloudSDKVersionEnum.V1_0_3),
V1_3_1("1.3.1", CloudSDKVersionEnum.V1_3_1),

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

106
dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertConstructInfoController.java

@ -0,0 +1,106 @@
package org.dromara.business.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo;
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo;
import org.dromara.business.service.IBusinessAlertConstructInfoService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
/**
* 预警任务-施工信息
* 前端访问路由地址为:/business/alertConstructInfo
*
* @author szs
* @date 2025-05-21
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/alertConstructInfo")
public class BusinessAlertConstructInfoController extends BaseController {
private final IBusinessAlertConstructInfoService businessAlertConstructInfoService;
/**
* 查询预警任务-施工信息列表
*/
@SaCheckPermission("business:businessAlertConstructInfo:list")
@GetMapping("/list")
public TableDataInfo<BusinessAlertConstructInfoVo> list(BusinessAlertConstructInfoBo bo, PageQuery pageQuery) {
return businessAlertConstructInfoService.queryPageList(bo, pageQuery);
}
/**
* 导出预警任务-施工信息列表
*/
@SaCheckPermission("business:businessAlertConstructInfo:export")
@Log(title = "预警任务-施工信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(BusinessAlertConstructInfoBo bo, HttpServletResponse response) {
List<BusinessAlertConstructInfoVo> list = businessAlertConstructInfoService.queryList(bo);
ExcelUtil.exportExcel(list, "预警任务-施工信息", BusinessAlertConstructInfoVo.class, response);
}
/**
* 获取预警任务-施工信息详细信息
*
* @param id 主键
*/
@SaCheckPermission("business:businessAlertConstructInfo:query")
@GetMapping("/{id}")
public R<BusinessAlertConstructInfoVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(businessAlertConstructInfoService.queryById(id));
}
/**
* 新增预警任务-施工信息
*/
@SaCheckPermission("business:businessAlertConstructInfo:add")
@Log(title = "预警任务-施工信息", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody BusinessAlertConstructInfoBo bo) {
return toAjax(businessAlertConstructInfoService.insertByBo(bo));
}
/**
* 修改预警任务-施工信息
*/
@SaCheckPermission("business:businessAlertConstructInfo:edit")
@Log(title = "预警任务-施工信息", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusinessAlertConstructInfoBo bo) {
return toAjax(businessAlertConstructInfoService.updateByBo(bo));
}
/**
* 删除预警任务-施工信息
*
* @param ids 主键串
*/
@SaCheckPermission("business:businessAlertConstructInfo:remove")
@Log(title = "预警任务-施工信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(businessAlertConstructInfoService.deleteWithValidByIds(List.of(ids), true));
}
}

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

@ -1,6 +1,8 @@
package org.dromara.business.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.client.utils.TenantUtil;
import io.swagger.v3.oas.annotations.Operation;
@ -14,6 +16,7 @@ import org.dromara.business.service.IBusinessAlertService;
import org.dromara.business.utils.MinioUntil;
import org.dromara.business.utils.constants.MinIOConstants;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
@ -105,30 +108,48 @@ public class BusinessAlertController extends BaseController {
*/
@Operation(summary ="ai实时流预警保存-用于演示",description = "ai实时流预警保存-用于演示")
@PostMapping("/saveAlert")
public R saveAlert(@RequestBody BusinessAlertVo vo) {
public R<BusinessAlert> saveAlert(@RequestBody BusinessAlert vo) {
vo.setBusinessType(2);
BusinessAlert businessAlert = businessAlertService.addBusinessAlert(vo);
vo.setHandleType("verify");
BusinessAlert businessAlert = businessAlertService.addAlert(vo);
return R.ok(businessAlert);
}
/**
* ai实时流预警保存
*/
@Operation(summary ="预警推送-实时预警模块专用",description = "预警推送-实时预警模块专用")
@GetMapping("/pushAlert")
public R pushAlert(Long alertId,@RequestParam(required = false) String deptId,@RequestParam(required = false)String deptName) {
BusinessAlert businessAlert= businessAlertService.getBusinessAlert(alertId);
if(!ObjectUtil.hasEmpty(deptId,deptName)){
businessAlert.setDeptName(deptName);
businessAlert.setDeptId(deptId);
}
businessAlert.setCreateTime(new Date());
//businessAlert.setJobName(deptName + businessAlert.getLabelCn() + DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",businessAlert.getCreateTime()));
businessAlertService.updateBusinessAlert(businessAlert);
RemoteStartProcess startProcess = new RemoteStartProcess();
startProcess.setBusinessId(String.valueOf(businessAlert.getId()));
startProcess.setFlowCode("alertChz");
remoteWorkflowService.startWorkFlowBatch(List.of(startProcess));
RemoteNoticeBo remoteNoticeBo = new RemoteNoticeBo();
remoteNoticeBo.setNoticeTitle(vo.getDeptName()+"产生预警,预警类型["+vo.getLabelCn()+"],请立即查看");
remoteNoticeBo.setNoticeTitle(businessAlert.getDeptName()+"产生预警,预警类型["+businessAlert.getLabelCn()+"],请立即查看");
remoteNoticeBo.setNoticeType("3");
remoteNoticeBo.setNoticeContent(vo.getDeptName()+"产生预警,预警类型["+vo.getLabelCn()+"],请立即查看");
remoteNoticeBo.setNoticeContent(businessAlert.getDeptName()+"产生预警,预警类型["+businessAlert.getLabelCn()+"],请立即查看");
remoteNoticeBo.setStatus("0");
remoteNoticeBo.setIsRead(0);
remoteNoticeBo.setCreateBy(1L);
remoteNoticeBo.setCreateDept(1L);
remoteNoticeBo.setCreateTime(businessAlert.getCreateTime());
if (businessAlert.getBusinessType() == 2){
businessAlert.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, vo.getImages(), 3600).toString());
businessAlert.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, businessAlert.getImages(), 3600).toString());
}
remoteNoticeBo.setDeviceSn(vo.getDeviceSn());
businessAlert.setDeviceSn(vo.getDeviceSn());
remoteNoticeBo.setDeviceSn(businessAlert.getDeviceSn());
businessAlert.setDeviceSn(businessAlert.getDeviceSn());
remoteNoticeBo.setParam(JSON.toJSONString(businessAlert));
remoteNoticeService.saveNotice(remoteNoticeBo);
remoteSubmailConfigService.remoteCmdSend("smsMultixsend", JSON.toJSONString(vo));
remoteSubmailConfigService.remoteCmdSend("smsMultixsend", JSON.toJSONString(businessAlert));
return R.ok();
}
@ -154,4 +175,45 @@ public class BusinessAlertController extends BaseController {
}
/**
* 查询实时流预警
*/
// @SaCheckPermission("business:alertAi:list")
@Operation(summary ="查询实时流预警",description = "查询实时流预警")
@GetMapping("/ai/verify/alert")
public R<TableDataInfo<BusinessAlertVo>> listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery) {
return R.ok(businessAlertService.listAiVerifyAlert(vo,pageQuery));
}
@Operation(summary ="ai实时流预警保存-用于演示",description = "ai实时流预警保存-用于演示")
@PostMapping("/saveAlert")
public R selectAlert(@RequestBody BusinessAlertVo vo) {
vo.setBusinessType(2);
BusinessAlert businessAlert = businessAlertService.addBusinessAlert(vo);
RemoteStartProcess startProcess = new RemoteStartProcess();
startProcess.setBusinessId(String.valueOf(businessAlert.getId()));
startProcess.setFlowCode("alertChz");
remoteWorkflowService.startWorkFlowBatch(List.of(startProcess));
RemoteNoticeBo remoteNoticeBo = new RemoteNoticeBo();
remoteNoticeBo.setNoticeTitle(vo.getDeptName()+"产生预警,预警类型["+vo.getLabelCn()+"],请立即查看");
remoteNoticeBo.setNoticeType("3");
remoteNoticeBo.setNoticeContent(vo.getDeptName()+"产生预警,预警类型["+vo.getLabelCn()+"],请立即查看");
remoteNoticeBo.setStatus("0");
remoteNoticeBo.setIsRead(0);
remoteNoticeBo.setCreateBy(1L);
remoteNoticeBo.setCreateDept(1L);
remoteNoticeBo.setCreateTime(businessAlert.getCreateTime());
if (businessAlert.getBusinessType() == 2){
businessAlert.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, vo.getImages(), 3600).toString());
}
remoteNoticeBo.setDeviceSn(vo.getDeviceSn());
businessAlert.setDeviceSn(vo.getDeviceSn());
remoteNoticeBo.setParam(JSON.toJSONString(businessAlert));
remoteNoticeService.saveNotice(remoteNoticeBo);
remoteSubmailConfigService.remoteCmdSend("smsMultixsend", JSON.toJSONString(vo));
return R.ok();
}
}

7
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));
}
/**
* 出警效率
@ -198,6 +204,7 @@ public class BusinessAlertStatisticsController extends BaseController {
@Operation(summary="预警对比统计(预警状态)", description="预警对比统计(预警状态)")
@GetMapping(value = "/compare/status/count")
public R<List<Map<String, Object>>> countAlertStatusCompare(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.countAlertStatusCompare(businessAlertBo));
}

5
dk-modules/business/src/main/java/org/dromara/business/domain/BusinessAlert.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.constant.TransConstant;
@ -252,4 +253,8 @@ public class BusinessAlert {
@TableField(exist = false)
private String deviceSn;
//预警扩展施工信息
@TableField(exist = false)
private BusinessAlertConstructInfoVo alertConstructInfoVo;
}

86
dk-modules/business/src/main/java/org/dromara/business/domain/BusinessAlertConstructInfo.java

@ -0,0 +1,86 @@
package org.dromara.business.domain;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 预警任务-施工信息对象 business_alert_construct_info
*
* @author szs
* @date 2025-05-21
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("business_alert_construct_info")
public class BusinessAlertConstructInfo extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id")
private Long id;
/**
* 1:图片比对预警 2AI实时预警
*/
private Long businessType;
/**
* job任务id
*/
private String jobId;
/**
* 预警名称
*/
private String jobName;
/**
* 预警任务id
*/
private Long businessAlertId;
/**
* 施工名称
*/
private String constructName;
/**
* 施工单位
*/
private String constructDept;
/**
* 施工单位负责人
*/
private String constructLeader;
/**
* 联系电话
*/
private String phonenumber;
/**
* 施工地址
*/
private String address;
/**
* 所属管道
*/
private String pipeline;
/**
* 备注
*/
private String remark;
}

87
dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertConstructInfoBo.java

@ -0,0 +1,87 @@
package org.dromara.business.domain.bo;
import org.dromara.business.domain.BusinessAlertConstructInfo;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/**
* 预警任务-施工信息业务对象 business_alert_construct_info
*
* @author szs
* @date 2025-05-21
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = BusinessAlertConstructInfo.class, reverseConvertGenerate = false)
public class BusinessAlertConstructInfoBo extends BaseEntity {
/**
*
*/
@NotNull(message = "不能为空", groups = { EditGroup.class })
private Long id;
/**
* 1:图片比对预警 2AI实时预警
*/
private Long businessType;
/**
* job任务id
*/
private String jobId;
/**
* 预警名称
*/
private String jobName;
/**
* 预警任务id
*/
@NotNull(message = "预警任务id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long businessAlertId;
/**
* 施工名称
*/
@NotBlank(message = "施工名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String constructName;
/**
* 施工单位
*/
private String constructDept;
/**
* 施工单位负责人
*/
private String constructLeader;
/**
* 联系电话
*/
private String phonenumber;
/**
* 施工地址
*/
private String address;
/**
* 所属管道
*/
private String pipeline;
/**
* 备注
*/
private String remark;
}

104
dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertConstructInfoVo.java

@ -0,0 +1,104 @@
package org.dromara.business.domain.vo;
import org.dromara.business.domain.BusinessAlertConstructInfo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 预警任务-施工信息视图对象 business_alert_construct_info
*
* @author szs
* @date 2025-05-21
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = BusinessAlertConstructInfo.class)
public class BusinessAlertConstructInfoVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "")
private Long id;
/**
* 1:图片比对预警 2AI实时预警
*/
@ExcelProperty(value = "1:图片比对预警 2:AI实时预警")
private Long businessType;
/**
* job任务id
*/
@ExcelProperty(value = "job任务id")
private String jobId;
/**
* 预警名称
*/
@ExcelProperty(value = "预警名称")
private String jobName;
/**
* 预警任务id
*/
@ExcelProperty(value = "预警任务id")
private Long businessAlertId;
/**
* 施工名称
*/
@ExcelProperty(value = "施工名称")
private String constructName;
/**
* 施工单位
*/
@ExcelProperty(value = "施工单位")
private String constructDept;
/**
* 施工单位负责人
*/
@ExcelProperty(value = "施工单位负责人")
private String constructLeader;
/**
* 联系电话
*/
@ExcelProperty(value = "联系电话")
private String phonenumber;
/**
* 施工地址
*/
@ExcelProperty(value = "施工地址")
private String address;
/**
* 所属管道
*/
@ExcelProperty(value = "所属管道")
private String pipeline;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}

4
dk-modules/business/src/main/java/org/dromara/business/dubbo/RemoteBusinessAlertServiceImpl.java

@ -29,8 +29,8 @@ public class RemoteBusinessAlertServiceImpl implements RemoteBusinessAlertServic
@Override
public Boolean saveBusinessAlert(List<RemoteBusinessAlertVo> alertVoList) {
return businessAlertService.batchAddBusinessAlert(alertVoList);
public Boolean saveBusinessAlert(List<RemoteBusinessAlertVo> alertVoList, String activeProfile) {
return businessAlertService.batchAddBusinessAlert(alertVoList, activeProfile);
}
/**

15
dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertConstructInfoMapper.java

@ -0,0 +1,15 @@
package org.dromara.business.mapper;
import org.dromara.business.domain.BusinessAlertConstructInfo;
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
/**
* 预警任务-施工信息Mapper接口
*
* @author szs
* @date 2025-05-21
*/
public interface BusinessAlertConstructInfoMapper extends BaseMapperPlus<BusinessAlertConstructInfo, BusinessAlertConstructInfoVo> {
}

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);

69
dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertConstructInfoService.java

@ -0,0 +1,69 @@
package org.dromara.business.service;
import org.dromara.business.domain.BusinessAlertConstructInfo;
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo;
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 预警任务-施工信息Service接口
*
* @author szs
* @date 2025-05-21
*/
public interface IBusinessAlertConstructInfoService {
/**
* 查询预警任务-施工信息
*
* @param id 主键
* @return 预警任务-施工信息
*/
BusinessAlertConstructInfoVo queryById(Long id);
/**
* 分页查询预警任务-施工信息列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 预警任务-施工信息分页列表
*/
TableDataInfo<BusinessAlertConstructInfoVo> queryPageList(BusinessAlertConstructInfoBo bo, PageQuery pageQuery);
/**
* 查询符合条件的预警任务-施工信息列表
*
* @param bo 查询条件
* @return 预警任务-施工信息列表
*/
List<BusinessAlertConstructInfoVo> queryList(BusinessAlertConstructInfoBo bo);
/**
* 新增预警任务-施工信息
*
* @param bo 预警任务-施工信息
* @return 是否新增成功
*/
Boolean insertByBo(BusinessAlertConstructInfoBo bo);
/**
* 修改预警任务-施工信息
*
* @param bo 预警任务-施工信息
* @return 是否修改成功
*/
Boolean updateByBo(BusinessAlertConstructInfoBo bo);
/**
* 校验并批量删除预警任务-施工信息信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

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

@ -36,6 +36,8 @@ public interface IBusinessAlertService {
* @return 是否新增成功
*/
BusinessAlert addBusinessAlert(BusinessAlertVo param);
//用于演示
BusinessAlert addAlert(BusinessAlert param);
void addBusinessAlertList(List<BusinessAlertVo> alertVoList);
@ -45,7 +47,7 @@ public interface IBusinessAlertService {
* @param alertVoList 预警任务
* @return 是否新增成功
*/
Boolean batchAddBusinessAlert(List<RemoteBusinessAlertVo> alertVoList);
Boolean batchAddBusinessAlert(List<RemoteBusinessAlertVo> alertVoList, String activeProfile);
/**
* 修改预警任务
@ -94,4 +96,10 @@ public interface IBusinessAlertService {
List<BusinessAlert> listHandleHistory(String lng, String lat, String createTime);
Boolean transferAlert(BusinessAlertVo vo);
BusinessAlert getBusinessAlert(Long alertId);
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);
List<StatObj> countPostAllAlert(BusinessAlertBo businessAlertBo);
}

138
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertConstructInfoServiceImpl.java

@ -0,0 +1,138 @@
package org.dromara.business.service.impl;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo;
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo;
import org.dromara.business.domain.BusinessAlertConstructInfo;
import org.dromara.business.mapper.BusinessAlertConstructInfoMapper;
import org.dromara.business.service.IBusinessAlertConstructInfoService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 预警任务-施工信息Service业务层处理
*
* @author szs
* @date 2025-05-21
*/
@RequiredArgsConstructor
@Service
public class BusinessAlertConstructInfoServiceImpl implements IBusinessAlertConstructInfoService {
private final BusinessAlertConstructInfoMapper baseMapper;
/**
* 查询预警任务-施工信息
*
* @param id 主键
* @return 预警任务-施工信息
*/
@Override
public BusinessAlertConstructInfoVo queryById(Long id){
return baseMapper.selectVoById(id);
}
/**
* 分页查询预警任务-施工信息列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 预警任务-施工信息分页列表
*/
@Override
public TableDataInfo<BusinessAlertConstructInfoVo> queryPageList(BusinessAlertConstructInfoBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = buildQueryWrapper(bo);
Page<BusinessAlertConstructInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的预警任务-施工信息列表
*
* @param bo 查询条件
* @return 预警任务-施工信息列表
*/
@Override
public List<BusinessAlertConstructInfoVo> queryList(BusinessAlertConstructInfoBo bo) {
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<BusinessAlertConstructInfo> buildQueryWrapper(BusinessAlertConstructInfoBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getBusinessType() != null, BusinessAlertConstructInfo::getBusinessType, bo.getBusinessType());
lqw.eq(StringUtils.isNotBlank(bo.getJobId()), BusinessAlertConstructInfo::getJobId, bo.getJobId());
lqw.like(StringUtils.isNotBlank(bo.getJobName()), BusinessAlertConstructInfo::getJobName, bo.getJobName());
lqw.eq(bo.getBusinessAlertId() != null, BusinessAlertConstructInfo::getBusinessAlertId, bo.getBusinessAlertId());
lqw.like(StringUtils.isNotBlank(bo.getConstructName()), BusinessAlertConstructInfo::getConstructName, bo.getConstructName());
lqw.eq(StringUtils.isNotBlank(bo.getConstructDept()), BusinessAlertConstructInfo::getConstructDept, bo.getConstructDept());
lqw.eq(StringUtils.isNotBlank(bo.getConstructLeader()), BusinessAlertConstructInfo::getConstructLeader, bo.getConstructLeader());
lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), BusinessAlertConstructInfo::getPhonenumber, bo.getPhonenumber());
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), BusinessAlertConstructInfo::getAddress, bo.getAddress());
lqw.eq(StringUtils.isNotBlank(bo.getPipeline()), BusinessAlertConstructInfo::getPipeline, bo.getPipeline());
return lqw;
}
/**
* 新增预警任务-施工信息
*
* @param bo 预警任务-施工信息
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(BusinessAlertConstructInfoBo bo) {
BusinessAlertConstructInfo add = MapstructUtils.convert(bo, BusinessAlertConstructInfo.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改预警任务-施工信息
*
* @param bo 预警任务-施工信息
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(BusinessAlertConstructInfoBo bo) {
BusinessAlertConstructInfo update = MapstructUtils.convert(bo, BusinessAlertConstructInfo.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(BusinessAlertConstructInfo entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除预警任务-施工信息信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

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

@ -3,18 +3,24 @@ package org.dromara.business.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertConstructInfo;
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.BusinessAlertConstructInfoVo;
import org.dromara.business.domain.vo.BusinessAlertVo;
import org.dromara.business.mapper.BusinessAlertConstructInfoMapper;
import org.dromara.business.mapper.BusinessAlertMapper;
import org.dromara.business.service.IBusinessAlertService;
import org.dromara.business.utils.BatchProcessorUtil;
@ -28,6 +34,7 @@ import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.business.utils.MinioUtil;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.RemoteLabelPostService;
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo;
@ -35,6 +42,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;
@ -62,12 +70,17 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
private final BusinessAlertMapper baseMapper;
@Autowired
private BusinessAlertConstructInfoMapper businessAlertConstructInfoMapper;
@DubboReference(timeout = 30000)
RemoteWorkflowService remoteWorkflowService;
@DubboReference
RemoteLabelPostService remoteLablePostService;
@Autowired
private ProjectTablePrefixConfig ptPrefix;
/**
* 新增预警任务
@ -79,8 +92,37 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
public BusinessAlert addBusinessAlert(BusinessAlertVo param) {
BusinessAlert alert = MapstructUtils.convert(param, BusinessAlert.class);
alert.setCreateTime(new Date());
alert.setCaseNumber(param.getCaseNumber());
alert.setJobName(alert.getDeptName()+alert.getLabelCn()+ DateUtils.getTime());
alert.setJobName(alert.getLabelCn()+ DateUtils.getTime());
//创建案件号
try {
incrementalAlertCount(alert);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
this.baseMapper.insert(alert);
return alert;
}
@Override
public BusinessAlert addAlert(BusinessAlert alert) {
alert.setCreateTime(new Date());
if(ObjectUtil.isNull(alert.getJobName())){
alert.setJobName(alert.getLabelCn()+ DateUtils.getTime());
alert.setDeptId("106");
alert.setDeptName("金山街道");
}
if(ObjectUtil.equals("车辆",alert.getLabelCn())){
alert.setLat("34.22403");
alert.setLng("117.13597");
}else if(ObjectUtil.equals("烟雾",alert.getLabelCn())){
alert.setLat("34.22825");
alert.setLng("117.14087");
}else if(ObjectUtil.equals("垃圾",alert.getLabelCn())){
alert.setLat("34.2264");
alert.setLng("117.13919");
}
this.baseMapper.insert(alert);
return alert;
}
@ -117,22 +159,38 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
* @return
*/
@Override
public Boolean batchAddBusinessAlert(List<RemoteBusinessAlertVo> alertVoList) {
public Boolean batchAddBusinessAlert(List<RemoteBusinessAlertVo> alertVoList, String activeProfile) {
List<BusinessAlert> businessAlerts = alertVoList.stream().map(alert -> {
BusinessAlert businessAlert = new BusinessAlert();
alert.setCreateTime(new Date());
alert.setHandleType(BusinessStatusEnum.VERIFY.getStatus());
RemoteBusinessAlertConstructInfo remoteAlertConstructInfo = alert.getRemoteAlertConstructInfo();
BusinessAlertConstructInfoVo alertConstructInfoVo = new BusinessAlertConstructInfoVo();
BeanUtils.copyProperties(alert.getRemoteAlertConstructInfo(), alertConstructInfoVo);
businessAlert.setAlertConstructInfoVo(alertConstructInfoVo);
BeanUtils.copyProperties(alert, businessAlert);
if(!StrUtil.equals("default", activeProfile)){
businessAlert.setBusinessType(2);
}
//查询历史预警
List<BusinessAlert> businessAlertList = this.listHandleHistory(alert.getLng(), alert.getLat(), DateUtils.parseDateToStr(FormatsType.YYYY_MM_DD_HH_MM_SS, alert.getCreateTime()));
businessAlert.setHandleNum(businessAlertList.size());
return businessAlert;
}).toList();
return this.baseMapper.insertBatch(businessAlerts);
boolean b = this.baseMapper.insertBatch(businessAlerts);
/*List<BusinessAlertConstructInfo> alertConstructInfoList = businessAlerts.stream().map(alert -> {
BusinessAlertConstructInfoVo alertConstructInfoVo = alert.getAlertConstructInfoVo();
BusinessAlertConstructInfo businessAlertConstructInfo = new BusinessAlertConstructInfo();
BeanUtils.copyProperties(alertConstructInfoVo, businessAlertConstructInfo);
businessAlertConstructInfo.setBusinessAlertId(alert.getId());
return businessAlertConstructInfo;
}).collect(Collectors.toList());
businessAlertConstructInfoMapper.insertBatch(alertConstructInfoList);*/
return b;
}
/**
@ -216,9 +274,9 @@ 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 {
try {//预警管理查询图片
page.getRecords().forEach(businessAlertVo->{
if (businessAlertVo.getBusinessType() == 2){
businessAlertVo.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, businessAlertVo.getImages(), 3600).toString());
@ -253,7 +311,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 +349,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->{
@ -311,7 +369,6 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return TableDataInfo.build(page);
}
/**
* 查询当前用户待办预警
* @param bo
@ -330,7 +387,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)) {
@ -371,11 +428,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->{
@ -490,7 +549,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){
@ -514,7 +573,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){
@ -554,7 +613,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;
@ -567,7 +626,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;
@ -604,7 +663,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){
@ -655,7 +714,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;
@ -669,6 +728,37 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return this.baseMapper.selectVoList(wrapper);
}
/**
* 查询实时流待验证预警
* @param vo
* @param pageQuery
* @return
*/
@Override
public TableDataInfo<BusinessAlertVo> listAiVerifyAlert(BusinessAlertVo vo,PageQuery pageQuery) {
LambdaQueryWrapper<BusinessAlert> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BusinessAlert::getHandleType, BusinessStatusEnum.VERIFY.getStatus());
wrapper.eq(BusinessAlert::getBusinessType, vo.getBusinessType());
if (ObjectUtil.isNotEmpty(vo.getDeptId())){
wrapper.eq(BusinessAlert::getDeptId, vo.getDeptId());
}
if (ObjectUtil.isNotEmpty(vo.getJobName())){
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);
businessAlertVo.setImages(url.toString());
});
return TableDataInfo.build(businessAlertVos);
}
@Override
public Boolean deleteAlert(List<Long> alertIdList) {
if (ObjectUtil.isEmpty(alertIdList)) {
@ -687,10 +777,14 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
//更新部门
this.baseMapper.batchUpdateDept(alertVoList);
incrementalCount(alertVoList);
try {
incrementalCount(alertVoList);
//更新number
this.baseMapper.batchUpdateCaseNumber(alertVoList);
//更新number
this.baseMapper.batchUpdateCaseNumber(alertVoList);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
@ -715,6 +809,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() {
List<String> days = new ArrayList<>(7);
@ -745,7 +855,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);
}
/**
@ -761,7 +871,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 {
@ -785,6 +895,16 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
LambdaUpdateWrapper<BusinessAlert> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(BusinessAlert::getId, alertId);
wrapper.set(BusinessAlert::getDelFlag,1);
BusinessAlert businessAlert = this.baseMapper.selectById(alertId);
//删除minio多余数据
try {
MinioUtil.deleteFile(businessAlert.getImages(), MinIOConstants.BUCKET_DKCY);
MinioUtil.deleteFile(businessAlert.getImages(), MinIOConstants.BUCKET_ALERT);
} catch (Exception e) {
throw new RuntimeException(e);
}
return this.baseMapper.update(wrapper) > 0;
}
@ -831,6 +951,16 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return this.baseMapper.update(wrapper) > 0;
}
@Override
public BusinessAlert getBusinessAlert(Long alertId) {
return baseMapper.selectById(alertId);
}
@Override
public Boolean updateBusinessAlert(BusinessAlert businessAlert) {
return baseMapper.updateById(businessAlert) > 0;
}
public static void main(String[] args) {
System.out.println(getLastSixDays());

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"));

183
dk-modules/business/src/main/java/org/dromara/business/utils/MinioUtil.java

@ -0,0 +1,183 @@
package org.dromara.business.utils;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import io.minio.*;
import io.minio.http.Method;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.util.HashMap;
@Component
public class MinioUtil {
// 指定MinIO服务的访问地址(包括协议、域名或IP以及端口)
private static String endpoint;
// MinIO的访问密钥(Access Key),用于身份验证
private static String accessKey;
// MinIO的秘密密钥(Secret Key),与访问密钥配对使用,也是认证的一部分。
private static String secretKey;
// 指定默认的存储桶(Bucket)名称,MinIO中用于组织和存储对象(文件)的基本容器。
private static String bucket;
@Value("${minio.endpoint:http://114.235.183.147:9090}")
public void setEndpoint(String endpoint) {
MinioUtil.endpoint = endpoint;
}
@Value("${minio.accessKey:wuyuan@yf}")
public void setAccessKey(String accessKey) {
MinioUtil.accessKey = accessKey;
}
@Value("${minio.secretKey:wuyuan@yf}")
public void setSecretKey(String secretKey) {
MinioUtil.secretKey = secretKey;
}
@Value("${minio.bucket:dkcy}")
public void setBucket(String bucket) {
MinioUtil.bucket = bucket;
}
/**
* 创建并返回一个配置好的MinioClient实例
* 用于与MinIO服务器交互,上传文件下载文件删除文件
*
* @return 配置
*/
public static MinioClient getMinioClient() {
return MinioClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.build();
}
/**
* 上传将一个输入流中的文件上传到MinIO服务器上指定的存储桶bucket
*
* @param objectName .object(objectName)指定了上传后对象的名称
* @param inputStream 转换为
* @param size 文件大小
* @param contentType 内容类型
* @throws Exception 异常
*/
public static void uploadFile(String objectName, InputStream inputStream, long size, String contentType,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
minioClient.putObject(
// .bucket(bucket) 指定了目标存储桶的名称。.object(objectName)指定了上传后对象的名称。
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(inputStream, size, -1)
// .contentType(contentType)指定了上传文件的内容类型。
.contentType(contentType)
.build());
}
/**
* 下载从MinIO服务器下载指定存储桶bucket中的文件
*
* @param objectName 指定要从MinIO下载的文件对象名称即文件路径和文件名
* @return 对象
* @throws Exception 异常
*/
public static InputStream downloadFile(String objectName,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
return minioClient.getObject(
GetObjectArgs.builder()
// .bucket(bucket)指定了文件所在的存储桶名称。
.bucket(bucketName)
// .object(objectName)指定了要下载的对象名称。
.object(objectName)
.build());
}
/**
* 预览生成一个预签名的URL允许用户通过浏览器或其他HTTP客户端以GET方法访问MinIO存储桶中指定对象文件的临时链接
*
* @param objectName 指定需要获取预览链接的文件对象名称包括路径
* @return 对象
* @throws Exception .method(Method.GET)指定了请求的方法为GET这是预览文件时的标准HTTP方法
* .bucket(bucket)指定了存储桶的名称
* .object(objectName)指定了对象文件的名称
*/
public static String getPreviewUrl(String objectName,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
return minioClient.getPresignedObjectUrl(
GetPresignedObjectUrlArgs.builder()
.method(Method.GET)
.bucket(bucketName)
.object(objectName)
.build());
}
/**
* 删除从MinIO服务器上的指定存储桶中删除一个文件
*
* @param objectName 指定要删除的文件对象名称包括路径和文件名
* @throws Exception
*/
public static void deleteFile(String objectName,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
minioClient.removeObject(
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());
}
//查询文件信息
public static HashMap<String,Object> getFileAsMultipart(String objectName, String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient client = getMinioClient();
// 获取对象
InputStream is = client.getObject(GetObjectArgs.builder()
.bucket(bucketName)
.object(objectName)
.build());
// 获取文件元信息(如 contentType)
StatObjectResponse stat = client.statObject(StatObjectArgs.builder()
.bucket(bucketName)
.object(objectName)
.build());
String contentType = stat.contentType();
// 将流读为 byte[] 以生成 MockMultipartFile
byte[] bytes = IoUtil.readBytes(is); // Hutool 工具类
HashMap<String, Object> map = new HashMap<>();
map.put("objectName",objectName);
map.put("contentType",contentType);
map.put("bytes",bytes);
return map;
}
//文件复制
public static void copyFile(String sourceObjectName, String targetObjectName, String sourceBucket, String targetBucket) throws Exception {
MinioClient client = getMinioClient();
// 使用服务器端复制,无需下载上传
client.copyObject(CopyObjectArgs.builder()
.bucket(targetBucket) // 目标桶
.object(targetObjectName) // 目标对象
.source(CopySource.builder()
.bucket(sourceBucket)
.object(sourceObjectName)
.build())
.build());
}
}

7
dk-modules/business/src/main/resources/mapper/business/BusinessAlertConstructInfoMapper.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.business.mapper.BusinessAlertConstructInfoMapper">
</mapper>

142
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
@ -111,54 +118,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="listMonthAlert" resultType="java.util.Map">
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -11 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 0 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -11 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -10 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 1 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -10 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -9 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 2 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -9 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -8 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 3 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -8 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -7 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 4 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -7 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -6 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 5 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -6 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -5 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 6 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -5 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -4 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 7 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -4 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -3 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 8 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -3 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -2 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 9 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -2 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 10 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 MONTH), '%Y-%m')
<include refid="searchSql"></include>
union all
SELECT DATE_FORMAT(CURDATE(), '%Y-%m') AS dateMonth,count(1) total from business_alert ba
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 11 MONTH), '%Y-%m')
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(CURDATE(), '%Y-%m')
<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

2
dk-modules/sample/src/main/java/org/dromara/sample/control/service/IControlService.java

@ -60,6 +60,8 @@ public interface IControlService {
* @param param
* @return
*/
HttpResultResponse seizeAuthorityCheck(String sn, DroneAuthorityEnum authority, DronePayloadParam param);
HttpResultResponse seizeAuthority(String sn, DroneAuthorityEnum authority, DronePayloadParam param);
/**

59
dk-modules/sample/src/main/java/org/dromara/sample/control/service/impl/ControlServiceImpl.java

@ -3,19 +3,18 @@ package org.dromara.sample.control.service.impl;
import cn.hutool.core.date.DateUtil;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sdk.cloudapi.control.*;
import org.dromara.common.sdk.cloudapi.wayline.OutOfControlActionEnum;
import org.dromara.common.sdk.cloudapi.wayline.TaskTypeEnum;
import org.dromara.common.sdk.cloudapi.wayline.WaylineJobTypeEnum;
import org.dromara.common.sdk.cloudapi.wayline.WaylineTypeEnum;
import org.dromara.sample.control.model.enums.PayloadCommandsEnum;
import org.dromara.sample.manage.model.dto.DeviceDTO;
import org.dromara.sample.manage.service.IDevicePayloadService;
import org.dromara.sample.manage.service.IDeviceRedisService;
import org.dromara.sample.manage.service.IDeviceService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.sdk.cloudapi.control.FlyToPointRequest;
import org.dromara.common.sdk.cloudapi.control.PayloadAuthorityGrabRequest;
import org.dromara.common.sdk.cloudapi.control.TakeoffToPointRequest;
import org.dromara.common.sdk.cloudapi.control.api.AbstractControlService;
import org.dromara.common.sdk.cloudapi.debug.DebugMethodEnum;
import org.dromara.common.sdk.cloudapi.debug.api.AbstractDebugService;
@ -32,6 +31,8 @@ import org.dromara.sample.control.model.enums.DroneAuthorityEnum;
import org.dromara.sample.control.model.enums.RemoteDebugMethodEnum;
import org.dromara.sample.control.model.param.*;
import org.dromara.sample.control.service.IControlService;
import org.dromara.sample.media.model.MediaFileCountDTO;
import org.dromara.sample.media.service.IMediaRedisService;
import org.dromara.sample.wayline.mapper.IWaylineJobMapper;
import org.dromara.sample.wayline.model.entity.WaylineJobEntity;
import org.dromara.sample.wayline.model.enums.WaylineJobStatusEnum;
@ -41,10 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import static org.dromara.common.sdk.cloudapi.device.RcLostActionEnum.RETURN_HOME;
import static org.dromara.common.sdk.cloudapi.wayline.WaylineMethodEnum.RETURN_HOME_CANCEL;
@ -85,6 +83,9 @@ public class ControlServiceImpl implements IControlService {
@Autowired
private IWaylineJobMapper waylineJobMapper;
@Autowired
private IMediaRedisService mediaRedisService;
private RemoteDebugHandler checkDebugCondition(String sn, RemoteDebugParam param, RemoteDebugMethodEnum controlMethodEnum) {
RemoteDebugHandler handler = Objects.nonNull(controlMethodEnum.getClazz()) ?
mapper.convertValue(Objects.nonNull(param) ? param : new Object(), controlMethodEnum.getClazz())
@ -194,11 +195,18 @@ public class ControlServiceImpl implements IControlService {
waylineJobEntity.setUsername(loginUser.getUsername());
waylineJobEntity.setExecuteTime(new Date());
waylineJobEntity.setBeginTime(new Date());
waylineJobEntity.setStatus(WaylineJobStatusEnum.PENDING.getVal());
waylineJobEntity.setStatus(WaylineJobStatusEnum.SUCCESS.getVal());
waylineJobEntity.setOutOfControlAction(OutOfControlActionEnum.RETURN_TO_HOME.getAction());
waylineJobEntity.setRthAltitude(param.getRthAltitude());
waylineJobEntity.setMediaCount(0);
waylineJobEntity.setProId(dockOpt.get().getProId());
waylineJobEntity.setFileId("-1");
waylineJobEntity.setJobType(WaylineJobTypeEnum.INSTRUCT.getType());
MediaFileCountDTO mediaFileCountDTO = new MediaFileCountDTO();
mediaFileCountDTO.setJobId(waylineJobEntity.getJobId());
mediaFileCountDTO.setDeviceSn(sn);
mediaFileCountDTO.setFileId("-1");
mediaRedisService.setMediaCount(sn, waylineJobEntity.getJobId(),mediaFileCountDTO);
TopicServicesResponse<ServicesReplyData> response = abstractControlService.takeoffToPoint(
SDKManager.getDeviceSDK(sn), mapper.convertValue(param, TakeoffToPointRequest.class));
ServicesReplyData reply = response.getData();
@ -212,6 +220,34 @@ public class ControlServiceImpl implements IControlService {
}
@Override
public HttpResultResponse seizeAuthorityCheck(String sn, DroneAuthorityEnum authority, DronePayloadParam param) {
TopicServicesResponse<ServicesReplyData> response;
switch (authority) {
case FLIGHT:
// if (deviceService.checkAuthorityFlight(sn)) {
// return HttpResultResponse.success();
// }
response = abstractControlService.flightAuthorityGrab(SDKManager.getDeviceSDK(sn));
break;
case PAYLOAD:
// if (checkPayloadAuthority(sn, param.getPayloadIndex())) {
// return HttpResultResponse.success();
// }
response = abstractControlService.payloadAuthorityGrab(SDKManager.getDeviceSDK(sn),
new PayloadAuthorityGrabRequest().setPayloadIndex(new PayloadIndex(param.getPayloadIndex())));
break;
default:
return HttpResultResponse.error(CloudSDKErrorEnum.INVALID_PARAMETER);
}
ServicesReplyData serviceReply = response.getData();
return serviceReply.getResult().isSuccess() ?
HttpResultResponse.success()
: HttpResultResponse.error(serviceReply.getResult());
}
@Override
public HttpResultResponse seizeAuthority(String sn, DroneAuthorityEnum authority, DronePayloadParam param) {
TopicServicesResponse<ServicesReplyData> response;
@ -228,7 +264,7 @@ public class ControlServiceImpl implements IControlService {
return HttpResultResponse.success();
}
response = abstractControlService.payloadAuthorityGrab(SDKManager.getDeviceSDK(sn),
new PayloadAuthorityGrabRequest().setPayloadIndex(new PayloadIndex(param.getPayloadIndex())));
new PayloadAuthorityGrabRequest().setPayloadIndex(new PayloadIndex(param.getPayloadIndex())));
break;
default:
return HttpResultResponse.error(CloudSDKErrorEnum.INVALID_PARAMETER);
@ -236,8 +272,8 @@ public class ControlServiceImpl implements IControlService {
ServicesReplyData serviceReply = response.getData();
return serviceReply.getResult().isSuccess() ?
HttpResultResponse.success()
: HttpResultResponse.error(serviceReply.getResult());
HttpResultResponse.success()
: HttpResultResponse.error(serviceReply.getResult());
}
private Boolean checkPayloadAuthority(String sn, String payloadIndex) {
@ -260,6 +296,7 @@ public class ControlServiceImpl implements IControlService {
mapper.convertValue(param.getData(), param.getCmd().getCmd().getClazz()));
ServicesReplyData serviceReply = response.getData();
return serviceReply.getResult().isSuccess() ?
HttpResultResponse.success()
: HttpResultResponse.error(serviceReply.getResult());

2
dk-modules/sample/src/main/java/org/dromara/sample/control/service/impl/PayloadCommandsHandler.java

@ -73,7 +73,7 @@ public abstract class PayloadCommandsHandler {
String deviceSn = checkDockOnline(dockSn);
checkDeviceOnline(deviceSn);
checkAuthority(deviceSn);
//checkAuthority(deviceSn);
if (!canPublish(deviceSn)) {
throw new RuntimeException("无人机的当前状态不支持此功能,请稍后再试。");

1
dk-modules/sample/src/main/java/org/dromara/sample/control/service/impl/SDKControlService.java

@ -69,6 +69,7 @@ public class SDKControlService extends AbstractControlService {
}
TakeoffToPointProgress eventsReceiver = request.getData();
webSocketMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), UserTypeEnum.WEB.getVal(),
BizCodeEnum.TAKE_OFF_TO_POINT_PROGRESS.getCode(),
ResultNotifyDTO.builder().sn(dockSn)

38
dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java

@ -9,6 +9,8 @@ import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.sample.manage.model.dto.DeviceDTO;
import org.dromara.sample.manage.model.dto.DeviceFirmwareUpgradeDTO;
import org.dromara.sample.manage.service.IDeviceProService;
import org.dromara.sample.manage.service.IDeviceRedisService;
import org.dromara.sample.manage.service.IDeviceService;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j;
@ -37,6 +39,10 @@ public class DeviceController {
@Autowired
private IDeviceService deviceService;
@Autowired
private IDeviceRedisService deviceRedisService;
/**
* 获取一个工作区中所有在线设备的列表
* Get the topology list of all online devices in one workspace.
@ -45,8 +51,8 @@ public class DeviceController {
@GetMapping("/{workspace_id}/devices")
@Operation(summary = "获取一个工作区中所有在线设备的列表。", description = "获取一个工作区中所有在线设备的列表")
public HttpResultResponse<List<DeviceDTO>> getDevices(@PathVariable("workspace_id") String workspaceId,
@RequestParam(name = "nickname",required = false) String nickname) {
List<DeviceDTO> devicesList = deviceService.getDevicesTopoForWeb(workspaceId,nickname);
@RequestParam(name = "nickname",required = false) String nickname,@RequestParam(name = "proIds",required = false) List<Integer> proIds) {
List<DeviceDTO> devicesList = deviceService.getDevicesTopoForWeb(workspaceId,nickname,proIds);
return HttpResultResponse.success(devicesList);
}
@ -92,9 +98,9 @@ public class DeviceController {
@PathVariable("workspace_id") String workspaceId,Integer domain,
@RequestParam(name = "pageNum", defaultValue = "1") Long page,
@RequestParam(name = "pageSize", defaultValue = "10") Long pageSize,
@RequestParam(name = "nickname",required = false) String nickname) {
LoginUser loginUser = LoginHelper.getLoginUser();
PaginationData<DeviceDTO> devices = deviceService.getBoundDevicesWithDomain(workspaceId, page, pageSize, domain,nickname);
@RequestParam(name = "nickname",required = false) String nickname,
@RequestParam(name = "proIds",required = false) List<Integer> proIds) {
PaginationData<DeviceDTO> devices = deviceService.getBoundDevicesWithDomain(workspaceId, page, pageSize, domain,nickname,proIds);
return HttpResultResponse.success(devices);
}
@ -125,6 +131,28 @@ public class DeviceController {
@PathVariable("workspace_id") String workspaceId,
@PathVariable("device_sn") String deviceSn) {
device.setDeviceSn(deviceSn);
Optional<DeviceDTO> deviceOnline = deviceRedisService.getDeviceOnline(deviceSn);
if(deviceOnline.isPresent()){
deviceOnline.get().setNickname(device.getNickname());
deviceOnline.get().setProId(device.getProId());
if(deviceOnline.get().getChildren() != null){
deviceOnline.get().getChildren().setProId(device.getProId());
deviceOnline.get().getChildren().setNickname(device.getNickname()+"-"+ deviceOnline.get().getChildren().getDeviceName());
deviceService.updateDevice(deviceOnline.get().getChildren());
}
deviceRedisService.setDeviceOnline(deviceOnline.get());
}else {
Optional<DeviceDTO> deviceBySn = deviceService.getDeviceBySn(device.getDeviceSn());
Optional<DeviceDTO> deviceByChildSn = deviceService.getDeviceBySn(device.getChildDeviceSn());
if(deviceByChildSn.isPresent()){
deviceByChildSn.get().setProId(device.getProId());
deviceByChildSn.get().setNickname(device.getNickname()+"-"+ deviceBySn.get().getChildren().getDeviceName());
deviceService.updateDevice(deviceByChildSn.get());
}
}
boolean isUpd = deviceService.updateDevice(device);
return isUpd ? HttpResultResponse.success() : HttpResultResponse.error();
}

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

@ -40,8 +40,11 @@ import org.dromara.sample.manage.model.dto.*;
import org.dromara.sample.manage.model.entity.DeviceStreamEntity;
import org.dromara.sample.manage.service.IDeviceStreamService;
import org.dromara.sample.media.mapper.IFileMapper;
import org.dromara.sample.wayline.model.dto.WaylineJobDTO;
import org.dromara.sample.wayline.service.IWaylineJobService;
import org.dromara.system.api.RemoteConfigService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -73,6 +76,8 @@ public class MegaphoneController {
@Resource
private ServicesPublish servicesPublish;
@Autowired
private IWaylineJobService waylineJobService;
@Resource
PropertySetPublish propertySetPublish;
@ -268,6 +273,7 @@ public class MegaphoneController {
@RequestBody Map<String,Object>objectMap
) {
String top = "task/image/disobey/smoke";
String topTow = "task/image/disobey/streamType";
//发送mqtt
String s = remoteConfigService.selectStreamIp();
DisobeyDTO param = Convert.convert(DisobeyDTO.class, objectMap);
@ -298,6 +304,26 @@ public class MegaphoneController {
disobeyDTO.setRtmpUrl(param.getRtmpUrl());
gatewayPublish.publish(top,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(disobeyDTO)),1);
Map<String,Object> map = new HashMap<>();
map.put("labelEn",type);
map.put("deviceSn",objectMap.get("deviceSn"));
if (Objects.isNull(objectMap.get("jobId"))){
map.put("jobId",objectMap.get("jobId"));
map.put("jobName",objectMap.get("jobName"));
}else {
Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobInternalId(objectMap.get("jobId").toString());
map.put("jobId",objectMap.get("jobId"));
if (!waylineJobDTO.isEmpty()){
map.put("jobName",waylineJobDTO.get().getJobName());
}else {
map.put("jobName",null);
}
}
StreamTypeDTO param1 = Convert.convert(StreamTypeDTO.class, map);
gatewayPublish.publish(topTow,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(param1)),1);
}
}
}else if (CollectionUtils.isNotEmpty(types) && split.length < types.size()){
@ -336,8 +362,41 @@ public class MegaphoneController {
gatewayPublish.publish(top,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(disobeyDTO)),1);
Map<String,Object> map = new HashMap<>();
map.put("labelEn",type);
map.put("deviceSn",objectMap.get("deviceSn"));
if (Objects.isNull(objectMap.get("jobId"))){
map.put("jobId",objectMap.get("jobId"));
map.put("jobName",objectMap.get("jobName"));
}else {
Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobInternalId(objectMap.get("jobId").toString());
map.put("jobId",waylineJobDTO.get().getJobId());
map.put("jobName",waylineJobDTO.get().getJobName());
}
StreamTypeDTO param1 = Convert.convert(StreamTypeDTO.class, map);
gatewayPublish.publish(topTow,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(param1)),1);
}
}
}else {
if (CollectionUtils.isNotEmpty(types)){
//删数据
for (String type : types){
deviceStreamMapper.delete(new QueryWrapper<DeviceStreamEntity>().eq("rtmp_url", param.getRtmpUrl())
.eq("stream_type", type));
List<String> list = new ArrayList<>();
list.add(type);
DisobeyDTO disobeyDTO = new DisobeyDTO();
disobeyDTO.setUrl(s);
disobeyDTO.setOpen(2);
disobeyDTO.setType(list);
disobeyDTO.setRtmpUrl(param.getRtmpUrl());
gatewayPublish.publish(top,new CommonTopicRequest<>()
.setData(Objects.requireNonNull(disobeyDTO)),1);
}
}else {
}
}
}
if (param.getOpen() == 2){

77
dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/SampleEngineRecordController.java

@ -0,0 +1,77 @@
package org.dromara.sample.manage.controller;
import com.alibaba.nacos.common.utils.CollectionUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.sdk.common.HttpResultResponse;
import org.dromara.sample.manage.model.dto.CallBackDTO;
import org.dromara.sample.manage.model.dto.EventsDTO;
import org.dromara.sample.manage.model.entity.WarningRecordEntity;
import org.dromara.sample.manage.service.ISampleEngineRecordService;
import org.dromara.sample.manage.service.ISampleWarningRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author sean.zhou
* @version 0.1
* @date 2021/11/15
*/
@RestController
@Slf4j
@RequestMapping("${url.manage.prefix}${url.manage.version}/saEngineRecord")
@Tag(name = "无人机设备模块")
public class SampleEngineRecordController {
@Autowired
private ISampleEngineRecordService sampleEngineRecordService;
@Autowired
private ISampleWarningRecordService sampleWarningRecordService;
/**
* 启动星罗引擎
* Get the topology list of all online devices in one workspace.
* @return
*/
@PostMapping("/startEngine")
@Operation(summary = "启动星罗引擎。", description = "启动星罗引擎")
public HttpResultResponse<Map<String,Object>> startEngine(@RequestBody Map<String,Object> objectMap) {
return HttpResultResponse.success(sampleEngineRecordService.startEngine(objectMap));
}
@PostMapping("/closeEngine")
@Operation(summary = "关闭星罗引擎。", description = "关闭星罗引擎")
public HttpResultResponse closeEngine(@RequestBody Map<String,Object> objectMap) {
sampleEngineRecordService.closeEngine(objectMap);
return HttpResultResponse.success();
}
@PostMapping("/some")
@Operation(summary = "存储推流的预警(对外接口)。", description = "存储推流的预警(对外接口)。")
public void some(@RequestBody CallBackDTO callBackVo){
WarningRecordEntity warningRecord = new WarningRecordEntity();
List<WarningRecordEntity> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(callBackVo.getEvents())){
for (EventsDTO eventsVo :callBackVo.getEvents()){
warningRecord.setTaskId(callBackVo.getTaskId());
warningRecord.setAlgoId(eventsVo.getAlgoId());
warningRecord.setEventId(eventsVo.getEventId());
warningRecord.setExtraType(eventsVo.getExtraType());
warningRecord.setPicUrl(eventsVo.getPicUrl());
warningRecord.setTimestamp(eventsVo.getTimestamp());
list.add(warningRecord);
}
sampleWarningRecordService.saveBatch(list);
System.out.println(callBackVo);
}
}
}

9
dk-modules/sample/src/main/java/org/dromara/sample/manage/mapper/ISampleEngineRecordMapper.java

@ -0,0 +1,9 @@
package org.dromara.sample.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.dromara.sample.manage.model.entity.EngineRecordEntity;
import org.mapstruct.Mapper;
public interface ISampleEngineRecordMapper extends BaseMapper<EngineRecordEntity> {
}

15
dk-modules/sample/src/main/java/org/dromara/sample/manage/mapper/ITaskJobMapper.java

@ -0,0 +1,15 @@
package org.dromara.sample.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.dromara.sample.manage.model.entity.PlayTextEntity;
import org.dromara.sample.manage.model.entity.TaskJobEntity;
/**
*
* @author sean.zhou
* @date 2021/11/10
* @version 0.1
*/
public interface ITaskJobMapper extends BaseMapper<TaskJobEntity> {
}

18
dk-modules/sample/src/main/java/org/dromara/sample/manage/mapper/SampleWarningRecordMapper.java

@ -0,0 +1,18 @@
package org.dromara.sample.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.dromara.sample.manage.model.entity.WarningRecordEntity;
/**
* 设备对象-用于存储设备Mapper接口
*
* @author wuyuan
* @date 2022-10-25
*/
@Mapper
public interface SampleWarningRecordMapper extends BaseMapper<WarningRecordEntity> {
}

212
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/BusinessAlertVo.java

@ -0,0 +1,212 @@
package org.dromara.sample.manage.model.dto;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 预警任务视图对象 wayline_alert
*
* @author LionLi
* @date 2025-02-27
*/
@Data
@ExcelIgnoreUnannotated
public class BusinessAlertVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
/**
* job任务id
*/
private String jobId;
/**
* 预警名称
*/
private String jobName;
/**
* 图片id 对应的media_file 的fileId
*/
private String taskImageId;
/**
* 处理原因
*/
private String reason;
/**
* 是否指派
*/
private Boolean assign;
/**
* 图片文件
*/
private String images;
/**
* 纬度
*/
private String lat;
/**
* 精度
*/
private String lng;
/**
* 标签名-
*/
private String labelCn;
/**
* 标签名-
*/
private String labelEn;
/**
* 任务内容
*/
private String taskContent;
/**
* 删除 0 正常 1已删除
*/
private Integer delFlag;
/**
* 模板图片
*/
private String mateSourceImgUrl;
/**
* 放大模板违建区域图片
*/
private String maxMateSourceImgUrl;
/**
* 预警类型
*/
private String alertType;
/**
* 放大违建区域图片
*/
private String maxImages;
/**
* 面积
*/
private Long area;
/**
* 面积
*/
private Long areaL;
/**
* 面积
*/
private Long areaW;
/**
* 流程处置状态(verify:验证,cancel:已撤销,draft:草稿,waiting:待审核,finish:已完成,invalid:已作废,back:已退回,termination:已终止)
*/
private String handleType;
/**
* 指派人员
*/
private String assignUserId;
/**
* 指派时间
*/
private Date assignDate;
/**
* 完成时间
*/
private Date completeDate;
/**
* 是否违建 01
*/
private Boolean isIllegal;
/**
* 部门id
*/
private String deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 处理时间
*/
private Date handleTime;
/**
* 其他内容
*/
private String taskHandle;
/**
* 像素坐标
*/
private String pixelCoordinate;
/**
* 当前位置预警数量
*/
private Integer handleNum;
/**
* 地类信息数据
*/
private String landCategories;
/**
* 忽略原因
*/
private String ignoringCause;
private Integer value;
/**
* 来源0平台 1小程序
*/
private Integer handleSource;
/**
* 指派人员名称
*/
private String assignUserName;
private Date createTime;
//1:图片比对预警 2:AI实时预警
private Integer businessType;
private String deviceSn;
/**
* 案件号
*/
private String caseNumber;
}

2
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/DeviceDTO.java

@ -102,7 +102,7 @@ public class DeviceDTO {
private String tenantId;
@Schema(description = "项目ID")
private String proId;
private Integer proId;
@Schema(description = "项目ID")
private DeviceProEntity deviceProEntity;

2
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/DeviceQrtzDTO.java

@ -96,4 +96,6 @@ public class DeviceQrtzDTO {
private String deptName;
private List<Long>deptIds;
private List<Integer> proIds;
}

30
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/EngineType.java

@ -0,0 +1,30 @@
package org.dromara.sample.manage.model.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* The entity class of the device
*
* @author sean.zhou
* @version 0.1
* @date 2021/11/10
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EngineType implements Serializable {
private String scene;
private int id;
}

30
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/dto/EngineTypeResponse.java

@ -0,0 +1,30 @@
package org.dromara.sample.manage.model.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* The entity class of the device
*
* @author sean.zhou
* @version 0.1
* @date 2021/11/10
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EngineTypeResponse implements Serializable {
private Long code;
private String message;
private EngineType data;
}

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

33
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/TaskJobEntity.java

@ -0,0 +1,33 @@
package org.dromara.sample.manage.model.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* The entity class of the device
*
* @author sean.zhou
* @version 0.1
* @date 2021/11/10
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "task_job")
public class TaskJobEntity implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
private String taskId;
private String jobId;
}

18
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/entity/WarningRecordEntity.java

@ -30,26 +30,18 @@ public class WarningRecordEntity implements Serializable {
private String taskId;
@TableField(value = "algo_id")
//算法 id")
private Integer algoId;
private Integer algoId; //算法 id")
@TableField(value = "extra_type")
//算法类型字符串")
private String extraType;
private String extraType; //算法类型字符串")
@TableField(value = "event_id")
//分配的事件 id")
private String eventId;
private String eventId;//分配的事件 id")
@TableField(value = "pic_url")
//保存后图片的 url")
private String picUrl;
private String picUrl;//保存后图片的 url")
@TableField(value = "timestamp")
//事件时间戳,单位:毫秒")
private Integer timestamp;
private Integer timestamp;//事件时间戳,单位:毫秒")
}

2
dk-modules/sample/src/main/java/org/dromara/sample/manage/model/param/DeviceQueryParam.java

@ -35,4 +35,6 @@ public class DeviceQueryParam {
private boolean orderBy;
private boolean isAsc;
private List<Integer> proIds;
}

4
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/IDeviceService.java

@ -68,7 +68,7 @@ public interface IDeviceService {
* @param workspaceId
* @return
*/
List<DeviceDTO> getDevicesTopoForWeb(String workspaceId,String nickname);
List<DeviceDTO> getDevicesTopoForWeb(String workspaceId,String nickname,List<Integer> proIds);
/**
@ -131,7 +131,7 @@ public interface IDeviceService {
* @param domain
* @return
*/
PaginationData<DeviceDTO> getBoundDevicesWithDomain(String workspaceId, Long page, Long pageSize, Integer domain,String nickname);
PaginationData<DeviceDTO> getBoundDevicesWithDomain(String workspaceId, Long page, Long pageSize, Integer domain,String nickname,List<Integer> proIds);
/**
* Unbind device base on device's sn.

9
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/ISampleEngineRecordService.java

@ -0,0 +1,9 @@
package org.dromara.sample.manage.service;
import java.util.Map;
public interface ISampleEngineRecordService {
Map<String,Object> startEngine(Map<String,Object> objectMap);
void closeEngine(Map<String,Object> objectMap);
}

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

@ -0,0 +1,8 @@
package org.dromara.sample.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.sample.manage.model.entity.WarningRecordEntity;
public interface ISampleWarningRecordService extends IService<WarningRecordEntity> {
}

15
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/ITaskJobService.java

@ -0,0 +1,15 @@
package org.dromara.sample.manage.service;
import org.dromara.common.sdk.common.HttpResultResponse;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.sample.manage.model.entity.PlayTextEntity;
import java.util.Map;
/**
* @author sean.zhou
* @date 2021/11/10
* @version 0.1
*/
public interface ITaskJobService {
}

106
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceQrtzServiceImpl.java

@ -154,12 +154,7 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService {
@Override
public Boolean add( DeviceQrtzDTO deviceQrtzDTO) {
if(!CollectionUtils.isEmpty(deviceQrtzDTO.getDeviceQrtzDates())){
deviceQrtzDTO.getDeviceQrtzDates().forEach(e->{
e.setQrtzId(deviceQrtzDTO.getId());
deviceQrtzDateMapper.insert(e);
});
}
DeviceQrtzEntity entity = new DeviceQrtzEntity();
entity.setDeviceSn(deviceQrtzDTO.getDeviceSn());
entity.setName(deviceQrtzDTO.getName());
@ -169,7 +164,14 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService {
entity.setNickName(loginUser.getNickname());
entity.setCreateDept(loginUser.getDeptId());
entity.setDeptName(loginUser.getDeptName());
return deviceQrtzMapper.insert(entity)>0;
int insert = deviceQrtzMapper.insert(entity);
if(!CollectionUtils.isEmpty(deviceQrtzDTO.getDeviceQrtzDates())){
deviceQrtzDTO.getDeviceQrtzDates().forEach(e->{
e.setQrtzId(entity.getId());
deviceQrtzDateMapper.insert(e);
});
}
return insert>0;
}
@Override
@ -190,7 +192,7 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService {
int sort=1;
Long qrtzId = Convert.toLong(map.get("qrtzId"));
String deviceSn = Convert.toStr(map.get("deviceSn"));
Date execDate = Convert.toDate(map.get("execDate"));
Date execDate = Convert.toDate(map.get("execDate"),new Date());
String waylineIdStr = Convert.toStr(map.get("waylineIdStr"));
List<DeviceQrtzFileEntity> selectList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>()
.eq("qrtz_id", qrtzId).eq("exec_date",execDate).orderByDesc("sort"));
@ -282,7 +284,6 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService {
if (RedisOpsUtils.checkExist(device.getDeviceSn())) {
return;
}
RedisOpsUtils.setWithExpire(device.getDeviceSn(), device, 180);
List<DeviceQrtzEntity> qrtzEntityList = deviceQrtzMapper.selectList(new LambdaQueryWrapper<DeviceQrtzEntity>().eq(DeviceQrtzEntity::getDeviceSn, device.getDeviceSn()).eq(DeviceQrtzEntity::getStatus, DeviceQrtzConstants.QRTZ_STATUS_1));
if(!qrtzEntityList.isEmpty()){
// 获取当前日期
@ -292,57 +293,64 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService {
DateTimeFormatter formatterS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化当前日期
String formattedDate = currentDate.format(formatter);
List<DeviceQrtzFileEntity> qrtzFileEntityList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>().eq("device_sn", qrtzEntityList.get(0).getDeviceSn()).eq("exec_date", formattedDate).eq("qrtz_id",qrtzEntityList.get(0).getId()).eq("status", DeviceQrtzConstants.QRTZ_FILE_STATUS_1).orderByAsc("sort"));
if (!qrtzFileEntityList.isEmpty()) {
DeviceQrtzFileEntity deviceQrtzFileEntity = qrtzFileEntityList.get(0);
List<DeviceQrtzDateEntity> qrtzDateEntityList = deviceQrtzDateMapper.listDeviceQrtzDateByQrtzAndDate(deviceQrtzFileEntity.getQrtzId());
if (!qrtzDateEntityList.isEmpty()) {
// 获取当前日期和时间
for (DeviceQrtzEntity deviceQrtzEntity : qrtzEntityList) {
List<DeviceQrtzDateEntity> qrtzDateEntityList = deviceQrtzDateMapper.listDeviceQrtzDateByQrtzAndDate(deviceQrtzEntity.getId());
//判断下是否有时间
if(!qrtzDateEntityList.isEmpty()){
//遍历,当前时间是否在范围内
for (DeviceQrtzDateEntity qrtzDate : qrtzDateEntityList) {
//在里面执行航线,进行无人机飞行
if (!currentDate.isBefore(Convert.toLocalDateTime(qrtzDate.getStartDate())) && !currentDate.isAfter(Convert.toLocalDateTime(qrtzDate.getEndDate()))) {
//获取航线数据发送之类
WaylineFileEntity waylineFileEntity = waylineFileMapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getWaylineId, deviceQrtzFileEntity.getWaylineId()));
if (waylineFileEntity == null) {
//更改为异常,当前航线不存在
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_0);
deviceQrtzFileMapper.updateById(deviceQrtzFileEntity);
continue;
}
//获取是否是工单航线,是修改状态
remoteBusinessTaskFeign.updateTaskStatus(deviceQrtzFileEntity.getWaylineId(), BusinessConstants.TASK_STATUS_2, null, null);
CreateJobParam createJobParam = new CreateJobParam();
try {
createJobParam.setName(deviceQrtzFileEntity.getWaylineName() + "" + currentDate.format(formatterS));
createJobParam.setWaylineName(deviceQrtzFileEntity.getWaylineName());
createJobParam.setFileId(deviceQrtzFileEntity.getWaylineId());
createJobParam.setDockSn(device.getDeviceSn());
createJobParam.setWaylineType(WaylineTypeEnum.find(Integer.parseInt(waylineFileEntity.getTemplateTypes())));
createJobParam.setTaskType(TaskTypeEnum.IMMEDIATE);
createJobParam.setJobId(UUID.randomUUID().toString());
//createJobParam.setRthAltitude();
createJobParam.setMinBatteryCapacity(50);
createJobParam.setJobType(WaylineJobTypeEnum.WISDOM_TASK);
createJobParam.setWaylinePrecisionType(WaylinePrecisionTypeEnum.RTK);
createJobParam.setOutOfControlAction(OutOfControlActionEnum.RETURN_TO_HOME);
createJobParam.setRthAltitude(120);
HttpResultResponse httpResultResponse = flightTaskService.publishFlightTask(device.getWorkspaceId(), createJobParam, deviceQrtzFileEntity.getNickName());
if(httpResultResponse.getCode() == 0){
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_2);
deviceQrtzFileEntity.setFlightDate(new Date());
List<DeviceQrtzFileEntity> qrtzFileEntityList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>().eq("device_sn",deviceQrtzEntity.getDeviceSn()).eq("exec_date", formattedDate).eq("qrtz_id",deviceQrtzEntity.getId()).eq("status", DeviceQrtzConstants.QRTZ_FILE_STATUS_1).orderByAsc("sort"));
if(!qrtzFileEntityList.isEmpty()){
DeviceQrtzFileEntity deviceQrtzFileEntity = qrtzFileEntityList.get(0);
//获取航线数据发送之类
WaylineFileEntity waylineFileEntity = waylineFileMapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getWaylineId, deviceQrtzFileEntity.getWaylineId()));
if (waylineFileEntity == null) {
//更改为异常,当前航线不存在
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_0);
deviceQrtzFileMapper.updateById(deviceQrtzFileEntity);
continue;
}
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_0);
deviceQrtzFileMapper.updateById(deviceQrtzFileEntity);
} catch (Exception e) {
e.printStackTrace();
//获取是否是工单航线,是修改状态
remoteBusinessTaskFeign.updateTaskStatus(deviceQrtzFileEntity.getWaylineId(), BusinessConstants.TASK_STATUS_2, null, null);
CreateJobParam createJobParam = new CreateJobParam();
try {
createJobParam.setName(deviceQrtzFileEntity.getWaylineName() + "" + currentDate.format(formatterS));
createJobParam.setWaylineName(deviceQrtzFileEntity.getWaylineName());
createJobParam.setFileId(deviceQrtzFileEntity.getWaylineId());
createJobParam.setDockSn(device.getDeviceSn());
createJobParam.setWaylineType(WaylineTypeEnum.find(Integer.parseInt(waylineFileEntity.getTemplateTypes())));
createJobParam.setTaskType(TaskTypeEnum.IMMEDIATE);
createJobParam.setJobId(UUID.randomUUID().toString());
//createJobParam.setRthAltitude();
createJobParam.setMinBatteryCapacity(50);
createJobParam.setJobType(WaylineJobTypeEnum.WISDOM_TASK);
createJobParam.setWaylinePrecisionType(WaylinePrecisionTypeEnum.RTK);
createJobParam.setOutOfControlAction(OutOfControlActionEnum.RETURN_TO_HOME);
createJobParam.setRthAltitude(120);
HttpResultResponse httpResultResponse = flightTaskService.publishFlightTask(device.getWorkspaceId(), createJobParam, deviceQrtzFileEntity.getNickName());
if(httpResultResponse.getCode() == 0){
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_2);
deviceQrtzFileEntity.setFlightDate(new Date());
deviceQrtzFileMapper.updateById(deviceQrtzFileEntity);
continue;
}
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_0);
deviceQrtzFileMapper.updateById(deviceQrtzFileEntity);
RedisOpsUtils.setWithExpire(device.getDeviceSn(), device, 180);
return;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
}

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

@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sdk.cloudapi.device.*;
import org.dromara.common.sdk.cloudapi.firmware.*;
import org.dromara.common.sdk.cloudapi.firmware.api.AbstractFirmwareService;
import org.dromara.common.sdk.cloudapi.livestream.VideoTypeEnum;
import org.dromara.common.sdk.cloudapi.property.api.AbstractPropertyService;
import org.dromara.common.sdk.cloudapi.tsa.DeviceIconUrl;
import org.dromara.common.sdk.cloudapi.tsa.TopologyDeviceModel;
@ -45,6 +47,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.sample.websocket.service.IWebSocketMessageService;
import org.dromara.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -58,6 +61,9 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.dromara.common.core.utils.StringUtils.DASH;
import static org.dromara.common.core.utils.StringUtils.SLASH;
/**
*
* @author sean.zhou
@ -132,6 +138,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Autowired
private IDeviceProMapper deviceProMapper;
@Autowired
private IDeviceProService deviceProService;
@Override
public void subDeviceOffline(String deviceSn) {
// If no information about this device exists in the cache, the drone is considered to be offline.
@ -221,21 +230,28 @@ public class DeviceServiceImpl implements IDeviceService {
}
})
.eq(StringUtils.hasText(param.getWorkspaceId()),
DeviceEntity::getWorkspaceId, param.getWorkspaceId())
DeviceEntity::getWorkspaceId, param.getWorkspaceId())
.eq(param.getBoundStatus() != null, DeviceEntity::getBoundStatus, param.getBoundStatus())
.in(ObjectUtil.isAllNotEmpty(param.getProIds()),
DeviceEntity::getProId, param.getProIds())
.orderBy(param.isOrderBy(),
param.isAsc(), DeviceEntity::getId))
param.isAsc(), DeviceEntity::getId))
.stream()
.map(this::deviceEntityConvertToDTO)
.collect(Collectors.toList());
}
@Override
public List<DeviceDTO> getDevicesTopoForWeb(String workspaceId,String nickname) {
public List<DeviceDTO> getDevicesTopoForWeb(String workspaceId,String nickname,List<Integer> proIds) {
LoginUser loginUser = LoginHelper.getLoginUser();
if(proIds == null){
proIds = deviceProService.listDeviceGroup(loginUser.getUserId());
}
List<DeviceDTO> devicesList = this.getDevicesByParams(
DeviceQueryParam.builder()
.workspaceId(workspaceId)
.domains(List.of(DeviceDomainEnum.REMOTER_CONTROL.getDomain(), DeviceDomainEnum.DOCK.getDomain()))
.proIds(proIds)
.build());
devicesList.stream()
@ -258,14 +274,15 @@ public class DeviceServiceImpl implements IDeviceService {
DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0);
subDevice.setStatus(deviceRedisService.checkDeviceOnline(subDevice.getDeviceSn()));
List<CapacityCameraDTO> capacityCameraByDeviceSn = capacityCameraService.getCapacityCameraByDeviceSn(gateway.getChildDeviceSn());
/*List<CapacityCameraDTO> capacityCameraByDeviceSn = capacityCameraService.getCapacityCameraByDeviceSn(gateway.getChildDeviceSn());
String videoId = "";
if(capacityCameraByDeviceSn != null && capacityCameraByDeviceSn.size() > 0 ){
if(capacityCameraByDeviceSn.get(0).getVideosList().size() > 0){
videoId = gateway.getChildDeviceSn() + "/" + capacityCameraByDeviceSn.get(0).getIndex() + "/" + capacityCameraByDeviceSn.get(0).getVideosList().get(0).getIndex();
}
}
subDevice.setVideoId(videoId);
}*/
String deviceVideoEnum = DeviceVideoEnum.find(subDevice.getDeviceName()).getDevice();
subDevice.setVideoId(new VideoId(subDevice.getDeviceSn()+SLASH+deviceVideoEnum+SLASH + VideoTypeEnum.NORMAL.getType() + DASH+DeviceTypeVideoEnum.ZERO.getVideoType()).toString());
gateway.setChildren(subDevice);
// gateway.setVideoId(DeviceEnum.videoId);
// payloads
@ -405,13 +422,17 @@ public class DeviceServiceImpl implements IDeviceService {
.map(WorkspaceDTO::getWorkspaceName).orElse("") : "")
.firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE)
.videoId(dockVideoId)
.thingVersion(entity.getVersion()).proId(ObjectUtil.isNotEmpty(entity.getProId())?String.valueOf(entity.getProId()):"").build();
.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());
@ -495,13 +516,14 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public PaginationData<DeviceDTO> getBoundDevicesWithDomain(String workspaceId, Long page,
Long pageSize, Integer domain,String nickname) {
Long pageSize, Integer domain,String nickname,List<Integer> proIds) {
Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize),
new LambdaQueryWrapper<DeviceEntity>()
.eq(DeviceEntity::getDomain, domain)
.eq(DeviceEntity::getWorkspaceId, workspaceId)
.eq(DeviceEntity::getBoundStatus, true)
.in(ObjectUtil.isAllNotEmpty(proIds),DeviceEntity::getProId, proIds)
.eq(org.dromara.common.core.utils.StringUtils.isNotEmpty(nickname),DeviceEntity::getNickname,nickname));
List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO)
.peek(device -> {
@ -728,7 +750,11 @@ public class DeviceServiceImpl implements IDeviceService {
.firmwareVersion(dto.getFirmwareVersion())
.compatibleStatus(dto.getFirmwareStatus() == null ? null :
DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != dto.getFirmwareStatus())
.deviceDesc(dto.getDeviceDesc()).proId(ObjectUtil.isNotEmpty(dto.getProId())?Integer.valueOf(dto.getProId()):null)
.deviceDesc(dto.getDeviceDesc())
.latitude(dto.getLatitude())
.longitude(dto.getLongitude())
.height(dto.getHeight())
.proId(dto.getProId() == null ? null : dto.getProId())
.build();
}
}

4
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/LiveStreamServiceImpl.java

@ -139,7 +139,7 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
default:
return HttpResultResponse.error(LiveErrorCodeEnum.URL_TYPE_NOT_SUPPORTED);
}
DeviceEntity deviceBySn = deviceService.getDeviceByChildSn(liveParam.getVideoId().getDroneSn());
/* DeviceEntity deviceBySn = deviceService.getDeviceByChildSn(liveParam.getVideoId().getDroneSn());
if(deviceBySn != null){
Optional<EventsReceiver<FlighttaskProgress>> runningWaylineJob = waylineRedisService.getRunningWaylineJob(deviceBySn.getDeviceSn());
@ -172,7 +172,7 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
}
}
}
}*/
// MessageProducerUtil.sendAsyncProducerMessage("videoStartConsum","videoStart",liveParam.getVideoId().getDroneSn(),liveParam.getVideoId().toString());
return HttpResultResponse.success(live);

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

@ -3,6 +3,7 @@ package org.dromara.sample.manage.service.impl;
import cn.hutool.core.util.ObjectUtil;
import org.dromara.common.redis.utils.RedisOpsUtils;
import org.dromara.common.rocketmq.producer.MessageProducerUtil;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.sdk.cloudapi.device.*;
import org.dromara.common.sdk.cloudapi.device.api.AbstractDeviceService;
import org.dromara.common.sdk.cloudapi.livestream.VideoTypeEnum;
@ -41,6 +42,8 @@ import java.util.stream.Collectors;
import static org.dromara.common.core.utils.StringUtils.DASH;
import static org.dromara.common.core.utils.StringUtils.SLASH;
import static org.dromara.common.core.constant.Constants.FLY_COUNT;
/**
* @author sean
* @version 1.7
@ -159,10 +162,15 @@ public class SDKDeviceService extends AbstractDeviceService {
if(request.getData().getMediaFileDetail() != null){
RedisOpsUtils.hashSet("updateMediaFileDetail",from,request.getData().getMediaFileDetail().getRemainUpload());
}
if( deviceRedisService.getDeviceOsd(deviceOpt.get().getChildDeviceSn(),OsdDockDrone.class).isEmpty() && deviceRedisService.checkDeviceVideo(deviceOpt.get().getChildDeviceSn())){
deviceRedisService.delDeviceVideo(deviceOpt.get().getChildDeviceSn());
}
DeviceDTO device = deviceOpt.get();
if(request.getData().getLatitude() != null && request.getData().getLongitude() != null
&& ((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());
}
if (StringUtils.hasText(device.getChildDeviceSn())) {
deviceService.getDeviceBySn(device.getChildDeviceSn()).ifPresent(device::setChildren);
}

250
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java

@ -0,0 +1,250 @@
package org.dromara.sample.manage.service.impl;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.seata.common.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.dromara.sample.common.util.Md5Utils;
import org.dromara.sample.manage.mapper.ISampleEngineRecordMapper;
import org.dromara.sample.manage.mapper.ITaskJobMapper;
import org.dromara.sample.manage.model.dto.*;
import org.dromara.sample.manage.model.entity.EngineRecordEntity;
import org.dromara.sample.manage.model.entity.TaskJobEntity;
import org.dromara.sample.manage.service.ISampleEngineRecordService;
import org.dromara.system.api.RemoteConfigService;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import static org.apache.commons.compress.utils.ArchiveUtils.sanitize;
@Service
@Slf4j
@Transactional
public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService {
@Resource
ISampleEngineRecordMapper mapper;
@Resource
ITaskJobMapper taskJobMapper;
@DubboReference
private RemoteConfigService remoteConfigService;
@Override
public Map<String, Object> startEngine(Map<String, Object> objectMap){
EngineRecordEntity record = new EngineRecordEntity();
String ip = remoteConfigService.selectStreamIp();
//获取token
//设置请求Header和Body(如JSON)
String md5 = Md5Utils.hash("xuzhou_ai");
JSONObject jsonObj = new JSONObject();
jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文
jsonObj.put("password", sanitize(md5));
String responseBody = PostRequest(jsonObj, "http://60.204.247.65:8100/Third/Login","");
JSONObject jsonObject = new JSONObject(responseBody);
// 逐层获取 data -> token
JSONObject data = jsonObject.getJSONObject("data");
String token = data.getString("token");
String sceneResponseBody = null;
String algorithmResponseBody = null;
//查询用户开通的场景
if (StringUtils.isNotEmpty(token)){
// try {
// URI uri = new URIBuilder("http://60.204.247.65:8100/V2/AI/WX/User/Scene")
// .build();
// sceneResponseBody = GetRequest(uri, token);
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// EngineTypeResponse engineTypeResponse = null;
// try {
// ObjectMapper mapper = new ObjectMapper();
// engineTypeResponse = mapper.readValue(sceneResponseBody, EngineTypeResponse.class);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
//// JSONObject jsonObject1 = new JSONObject(sceneResponseBody);
// // 逐层获取 data -> token
//// JSONObject data1 = jsonObject1.getJSONObject("data");
// String scene = engineTypeResponse.getData().getScene();
//
// //查询场景算法
// List<String> extra_type_list = new ArrayList<>();
// try {
// URI uri = new URIBuilder("http://60.204.247.65:8100/V2/AI/WX/User/ExtraType/Get")
// .addParameter("scene",scene)
// .addParameter("if_open","1")
// .build();
// algorithmResponseBody = GetRequest(uri, token);
// ObjectMapper mapper = new ObjectMapper();
// ExtraTypeResponse response = mapper.readValue(algorithmResponseBody,ExtraTypeResponse.class);
// List<ExtraType> list = response.getData();
// for (ExtraType extraType : list) {
// extra_type_list.add(extraType.getExtra_type());
// break;
// }
// } catch (URISyntaxException | JsonProcessingException e) {
// throw new RuntimeException(e);
// }
JSONObject jsonObj2 = new JSONObject();
String type = objectMap.get("type").toString();
if (StringUtils.isNotEmpty(type)){
List<String> list = Arrays.asList(type.split(","));
jsonObj2.put("scene", "可见光"); // sanitize函数见下文
jsonObj2.put("callback_url", "http://114.235.183.162:9888/ces/iot/deviceLog/some");
jsonObj2.put("extra_type_list",new JSONArray(list));
jsonObj2.put("input_url","http://"+ip+":19008/live/livesteam/"+objectMap.get("rtmpUrl")+".flv");
jsonObj2.put("push_url", "rtmp://"+ip+"/live/livesteam/"+objectMap.get("rtmpUrl")+"ai1");
// jsonObj2.put("play_url", objectMap.get("play_url"));
String responseBody2 = PostRequest(jsonObj2, "http://60.204.247.65:8100/Third/Engine/Start",token);
ObjectMapper mapper1 = new ObjectMapper();
EngineResponse response = null;
try {
response = mapper1.readValue(responseBody2, EngineResponse.class);
if (response.getCode() != 200){
throw new RuntimeException("第三方接口调用失败!");
}
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
objectMap.put("task_id",response.getData().getTask_id());
record.setPushUrl(objectMap.get("rtmpUrl").toString());
record.setTaskId(MapUtil.getStr(objectMap,"task_id",""));
record.setDeviceSn(MapUtil.getStr(objectMap,"deviceSn",""));
record.setTaskId(response.getData().getTask_id());
record.setExtraType(objectMap.get("type").toString());
System.out.print(objectMap);
}
}
Map<String, Object> map = new HashMap();
map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+objectMap.get("rtmpUrl")+"ai1");
map.put("task_id", objectMap.get("task_id"));
//添加启动引擎记录
mapper.insert(record);
//添加任务id和jobid关联关系
TaskJobEntity taskJobEntity = new TaskJobEntity();
taskJobEntity.setJobId(objectMap.get("jobId").toString());
taskJobEntity.setTaskId(objectMap.get("task_id").toString());
taskJobMapper.insert(taskJobEntity);
return map;
}
@Override
public void closeEngine(Map<String, Object> objectMap) {
JSONObject jsonObj2 = new JSONObject();
EngineRecordEntity record = mapper.selectOne(new LambdaQueryWrapper<EngineRecordEntity>().eq(EngineRecordEntity::getDeviceSn, objectMap.get("deviceSn")));
if (record == null){
// throw new RuntimeException("关闭引擎失败!");
}else {
//获取token
//设置请求Header和Body(如JSON)
String md5 = Md5Utils.hash("xuzhou_ai");
JSONObject jsonObj = new JSONObject();
jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文
jsonObj.put("password", sanitize(md5));
String responseBody = PostRequest(jsonObj, "http://60.204.247.65:8100/Third/Login","");
JSONObject jsonObject = new JSONObject(responseBody);
// 逐层获取 data -> token
JSONObject data = jsonObject.getJSONObject("data");
String token = data.getString("token");
jsonObj2.put("task_id", record.getTaskId()); // sanitize函数见下文
String responseBody2 = PostRequest(jsonObj2, "http://60.204.247.65:8100/Third/Engine/Stop",token);
JSONObject json = new JSONObject(responseBody2);
// 方式2:安全获取(先判空再转换)
Object dataObj = json.get("data");
if(dataObj != null && dataObj instanceof Integer) {
int data1 = (Integer) dataObj;
if (data1 ==1){
mapper.delete(new LambdaQueryWrapper<EngineRecordEntity>().eq(EngineRecordEntity::getDeviceSn, objectMap.get("deviceSn")));
}else {
throw new RuntimeException("关闭引擎失败!");
}
} else {
throw new RuntimeException("关闭引擎失败!");
}
}
}
public String PostRequest( JSONObject jsonObj, String url, String token
) {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// 1. 创建POST请求对象
HttpPost post = new HttpPost(url);
StringEntity requestEntity = new StringEntity(jsonObj.toString(), "UTF-8");
requestEntity.setContentType("application/json");
post.setEntity(requestEntity);
post.setHeader("Accept", "application/json");
post.setHeader("token", token);
// 3. 执行请求并获取响应
try (CloseableHttpResponse response = httpClient.execute(post)) {
String responseBody = EntityUtils.toString(response.getEntity());
if (response.getStatusLine().getStatusCode() == 200) {
return responseBody;
} else {
throw new RuntimeException("第三方接口调用失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public String GetRequest(URI uri, String token
) {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// URI uri = new URIBuilder("https://api.example.com/data")
// .addParameter("param1", "value1")
// .addParameter("param2", "value2")
// .build();
HttpGet httpGet = new HttpGet(uri);
if (StringUtils.isNotEmpty(token)){
httpGet.setHeader("token",token);
}
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
// 处理响应
String responseBody = EntityUtils.toString(response.getEntity());
if (response.getStatusLine().getStatusCode() == 200){
return responseBody;
}else {
throw new RuntimeException("第三方接口调用失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

15
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleWarningRecordServiceImpl.java

@ -0,0 +1,15 @@
package org.dromara.sample.manage.service.impl;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.dromara.sample.manage.mapper.SampleWarningRecordMapper;
import org.dromara.sample.manage.mapper.WarningRecordMapper;
import org.dromara.sample.manage.model.entity.WarningRecordEntity;
import org.dromara.sample.manage.service.ISampleWarningRecordService;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class SampleWarningRecordServiceImpl extends ServiceImpl<SampleWarningRecordMapper, WarningRecordEntity> implements ISampleWarningRecordService {
}

44
dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/TaskJobServiceImpl.java

@ -0,0 +1,44 @@
package org.dromara.sample.manage.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.sdk.common.HttpResultResponse;
import org.dromara.common.sdk.common.Pagination;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.common.sdk.mqtt.CommonTopicRequest;
import org.dromara.common.sdk.mqtt.MqttGatewayPublish;
import org.dromara.sample.feign.RemoteSystemFeign;
import org.dromara.sample.manage.mapper.IPlayTextMapper;
import org.dromara.sample.manage.model.dto.StreamTypeDTO;
import org.dromara.sample.manage.model.entity.PlayTextEntity;
import org.dromara.sample.manage.service.IPlayTextService;
import org.dromara.sample.manage.service.ITaskJobService;
import org.dromara.system.api.RemoteConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author sean.zhou
* @version 0.1
* @date 2021/11/10
*/
@Service
@Slf4j
@Transactional
public class TaskJobServiceImpl implements ITaskJobService {
}

14
dk-modules/sample/src/main/java/org/dromara/sample/media/controller/FileController.java

@ -6,6 +6,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sdk.common.HttpResultResponse;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.sample.manage.service.IDeviceProService;
import org.dromara.sample.media.model.MediaFileDTO;
import org.dromara.sample.media.service.IFileService;
import org.dromara.system.api.model.LoginUser;
@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.net.URL;
import java.util.List;
/**
* @author sean
@ -28,6 +30,8 @@ public class FileController {
@Autowired
private IFileService fileService;
/**
* 根据工作区id获取此工作区中所有媒体文件的信息
* Get information about all the media files in this workspace based on the workspace id.
@ -37,8 +41,9 @@ public class FileController {
@Operation(summary = "根据工作区id获取此工作区中所有媒体文件的信息。", description = "根据工作区id获取此工作区中所有媒体文件的信息。")
public HttpResultResponse<PaginationData<MediaFileDTO>> getFilesList(@RequestParam(name = "pageNum", defaultValue = "1") Long page,
@RequestParam(name = "pageSize", defaultValue = "10") Long pageSize,
@PathVariable(name = "workspace_id") String workspaceId) {
PaginationData<MediaFileDTO> filesList = fileService.getMediaFilesPaginationByWorkspaceId(workspaceId, page, pageSize);
@PathVariable(name = "workspace_id") String workspaceId,
@RequestParam(name = "proIds",required = false) List<Integer> proIds) {
PaginationData<MediaFileDTO> filesList = fileService.getMediaFilesPaginationByWorkspaceId(workspaceId, page, pageSize,proIds);
return HttpResultResponse.success(filesList);
}
@ -72,8 +77,9 @@ public class FileController {
public HttpResultResponse<PaginationData<MediaFileDTO>> getFilesByJobId(@RequestParam(name = "pageNum", defaultValue = "1") Long page,
@RequestParam(name = "pageSize", defaultValue = "10") Long pageSize,
@PathVariable(name = "workspace_id") String workspaceId,
@PathVariable(name = "job_id") String jobId) {
PaginationData<MediaFileDTO> filesList = fileService.getMediaFilesPaginationByJobId(workspaceId, page, pageSize,jobId);
@PathVariable(name = "job_id") String jobId,
@RequestParam(name = "type", required = false) Integer type) {
PaginationData<MediaFileDTO> filesList = fileService.getMediaFilesPaginationByJobId(workspaceId, page, pageSize,jobId,type);
for (MediaFileDTO mediaFileDTO :filesList.getList()){
mediaFileDTO.setUrl(fileService.getObjectUrl(workspaceId, mediaFileDTO.getFileId()).toString());
}

4
dk-modules/sample/src/main/java/org/dromara/sample/media/controller/MediaController.java

@ -52,8 +52,8 @@ public class MediaController implements IHttpMediaService {
* @return
*/
@Override
public HttpResultResponse<String> mediaUploadCallback( String workspaceId, @Valid MediaUploadCallbackRequest request, HttpServletRequest req, HttpServletResponse rsp) {
mediaService.saveMediaFile(workspaceId, request);
public HttpResultResponse<String> mediaUploadCallback( String workspaceId,Integer proId, @Valid MediaUploadCallbackRequest request, HttpServletRequest req, HttpServletResponse rsp) {
mediaService.saveMediaFile(workspaceId, request,proId);
return HttpResultResponse.success(request.getObjectKey());
}

3
dk-modules/sample/src/main/java/org/dromara/sample/media/model/MediaFileEntity.java

@ -111,5 +111,8 @@ public class MediaFileEntity implements Serializable {
@TableField("file_index")
private Integer fileIndex;
@TableField("pro_id")
private Integer proId;
}

8
dk-modules/sample/src/main/java/org/dromara/sample/media/service/IFileService.java

@ -29,7 +29,7 @@ public interface IFileService {
* @param file
* @return
*/
Integer saveFile(String workspaceId, MediaUploadCallbackRequest file, FlightTask flightTask);
Integer saveFile(String workspaceId, MediaUploadCallbackRequest file, FlightTask flightTask,Integer proId);
/**
* Query information about all files in this workspace based on the workspace id.
@ -45,7 +45,7 @@ public interface IFileService {
* @param pageSize
* @return
*/
PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize);
PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize,List<Integer> proIds);
/**
* Get the download address of the file.
@ -71,7 +71,7 @@ public interface IFileService {
* @param pageSize
* @return
*/
PaginationData<MediaFileDTO> getMediaFilesPaginationByJobId(String workspaceId, long page, long pageSize,String JobId);
PaginationData<MediaFileDTO> getMediaFilesPaginationByJobId(String workspaceId, long page, long pageSize,String JobId,Integer type);
/**
@ -86,4 +86,6 @@ public interface IFileService {
* @param fileType 图片类型 "jpeg,mp4"
* */
List<MediaFileDTO> getMediaFileDTO( String jobId,String fileType);
String copyFile(String sourceBucket, String originFileUrl, String targetBucket);
}

2
dk-modules/sample/src/main/java/org/dromara/sample/media/service/IMediaService.java

@ -26,7 +26,7 @@ public interface IMediaService {
* @param file
* @return
*/
Integer saveMediaFile(String workspaceId, MediaUploadCallbackRequest file);
Integer saveMediaFile(String workspaceId, MediaUploadCallbackRequest file,Integer proId);
/**
* Query tiny fingerprints about all files in this workspace based on the workspace id.

43
dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/FileServiceImpl.java

@ -1,11 +1,14 @@
package org.dromara.sample.media.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.dromara.common.oss.core.OssClient;
import org.dromara.common.oss.factory.OssFactory;
import org.dromara.common.redis.utils.RedisOpsUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sdk.cloudapi.device.DeviceEnum;
import org.dromara.common.sdk.cloudapi.media.FlightTask;
import org.dromara.common.sdk.cloudapi.media.MediaSubFileTypeEnum;
@ -14,11 +17,14 @@ import org.dromara.common.sdk.common.Pagination;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.sample.manage.model.dto.DeviceDictionaryDTO;
import org.dromara.sample.manage.service.IDeviceDictionaryService;
import org.dromara.sample.manage.service.IDeviceProService;
import org.dromara.sample.media.constant.MinIOConstants;
import org.dromara.sample.media.mapper.IFileMapper;
import org.dromara.sample.media.model.MediaFileDTO;
import org.dromara.sample.media.model.MediaFileEntity;
import org.dromara.sample.media.service.IFileService;
import org.dromara.sample.utils.MinioUtil;
import org.dromara.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -43,6 +49,8 @@ public class FileServiceImpl implements IFileService {
@Autowired
private IDeviceDictionaryService deviceDictionaryService;
@Autowired
private IDeviceProService deviceProService;
private Optional<MediaFileEntity> getMediaByFingerprint(String workspaceId, String fingerprint) {
@ -65,10 +73,15 @@ public class FileServiceImpl implements IFileService {
}
@Override
public Integer saveFile(String workspaceId, MediaUploadCallbackRequest file, FlightTask flightTask) {
public Integer saveFile(String workspaceId, MediaUploadCallbackRequest file, FlightTask flightTask,Integer proId) {
MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file,flightTask);
if(RedisOpsUtils.checkExist("jobId-media:"+fileEntity.getJobId()+fileEntity.getFileName())) {
return 1;
}
RedisOpsUtils.setWithExpire("jobId-media:"+fileEntity.getJobId()+fileEntity.getFileName(),fileEntity.getObjectKey(),10800);
fileEntity.setWorkspaceId(workspaceId);
fileEntity.setFileId(UUID.randomUUID().toString());
fileEntity.setProId(proId);
fileEntity.setFileType(fileEntity.getFileName().substring( fileEntity.getFileName().lastIndexOf(".")+1));
if(!fileEntity.getFileType().equals("DAT")){
fileEntity.setFileStatus(fileEntity.getFileName().substring( fileEntity.getFileName().lastIndexOf("_")+1, fileEntity.getFileName().lastIndexOf(".")));
@ -91,11 +104,16 @@ public class FileServiceImpl implements IFileService {
}
@Override
public PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize) {
public PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize,List<Integer> proIds) {
LoginUser loginUser = LoginHelper.getLoginUser();
if(proIds == null){
proIds = deviceProService.listDeviceGroup(loginUser.getUserId());
}
Page<MediaFileEntity> pageData = mapper.selectPage(
new Page<MediaFileEntity>(page, pageSize),
new LambdaQueryWrapper<MediaFileEntity>()
.eq(MediaFileEntity::getWorkspaceId, workspaceId)
.in(ObjectUtil.isAllNotEmpty(proIds),MediaFileEntity::getProId, proIds)
.orderByDesc(MediaFileEntity::getId));
List<MediaFileDTO> records = pageData.getRecords()
.stream()
@ -125,12 +143,15 @@ public class FileServiceImpl implements IFileService {
}
@Override
public PaginationData<MediaFileDTO> getMediaFilesPaginationByJobId(String workspaceId, long page, long pageSize, String JobId) {
public PaginationData<MediaFileDTO> getMediaFilesPaginationByJobId(String workspaceId, long page, long pageSize, String JobId,Integer type) {
String [] fileTypes = new String[]{"jpeg","mp4"};
Page<MediaFileEntity> pageData = mapper.selectPage(
new Page<MediaFileEntity>(page, pageSize),
new LambdaQueryWrapper<MediaFileEntity>()
.eq(MediaFileEntity::getWorkspaceId, workspaceId)
.eq(MediaFileEntity::getJobId, JobId)
.in(ObjectUtil.isNotEmpty(type),MediaFileEntity::getFileType,fileTypes)
.orderByDesc(MediaFileEntity::getId));
List<MediaFileDTO> records = pageData.getRecords()
.stream()
@ -164,6 +185,22 @@ public class FileServiceImpl implements IFileService {
}
//文件从 mediafile 复制到 alert库,文件保持相同目录
@Override
public String copyFile(String sourceBucket, String originFileUrl, String targetBucket) {
String fileUrl = "";
try {
// String originalfileName = FileUtil.getName(originFileUrl);
MinioUtil.copyFile(originFileUrl,originFileUrl,sourceBucket,targetBucket);//列表图片
MinioUtil.copyFile(originFileUrl,originFileUrl,sourceBucket,MinIOConstants.BUCKET_ALERT);//预览图片
} catch (Exception e) {
throw new RuntimeException(e);
}
return fileUrl;
}
/**
* Convert the received file object into a database entity object.
* @param file

19
dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/MediaServiceImpl.java

@ -1,5 +1,6 @@
package org.dromara.sample.media.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.dromara.common.core.constant.DeviceQrtzConstants;
@ -34,6 +35,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@ -80,8 +82,8 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
}
@Override
public Integer saveMediaFile(String workspaceId, MediaUploadCallbackRequest file) {
return fileService.saveFile(workspaceId, file,null);
public Integer saveMediaFile(String workspaceId, MediaUploadCallbackRequest file,Integer proId) {
return fileService.saveFile(workspaceId, file,null,proId);
}
@Override
@ -123,8 +125,12 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
}
return new TopicEventsResponse<MqttReply>().setData(MqttReply.success());
}
List<DeviceQrtzFileEntity> deviceQrtzFileEntities = new ArrayList<>();
MediaFileCountDTO mediaFileCount = mediaRedisService.getMediaCount(request.getGateway(), jobId);
List<DeviceQrtzFileEntity> deviceQrtzFileEntities = deviceQrtzFileMapper.selectList(new LambdaQueryWrapper<DeviceQrtzFileEntity>().eq(DeviceQrtzFileEntity::getDeviceSn, request.getGateway()).eq(DeviceQrtzFileEntity::getStatus, DeviceQrtzConstants.QRTZ_FILE_STATUS_2).eq(DeviceQrtzFileEntity::getWaylineId, mediaFileCount.getFileId()));
if(ObjectUtil.isNull(mediaFileCount)){
deviceQrtzFileEntities = deviceQrtzFileMapper.selectList(new LambdaQueryWrapper<DeviceQrtzFileEntity>().eq(DeviceQrtzFileEntity::getDeviceSn, request.getGateway()).eq(DeviceQrtzFileEntity::getStatus, DeviceQrtzConstants.QRTZ_FILE_STATUS_2).eq(DeviceQrtzFileEntity::getWaylineId, mediaFileCount.getFileId()));
}
// duplicate data
if (deviceOpt.isEmpty()
|| (Objects.nonNull(mediaFileCount) && request.getBid().equals(mediaFileCount.getBid())
@ -145,10 +151,11 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
return null;
}
notifyUploadedCount(mediaFileCount, request, jobId, device,deviceQrtzFileEntities);
notifyUploadedCount(mediaFileCount, request, jobId, device);
return new TopicEventsResponse<MqttReply>().setData(MqttReply.success());
}
@Override
public TopicEventsResponse<MqttReply> highestPriorityUploadFlightTaskMedia(
TopicEventsRequest<HighestPriorityUploadFlightTaskMedia> request, MessageHeaders headers) {
@ -189,12 +196,12 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
file.setPath(objectKey.substring(Optional.of(objectKey.indexOf("mediafile"))
.filter(index -> index > 0).map(index -> index++).orElse(0),
objectKey.lastIndexOf("/")));
Integer fileFlag = fileService.saveFile(device.getWorkspaceId(), file, callback.getFlightTask());
Integer fileFlag = fileService.saveFile(device.getWorkspaceId(), file, callback.getFlightTask(),device.getProId());
return fileFlag> 0;
}
private void notifyUploadedCount(MediaFileCountDTO mediaFileCount, TopicEventsRequest<FileUploadCallback> request, String jobId, DeviceDTO dock, List<DeviceQrtzFileEntity> deviceQrtzFileEntities) {
private void notifyUploadedCount(MediaFileCountDTO mediaFileCount, TopicEventsRequest<FileUploadCallback> request, String jobId, DeviceDTO dock) {
// Do not notify when files that do not belong to the route are uploaded.
//不通知不属于路由的文件被上传。
if (Objects.isNull(mediaFileCount)) {

183
dk-modules/sample/src/main/java/org/dromara/sample/utils/MinioUtil.java

@ -0,0 +1,183 @@
package org.dromara.sample.utils;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import io.minio.*;
import io.minio.http.Method;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.util.HashMap;
@Component
public class MinioUtil {
// 指定MinIO服务的访问地址(包括协议、域名或IP以及端口)
private static String endpoint;
// MinIO的访问密钥(Access Key),用于身份验证
private static String accessKey;
// MinIO的秘密密钥(Secret Key),与访问密钥配对使用,也是认证的一部分。
private static String secretKey;
// 指定默认的存储桶(Bucket)名称,MinIO中用于组织和存储对象(文件)的基本容器。
private static String bucket;
@Value("${minio.endpoint:http://114.235.183.147:9090}")
public void setEndpoint(String endpoint) {
MinioUtil.endpoint = endpoint;
}
@Value("${minio.accessKey:wuyuan@yf}")
public void setAccessKey(String accessKey) {
MinioUtil.accessKey = accessKey;
}
@Value("${minio.secretKey:wuyuan@yf}")
public void setSecretKey(String secretKey) {
MinioUtil.secretKey = secretKey;
}
@Value("${minio.bucket:dkcy}")
public void setBucket(String bucket) {
MinioUtil.bucket = bucket;
}
/**
* 创建并返回一个配置好的MinioClient实例
* 用于与MinIO服务器交互,上传文件下载文件删除文件
*
* @return 配置
*/
public static MinioClient getMinioClient() {
return MinioClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.build();
}
/**
* 上传将一个输入流中的文件上传到MinIO服务器上指定的存储桶bucket
*
* @param objectName .object(objectName)指定了上传后对象的名称
* @param inputStream 转换为
* @param size 文件大小
* @param contentType 内容类型
* @throws Exception 异常
*/
public static void uploadFile(String objectName, InputStream inputStream, long size, String contentType,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
minioClient.putObject(
// .bucket(bucket) 指定了目标存储桶的名称。.object(objectName)指定了上传后对象的名称。
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(inputStream, size, -1)
// .contentType(contentType)指定了上传文件的内容类型。
.contentType(contentType)
.build());
}
/**
* 下载从MinIO服务器下载指定存储桶bucket中的文件
*
* @param objectName 指定要从MinIO下载的文件对象名称即文件路径和文件名
* @return 对象
* @throws Exception 异常
*/
public static InputStream downloadFile(String objectName,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
return minioClient.getObject(
GetObjectArgs.builder()
// .bucket(bucket)指定了文件所在的存储桶名称。
.bucket(bucketName)
// .object(objectName)指定了要下载的对象名称。
.object(objectName)
.build());
}
/**
* 预览生成一个预签名的URL允许用户通过浏览器或其他HTTP客户端以GET方法访问MinIO存储桶中指定对象文件的临时链接
*
* @param objectName 指定需要获取预览链接的文件对象名称包括路径
* @return 对象
* @throws Exception .method(Method.GET)指定了请求的方法为GET这是预览文件时的标准HTTP方法
* .bucket(bucket)指定了存储桶的名称
* .object(objectName)指定了对象文件的名称
*/
public static String getPreviewUrl(String objectName,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
return minioClient.getPresignedObjectUrl(
GetPresignedObjectUrlArgs.builder()
.method(Method.GET)
.bucket(bucketName)
.object(objectName)
.build());
}
/**
* 删除从MinIO服务器上的指定存储桶中删除一个文件
*
* @param objectName 指定要删除的文件对象名称包括路径和文件名
* @throws Exception
*/
public static void deleteFile(String objectName,String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient minioClient = getMinioClient();
minioClient.removeObject(
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());
}
//查询文件信息
public static HashMap<String,Object> getFileAsMultipart(String objectName, String newBucket) throws Exception {
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket;
MinioClient client = getMinioClient();
// 获取对象
InputStream is = client.getObject(GetObjectArgs.builder()
.bucket(bucketName)
.object(objectName)
.build());
// 获取文件元信息(如 contentType)
StatObjectResponse stat = client.statObject(StatObjectArgs.builder()
.bucket(bucketName)
.object(objectName)
.build());
String contentType = stat.contentType();
// 将流读为 byte[] 以生成 MockMultipartFile
byte[] bytes = IoUtil.readBytes(is); // Hutool 工具类
HashMap<String, Object> map = new HashMap<>();
map.put("objectName",objectName);
map.put("contentType",contentType);
map.put("bytes",bytes);
return map;
}
//文件复制
public static void copyFile(String sourceObjectName, String targetObjectName, String sourceBucket, String targetBucket) throws Exception {
MinioClient client = getMinioClient();
// 使用服务器端复制,无需下载上传
client.copyObject(CopyObjectArgs.builder()
.bucket(targetBucket) // 目标桶
.object(targetObjectName) // 目标对象
.source(CopySource.builder()
.bucket(sourceBucket)
.object(sourceObjectName)
.build())
.build());
}
}

29
dk-modules/sample/src/main/java/org/dromara/sample/wayline/controller/WaylineFileController.java

@ -1,6 +1,7 @@
package org.dromara.sample.wayline.controller;
import io.seata.common.util.CollectionUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
@ -14,6 +15,10 @@ import org.dromara.common.sdk.cloudapi.wayline.*;
import org.dromara.common.sdk.cloudapi.wayline.api.IHttpWaylineService;
import org.dromara.common.sdk.common.HttpResultResponse;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.sample.manage.mapper.IDeviceProUserMapper;
import org.dromara.sample.manage.model.dto.DeviceDTO;
import org.dromara.sample.manage.service.IDeviceProService;
import org.dromara.sample.manage.service.IDeviceRedisService;
import org.dromara.sample.wayline.model.dto.WaylineFileDTO;
import org.dromara.sample.wayline.model.entity.AudioFileEntity;
import org.dromara.sample.wayline.model.entity.WaylineFileEntity;
@ -31,8 +36,11 @@ import java.net.URL;
import java.sql.SQLException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.bouncycastle.internal.asn1.cms.CMSObjectIdentifiers.data;
/**
* @author sean
@ -46,6 +54,9 @@ public class WaylineFileController implements IHttpWaylineService {
@Autowired
private IWaylineFileService waylineFileService;
@Autowired
private IDeviceRedisService deviceRedisService;
/**
* 根据waylineID删除工作区中的wayline文件
* Delete the wayline file in the workspace according to the wayline id.
@ -67,13 +78,17 @@ public class WaylineFileController implements IHttpWaylineService {
*/
@PostMapping("${url.wayline.prefix}${url.wayline.version}/workspaces/{workspace_id}/waylines/file/{deviceSn}/upload")
@Operation(summary = "导入kmz航路文件。", description = "导入kmz航路文件。")
public HttpResultResponse importKmzFile(@PathVariable(name = "workspace_id") String workspaceId,HttpServletRequest request, MultipartFile file,@PathVariable(name = "deviceSn") String deviceSn) {
public HttpResultResponse importKmzFile(@PathVariable(name = "workspace_id") String workspaceId,HttpServletRequest request, MultipartFile file,@PathVariable(name = "deviceSn") String deviceSn,@RequestParam(name = "proId",required = false) Integer proId) {
if (Objects.isNull(file)) {
return HttpResultResponse.error("未收到文件。");
}
Optional<DeviceDTO> deviceOnline = deviceRedisService.getDeviceOnline(deviceSn);
if(proId == null){
proId = deviceOnline.get().getProId();
}
LoginUser loginUser = LoginHelper.getLoginUser();
String creator = loginUser.getUsername();
waylineFileService.importKmzFile(file, workspaceId, creator,deviceSn);
waylineFileService.importKmzFile(file, workspaceId, creator,deviceSn,proId);
return HttpResultResponse.success();
}
@ -86,11 +101,17 @@ public class WaylineFileController implements IHttpWaylineService {
* @return
*/
@Override
public HttpResultResponse<PaginationData<GetWaylineListResponse>> getWaylineList(@Valid GetWaylineListRequest request,String workspaceId, HttpServletRequest req, HttpServletResponse rsp) {
PaginationData<GetWaylineListResponse> data = waylineFileService.getWaylinesByParam(workspaceId, request);
public HttpResultResponse<PaginationData<GetWaylineListResponse>> getWaylines(@Valid GetWaylineListRequest request,String workspaceId,List<Integer> proIds, HttpServletRequest req, HttpServletResponse rsp) {
PaginationData<GetWaylineListResponse> data = waylineFileService.getWaylinesByParam(workspaceId, request,proIds);
return HttpResultResponse.success(data);
}
@Override
public HttpResultResponse<List<GetWaylineListResponse>> getWaylineList(String workspaceId,Integer proId, HttpServletRequest req, HttpServletResponse rsp) {
List<GetWaylineListResponse> waylinesByParamList = waylineFileService.getWaylinesByParamList(workspaceId, proId);
return HttpResultResponse.success(waylinesByParamList);
}
/**
* 根据 wayline 文件 ID 查询文件的下载地址并直接重定向到此地址进行下载
* Query the download address of the file according to the wayline file id,

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

@ -16,12 +16,15 @@ import org.dromara.sample.component.mqtt.model.EventsReceiver;
import org.dromara.sample.media.model.MediaFileDTO;
import org.dromara.sample.wayline.model.dto.WaylineJobDTO;
import org.dromara.sample.wayline.model.enums.WaylineTaskStatusEnum;
import org.dromara.sample.wayline.model.entity.WaylineFileEntity;
import org.dromara.sample.wayline.model.param.CreateJobParam;
import org.dromara.sample.wayline.model.param.UpdateJobParam;
import org.dromara.sample.wayline.service.IFlightTaskService;
import org.dromara.sample.wayline.service.IWaylineFileService;
import org.dromara.sample.wayline.service.IWaylineJobService;
import org.dromara.sample.wayline.service.IWaylineRedisService;
import org.dromara.sample.wayline.service.IWaylineRedisService;
import org.dromara.sample.wayline.service.impl.WaylineFileServiceImpl;
import org.dromara.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -33,6 +36,8 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import static org.bouncycastle.asn1.x500.style.RFC4519Style.name;
/**
* @author sean
@ -81,8 +86,11 @@ public class WaylineJobController {
@Operation(summary = "查询工作区中的所有作业。。", description = "查询工作区中的所有作业。")
public HttpResultResponse<PaginationData<WaylineJobDTO>> getJobs(@RequestParam(name = "pageNum", defaultValue = "1") Long page,
@RequestParam(name = "pageSize", defaultValue = "10") Long pageSize,
@PathVariable(name = "workspace_id") String workspaceId) {
PaginationData<WaylineJobDTO> data = waylineJobService.getJobsByWorkspaceId(workspaceId, page, pageSize);
@PathVariable(name = "workspace_id") String workspaceId,
@RequestParam(name = "proIds" , required = false) List<Integer> proIds,
@RequestParam(name = "fileId" , required = false) String fileId,
@RequestParam(name = "name" , required = false) String name) {
PaginationData<WaylineJobDTO> data = waylineJobService.getJobsByWorkspaceId(workspaceId, page, pageSize,fileId,proIds,name);
return HttpResultResponse.success(data);
}
@ -120,28 +128,25 @@ public class WaylineJobController {
flighttaskService.updateJobStatus(workspaceId, jobId, param);
return HttpResultResponse.success();
}
public static void main(String[] args) {
WaylineTaskStatusEnum pause = WaylineTaskStatusEnum.RESUME;
System.out.println(pause.getVal());
@GetMapping("/{workspace_id}/getJobIdByDeviceSn")
@Operation(summary = "根据设备查询飞行任务。", description = "根据设备查询飞行任务。")
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())return HttpResultResponse.error("不存在");
return HttpResultResponse.success(runningWaylineJob.get().getOutput().getExt().getFlightId()!=null?runningWaylineJob.get().getOutput().getExt().getFlightId():null);
}
@GetMapping("/{workspace_id}/getJobFileUrlByDeviceSn")
@Operation(summary = "根据设备查询飞行任务。", description = "根据设备查询飞行任务。")
public void getJobFileUrlByDeviceSn(@PathVariable(name = "workspace_id") String workspaceId,
@RequestParam(name = "device_sn") String deviceSn, HttpServletRequest req, HttpServletResponse rsp) {
@RequestParam(name = "device_sn") String deviceSn, HttpServletRequest req, HttpServletResponse rsp) {
try {
Optional<EventsReceiver<FlighttaskProgress>> runningWaylineJob = waylineRedisService.getRunningWaylineJob(deviceSn);
if(runningWaylineJob.isEmpty()) {
return;
}
if(runningWaylineJob.isEmpty())return;
String jobId = runningWaylineJob.get().getOutput().getExt().getFlightId();
Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobId(workspaceId, jobId);
if(waylineJobDTO.isEmpty()) {
return;
}
if(waylineJobDTO.isEmpty())return;
URL url = waylineFileService.getObjectUrl(workspaceId, waylineJobDTO.get().getFileId());
rsp.sendRedirect(url.toString());
} catch (IOException | SQLException e) {

2
dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/dto/WaylineFileDTO.java

@ -47,4 +47,6 @@ public class WaylineFileDTO {
private Integer fileNo;
private Integer proId;
}

3
dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/dto/WaylineJobDTO.java

@ -10,6 +10,7 @@ import org.dromara.common.sdk.cloudapi.wayline.TaskTypeEnum;
import org.dromara.common.sdk.cloudapi.wayline.WaylineTypeEnum;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author sean
@ -72,4 +73,6 @@ public class WaylineJobDTO {
private String parentId;
private ProgressExtBreakPoint breakPoint;
private List<Integer> proIds;
}

2
dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/entity/WaylineFileEntity.java

@ -69,4 +69,6 @@ public class WaylineFileEntity implements Serializable {
@TableField(exist = false)
private String deviceName;
@TableField("pro_id")
private Integer proId;
}

3
dk-modules/sample/src/main/java/org/dromara/sample/wayline/model/entity/WaylineJobEntity.java

@ -94,4 +94,7 @@ public class WaylineJobEntity implements Serializable {
@TableField(exist = false)
private ProgressExtBreakPoint breakPoint;
@TableField("pro_id")
private Integer proId;
}

9
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/IWaylineFileService.java

@ -5,6 +5,7 @@ import org.dromara.common.sdk.cloudapi.wayline.GetWaylineListResponse;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.sample.wayline.model.dto.WaylineFileDTO;
import org.dromara.sample.wayline.model.entity.AudioFileEntity;
import org.dromara.sample.wayline.model.entity.WaylineFileEntity;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
@ -26,7 +27,9 @@ public interface IWaylineFileService {
* @param param
* @return
*/
PaginationData<GetWaylineListResponse> getWaylinesByParam(String workspaceId, GetWaylineListRequest param);
PaginationData<GetWaylineListResponse> getWaylinesByParam(String workspaceId, GetWaylineListRequest param,List<Integer> proIds);
List<GetWaylineListResponse> getWaylinesByParamList(String workspaceId,Integer proId);
/**
* Query the information of this wayline file according to the wayline file id.
@ -83,10 +86,12 @@ public interface IWaylineFileService {
* @param creator
* @return
*/
void importKmzFile(MultipartFile file, String workspaceId, String creator,String deviceSn);
void importKmzFile(MultipartFile file, String workspaceId, String creator,String deviceSn,Integer proId);
String getWaylineIdByFileId(Integer fileId);
WaylineFileEntity getWaylineFileByWaylineId(Integer waylineId);
/**
* Perform paging queries based on query parameters.

4
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/IWaylineJobService.java

@ -28,7 +28,7 @@ public interface IWaylineJobService {
* @param endTime The time the job ended.
* @return
*/
Optional<WaylineJobDTO> createWaylineJob(CreateJobParam param, String workspaceId, String username, Date beginTime, Date endTime);
Optional<WaylineJobDTO> createWaylineJob(CreateJobParam param, String workspaceId, String username, Date beginTime, Date endTime, Integer proId);
/**
* Create a sub-task based on the information of the parent task.
@ -71,7 +71,7 @@ public interface IWaylineJobService {
* @param pageSize
* @return
*/
PaginationData<WaylineJobDTO> getJobsByWorkspaceId(String workspaceId, long page, long pageSize);
PaginationData<WaylineJobDTO> getJobsByWorkspaceId(String workspaceId, long page, long pageSize,String fileId,List<Integer> proIds,String name);
/**
* Query the wayline execution status of the dock.

123
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/AiCompareServiceImpl.java

@ -1,25 +1,26 @@
package org.dromara.sample.wayline.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.minio.MinioClient;
import io.minio.StatObjectArgs;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.ibatis.executor.BatchResult;
import org.dromara.business.api.RemoteBusinessAlertService;
import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertConstructInfo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo;
import org.dromara.common.core.constant.AiCompareStatusConstants;
import org.dromara.common.core.constant.BusinessConstants;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -28,10 +29,7 @@ import org.dromara.common.sdk.mqtt.CommonTopicRequest;
import org.dromara.common.sdk.mqtt.MqttGatewayPublish;
import org.dromara.common.sdk.mqtt.TopicConst;
import org.dromara.sample.media.constant.MinIOConstants;
import org.dromara.sample.media.mapper.IFileMapper;
import org.dromara.sample.media.model.MediaFileEntity;
import org.dromara.sample.media.service.IFileService;
import org.dromara.sample.media.service.IMediaService;
import org.dromara.sample.wayline.mapper.IAiCompareMapper;
import org.dromara.sample.wayline.mapper.IAiComparePlateMapper;
import org.dromara.sample.wayline.mapper.IWaylineJobMapper;
@ -45,13 +43,11 @@ import org.dromara.sample.wayline.service.IAiCompareService;
import org.dromara.system.api.model.LoginUser;
import org.dromara.workflow.api.RemoteWorkflowService;
import org.dromara.workflow.api.domain.RemoteStartProcess;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -206,21 +202,116 @@ public class AiCompareServiceImpl implements IAiCompareService {
AiCompareEntity aiCompareEntity = aiCompareMapper.selectById(id);
return listMediaFile(aiCompareEntity.getJobId(),aiCompareEntity.getId(),3600,true);
}
// @Value("${spring.profiles.active}")
// private String activeProfile;
@Override
public Boolean pictureFrame(Map<String,Object>objectMap) {
public Boolean pictureFrame(Map<String,Object> objectMap) {
FrameDTO frameDTO = Convert.convert(FrameDTO.class, objectMap);
AiCompareEntity aiCompareEntity = aiCompareMapper.selectById(frameDTO.getCompareId());
aiCompareEntity.setStatus(AiCompareStatusConstants.COMPARE_STATUS_3);
aiCompareEntity.setId(frameDTO.getCompareId());
aiCompareMapper.updateById(aiCompareEntity);
frameDTO.setJobName(aiCompareEntity.getJobName());
frameDTO.setFileUrl(fileService.getObjectUrlOne(MinIOConstants.BUCKET_MEDIAFILE,frameDTO.getFileUrl(),3600).toString());
frameDTO.setMateFileUrl(fileService.getObjectUrlOne(MinIOConstants.BUCKET_MEDIAFILE,frameDTO.getMateFileUrl(),3600).toString());
String originFileUrl = frameDTO.getFileUrl();
String fileUrl = fileService.getObjectUrlOne(MinIOConstants.BUCKET_MEDIAFILE, originFileUrl, 3600).toString();
frameDTO.setFileUrl(fileUrl);
String originMateFileUrl = frameDTO.getMateFileUrl();
String mateFileUrl = fileService.getObjectUrlOne(MinIOConstants.BUCKET_MEDIAFILE, originMateFileUrl, 3600).toString();
frameDTO.setMateFileUrl(mateFileUrl);
String topic = TopicConst.IMAGE +TopicConst.FRAME;
mqttGatewayPublish.publish(topic,new CommonTopicRequest().setData(frameDTO),1);
// if(StrUtil.equals(activeProfile,"w_fengxianranqi"))
// activeProfile="w_fengxianranqi"
String activeProfile = MapUtil.getStr(objectMap, "activeProfile", "default");
if (StrUtil.equals("default", activeProfile)) {
//发送mqtt给算法,处理完
mqttGatewayPublish.publish(topic, new CommonTopicRequest().setData(frameDTO), 1);
} else {
//图片处理
// fileService.get(MinIOConstants.BUCKET_MEDIAFILE, originMateFileUrl, 3600);
//复制原图到指定bucket
String copyFileUrl = fileService.copyFile(MinIOConstants.BUCKET_MEDIAFILE, originMateFileUrl, MinIOConstants.BUCKET_DKCY);
// String copyFileUrl = fileService.copyFile(MinIOConstants.BUCKET_MEDIAFILE, originFileUrl, MinIOConstants.BUCKET_ALERT);
ArrayList<RemoteBusinessAlertVo> alertVoList = new ArrayList<>();
//手动简化逻辑,上传图片
int frameCount =0;
for (Map<String, Object> alertMap : frameDTO.getFrameList()) {
if(frameCount >= 1 ){continue;} //暂时只保存一个文件
//businessAlert数据
RemoteBusinessAlertVo remoteBusinessAlertVo = new RemoteBusinessAlertVo();
// remoteBusinessAlertVo.setAlertType("1"); //1:图片比对预警 2:AI实时预警
remoteBusinessAlertVo.setJobId(aiCompareEntity.getJobId());
remoteBusinessAlertVo.setJobName(aiCompareEntity.getJobName());
remoteBusinessAlertVo.setAssign(false);
remoteBusinessAlertVo.setImages(originMateFileUrl);//fileUrl
remoteBusinessAlertVo.setMaxImages(originMateFileUrl);//mateFileUrl
remoteBusinessAlertVo.setMateSourceImgUrl(originFileUrl);//mateFileUrl
remoteBusinessAlertVo.setLat("34.20912175973148");
remoteBusinessAlertVo.setLng("117.2260332850499");
remoteBusinessAlertVo.setLabelCn(MapUtil.getStr(alertMap,"labelCn",""));
remoteBusinessAlertVo.setLabelEn(MapUtil.getStr(alertMap,"labelEn",""));
remoteBusinessAlertVo.setTaskContent("");
//面积计算
setupArea(alertMap, remoteBusinessAlertVo);
remoteBusinessAlertVo.setHandleType("waiting");
remoteBusinessAlertVo.setDeptId(aiCompareEntity.getCreateDept()+"");
remoteBusinessAlertVo.setDeptName(aiCompareEntity.getDeptName());
remoteBusinessAlertVo.setHandleNum(0);
//businessAlertConstructInfo数据
RemoteBusinessAlertConstructInfo acInfo = new RemoteBusinessAlertConstructInfo();
acInfo.setBusinessType(2l);
acInfo.setJobId(aiCompareEntity.getJobId());
acInfo.setJobName(aiCompareEntity.getJobName());
acInfo.setConstructName(MapUtil.getStr(alertMap,"constructName",""));
acInfo.setConstructDept(MapUtil.getStr(alertMap,"constructDept",""));
acInfo.setConstructLeader(MapUtil.getStr(alertMap,"constructLeader",""));
acInfo.setPhonenumber(MapUtil.getStr(alertMap,"phonenumber",""));
acInfo.setAddress(MapUtil.getStr(alertMap,"address",""));
acInfo.setPipeline(MapUtil.getStr(alertMap,"pipeline",""));
acInfo.setRemark(MapUtil.getStr(alertMap,"remark",""));
remoteBusinessAlertVo.setRemoteAlertConstructInfo(acInfo);
alertVoList.add(remoteBusinessAlertVo);
frameCount +=1;
}
businessAlertService.saveBusinessAlert(alertVoList,activeProfile);
}
return true;
}
private static void setupArea(Map<String, Object> alertMap, RemoteBusinessAlertVo remoteBusinessAlertVo) {
double lx = MapUtil.getInt(alertMap,"lx",0);
double ly = MapUtil.getInt(alertMap,"ly",0);
double rx = MapUtil.getInt(alertMap,"rx",0);
double ry = MapUtil.getInt(alertMap,"ry",0);
double areaw = Math.abs(rx - lx);
double areal = Math.abs(ry - ly);
double area = areaw * areal;
remoteBusinessAlertVo.setArea((long)area);
remoteBusinessAlertVo.setAreaL((long)areal);
remoteBusinessAlertVo.setAreaW((long)areaw);
JSONObject entries = new JSONObject();
entries.set("lef_x", lx);
entries.set("lef_y", ly);
entries.set("right_x", rx);
entries.set("right_y", ry);
remoteBusinessAlertVo.setPixelCoordinate(entries.toString());
}
@Override
public Boolean expose(List<Map<String,Object>> mapList) {
if(!mapList.isEmpty()){
@ -246,7 +337,7 @@ public class AiCompareServiceImpl implements IAiCompareService {
AiCompareAlertDTO compareAlertDTO = Convert.convert(AiCompareAlertDTO.class,map);
aiComparePlateMapper.update(new LambdaUpdateWrapper<AiComparePlateEntity>().eq(AiComparePlateEntity::getFileId,compareAlertDTO.getFileId()).set(AiComparePlateEntity::getPatternName,compareAlertDTO.getDiscernImgUrl()));
List<RemoteBusinessAlertVo> handleList = compareAlertDTO.getHandleList();
return businessAlertService.saveBusinessAlert(handleList);
return businessAlertService.saveBusinessAlert(handleList,"default");
}
@Override

20
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/FlightTaskServiceImpl.java

@ -241,8 +241,14 @@ public class FlightTaskServiceImpl extends AbstractWaylineService implements IFl
if (TaskTypeEnum.IMMEDIATE != param.getTaskType() && endTime < System.currentTimeMillis()) {
continue;
}
Optional<WaylineJobDTO> waylineJobOpt = waylineJobService.createWaylineJob(param, workspaceId, loginUser.getUsername(), new Date(beginTime), new Date(endTime));
Optional<DeviceDTO> deviceOnline = deviceRedisService.getDeviceOnline(param.getDockSn());
if(deviceOnline.isEmpty()){
throw new SQLException("机场信息不存在");
}
if(deviceOnline.get().getProId() == null){
throw new SQLException("项目组不存在");
}
Optional<WaylineJobDTO> waylineJobOpt = waylineJobService.createWaylineJob(param, workspaceId, loginUser.getUsername(), new Date(beginTime), new Date(endTime),deviceOnline.get().getProId());
if (waylineJobOpt.isEmpty()) {
throw new SQLException("无法创建路线作业。");
}
@ -273,8 +279,14 @@ public class FlightTaskServiceImpl extends AbstractWaylineService implements IFl
if (TaskTypeEnum.IMMEDIATE != param.getTaskType() && endTime < System.currentTimeMillis()) {
continue;
}
Optional<WaylineJobDTO> waylineJobOpt = waylineJobService.createWaylineJob(param, workspaceId, username, new Date(beginTime), new Date(endTime));
Optional<DeviceDTO> deviceOnline = deviceRedisService.getDeviceOnline(param.getDockSn());
if(deviceOnline.isEmpty()){
throw new SQLException("机场信息不存在");
}
if(deviceOnline.get().getProId() == null){
throw new SQLException("项目组不存在");
}
Optional<WaylineJobDTO> waylineJobOpt = waylineJobService.createWaylineJob(param, workspaceId, username, new Date(beginTime), new Date(endTime),deviceOnline.get().getProId());
if (waylineJobOpt.isEmpty()) {
throw new SQLException("无法创建路线作业。");
}

15
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/SDKWaylineService.java

@ -3,6 +3,7 @@ package org.dromara.sample.wayline.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.dromara.common.core.constant.DeviceQrtzConstants;
import org.dromara.common.sdk.cloudapi.device.OsdDockDrone;
import org.dromara.common.sdk.cloudapi.wayline.*;
import org.dromara.common.sdk.cloudapi.wayline.api.AbstractWaylineService;
import org.dromara.common.sdk.mqtt.MqttReply;
@ -16,8 +17,10 @@ import org.dromara.sample.common.error.CommonErrorEnum;
import org.dromara.sample.component.mqtt.model.EventsReceiver;
import org.dromara.sample.manage.mapper.IDeviceQrtzFileMapper;
import org.dromara.sample.manage.model.dto.DeviceDTO;
import org.dromara.sample.manage.model.entity.DeviceFlightRecordsEntity;
import org.dromara.sample.manage.model.entity.DeviceQrtzFileEntity;
import org.dromara.sample.manage.model.enums.UserTypeEnum;
import org.dromara.sample.manage.service.IDeviceFlightRecordsService;
import org.dromara.sample.manage.service.IDeviceRedisService;
import org.dromara.sample.media.model.MediaFileCountDTO;
import org.dromara.sample.media.service.IMediaRedisService;
@ -71,6 +74,9 @@ public class SDKWaylineService extends AbstractWaylineService {
@Autowired
private IWebSocketMessageService webSocketMessageService;
@Autowired
private IDeviceFlightRecordsService deviceFlightRecordsService;
@Override
public TopicEventsResponse<MqttReply> deviceExitHomingNotify(TopicEventsRequest<DeviceExitHomingNotify> request, MessageHeaders headers) {
return super.deviceExitHomingNotify(request, headers);
@ -105,6 +111,15 @@ public class SDKWaylineService extends AbstractWaylineService {
.completedTime(LocalDateTime.now())
.mediaCount(output.getExt().getMediaCount())
.build();
//Optional<OsdDockDrone> deviceOsd = deviceRedisService.getDeviceOsd(deviceOpt.get().getChildDeviceSn(), OsdDockDrone.class);
// Integer totalFlightSorties = deviceOsd.get().getTotalFlightSorties();
// Float totalFlightTime = deviceOsd.get().getTotalFlightTime();
// DeviceFlightRecordsEntity deviceFlightRecords = new DeviceFlightRecordsEntity();
// deviceFlightRecords.setDeviceSn(response.getGateway());
// deviceFlightRecords.setFlyCount(totalFlightSorties);
// deviceFlightRecords.setFlyAccTime(totalFlightTime.intValue());
// deviceFlightRecordsService.saveDeviceFlight(deviceFlightRecords);
// record the update of the media count.
if (Objects.nonNull(job.getMediaCount()) && job.getMediaCount() != 0) {

53
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/WaylineFileServiceImpl.java

@ -17,6 +17,7 @@ import org.dom4j.io.SAXReader;
import org.dromara.common.oss.core.OssClient;
import org.dromara.common.oss.entity.UploadResult;
import org.dromara.common.oss.factory.OssFactory;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sdk.cloudapi.device.DeviceDomainEnum;
import org.dromara.common.sdk.cloudapi.device.DeviceEnum;
import org.dromara.common.sdk.cloudapi.device.DeviceSubTypeEnum;
@ -28,6 +29,8 @@ import org.dromara.common.sdk.common.Pagination;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.resource.api.RemoteFileService;
import org.dromara.resource.api.domain.RemoteFile;
import org.dromara.sample.manage.service.IDeviceProService;
import org.dromara.sample.manage.service.IDeviceRedisService;
import org.dromara.sample.wayline.mapper.IAudioFileMapper;
import org.dromara.sample.wayline.mapper.IWaylineFileMapper;
import org.dromara.sample.wayline.model.dto.KmzFileProperties;
@ -35,6 +38,7 @@ import org.dromara.sample.wayline.model.dto.WaylineFileDTO;
import org.dromara.sample.wayline.model.entity.AudioFileEntity;
import org.dromara.sample.wayline.model.entity.WaylineFileEntity;
import org.dromara.sample.wayline.service.IWaylineFileService;
import org.dromara.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -77,9 +81,21 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
@DubboReference
private RemoteFileService remoteFileService;
@Autowired
private IDeviceProService deviceProService;
@Autowired
private IDeviceRedisService deviceRedisService;
@Override
public PaginationData<GetWaylineListResponse> getWaylinesByParam(String workspaceId, GetWaylineListRequest param) {
public PaginationData<GetWaylineListResponse> getWaylinesByParam(String workspaceId, GetWaylineListRequest param,List<Integer> proIds) {
LoginUser loginUser = LoginHelper.getLoginUser();
if(proIds == null){
proIds = deviceProService.listDeviceGroup(loginUser.getUserId());
}
// Paging Query
List<Integer> finalProIds = proIds;
Page<WaylineFileEntity> page = mapper.selectPage(
new Page<WaylineFileEntity>(param.getPage(), param.getPageSize()),
new LambdaQueryWrapper<WaylineFileEntity>()
@ -103,6 +119,9 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
.and(ObjectUtil.isNotEmpty(param.getDeviceSn()), wrapper -> {
wrapper.eq(WaylineFileEntity::getDeviceSn, param.getDeviceSn()).or();
})
.and(ObjectUtil.isAllNotEmpty(proIds), wrapper -> {
wrapper.in(WaylineFileEntity::getProId, finalProIds);
})
.like(Objects.nonNull(param.getKey()), WaylineFileEntity::getName, param.getKey())
// There is a risk of SQL injection
.last(Objects.nonNull(param.getOrderBy()), " order by " + param.getOrderBy().toString()));
@ -115,6 +134,24 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
return new PaginationData<>(records, new Pagination(page.getCurrent(), page.getSize(), page.getTotal()));
}
@Override
public List<GetWaylineListResponse> getWaylinesByParamList(String workspaceId,Integer proId) {
List<WaylineFileEntity> waylineFileEntities = mapper.selectList(
new LambdaQueryWrapper<WaylineFileEntity>()
.eq(WaylineFileEntity::getWorkspaceId, workspaceId)
.eq(WaylineFileEntity::getProId, proId)
// There is a risk of SQL injection
.orderByDesc(WaylineFileEntity::getCreateTime));
// Wrap the results of a paging query into a custom paging object.
List<GetWaylineListResponse> records = waylineFileEntities
.stream()
.map(this::entityConvertToDTO)
.collect(Collectors.toList());
return records;
}
@Override
public Optional<GetWaylineListResponse> getWaylineByWaylineId(String workspaceId, String waylineId) {
return Optional.ofNullable(
@ -203,7 +240,10 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
}
@Override
public void importKmzFile(MultipartFile file, String workspaceId, String creator,String deviceSn) {
public void importKmzFile(MultipartFile file, String workspaceId, String creator,String deviceSn,Integer proId) {
if(ObjectUtil.isNull(proId)){
proId = deviceRedisService.getDeviceOnline(deviceSn).get().getProId();
}
Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file);
if (waylineFileOpt.isEmpty()) {
throw new RuntimeException("文件格式不正确。");
@ -230,6 +270,7 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
}else {
waylineFile.setFileNo(1);
}
waylineFile.setProId(proId);
this.saveWaylineFile(workspaceId, waylineFile);
} catch (IOException e) {
e.printStackTrace();
@ -244,6 +285,13 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
return waylineId;
}
@Override
public WaylineFileEntity getWaylineFileByWaylineId(Integer waylineId) {
return mapper.selectOne(
new LambdaQueryWrapper<WaylineFileEntity>()
.eq(WaylineFileEntity::getId, waylineId));
}
@Override
public PaginationData<GetWaylineListResponse> getWaylinesByParamNew(String workspaceId, GetWaylineListRequest param) {
Page<WaylineFileEntity> waylineFileEntityPage = new Page<>(param.getPage(), param.getPageSize());
@ -466,6 +514,7 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
.favorited(file.getFavorited())
.sign(file.getSign())
.deviceSn(file.getDeviceSns().get(0))
.proId(file.getProId())
.build();
}

37
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/WaylineJobServiceImpl.java

@ -1,10 +1,12 @@
package org.dromara.sample.wayline.service.impl;
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.extension.plugins.pagination.Page;
import org.dromara.common.redis.config.RedisConst;
import org.dromara.common.redis.utils.RedisOpsUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sdk.cloudapi.device.DockModeCodeEnum;
import org.dromara.common.sdk.cloudapi.device.DroneModeCodeEnum;
import org.dromara.common.sdk.cloudapi.device.OsdDock;
@ -12,8 +14,10 @@ import org.dromara.common.sdk.cloudapi.device.OsdDockDrone;
import org.dromara.common.sdk.cloudapi.wayline.*;
import org.dromara.common.sdk.common.Pagination;
import org.dromara.common.sdk.common.PaginationData;
import org.dromara.common.sdk.exception.CloudSDKException;
import org.dromara.sample.component.mqtt.model.EventsReceiver;
import org.dromara.sample.manage.model.dto.DeviceDTO;
import org.dromara.sample.manage.service.IDeviceProService;
import org.dromara.sample.manage.service.IDeviceRedisService;
import org.dromara.sample.manage.service.IDeviceService;
import org.dromara.sample.media.model.MediaFileCountDTO;
@ -29,12 +33,14 @@ import org.dromara.sample.wayline.service.IWaylineJobService;
import org.dromara.sample.wayline.service.IWaylineRedisService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.sql.SQLException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -72,6 +78,9 @@ public class WaylineJobServiceImpl implements IWaylineJobService {
@Autowired
private IWaylineRedisService waylineRedisService;
@Autowired
private IDeviceProService deviceProService;
private Optional<WaylineJobDTO> insertWaylineJob(WaylineJobEntity jobEntity) {
int id = mapper.insert(jobEntity);
if (id <= 0) {
@ -81,7 +90,7 @@ public class WaylineJobServiceImpl implements IWaylineJobService {
}
@Override
public Optional<WaylineJobDTO> createWaylineJob(CreateJobParam param, String workspaceId, String username, Date beginTime, Date endTime) {
public Optional<WaylineJobDTO> createWaylineJob(CreateJobParam param, String workspaceId, String username, Date beginTime, Date endTime,Integer proId) {
if (Objects.isNull(param)) {
return Optional.empty();
}
@ -104,6 +113,7 @@ public class WaylineJobServiceImpl implements IWaylineJobService {
.mediaCount(0)
.breakPoint(param.getBreakPoint())
.jobType(param.getJobType().getType())
.proId(proId)
.build();
return insertWaylineJob(jobEntity);
@ -163,13 +173,26 @@ public class WaylineJobServiceImpl implements IWaylineJobService {
}
@Override
public PaginationData<WaylineJobDTO> getJobsByWorkspaceId(String workspaceId, long page, long pageSize) {
public PaginationData<WaylineJobDTO> getJobsByWorkspaceId(String workspaceId, long page, long pageSize,String fileId,List<Integer> proIds,String name) {
LoginUser loginUser = LoginHelper.getLoginUser();
if(ObjectUtil.isAllEmpty(proIds)){
proIds = deviceProService.listDeviceGroup(loginUser.getUserId());
}
LambdaQueryWrapper<WaylineJobEntity> waylineJobEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
waylineJobEntityLambdaQueryWrapper.eq(WaylineJobEntity::getWorkspaceId, workspaceId);
if(ObjectUtil.isNotEmpty(fileId)) {
waylineJobEntityLambdaQueryWrapper.eq(WaylineJobEntity::getFileId, fileId);
}
waylineJobEntityLambdaQueryWrapper.in(ObjectUtil.isAllNotEmpty(proIds),WaylineJobEntity::getProId,proIds);
if(ObjectUtil.isNotEmpty(name)){
waylineJobEntityLambdaQueryWrapper.and(wrapper ->{
wrapper.like(WaylineJobEntity::getName, name).or().like(WaylineJobEntity::getWaylineName, name);
});
};
waylineJobEntityLambdaQueryWrapper.orderByDesc(WaylineJobEntity::getId);
Page<WaylineJobEntity> pageData = mapper.selectPage(
new Page<WaylineJobEntity>(page, pageSize),
new LambdaQueryWrapper<WaylineJobEntity>()
.eq(WaylineJobEntity::getWorkspaceId, workspaceId)
.orderByDesc(WaylineJobEntity::getId));
List<WaylineJobDTO> records = pageData.getRecords()
new Page<WaylineJobEntity>(page, pageSize),waylineJobEntityLambdaQueryWrapper);
List<WaylineJobDTO> records = pageData.getRecords()
.stream()
.map(this::entity2Dto)
.collect(Collectors.toList());

6
dk-modules/sample/src/main/resources/mapper/DeviceQrtzMapper.xml

@ -43,6 +43,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</if>
<if test="condition.proIds.size > 0">
AND wd.pro_id in
<foreach item="proId" collection="condition.proIds" open="(" separator="," close=")">
#{proId}
</foreach>
</if>
order by wdq.status asc, wdq.create_time desc
</select>
<select id="calendarList" resultType="java.util.Map"></select>

54
dk-modules/sample/src/main/resources/mapper/IDeviceProMapper.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.sample.manage.mapper.IDeviceProMapper">
<resultMap id="listDeviceProEntityMap" type="org.dromara.sample.manage.model.entity.DeviceProEntity">
<result column="pro_id" property="id"/>
@ -10,24 +10,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result column="bind_type" property="bindType"/>
<result column="nick_name" property="nickName"/>
<result column="create_time" property="createTime"/>
<collection property="deviceProUserEntityList" ofType="org.dromara.sample.manage.model.entity.DeviceProUserEntity">
<result column="pro_user_id" property="id"/>
<result column="device_pro_id" property="deviceProId"/>
<result column="user_id" property="userId"/>
<result column="user_name" property="userName"/>
</collection>
<collection property="deviceEntityList" ofType="org.dromara.sample.manage.model.entity.DeviceEntity">
<result column="device_id" property="id"/>
<result column="device_sn" property="deviceSn"/>
<result column="device_name" property="deviceName"/>
<result column="device_type" property="deviceType"/>
<result column="sub_type" property="subType"/>
<result column="domain" property="domain"/>
<result column="child_sn" property="childSn"/>
<result column="workspace_id" property="workspaceId"/>
<result column="device_pro_number" property="proId"/>
<result column="device_nick_name" property="nickname"/>
</collection>
</resultMap>
<select id="listDeviceProEntityMap" resultMap="listDeviceProEntityMap">
SELECT
@ -36,32 +18,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dp.bind_code,
dp.bind_type,
dp.nick_name,
dp.create_time,
dpu.id pro_user_id,
dpu.device_pro_id,
dpu.user_id,
dpu.user_name,
d.id device_id,
d.device_sn,
d.device_name,
d.device_type,
d.sub_type,
d.domain,
d.child_sn,
d.workspace_id,
d.pro_id device_pro_number,
d.nickname device_nick_name
dp.create_time
FROM
manage_device_pro dp
LEFT JOIN manage_device d ON dp.id = d.pro_id
LEFT JOIN manage_device_pro_user dpu ON dp.id = dpu.device_pro_id
manage_device_pro dp
<where>
<if test="condition.bind_code != null and condition.bind_code != ''">
and dp.bind_code like concat(concat('%',#{condition.bind_code}),'%')
</if>
<if test="condition.pro_name != null and condition.pro_name != ''">
and dp.pro_name like concat(concat('%',#{condition.pro_name}),'%')
</if>
<if test="condition.bind_code != null and condition.bind_code != ''">
and dp.bind_code like concat(concat('%',#{condition.bind_code}),'%')
</if>
<if test="condition.pro_name != null and condition.pro_name != ''">
and dp.pro_name like concat(concat('%',#{condition.pro_name}),'%')
</if>
</where>
</select>
</mapper>

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

17
dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteNoticeServiceImpl.java

@ -1,5 +1,6 @@
package org.dromara.system.dubbo;
import cn.hutool.core.convert.Convert;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
@ -9,9 +10,14 @@ import org.dromara.resource.api.RemoteMessageService;
import org.dromara.system.api.RemoteNoticeService;
import org.dromara.system.api.domain.bo.RemoteNoticeBo;
import org.dromara.system.domain.SysNotice;
import org.dromara.system.domain.vo.SysDictDataVo;
import org.dromara.system.mapper.SysNoticeMapper;
import org.dromara.system.service.ISysDictTypeService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
@ -27,12 +33,21 @@ public class RemoteNoticeServiceImpl implements RemoteNoticeService {
private final SysNoticeMapper sysNoticeMapper;
@DubboReference
private final RemoteMessageService remoteMessageService;
private final ISysDictTypeService dictTypeService;
private final ScheduledExecutorService scheduledExecutorService;
@Override
public int saveNotice(RemoteNoticeBo bo) {
SysNotice notice = MapstructUtils.convert(bo, SysNotice.class);
/*String type = dictService.getDictLabel("sys_notice_type", notice.getNoticeType());*/
remoteMessageService.publishAll(bo.getParam());
List<SysDictDataVo> data = dictTypeService.selectDictDataByType("ai_push");
List<Long> list = data.stream().map(SysDictDataVo::getDictValue).distinct().toList().stream().map(Long::parseLong).toList();
//获取字典值
scheduledExecutorService.schedule(() -> {
remoteMessageService.publishMessage(list, bo.getParam());
}, 3, TimeUnit.SECONDS);
return sysNoticeMapper.insert(notice);
}
}

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