Initial commit: reorganized source tree

- backend/: 13 Maven modules (cw-elevator-application, cloudwalk-cloud, intelligent-cwoscomponent, ninca-crk, etc.)
- frontend/: 4 Vue projects (elevator-front, cwos-portal, alarm-front, front_acs) + decompiled + scripts
- scripts/: build, test-env, tools (Docker Compose, service templates, API parity)
- docs/: AGENTS.md, superpowers specs, architecture docs
- .gitignore: standard Java/Maven exclusions

Moved from legacy maven-*/ root layout to backend/ organized structure.
This commit is contained in:
hpd840321
2026-05-09 09:00:12 +08:00
commit 7b2bd307f1
7260 changed files with 612980 additions and 0 deletions
@@ -0,0 +1,108 @@
# 00 总览:模块定位与领域结构
## 1. 模块在系统中的位置
`cw-elevator-application-service` 是电梯应用的 **业务编排与领域服务实现** 层:
- **向上** 被 `cw-elevator-application-web`HTTP 入口)等调用。
- **向下** 依赖 `cw-elevator-application-data`DAO/MyBatis)与多类 **OpenFeign 客户端**(CWOS 设备/人员/图库/系统设置、访客标准服务、第三方 MQTT 等)。
- **横切** 使用 Spring 事件(`CloudwalkEventManager`)、缓存(`@Cacheable`)、异步(`@Async`)等。
```mermaid
flowchart LR
subgraph Web["cw-elevator-application-web"]
C[Controllers]
end
subgraph Svc["cw-elevator-application-service 本文档范围"]
D[device]
P[passrule / person]
R[record]
Z[zone / code]
M[mqtt / export / ...]
end
subgraph Data["cw-elevator-application-data"]
DAO[DAO / Mapper]
end
subgraph Ext["外部服务 Feign / HTTP"]
W[CWOS intelligent-*]
V[访客 ninca-crk-std]
Q[MQTT 第三方]
end
C --> Svc
Svc --> DAO
Svc --> W
Svc --> V
Svc --> Q
```
## 2. 领域全景(思维导图)
```mermaid
mindmap
root((elevator service))
设备 device
本应用电梯设备 CRUD
与平台设备联动分页
重组绑定 楼层/人员/条件
异步任务 进度
通行与人员
规则 passrule
图库规则 image 规则
人员 acs 与 规则 person
记录 record
通行记录
识别记录
分析统计
区域与编码
区域树 zone
电梯码 codeElevatorArea
集成
mqtt 推送
导出 export
下载 downloadcenter
文件 storage
```
## 3. 核心服务接口与包对应关系
```mermaid
classDiagram
class AcsElevatorDeviceService
class AcsDeviceTaskService
class AcsPassRuleService
class ImageRuleRefService
class AcsPersonService
class PersonRuleService
class AcsElevatorRecordService
class AcsRecogRecordService
class ZoneService
class AcsElevatorCodeService
class MqttService
AcsElevatorDeviceService : +设备与绑定编排
AcsDeviceTaskService : +updateFloors 任务推进
AcsPassRuleService : +规则 CRUD 与图库 list
ImageRuleRefService : +图库视角规则
AcsPersonService : +人员 page 等
PersonRuleService : +规则内人员/访客
AcsElevatorRecordService : +通行记录
AcsRecogRecordService : +识别记录 add
ZoneService : +区域树
AcsElevatorCodeService : +电梯码
MqttService : +sendInfoToOne
```
## 4. 与外部系统协作(逻辑视图)
| 外部能力 | 典型用途 |
|----------|----------|
| `intelligent` 设备/人员/图库/系统设置 | 设备主数据、人员同步、图库、区域树 |
| `ninca-crk-std`IP 配置 + RestTemplate 或 Feign | 访客 **three 线****Feign `VisitorFeignClient`** 不同路径 |
| `cloudwalk-device-thirdparty` / MQTT | 发布主题推送识别摘要 |
| DaVinci 文件分片 | `AcsFileStorageService` 大文件 |
| 下载中心 | 异步任务结果取回 |
## 5. 读文档建议
1. 先读 [01-device-and-task.md](01-device-and-task.md) 理解「设备—楼层—任务」主路径。
2. 再读 [02-passrule-and-person.md](02-passrule-and-person.md) 理解规则与人员两条下发线。
3. 记录、MQTT 与事件见 [03-record-recognition.md](03-record-recognition.md) 与 [04-mqtt-visitor-event.md](04-mqtt-visitor-event.md)。
@@ -0,0 +1,75 @@
# 01 设备与设备任务(`device`
## 1.1 业务目标
- 维护 **本应用视角** 的电梯设备与平台设备(`DeviceService`)的关联数据。
- 支持 **重组/绑定**:按区域、标签、组织等条件选择楼层,将 **人员****规则** 批量下发到设备侧(经远程服务)。
- 通过 **设备任务**`AcsDeviceTaskService` / `AcsDeviceTaskServiceImpl`)在楼层维度 **有界并行** 执行远程步骤,并 **按完成顺序** 推进任务上的 `bindDevices` 等进度(与走查约定 §9 一致)。
## 1.2 主接口 `AcsElevatorDeviceService`
| 方法 | 行为概要 |
|------|----------|
| `add` / `edit` / `delete` | 电梯设备增删改,写本库并协调平台设备信息 |
| `get` / `getById` / `getFo` | 分页列表、单条、表单选项数据 |
| `getBuildingId` / `getBusinessId` | 从查询条件解析楼宇或租户 |
| `devicePage` | 走 **平台** 设备分页,与 `Acs` 表关联展示 |
| `listUnbindFloors` / `listFloors` / `listCondition` / `listConditionByLabelIds` | 绑定时待选楼层、已绑楼层、条件筛选(标签等) |
| `bindingFloors` / `bindingPerson` | 启动绑定:创建/更新设备任务,异步 `updateFloors` |
| `getTask` / `setTaskStop` | 查询任务进度、停止任务 |
**实现类**`device/impl/AcsElevatorDeviceServiceImpl.java`
## 1.3 设备任务 `AcsDeviceTaskService`
| 方法 | 行为概要 |
|------|----------|
| `updateFloors` | 在 **增加楼层 / 删除楼层** 两路上,将远程调用按 **每批 `UPDATE_FLOORS_FLOOR_PARALLEL` 个楼层** 提交到 `elevatorRemoteBoundedExecutor``FeignThreadLocalUtil` 在子任务中恢复租户上下文;每步成功再 `advanceBindProgressOne` 更新 `bindDevices`。 |
**实现类**`device/impl/AcsDeviceTaskServiceImpl.java`
## 1.4 用例级视图(操作者:管理员 / 系统)
```mermaid
flowchart TB
subgraph 电梯设备管理
A[增删改电梯设备]
B[分页查询/详情]
end
subgraph 重组绑定
C[选楼层/人员或规则]
D[启动 bindingFloors/bindingPerson]
E[异步 updateFloors]
end
A --> B
C --> D --> E
```
## 1.5 时序:启动楼层绑定后异步推进(概念)
```mermaid
sequenceDiagram
participant Web as Web/Controller
participant Dev as AcsElevatorDeviceServiceImpl
participant Task as AcsDeviceTaskService
participant Pool as 有界线程池
participant Remote as 人员/规则 Feign
Web->>Dev: bindingFloors(参数)
Dev->>Task: 异步 updateFloors(...)
loop 每批楼层
Task->>Pool: invokeAll(子任务)
Pool->>Remote: add/delete 单楼层步骤
Remote-->>Task: 成功
Task->>Task: advanceBindProgressOne(taskId)
end
```
## 1.6 设备设置子域 `device/setting`
- **`AcsDeviceSettingService`**:如体温相关设置查询(`getTemperatureSetting`)。
- **`AcsDeviceImageStoreAppBindService`**:设备与图库应用绑定/解绑等(实现见 `setting/impl`)。
## 1.7 与邻域关系
- **规则/人员**`updateFloors` 内调 `PersonRuleService``ImageRuleRefService` 等,取决于绑定参数是 `personId` 还是标签/组织。
- **data 层**`AcsDeviceTaskDao`、设备相关 DAO 在 **data 模块**
@@ -0,0 +1,68 @@
# 02 通行规则与人员(`passrule` / `person`
## 2.1 业务目标
- **通行规则**:按 **区域/楼层/图库/标签/组织** 等维护通行策略,与平台图库、设备绑定任务配合。
- **图库规则引用**`ImageRuleRefService`):从 **图库/图片 ID** 视角查规则列表、只增规则、人员列表、分页等,与 `AcsPassRuleService` 的「规则主 CRUD」互补。
- **人员**`AcsPersonService` 面向业务侧人员维护;`PersonRuleService`**规则上下文** 下做人员/访客的增删改查及 **与图库人员** 的关联(如 `personDetail`)。
## 2.2 `AcsPassRuleService` 方法表
| 方法 | 概要 |
|------|------|
| `listFloor` | 规则关联楼层列表 |
| `getIsDefaultByZoneId` | 区域下是否默认规则等标识 |
| `add` / `update` / `delete` / `detail` / `page` / `list` | 标准 CRUD 与详情分页 |
| `listByImageId` | 按图库/图片查规则 DTO 列表,供设备或绑定流使用 |
## 2.3 `ImageRuleRefService` 方法表
| 方法 | 概要 |
|------|------|
| `page` | 图库规则分页(与规则查询参数共用部分字段) |
| `listFloor` | 图库侧楼层规则列表 |
| `listByPersonInfo` | 按人维度列规则/楼层 |
| `listByPersonList` | 批量人列表与规则关系 |
| `detail` | 单条图库规则详情 |
| `addOnlyRule` | **仅** 建规则(设备任务中「非人员」线可能走此路) |
| `update` / `delete` | 更新/删除,与 `AcsPassRuleService` 分工依实现类而定 |
**实现基类提示**`passrule/impl/AbstractAcsPassService.java` 可抽取与远程/DAO 的共性。
## 2.4 `AcsPersonService` 与 `PersonRuleService`
| 接口 | 特点 |
|------|------|
| `AcsPersonService` | `add` / `edit` / `delete` / `page` / `timeDetail` / `pageByApp` |
| `PersonRuleService` | 在规则域增加 `addVisitor``personDetail(图库人员)` 等 |
## 2.5 用例图(简)
```mermaid
flowchart LR
Admin((管理员))
Admin --> P1[维护通行规则]
Admin --> P2[按图查规则/楼层]
Admin --> P3[维护人员/访客]
P1 --> S1[AcsPassRuleService]
P2 --> S2[ImageRuleRefService]
P3 --> S3[PersonRuleService / AcsPersonService]
```
## 2.6 时序:仅创建规则(与设备任务线关联)
```mermaid
sequenceDiagram
participant Task as AcsDeviceTaskServiceImpl
participant IMG as ImageRuleRefService
Task->>IMG: addOnlyRule(区域/标签/组织)
IMG-->>Task: CloudwalkResult
Note over Task: 成功后再推进 bind 进度
```
## 2.7 与设备任务关系(概念)
- **人员绑定**`updateFloors` 中若带 `personId`,走 `PersonRuleService.add/delete`**楼层/区域** 维度。
- **非人员**(标签/组织):建/删 **规则名**`ImageRuleRef` DAO,并调 `imageRuleRefService` 的删除或 `addOnlyRule`
更多细节以 `AcsPassRuleServiceImpl.java``AcsDeviceTaskServiceImpl.java` 源码为准。
@@ -0,0 +1,63 @@
# 03 通行记录与识别记录(`record`)
## 3.1 业务目标
- **电梯通行/开门记录**`AcsElevatorRecordService`):分页查询、**新增**(落库、访客判断、发域事件)、修改状态、统计、Redis 缓存键等。
- **人员识别记录**`AcsRecogRecordService`):单接口 `add`,与图库/识别流对接。
- **图库文件**`PersonFileService`):`upload` 小图片字节上传,给记录新增时 **Base64 解码后** 调图库。
- **`SendRecordTimeService`**:接口体为空,**无方法**,可视为占位或历史契约保留。
## 3.2 `AcsElevatorRecordService` 方法表
| 方法 | 概要 |
|------|------|
| `openRecord` | 分页查开门记录明细,**一年** 窗口校验;组装区域/片区/人员展示字段 |
| `add` | 见 [04-mqtt-visitor-event.md](04-mqtt-visitor-event.md) 的访客与事件说明 |
| `modify` | 按条件改开门记录 **状态**(如从 INIT 更新) |
| `createCache` | 分布式任务锁下 **Redis 缓存** 初始化 |
| `pageInfo` | 分页查询请求维表信息类结果 |
| `analyseCycle` / `analyseCount` | 按周期/条件的开门统计、排行等 |
**实现类**`record/impl/AcsElevatorRecordServiceImpl.java`
## 3.3 识别子域
- **`AcsRecogRecordService#add`**`AcsRecogRecordServiceImpl` 中增加识别记录(实现细节见同文件)。
## 3.4 流程图:`openRecord` 主路径
```mermaid
flowchart TD
A[入参+分页] --> B{时间跨度>1年?}
B -- 是 --> X[失败返回]
B -- 否 --> C[DAO 分页]
C --> D[去重取片区/区域id]
D --> E[批量查设备片区名]
E --> F[取区域树缓存/区域父名]
F --> G[批量查人员底库照]
G --> H[组装 AcsElevatorRecordResult 分页返回]
```
## 3.5 时序:`add` 落库前访客与人员(节选)
```mermaid
sequenceDiagram
participant S as AcsElevatorRecordServiceImpl
participant HTTP as ninca-crk-std HTTP
participant P as PersonService
participant DAO as AcsElevatorRecordDao
participant EVT as CloudwalkEventManager
S->>HTTP: POST three/visitor/record/query
HTTP-->>S: 是否访客+被访人
S->>P: detail(识别脸 id)
P-->>S: 工号/组织
S->>DAO: add(DTO)
S->>EVT: publish(VisitorRecordPushEvent)
```
## 3.6 领域事件
- 类型:`record/result/VisitorRecordPushEvent.java`
- 主题 `getTopic()` 固定为 `VISITOR_RECORD_TOPIC`(供订阅方区分)。
与 MQTT 的关系见 [04-mqtt-visitor-event.md](04-mqtt-visitor-event.md)。
@@ -0,0 +1,51 @@
# 04 MQTT、访客与域事件
## 4.1 双通道:访客查询
| 方式 | 路径/Bean | 使用场景(本模块) |
|------|-----------|---------------------|
| **HTTP + RestTemplate** | `combineAuthClientURI("intelligent/three/visitor/record/query")` | `AcsElevatorRecordServiceImpl#add` 反查是否访客 |
| **Feign** | `VisitorFeignClient``/intelligent/visitor/record/query` | 定义在 `visitor/client`**本模块内无直接注入调用** |
两者 **不是** 同一路径;业务上均面向标准访客中心,但 **「three」** 与 **「intelligent」** 为产品/版本差异,部署时需与 `ninca-crk-std` 实际路由一致。
## 4.2 `MqttService` 与 `MqttServiceImpl`
| 项 | 说明 |
|----|------|
| `sendInfoToOne` | `@Async`:先 **睡眠约 10s** 等待识别记录落库,再查识别流水,拼 `AcsElevatorRecordMqttParam`,向 topic `{businessId}+_elevator_record` 发 JSON |
| 远程 | `MqttFeignClient#publish` → 设备第三方 MQTT 服务 |
**调用关系**:本模块中 **`AcsElevatorRecordServiceImpl` 注入了 `MqttService` 但当前未调用**;若产品要求「保存记录后推送大屏」,可在 **监听 `VisitorRecordPushEvent` 的处理器****在 `add` 成功后** 显式调用 `sendInfoToOne`(需评估与异步睡眠设计是否一致)。
## 4.3 时序:MQTT 推送(当显式调用 `sendInfoToOne` 时)
```mermaid
sequenceDiagram
participant Caller as 业务/监听器
participant M as MqttServiceImpl
participant DAO as AcsRecogRecordDao
participant F as MqttFeignClient
Caller->>M: sendInfoToOne(DTO)
Note over M: sleep 10s
M->>DAO: page(识别流水)
DAO-->>M: 人名/标签
M->>F: publish(topic, JSON)
F-->>M: CloudwalkResult
```
## 4.4 状态机:从「仅事件」到「+ MQTT」(部署选项)
```mermaid
stateDiagram-v2
[*] --> RecordSaved: add DAO 成功
RecordSaved --> EventPublished: VisitorRecordPushEvent
EventPublished --> MqttOptional: 可选
MqttOptional --> MqttPush: 若接线 sendInfoToOne
MqttOptional --> NoMqtt: 当前默认
```
## 4.5 域事件与 MQTT 解耦说明
- `VisitorRecordPushEvent``CloudwalkEventManager` 发布,**不保证** 与 MQTT 同一步骤执行。
- 下游可独立订阅 **事件****MQTT topic**,避免强耦合。
@@ -0,0 +1,45 @@
# 05 区域与电梯区域编码(`zone` / `codeElevatorArea`
## 5.1 `ZoneService`
| 方法 | 概要 |
|------|------|
| `tree` | 入参 `ZoneNextTreeParam`,调 **平台区域/系统设置** 能力,组装 **下一级树** 等,返回 `List<ZoneTreeResult>`(实现中常经 Feign + 工具类 `ZoneTreeCollectors` |
| `page` | 区域维度的分页列表 `ZoneResult` |
**实现类**`zone/impl/ZoneServiceImpl.java`
## 5.2 `AcsElevatorCodeService``codeElevatorArea`
| 方法 | 概要 |
|------|------|
| `insertNew` / `updateOld` | 电梯与区域绑定的 **编码** 数据维护 |
| `get` / `getFirstByParentId` | 单条/按父级取首条 |
| `mapByZoneIds` | **批量** 按区域 id 查电梯编码,供树形接口 **一次** 拉取,避免 N+1(见接口内 Javadoc |
## 5.3 时序:区域树 + 树上网格批量取码(概念)
```mermaid
sequenceDiagram
participant Web as 上层
participant Z as ZoneService
participant Sy as 平台区域服务
participant C as AcsElevatorCodeService
Web->>Z: tree(参数)
Z->>Sy: Feign 取区域
Sy-->>Z: AreaTree
Z-->>Web: ZoneTreeResult
Web->>C: mapByZoneIds(多 zoneId)
C-->>Web: Map 区域id→编码
```
## 5.4 用例简图
```mermaid
flowchart TB
U[运营/系统]
U --> T[浏览区域树选楼层]
U --> M[维护电梯-区域码]
T --> ZoneService
M --> AcsElevatorCodeService
```
@@ -0,0 +1,51 @@
# 06 导出、下载与存储(`export` / `downloadcenter` / `storage`
## 6.1 异步导出 `export`
- 抽象基类:`AcsAbstractExportAsyncService` —— 泛型封装 **分页拉取** → 转 Excel 行 DTO → 与下载中心协作。
- **实现示例**`ElevatorDeviceExportService`
- 注入 `AcsElevatorDeviceService#get` 取设备分页。
-`queryPage` 中将 DTO 转为 `ElevatorDeviceRecordExcelResult`,并翻译 **在线/禁用** 等展示中文。
**典型时序**(概念):
```mermaid
sequenceDiagram
participant User as 用户/任务
participant E as ElevatorDeviceExportService
participant D as AcsElevatorDeviceService
participant DC as 下载中心
User->>E: 触发导出任务
loop 分页
E->>D: get(查询+分页)
D-->>E: 行数据
end
E->>DC: 完成文件/回写状态
```
## 6.2 下载中心 `AcsDownloadCenterService`
| 方法 | 概要 |
|------|------|
| `createDownload` | 创建下载任务/令牌 |
| `finishDownload` | 任务完成回执 |
| `queryDownloadStatus` | 轮询或查询状态 |
**实现类**`downloadcenter/impl/AcsDownloadCenterServiceImpl.java`(以源码为准)。
## 6.3 分片文件 `AcsFileStorageService``storage`
| 方法 | 概要 |
|------|------|
| `filePartInit` / `filePartAppend` / `filePartFinish` | DaVinci/门户 **分片上传** 生命周期 |
| `getFileBase64` | 按 id 回读为 Base64 |
## 6.4 ER/依赖(导出子域)
```mermaid
flowchart LR
Export[导出任务] --> Abs[AcsAbstractExportAsyncService]
Abs --> Svc[具体领域 Service 如 设备]
Abs --> Download[AcsDownloadCenterService]
Storage[AcsFileStorageService] -.大文件.-> 门户
```
@@ -0,0 +1,42 @@
# 07 横切与公共(`common` / `cacheable` / 基类)
## 7.1 `AcsApplicationService`
- 方法 `getApplicationId`:按业务/租户等解析 **应用 ID**`AcsApplicationServiceImpl` 实现,细节见类)。
## 7.2 `AcsAreaTreeCacheableService`
- 包装 `SysettingAreaService#tree`
- `@Cacheable``ACS_AreaTreeCache`key 与 `CacheOverrideConfig`**租户前缀** 拼出,减少区域树 **重复远程调用**
## 7.3 基类
| 类 | 作用 |
|----|------|
| `AbstractCloudwalkService` | 与 Cloudwalk 框架通用基能力(见父类/模块) |
| `AbstractAcsDeviceService` | 设备域公用:区域树展平、构造带 `FeignThreadLocalUtil``CloudwalkCallContext` 等(见 `common/AbstractAcsDeviceService` |
| `AbstractAcsPassService` | 通行/规则子域抽取(见 `passrule/impl` |
## 7.4 空接口
- `SendRecordTimeService`:无方法;若需扩展 **发送记录时间** 类能力,可在此增方法并由实现类承载。
## 7.5 包级 `package-info`
各子包在源码中已逐步补充 `package-info.java``device`/`record`/`mqtt`/`visitor` 等),可与本 `docs` 互参。
## 7.6 多维度总览表(维度矩阵)
| 维度 | 读者关注点 | 建议文档 |
|------|------------|----------|
| 业务价值 | 电梯设备、规则、人员、记录 | 01–03 |
| 集成 | 访客、MQTT、Feign | 04, 00 |
| 可运维 | 缓存、异步、任务进度 | 01, 07, 04 |
| 可观测 | 事件、topic、锁 | 03, 04, 03-锁 |
**读文档优先级(示意,非绝对)**
| | 远程依赖多 | 本地/缓存多 |
|--|------------|-------------|
| **写路径多** | 设备任务、规则+人员 | (较少) |
| **读路径多** | 记录 openRecord | 区域树缓存、电梯码 map |
@@ -0,0 +1,361 @@
# 访客与电梯业务:注册/登记与派梯授权完整说明
> 本文档覆盖 **组织组件**`maven-ninca-common-component-organization`)、**智能组件 Feign 路由**`maven-intelligent-cwoscomponent`)与 **电梯应用**`maven-cw-elevator-application`)中与「访客派梯」相关的可追踪路径;区分 **访客主数据登记** 与 **`POST /elevator/person/add/visitor` 派梯授权**。文中源码路径均相对于各 Maven 模块仓库根目录。
---
## 1. 概念与边界
| 概念 | 通常含义 | 在本项目中的落点 |
|------|----------|------------------|
| **访客主数据登记/注册** | 在标准访客/一卡通中录入档案 | **不在**电梯应用内完成完整登记 UI;人员以 **`visitorId`(平台 personId)** 等形式存在于外部服务。 |
| **电梯侧「访客派梯授权」** | 在已有访客人员 ID 前提下写入通行规则、绑定图库、访期 | **`PersonRuleServiceImpl#addVisitor`** → **`POST /elevator/person/add/visitor`**`AcsPersonController`)。 |
| **通行记录「是否访客」打标** | 识别流水写库时标记访客/被访人 | **`AcsElevatorRecordServiceImpl#add`** → CRK **`/intelligent/three/visitor/record/query`**(见第 8 节)。 |
---
## 2. 组件关系总览
访客邀约页、电梯 **`addVisitor`** 在 **`floorList` 语义上应对齐**:二者都应依赖 **`PersonService.detail``PersonResult.floorList`**(经 Intelligent 转发到组织 **`POST /component/person/detail`**)。组织组装 `floorList` 时会 **Feign 回调电梯**(见 **§3.3**):电梯 **`image_rule_ref`** 里已有的人员—楼层规则,经 **`/elevator/passRule/image`** 转成 **`zoneId` 列表**,再写回组织的 **`floorList`**。
```mermaid
flowchart LR
subgraph fe["前端 / BFF / 第三方"]
UI[访客邀约 / 派梯调用方]
end
subgraph intelligent["maven-intelligent-cwoscomponent"]
PS[PersonService / RestPersonServiceImpl]
PFC[PersonFeignClient → /component/person]
end
subgraph org["maven-ninca-common-component-organization"]
PC[PersonController /component/person]
IMG[ImgPersonServiceImpl]
EF[ElevatorFeignClient → /elevator/passRule/image]
end
subgraph elevator["maven-cw-elevator-application"]
AC[AcsPersonController /elevator/person/add/visitor]
PR[PersonRuleServiceImpl addVisitor]
IRR[ImageRuleRefDao / ZoneService / DeviceImageStoreDao]
IS[ImageStorePersonService Feign 绑定图库]
end
UI --> PS
PS --> PFC --> PC --> IMG
IMG --> EF
UI --> AC --> PR
PR --> PS
PR --> IRR
PR --> IS
```
---
## 3. 组织侧:被访人 `detail` 与 `floorList`(邀约页 / UC-01 的数据源)
### 3.1 HTTP 入口与实现类
| 项 | 说明 |
|----|------|
| **路径** | **`POST /component/person/detail`** |
| **Controller** | `cwos-component-organization-web` · `PersonController#detail` |
| **服务** | `ImgStorePersonService#detail`**`ImgPersonServiceImpl#detail`** |
对外契约返回 **`CloudwalkResult<ImgStorePersonGetResult>`**;经 Intelligent **`PersonFeignClient`** 解码为 **`PersonResult`**(字段名一致部分落入 **`floorList`**,电梯 **`addVisitor`** 仅消费 **`PersonResult.getFloorList()`**)。
### 3.2 `ImgPersonServiceImpl#detail` 处理顺序(与源码一致)
| 步骤 | 做什么 | 与 `floorList` 的关系 |
|------|--------|----------------------|
| 1 | **`selectByPrimaryKey`** 查组织库人员 | 无此人则 **`data` 可为 null**(见下) |
| 2 | 可选 **`defaultFloor`** → **`zoneFeignClient.findZonelist`** | 仅 **`floorName` 展示****不等于**下面得到的 **`floorList`** |
| 3 | 可选 **`vehicleFeignClient.getVehicleIds`** | 与楼层列表无关 |
| 4 | **`getImgStorePersonResults`** | 得到 **`organizationIds``labelIds`**,供 **§3.3** 调用电梯 |
| 5 | **`elevatorFeignClient.listByImageId(...)`**Feign,语义见 **§3.3** | **唯一**写入 **`floorList` / `floorNames`**(在返回码成功且进入分支时) |
| 6 | (规范)租户 **`allow_zone_ids` 替代** | **当前未实现**,运行态 **`floorList`** = 步骤 5 结果 |
| 7 | **`portalUserService.query`** 填创建/更新人姓名 | 与楼层无关 |
- **查无此人****`result` 仍为 null**,接口 **`CloudwalkResult.success(null)`**;电梯 **`addVisitor`** 取 **`personResult == null`** → **`76260531`**。
- **步骤 5 失败或未进入分支**:**`floorList` 不会被赋值**(可能为 **null** / 未覆盖);UC-01 **`addVisitor`** → **`76260531`**。
---
### 3.3 组织 Feign `listByImageId` ↔ 电梯 HTTP ↔ 真实落库(避免混淆)
这一块名字容易混:**组织侧 Java 方法叫 `listByImageId`,并不等于电梯里另一个 DAO 方法 `listByImageId`。**
#### 3.3.1 组织侧调用(入口)
| 项 | 说明 |
|----|------|
| **组织代码** | `ElevatorFeignClient#listByImageId``cwos-component-organization-service/.../feign/ElevatorFeignClient.java` |
| **HTTP** | **`POST {elevator-base}/elevator/passRule/image`**Feign **`name`** 一般为 **`feign.elevator.name`**,如 **`elevator-app`** |
| **请求体** | **`AcsPassRuleImageForm`**`personId``businessId``includeOrganizations``includeLabels`(对应组织 **`detail`** 里 **`getImgStorePersonResults`** 填好的档案字段) |
#### 3.3.2 电梯侧实际执行(与「另一个 listByImageId」区分)
| 易混点 | 说明 |
|--------|------|
| **本链路** | **`AcsPassRuleController`**(类上 **`@RequestMapping("/elevator/passRule")`**)方法 **`@RequestMapping("/image")`** → **`ImageRuleRefServiceImpl#listByPersonInfo`** → **`ImageRuleRefDao#listByPersonInfo`** → **`ImageRuleRefMapper.xml#listByPersonInfo`** |
| **勿混** | **`AcsPassRuleServiceImpl#listByImageId`** → **`acsPassRuleDao.listByImageId`** 查的是 **`it_acs_pass_rule`**,按 **`imageStoreIds`** 过滤——**不是**组织 Feign 这条 HTTP 路径当前走的实现。 |
#### 3.3.3 `listByPersonInfo` 在查什么(业务语义)
- **表**:电梯库 **`image_rule_ref`**(人员与楼层通行规则引用:访客 **`addVisitor`** 写入的也是这张表的语义同类数据)。
- **返回字段****`DISTINCT zone_id, zone_name`**(映射 **`AcsPassRuleImageResultDto`**)。
- **查询逻辑(摘要)**
- 至少包含:**`person_id = 被访人`** 且 **`person_delete = 0`** 的规则所对应的楼层;
-**`includeOrganizations` / `includeLabels`** 非空,SQL 中另有 **`OR`** 分支,按机构/标签关联规则补充楼层,并排除 **`person_delete = 1`** 等条件下已标记删除的 **`zone_id`**(详见 **`ImageRuleRefMapper.xml`** 全文)。
- **排序****`order by CAST(zone_name as signed)`**(按楼层名称可解析的数字排序)。
因此:**组织 `detail` 里的 `floorList`,本质上是「电梯侧已为该被访人(及档案上的机构/标签)开通过的楼层 zoneId 列表」的只读投影**,不是组织库自己存的楼层字段。
#### 3.3.4 组织如何把返回值写进 `detail`
仅当 **`images.getCode()`** 等于 **`00000000`**(成功)时,`ImgPersonServiceImpl#detail` 才遍历 **`images.getData()`**,把每条 **`zoneId`** 依次 **`floorList.add`**,并把 **`zoneName`** 拼成逗号分隔的 **`floorNames`**。
若 Feign **失败**、**超时**、或业务码非 **`00000000`****不会进入该分支****`floorList` 保持未赋值** → 下游 UC-01 常 **`76260531`**。
#### 3.3.5 与「访客派梯 `addVisitor`」的数据关系(闭环)
| 环节 | 数据 |
|------|------|
| 被访人已在电梯侧挂规则 | **`image_rule_ref`** 中有 **`person_id=被访人`** 等记录 |
| 组织 **`detail`** | **`listByImageId`(Feign) → `/passRule/image``listByPersonInfo`** 读出 **zone 列表****`PersonResult.floorList`** |
| 电梯 **`addVisitor` UC-01** | 再次 **`PersonService.detail`**,用同一 **`floorList`** 作为 **`effective`**,再 **写入访客**的 **`image_rule_ref`** 等 |
所以:**`floorList` 不是「组织凭空算的」,而是「电梯规则表里已有被访人楼层」经 **`/passRule/image`** 汇总后的结果**;租户策略若要做「替代」,应在步骤 **§3.2 第 6 步**改 **`floorList`**,而不是再发明一套与 **`image_rule_ref`** 无关的算法(除非产品另行约定)。
---
### 3.4 时序图 — 组织侧「单人 detail」(含回调电梯)
```mermaid
sequenceDiagram
autonumber
participant Caller as 调用方 / Intelligent
participant PC as PersonController
participant IMG as ImgPersonServiceImpl
participant Zone as ZoneFeignClient
participant Veh as VehicleFeignClient
participant Elev as ElevatorFeignClient<br/>方法名 listByImageId
participant EA as 电梯 AcsPassRuleController<br/>/elevator/passRule/image<br/>→ ImageRuleRefService listByPersonInfo
Caller->>PC: POST /component/person/detail
PC->>IMG: detail(param, context)
IMG->>IMG: selectByPrimaryKey(personId)
opt defaultFloor 非空
IMG->>Zone: findZonelist
Zone-->>IMG: ZoneResult
end
IMG->>Veh: getVehicleIds
Veh-->>IMG: vehicle ids
IMG->>IMG: getImgStorePersonResults → organizationIds, labelIds
IMG->>Elev: listByImageId(AcsPassRuleImageForm)
Elev->>EA: POST /elevator/passRule/image
EA->>EA: listByPersonInfo → SQL image_rule_ref
EA-->>Elev: List zoneId/zoneName
Elev-->>IMG: CloudwalkResult code=00000000 + list
IMG->>IMG: setFloorList / setFloorNames(策略替代:待实现)
IMG-->>PC: ImgStorePersonGetResult
PC-->>Caller: CloudwalkResult
```
---
## 4. 电梯侧:`addVisitor` 业务步骤
### 4.1 对外入口
| 项 | 值 |
|----|-----|
| HTTP | **`POST /elevator/person/add/visitor`** |
| Controller | `cw-elevator-application-web` · **`AcsPersonController#addVisitor`** |
| 实现 | **`PersonRuleServiceImpl#addVisitor`** |
### 4.2 与源码一致的执行顺序
**阶段 1 — 被访人详情(必经)**
- 组装 **`PersonDetailParam`**`id = param.getPersonId()`(被访人),**`businessId = context.getCompany().getCompanyId()`**。
- **`personService.detail(detailParam, context)`** → Intelligent **`PersonFeignClient`** → 组织 **`POST /component/person/detail`**。
- 失败或 **`personResult == null`** → 返回失败码(常见 **`76260531`**)。
**阶段 2 — 生效楼层 `effective`UC 分流)**
- **`callerProvidedFloors = !CollectionUtils.isEmpty(param.getFloorIds())`**
- **`true`UC-02****`effective = param.getFloorIds()`****不**使用 **`personResult.getFloorList()`** 作为列表来源;**仍已执行阶段 1**,用于保证被访人可查)。
- **`false`UC-01****`effective = personResult.getFloorList()`****空** → **`76260531`**。
**阶段 3 — 再次空集校验** — 防御 **`effective` 仍为空**。
**阶段 4 — 楼栋与图库**
- **`zoneService.page`**:查询 **`effective.get(0)`** 对应 **`ZoneResult`**,取 **`parentId`** 作为楼栋。
- **`deviceImageStoreDao.getByBuildingId(parentId)`** → **`imageStoreId`**(后续 **`batchBind` / `updateGroupPersonRef`** 均绑定该图库)。
**阶段 5 — 每层通行规则引用**
- 对每个 **`floorId`****`imageRuleRefDao.getDefaultByZoneId(floorId)`** 取默认父规则,拼装 **`ImageRuleRefAddDto`****`personId = visitorId`**),**`imageRuleRefDao.insertList`**。
**阶段 6 — 图库与分组**
- **`ImageStorePersonBindParam`**`imageStoreId``personIds=[visitorId]`、访期 **`begVisitorTime`/`endVisitorTime`**。
- **`imageStorePersonService.batchBind`**Feign 至 Intelligent/组织图库能力)。
- **`updateGroupPersonRef`** 同步组人员引用。
**异常** — 未捕获的运行异常包装 **`76260530`****`batchBind`** 失败透传下游码。
### 4.3 租户策略语义(与仓库规范一致)
电梯 **不**注入 **`TenantVisitorFloorPolicyDao`****不**在 **`addVisitor` 内做 `floorList ∩ allow`**。租户 **`allow_zone_ids` 替代**须落在 **组织 `detail`**(见第 3.2 节「待实现」说明)。
---
## 5. 时序图 — 电梯 `addVisitor`UC-01:不传 floorIds
```mermaid
sequenceDiagram
autonumber
participant C as 调用方
participant API as AcsPersonController
participant PR as PersonRuleServiceImpl
participant PS as PersonService Intelligent
participant Org as 组织 /component/person/detail
participant Z as ZoneService
participant DIS as DeviceImageStoreDao
participant IRR as ImageRuleRefDao
participant IS as ImageStorePersonService
C->>API: POST /elevator/person/add/visitorfloorIds 空)
API->>PR: addVisitor(param, context)
PR->>PS: detail(personId, businessId)
PS->>Org: Feign POST detail
Org-->>PS: PersonResult.floorList
PS-->>PR: PersonResult
Note over PR: effective = floorList;空则 76260531
PR->>Z: page(首 floorId)
Z-->>PR: ZoneResult.parentId
PR->>DIS: getByBuildingId(parentId)
DIS-->>PR: imageStoreId
loop 每个 floorId
PR->>IRR: getDefaultByZoneId + insertList
end
PR->>IS: batchBind(visitorId, 访期, imageStoreId)
IS-->>PR: 成功
PR->>IS: updateGroupPersonRef
PR-->>API: CloudwalkResult Boolean
API-->>C: 结果
```
## 6. 时序图 — 电梯 `addVisitor`UC-02:显式 floorIds
```mermaid
sequenceDiagram
autonumber
participant C as 调用方
participant API as AcsPersonController
participant PR as PersonRuleServiceImpl
participant PS as PersonService Intelligent
participant Z as ZoneService
participant DIS as DeviceImageStoreDao
participant IRR as ImageRuleRefDao
participant IS as ImageStorePersonService
C->>API: POST /elevator/person/add/visitorfloorIds 非空)
API->>PR: addVisitor
PR->>PS: detail(被访人)(校验被访人存在)
PS-->>PR: PersonResult
Note over PR: effective = param.floorIds(不用 detail.floorList
PR->>Z: page(首 floorId)
Z-->>PR: parentId
PR->>DIS: getByBuildingId
DIS-->>PR: imageStoreId
loop 每层
PR->>IRR: 默认规则 + insertList visitorId
end
PR->>IS: batchBind + updateGroupPersonRef
PR-->>API: success
```
---
## 7. 活动图(addVisitor 分支汇总)
```mermaid
flowchart TD
Start([POST /elevator/person/add/visitor]) --> D[PersonService.detail 被访人]
D --> E{success 且 PersonResult 非空?}
E -- 否 --> E1[76260531 等]
E -- 是 --> F{param.floorIds 非空?}
F -- 是 UC-02 --> G[effective = floorIds]
F -- 否 UC-01 --> H{personResult.floorList 非空?}
H -- 否 --> E1
H -- 是 --> G2[effective = floorList]
G --> K[zone.page 首层 → imageStoreId]
G2 --> K
K --> L[逐层 ImageRuleRef 挂 visitorId]
L --> M[batchBind + updateGroupPersonRef]
M --> Ok([true])
```
---
## 8. 主线 B:通行记录落库时「访客身份」认定(非派梯)
**场景**:设备上报识别结果写入电梯通行记录。
**实现**`AcsElevatorRecordServiceImpl#add` 在写库前 **`RestTemplateUtil.post`** → **`http://{ninca-crk-std}/intelligent/three/visitor/record/query`**;返回非空则 **`isVisitor=1`** 并回填被访人。该路径 **不创建** 访客主档,与第 3~7 节派梯链路独立。
```mermaid
sequenceDiagram
participant R as AcsElevatorRecordServiceImpl
participant HTTP as CRK three/query
participant DAO as 电梯记录 DAO
R->>HTTP: visitorId + tenant
HTTP-->>R: 访客档案或空
R->>DAO: add(含 isVisitor, interviewee)
```
---
## 9. 其它:MQTT 访客标签
`MqttServiceImpl` 若识别流水 **`personLabelIds` 含 "1"**MQTT JSON 置 **`isVisitor=true`**(**标签维度**,与档案访客不同)。
---
## 10. 错误与日志索引(addVisitor
| 场景 | 码 |
|------|-----|
| detail 失败 / 被访人无数据 / UC-01 **`floorList` 为空** / **`effective` 仍为空** | **`76260531`** |
| 其它未预期异常 | **`76260530`** |
| **`batchBind`** 失败 | 透传下游 **code/message** |
**日志关键字**`根据被访人添加访客派梯权限``UC-01` / `UC-02``最终生效楼层``访客添加派梯权限``远程调用绑定人员图库`
---
## 11. 关键源码索引
| 层级 | 路径 |
|------|------|
| 电梯 Controller | `cw-elevator-application-web/.../person/controller/AcsPersonController.java` |
| 电梯派梯 | `cw-elevator-application-service/.../person/impl/PersonRuleServiceImpl.java` **`addVisitor`** |
| Intelligent Feign | `intelligent-cwoscomponent-rest/.../person/feign/PersonFeignClient.java`**`/component/person/detail`** |
| 组织 Controller | `cwos-component-organization-web/.../controller/PersonController.java` **`/detail`** |
| 组织 detail 实现 | `cwos-component-organization-service/.../ImgPersonServiceImpl.java` **`detail`** |
| 组织→电梯 Feign | `cwos-component-organization-service/.../feign/ElevatorFeignClient.java`(方法 **`listByImageId`** → **`POST /elevator/passRule/image`** |
| 电梯「按人员信息列楼层」 | `cw-elevator-application-web/.../passrule/controller/AcsPassRuleController.java` **`/image`** |
| 电梯实现 | `cw-elevator-application-service/.../passrule/impl/ImageRuleRefServiceImpl.java` **`listByPersonInfo`** |
| 电梯 SQL | `cw-elevator-application-data/.../mapper/ImageRuleRefMapper.xml` **`listByPersonInfo`**(表 **`image_rule_ref`** |
| (勿与本链路混淆) | `AcsPassRuleServiceImpl#listByImageId` / **`it_acs_pass_rule`** — **不同入口** |
| 通行访客打标 | `cw-elevator-application-service/.../record/impl/AcsElevatorRecordServiceImpl.java` **`add`** |
---
## 12. 规范交叉引用
- 租户楼层策略 **替代** 语义与迁移边界:**`docs/superpowers/specs/2026-05-06-tenant-visitor-policy-organization-implementation.md`**
---
**说明**:组织 **`detail` 内租户策略替代**若未落地,UC-01 的 **`floorList`** 完全等于 **`/elevator/passRule/image``listByPersonInfo`** 返回的 **zone 列表**(经 Feign **`listByImageId`** 写入 **`ImgStorePersonGetResult`**)。与产品「仅开放接待层」不一致时,应排查 **`image_rule_ref` 数据**、该接口 **成功与否**,以及 **组织侧策略替代**是否已实现。
@@ -0,0 +1,56 @@
# `cw-elevator-application-service` 业务逻辑文档总索引
本目录以 **本 Maven 模块源码根**`src/main/java/cn/cloudwalk/elevator`)为范围,对电梯应用 **业务编排层** 作多维度说明:分域业务、接口级能力、用例/时序/流程等图(Mermaid)及与外部系统的协作关系。
| 元数据 | 说明 |
|--------|------|
| 模块路径 | `maven-cw-elevator-application/cw-elevator-application-service` |
| 文档根 | 本目录 `.../cw-elevator-application-service/docs/` |
| 源码包根 | `cn.cloudwalk.elevator` |
| 产出形态 | Markdown + Mermaid(可用支持 Mermaid 的 IDE、Git 站点或 [mermaid.live](https://mermaid.live) 渲染) |
## 与仓库级文档的关系
- 全仓约定、走查、接口不变等说明见仓库根下 **`../../../docs/`**(相对本文件)。
- 发布包与**历史 JAR 接口对拍**(计划/报告)见聚合工程目录 **`../../docs/elevator-api-parity/PLAN.md`**、脚本 `../../scripts/run_elevator_parity.sh`
- 本目录专注 **本 service 模块内** 类职责与业务流程梳理,不替代对外 API 合同文档。
## 分册导航
| 文档 | 内容摘要 |
|------|----------|
| [00-overview.md](00-overview.md) | 模块定位、包结构、领域全景、组件依赖图 |
| [01-device-and-task.md](01-device-and-task.md) | 设备 CRUD、绑定楼层/人员、设备任务与并行推进 |
| [02-passrule-and-person.md](02-passrule-and-person.md) | 通行规则、图库规则引用、人员规则、人员管理 |
| [03-record-recognition.md](03-record-recognition.md) | 电梯通行记录、识别记录、图库文件、分析统计 |
| [04-mqtt-visitor-event.md](04-mqtt-visitor-event.md) | MQTT 推送、访客查询差异、域事件 `VisitorRecordPushEvent` |
| [05-zone-code.md](05-zone-code.md) | 区域树/分页、电梯区域编码 |
| [06-export-download-storage.md](06-export-download-storage.md) | 异步导出、下载中心、分片存储 |
| [07-cross-cutting.md](07-cross-cutting.md) | 缓存、公共应用 ID、基类、空接口等横切项 |
| [08-visitor-registration-and-elevator-auth.md](08-visitor-registration-and-elevator-auth.md) | **访客:登记/授权边界、派梯 `add/visitor` 全链路、记录打标、时序/活动图** |
## 包 → 主入口(速查)
| 包路径 | 主要 `*Service` 接口 / 类 |
|--------|---------------------------|
| `device` | `AcsElevatorDeviceService``AcsDeviceTaskService` |
| `device/setting` | `AcsDeviceSettingService``AcsDeviceImageStoreAppBindService` |
| `passrule` | `AcsPassRuleService``ImageRuleRefService` |
| `person` | `AcsPersonService``PersonRuleService` |
| `record` | `AcsElevatorRecordService``AcsRecogRecordService``PersonFileService``SendRecordTimeService`(空) |
| `zone` | `ZoneService` |
| `codeElevatorArea` | `AcsElevatorCodeService` |
| `mqtt` | `MqttService` |
| `export` | `AcsAbstractExportAsyncService` 子类如 `ElevatorDeviceExportService` |
| `downloadcenter` | `AcsDownloadCenterService` |
| `storage` | `AcsFileStorageService` |
| `common` | `AcsApplicationService` |
| `cacheable` | `AcsAreaTreeCacheableService`(非 interface,为 `@Service` 包装) |
## 图例说明
- **用例图**:采用 Mermaid `flowchart` / `C4` 简图表达参与者与用例分箱;需要标准 UML 用例图时可自工具导出。
- **时序图**`sequenceDiagram` 表示一次调用链。
- **活动/状态**`flowchart TB``stateDiagram-v2` 表示分支与状态。
最后更新与源码版本以当前工作区 `cw-elevator-application-service` 反编译/还原代码为准;若与线上运行版本不一致,以发布制品为准。
@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.cloudwalk.elevator</groupId>
<artifactId>cw-elevator-application-reactor</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>cw-elevator-application-service</artifactId>
<packaging>jar</packaging>
<properties>
<alibaba.eclipse.codestyle.path>${project.basedir}/../../docs/style/alibaba-eclipse-codestyle.xml</alibaba.eclipse.codestyle.path>
</properties>
<dependencies>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-common-service</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-common-serial</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.cloudwalk</groupId>
<artifactId>cwos-java-sdk-resource</artifactId>
<exclusions>
<exclusion>
<groupId>cn.cloudwalk</groupId>
<artifactId>cwos-portal-interface</artifactId>
</exclusion>
<!-- 部分私服 POM 仍传递 stub,双保险 -->
<exclusion>
<groupId>cn.cloudwalk</groupId>
<artifactId>cwos-device-pkg-stub</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 自行声明 portal,排除 V2 引入的 stub / validator 6.x / validation starter,贴近 V1 lib -->
<dependency>
<groupId>cn.cloudwalk</groupId>
<artifactId>cwos-portal-interface</artifactId>
<exclusions>
<exclusion>
<groupId>cn.cloudwalk</groupId>
<artifactId>cwos-device-pkg-stub</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- V1 fat-jar 中出现的扩展链(历史 starter 传递) -->
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-device-manager-common</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-device-manager-interface</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cwos-common-aks-interface</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cwos-device-authentication-interface</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk</groupId>
<artifactId>cloudwalk-device-sdk-protocol-entity</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
</dependency>
<!-- V1 fat-jar 中与本业务相邻出现的扩展库(补齐后与 baseline multiset 更接近) -->
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-afterburner</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.intelligent</groupId>
<artifactId>cloudwalk-intelligent-component-lock</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-common-event</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cwos-sdk-event</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.elevator</groupId>
<artifactId>cw-elevator-application-data</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.cloudwalk.intelligent</groupId>
<artifactId>davinci-manager-storage</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.intelligent</groupId>
<artifactId>intelligent-cwoscomponent-interface</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.intelligent</groupId>
<artifactId>intelligent-cwoscomponent-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- V1 fat-jar 中独立出现的 Netflix / Consul starters(与 OpenFeign 并存) -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,44 @@
package cn.cloudwalk.client.davinci.portal.file.param.part;
import java.io.Serializable;
/** 分片追加参数(与存储层 append 调用约定一致)。 */
public class FilePartAppendParam<T> implements Serializable {
private static final long serialVersionUID = 1L;
private String filePath;
private Integer partNumber;
private String uploadId;
private T content;
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public Integer getPartNumber() {
return partNumber;
}
public void setPartNumber(Integer partNumber) {
this.partNumber = partNumber;
}
public String getUploadId() {
return uploadId;
}
public void setUploadId(String uploadId) {
this.uploadId = uploadId;
}
public T getContent() {
return content;
}
public void setContent(T content) {
this.content = content;
}
}
@@ -0,0 +1,44 @@
package cn.cloudwalk.client.davinci.portal.file.param.part;
import java.io.Serializable;
/** 分片结束参数(与 PartFinishDTO 字段对齐)。 */
public class FilePartFinishParam implements Serializable {
private static final long serialVersionUID = 1L;
private String uploadId;
private Long fileSize;
private String filePath;
private Integer returnType;
public String getUploadId() {
return uploadId;
}
public void setUploadId(String uploadId) {
this.uploadId = uploadId;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public Integer getReturnType() {
return returnType;
}
public void setReturnType(Integer returnType) {
this.returnType = returnType;
}
}
@@ -0,0 +1,17 @@
package cn.cloudwalk.client.davinci.portal.file.param.part;
import java.io.Serializable;
/** 分片上传初始化参数(与 PartInitDTO 字段对齐,供 BeanCopy 与业务层使用)。 */
public class FilePartInitParam implements Serializable {
private static final long serialVersionUID = 1L;
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.client.davinci.portal.file.result;
import java.io.Serializable;
/** 分片初始化/追加返回(与 PartInitResultDTO 字段对齐)。 */
public class FilePartResult implements Serializable {
private static final long serialVersionUID = 1L;
private String filePath;
private String uploadId;
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getUploadId() {
return uploadId;
}
public void setUploadId(String uploadId) {
this.uploadId = uploadId;
}
}
@@ -0,0 +1,68 @@
package cn.cloudwalk.elevator;
import cn.cloudwalk.cloud.context.CloudwalkSessionContextHolder;
import cn.cloudwalk.cloud.context.CloudwalkSessionObject;
import cn.cloudwalk.elevator.config.FeignThreadLocalUtil;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import java.util.Collection;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@Configuration
public class AcsFeignConfiguration implements RequestInterceptor {
protected final Logger logger = LoggerFactory.getLogger(AcsFeignConfiguration.class);
@Autowired
private CloudwalkSessionContextHolder cloudwalkSessionContextHolder;
public void apply(RequestTemplate requestTemplate) {
Map<String, String> map = FeignThreadLocalUtil.get();
if (map != null && !map.isEmpty()) {
requestTemplate.header("platformuserid", new String[] {map.get("platformuserid")});
requestTemplate.header("loginid", new String[] {map.get("loginid")});
requestTemplate.header("businessid", new String[] {map.get("businessid")});
requestTemplate.header("username", new String[] {map.get("username")});
requestTemplate.header("applicationid", new String[] {map.get("applicationid")});
requestTemplate.header("authorization", new String[] {map.get("authorization")});
this.logger.info("feign调用配置header参数, businessId={}, threadId={}",
requestTemplate.headers().get("businessid"), Long.valueOf(Thread.currentThread().getId()));
} else {
Map<String, Collection<String>> headerMap = requestTemplate.headers();
ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
if (null != attributes) {
HttpServletRequest request = attributes.getRequest();
if (!headerMap.containsKey("platformuserid")) {
requestTemplate.header("platformuserid", new String[] {request.getHeader("platformuserid")});
}
if (!headerMap.containsKey("loginid")) {
requestTemplate.header("loginid", new String[] {request.getHeader("loginid")});
}
if (!headerMap.containsKey("businessid")) {
requestTemplate.header("businessid", new String[] {request.getHeader("businessid")});
}
if (!headerMap.containsKey("username")) {
requestTemplate.header("username", new String[] {request.getHeader("username")});
}
if (!headerMap.containsKey("applicationid")) {
requestTemplate.header("applicationid", new String[] {request.getHeader("applicationid")});
}
if (!headerMap.containsKey("authorization")) {
requestTemplate.header("authorization", new String[] {request.getHeader("authorization")});
}
CloudwalkSessionObject session = this.cloudwalkSessionContextHolder.getSession();
if (StringUtils.isBlank(request.getHeader("businessid")) && session != null) {
requestTemplate.header("businessid", new String[] {session.getCompany().getCompanyId()});
}
if (StringUtils.isBlank(request.getHeader("applicationid")) && session != null)
requestTemplate.header("applicationid", new String[] {session.getApplicationId()});
}
}
}
}
@@ -0,0 +1,15 @@
package cn.cloudwalk.elevator;
import cn.cloudwalk.cloud.context.CloudwalkSessionContextHolder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/** 未扫描 {@code cn.cloudwalk.web} 时,等价于 LocaleConfiguration 中的 SessionHolder Bean。 */
@Configuration
public class CloudwalkSessionHolderConfiguration {
@Bean
public CloudwalkSessionContextHolder cloudwalkSessionContextHolder() {
return new CloudwalkSessionContextHolder();
}
}
@@ -0,0 +1,23 @@
package cn.cloudwalk.elevator.cacheable;
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.service.SysettingAreaService;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@Service
public class AcsAreaTreeCacheableService {
@Resource
private SysettingAreaService sysettingAreaService;
@Cacheable(cacheNames = {"ACS_AreaTreeCache"},
key = "T(cn.cloudwalk.elevator.cache.CacheOverrideConfig).CACHE_KEY_ACS_AREA_TREE_PREFIX + #param.businessId")
public CloudwalkResult<List<AreaTreeResult>> tree(DeviceAreaTreeParam param, CloudwalkCallContext context) {
return this.sysettingAreaService.tree(param, context);
}
}
@@ -0,0 +1,70 @@
package cn.cloudwalk.elevator.codeElevatorArea.impl;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.codeElevatorArea.dao.AcsElevatorCodeDao;
import cn.cloudwalk.elevator.codeElevatorArea.dto.AcsElevatorCodeDTO;
import cn.cloudwalk.elevator.codeElevatorArea.dto.AcsElevatorCodeResultDTO;
import cn.cloudwalk.elevator.codeElevatorArea.param.AcsElevatorCodeParam;
import cn.cloudwalk.elevator.codeElevatorArea.service.AcsElevatorCodeService;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;
@Repository
public class AcsElevatorCodeServiceImpl implements AcsElevatorCodeService {
@Resource
private AcsElevatorCodeDao acsElevatorCodeDao;
protected final Logger logger = LoggerFactory.getLogger(getClass());
public Integer insertNew(AcsElevatorCodeParam param) throws ServiceException {
AcsElevatorCodeDTO dto = (AcsElevatorCodeDTO)BeanCopyUtils.copyProperties(param, AcsElevatorCodeDTO.class);
Long createTime = Long.valueOf(System.currentTimeMillis());
dto.setCreateTime(createTime);
dto.setLastUpdateTime(createTime);
return this.acsElevatorCodeDao.insertNew(dto);
}
public Integer updateOld(AcsElevatorCodeParam param) throws ServiceException {
AcsElevatorCodeDTO dto = (AcsElevatorCodeDTO)BeanCopyUtils.copyProperties(param, AcsElevatorCodeDTO.class);
Long nowTime = Long.valueOf(System.currentTimeMillis());
dto.setLastUpdateTime(nowTime);
return this.acsElevatorCodeDao.updateOld(dto);
}
public AcsElevatorCodeResultDTO get(AcsElevatorCodeParam param) throws ServiceException {
AcsElevatorCodeDTO dto = (AcsElevatorCodeDTO)BeanCopyUtils.copyProperties(param, AcsElevatorCodeDTO.class);
AcsElevatorCodeResultDTO result = this.acsElevatorCodeDao.get(dto);
if (!ObjectUtils.isEmpty(result)) {
return result;
}
return null;
}
public AcsElevatorCodeResultDTO getFirstByParentId(String parentId) throws ServiceException {
return this.acsElevatorCodeDao.getFirstByParentId(parentId);
}
public Map<String, AcsElevatorCodeResultDTO> mapByZoneIds(List<String> zoneIds) throws ServiceException {
if (zoneIds == null || zoneIds.isEmpty()) {
return Collections.emptyMap();
}
List<AcsElevatorCodeResultDTO> list = this.acsElevatorCodeDao.listByZoneIds(zoneIds);
if (list == null || list.isEmpty()) {
return Collections.emptyMap();
}
Map<String, AcsElevatorCodeResultDTO> map = new HashMap<>(list.size() * 2);
for (AcsElevatorCodeResultDTO row : list) {
if (row != null && row.getZoneId() != null) {
map.put(row.getZoneId(), row);
}
}
return map;
}
}
@@ -0,0 +1,43 @@
package cn.cloudwalk.elevator.codeElevatorArea.param;
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
import java.io.Serializable;
public class AcsElevatorCodeParam extends CloudwalkBaseTimes implements Serializable {
private String zoneId;
private String parentId;
private String code;
private Integer isFirst;
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getIsFirst() {
return this.isFirst;
}
public void setIsFirst(Integer isFirst) {
this.isFirst = isFirst;
}
}
@@ -0,0 +1,31 @@
package cn.cloudwalk.elevator.codeElevatorArea.result;
public class AcsElevatorCodeResult {
private String zoneId;
private String code;
private Integer isFirst;
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getIsFirst() {
return this.isFirst;
}
public void setIsFirst(Integer isFirst) {
this.isFirst = isFirst;
}
}
@@ -0,0 +1,22 @@
package cn.cloudwalk.elevator.codeElevatorArea.service;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.elevator.codeElevatorArea.dto.AcsElevatorCodeResultDTO;
import cn.cloudwalk.elevator.codeElevatorArea.param.AcsElevatorCodeParam;
import java.util.List;
import java.util.Map;
public interface AcsElevatorCodeService {
Integer insertNew(AcsElevatorCodeParam paramAcsElevatorCodeParam) throws ServiceException;
Integer updateOld(AcsElevatorCodeParam paramAcsElevatorCodeParam) throws ServiceException;
AcsElevatorCodeResultDTO get(AcsElevatorCodeParam paramAcsElevatorCodeParam) throws ServiceException;
AcsElevatorCodeResultDTO getFirstByParentId(String paramString) throws ServiceException;
/**
* 按区域 ID 批量查询电梯编码,供树形接口一次拉取,避免循环内逐条查询。 不改变 {@link #get} 语义;入参去重由调用方控制。
*/
Map<String, AcsElevatorCodeResultDTO> mapByZoneIds(List<String> zoneIds) throws ServiceException;
}
@@ -0,0 +1,43 @@
package cn.cloudwalk.elevator.common;
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.session.company.CompanyContext;
import cn.cloudwalk.cloud.session.user.UserContext;
import cn.cloudwalk.cloud.utils.CloudwalkDateUtils;
import cn.cloudwalk.elevator.config.FeignThreadLocalUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 设备相关服务的抽象基类:提供区域树扁平化、以及为远程调用组装的 {@link CloudwalkCallContext}(含 Feign 线程本地传参)。
*/
public class AbstractAcsDeviceService extends AbstractCloudwalkService {
protected void getAreaMap(List<AreaTreeResult> areaTreeResultList, Map<String, String> areaMap) {
for (AreaTreeResult areaTree : areaTreeResultList) {
areaMap.put(areaTree.getId(), areaTree.getName());
if (areaTree.getChildren() != null) {
getAreaMap(areaTree.getChildren(), areaMap);
}
}
}
public CloudwalkCallContext getCloudwalkContext(String businessId) {
CloudwalkCallContext context = new CloudwalkCallContext();
CompanyContext companyContext = new CompanyContext();
companyContext.setCompanyId(businessId);
context.setCompany(companyContext);
UserContext userContext = new UserContext();
userContext.setCaller("defaultUserId");
userContext.setCallerName("defaultUserName");
context.setUser(userContext);
context.setCallTime(CloudwalkDateUtils.getCurrentDate());
Map<String, String> feignThreadLoaclMap = new HashMap<>(3);
feignThreadLoaclMap.put("businessid", businessId);
feignThreadLoaclMap.put("platformuserid", "defaultUserId");
feignThreadLoaclMap.put("username", "defaultUserName");
FeignThreadLocalUtil.set(feignThreadLoaclMap);
return context;
}
}
@@ -0,0 +1,39 @@
package cn.cloudwalk.elevator.common;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
import cn.cloudwalk.cloud.serial.UUIDSerial;
import cn.cloudwalk.cloud.utils.CloudwalkDateUtils;
import cn.cloudwalk.serial.code.AbstractGeneralCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
public class AbstractCloudwalkService {
@Autowired
protected DeviceService deviceService;
protected final Logger logger = LoggerFactory.getLogger(getClass());
private static final int GENGRAL_CODE_LENGTH = 8;
@Autowired
private MessageSource messageSource;
@Autowired
protected AbstractGeneralCode generalCode;
@Autowired(required = false)
private UUIDSerial uuidSerial;
public String getMessage(String code) {
return this.messageSource.getMessage(code, null, "", LocaleContextHolder.getLocale());
}
public String createGeneralCode() {
return this.generalCode.generalCode(CloudwalkDateUtils.getDate8YMD(), Integer.valueOf(8));
}
public String genUUID() {
if (null != this.uuidSerial) {
return this.uuidSerial.uuid();
}
return CloudwalkDateUtils.getUUID();
}
}
@@ -0,0 +1,42 @@
package cn.cloudwalk.elevator.common;
import cn.cloudwalk.client.resource.application.param.ApplicationQueryParam;
import cn.cloudwalk.client.resource.application.result.ApplicationResult;
import cn.cloudwalk.client.resource.application.service.ApplicationService;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.common.service.AcsApplicationService;
import java.util.Collection;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@Service
public class AcsApplicationServiceImpl implements AcsApplicationService {
private static final Logger logger = LoggerFactory.getLogger(AcsApplicationServiceImpl.class);
@Resource
private ApplicationService applicationService;
@Cacheable(cacheNames = {"ACS_Applicationids"},
key = "T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_APPLICATION_IDS_PREFIX + #businessId")
@Override
public String getApplicationId(String businessId) throws ServiceException {
ApplicationQueryParam param = new ApplicationQueryParam();
param.setBusinessId(businessId);
param.setServiceCode("elevator-app");
CloudwalkResult cloudwalkResult = this.applicationService.query(param);
if (cloudwalkResult.isSuccess()) {
if (CollectionUtils.isNotEmpty((Collection)((Collection)cloudwalkResult.getData()))) {
return ((ApplicationResult)((List)cloudwalkResult.getData()).get(0)).getId();
}
logger.info("未查到applicationId");
throw new ServiceException("76260005", "未查到applicationId");
}
logger.info("查询applicationId失败");
throw new ServiceException("76260006", "查询applicationId失败");
}
}
@@ -0,0 +1,27 @@
package cn.cloudwalk.elevator.common;
import java.util.concurrent.ThreadPoolExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Configuration
public class ElevatorRemoteIoExecutorConfig {
@Autowired
private ElevatorRemoteIoPoolProperties elevatorRemoteIoPoolProperties;
@Bean(name = {"elevatorRemoteBoundedExecutor"})
public ThreadPoolTaskExecutor elevatorRemoteBoundedExecutor() {
ThreadPoolTaskExecutor ex = new ThreadPoolTaskExecutor();
ex.setCorePoolSize(this.elevatorRemoteIoPoolProperties.getCorePoolSize());
ex.setMaxPoolSize(this.elevatorRemoteIoPoolProperties.getMaxPoolSize());
ex.setQueueCapacity(this.elevatorRemoteIoPoolProperties.getQueueCapacity());
ex.setKeepAliveSeconds(this.elevatorRemoteIoPoolProperties.getKeepAliveSeconds());
ex.setAllowCoreThreadTimeOut(this.elevatorRemoteIoPoolProperties.isAllowCoreThreadTimeOut());
ex.setThreadNamePrefix("elevator-remote-io-");
ex.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
ex.initialize();
return ex;
}
}
@@ -0,0 +1,55 @@
package cn.cloudwalk.elevator.common;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "ninca.elevator.remote-io.pool")
public class ElevatorRemoteIoPoolProperties {
/** 约定 §3.2 / §3.3 / §3.4:有界并行建议 4~8,默认 6 */
private int corePoolSize = 6;
private int maxPoolSize = 6;
private int queueCapacity = 512;
private int keepAliveSeconds = 60;
private boolean allowCoreThreadTimeOut = true;
public int getCorePoolSize() {
return this.corePoolSize;
}
public void setCorePoolSize(int corePoolSize) {
this.corePoolSize = corePoolSize;
}
public int getMaxPoolSize() {
return this.maxPoolSize;
}
public void setMaxPoolSize(int maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public int getQueueCapacity() {
return this.queueCapacity;
}
public void setQueueCapacity(int queueCapacity) {
this.queueCapacity = queueCapacity;
}
public int getKeepAliveSeconds() {
return this.keepAliveSeconds;
}
public void setKeepAliveSeconds(int keepAliveSeconds) {
this.keepAliveSeconds = keepAliveSeconds;
}
public boolean isAllowCoreThreadTimeOut() {
return this.allowCoreThreadTimeOut;
}
public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) {
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
}
}
@@ -0,0 +1,54 @@
package cn.cloudwalk.elevator.common;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "ninca.update.floor.pool")
public class UpdateFloorsPoolProperties {
private int corePoolSize = 3;
private int maxPoolSize = 5;
private int keepAliveSeconds = 150;
private int queueCapacity = 100;
private boolean allowCoreThreadTimeOut = true;
public int getCorePoolSize() {
return this.corePoolSize;
}
public void setCorePoolSize(int corePoolSize) {
this.corePoolSize = corePoolSize;
}
public int getMaxPoolSize() {
return this.maxPoolSize;
}
public void setMaxPoolSize(int maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public int getKeepAliveSeconds() {
return this.keepAliveSeconds;
}
public void setKeepAliveSeconds(int keepAliveSeconds) {
this.keepAliveSeconds = keepAliveSeconds;
}
public int getQueueCapacity() {
return this.queueCapacity;
}
public void setQueueCapacity(int queueCapacity) {
this.queueCapacity = queueCapacity;
}
public boolean isAllowCoreThreadTimeOut() {
return this.allowCoreThreadTimeOut;
}
public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) {
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
}
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.elevator.common;
import java.util.concurrent.ThreadPoolExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Configuration
public class UpdateFloorsTaskExecutor {
@Autowired
private UpdateFloorsPoolProperties updateFloorsPoolProperties;
@Bean(name = {"updateFloorsExecutor"})
public ThreadPoolTaskExecutor pictureRevisionTaskExecutor() {
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setCorePoolSize(this.updateFloorsPoolProperties.getCorePoolSize());
threadPoolTaskExecutor.setAllowCoreThreadTimeOut(this.updateFloorsPoolProperties.isAllowCoreThreadTimeOut());
threadPoolTaskExecutor.setMaxPoolSize(this.updateFloorsPoolProperties.getMaxPoolSize());
threadPoolTaskExecutor.setQueueCapacity(this.updateFloorsPoolProperties.getQueueCapacity());
threadPoolTaskExecutor.setThreadNamePrefix("update-floors-pool-");
threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
threadPoolTaskExecutor.initialize();
return threadPoolTaskExecutor;
}
}
@@ -0,0 +1,6 @@
/**
* 电梯应用业务编排层中的公共抽象与基础服务实现(与 common 模块中的“工具型 common”区分)。
* <p>
* 放置跨领域的服务基类、模板方法等,供本模块内各子包复用。
*/
package cn.cloudwalk.elevator.common;
@@ -0,0 +1,7 @@
package cn.cloudwalk.elevator.common.service;
import cn.cloudwalk.cloud.exception.ServiceException;
public interface AcsApplicationService {
String getApplicationId(String paramString) throws ServiceException;
}
@@ -0,0 +1,281 @@
package cn.cloudwalk.elevator.device.impl;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.DataAccessException;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.common.AbstractAcsDeviceService;
import cn.cloudwalk.elevator.device.dao.AcsDeviceTaskDao;
import cn.cloudwalk.elevator.device.dto.AcsDeviceTaskAddDto;
import cn.cloudwalk.elevator.device.dto.AcsDeviceTaskDTO;
import cn.cloudwalk.elevator.device.param.AcsRestructureBindingParam;
import cn.cloudwalk.elevator.device.service.AcsDeviceTaskService;
import cn.cloudwalk.elevator.passrule.dao.ImageRuleRefDao;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleDeleteDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageResultDto;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleDeleteParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleNewParam;
import cn.cloudwalk.elevator.config.FeignThreadLocalUtil;
import cn.cloudwalk.elevator.passrule.service.ImageRuleRefService;
import cn.cloudwalk.elevator.person.param.AcsPersonAddParam;
import cn.cloudwalk.elevator.person.param.AcsPersonDeleteParam;
import cn.cloudwalk.elevator.person.service.PersonRuleService;
import cn.cloudwalk.elevator.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
/**
* 设备异步任务:推进绑定进度、按楼层增删人员/规则;{@code updateFloors} 在楼层维度使用有界线程池并行远程调用,并按 Future 完成顺序推进 {@code bindDevices},与走查约定 §9 一致。
*/
@Service
public class AcsDeviceTaskServiceImpl extends AbstractAcsDeviceService implements AcsDeviceTaskService {
/** 单次并发执行的楼层数上限,与 {@code elevatorRemoteBoundedExecutor} 池容量配合,避免对下游突发压测。 */
private static final int UPDATE_FLOORS_FLOOR_PARALLEL = 6;
@Autowired
private PersonRuleService personRuleService;
@Autowired
private ImageRuleRefService imageRuleRefService;
@Resource
private AcsDeviceTaskDao acsDeviceTaskDao;
@Resource
private ImageRuleRefDao imageRuleRefDao;
@Autowired
@Qualifier("elevatorRemoteBoundedExecutor")
private ThreadPoolTaskExecutor elevatorRemoteBoundedExecutor;
@Async("updateFloorsExecutor")
public void updateFloors(AcsRestructureBindingParam param, List<AcsPassRuleImageResultDto> addFloors,
List<String> delFloorIds, CloudwalkCallContext context) throws ServiceException {
try {
if (!CollectionUtils.isEmpty(addFloors)) {
runAddFloorsInBoundedParallel(param, addFloors, context);
}
if (!CollectionUtils.isEmpty(delFloorIds)) {
List<AcsPassRuleImageResultDto> ruleList = this.imageRuleRefDao.listZoneInfoByIds(delFloorIds);
Map<String, String> ruleMap = new HashMap<>();
ruleList.forEach(rule -> ruleMap.put(rule.getZoneId(), rule.getZoneName()));
runDelFloorsInBoundedParallel(param, delFloorIds, ruleMap, context);
}
} catch (Exception e) {
this.logger.error("处理设备任务失败,失败原因:{}", e);
if (e instanceof ServiceException) {
throw (ServiceException)e;
}
throw new ServiceException(e.getMessage());
}
}
/**
* 约定 §3.5:楼层级有界并行发起远程调用;本方法内按原列表顺序 {@code get()} Future 与串行时一致地「每成功一层 → 重读任务行并 BIND_DEVICES+1」。
*/
private void runAddFloorsInBoundedParallel(AcsRestructureBindingParam param,
List<AcsPassRuleImageResultDto> addFloors, CloudwalkCallContext context) throws ServiceException {
for (int i = 0; i < addFloors.size(); i += UPDATE_FLOORS_FLOOR_PARALLEL) {
int end = Math.min(i + UPDATE_FLOORS_FLOOR_PARALLEL, addFloors.size());
List<Callable<Integer>> batch = new ArrayList<>();
for (int j = i; j < end; j++) {
final AcsPassRuleImageResultDto addFloor = addFloors.get(j);
batch.add(() -> FeignThreadLocalUtil.callWithContext(context,
() -> addOneFloorStep(addFloor, param, context)));
}
List<Future<Integer>> futures;
try {
futures = this.elevatorRemoteBoundedExecutor.getThreadPoolExecutor().invokeAll(batch);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260540", "updateFloors 被中断");
}
for (Future<Integer> f : futures) {
int inc;
try {
inc = f.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260540", "updateFloors 被中断");
} catch (ExecutionException e) {
Throwable c = e.getCause();
if (c instanceof ServiceException) {
throw (ServiceException)c;
}
throw new ServiceException(c != null ? c.getMessage() : e.getMessage());
}
if (inc > 0) {
advanceBindProgressOne(param.getTaskId());
}
}
}
}
private void runDelFloorsInBoundedParallel(AcsRestructureBindingParam param, List<String> delFloorIds,
Map<String, String> ruleMap, CloudwalkCallContext context) throws ServiceException {
for (int i = 0; i < delFloorIds.size(); i += UPDATE_FLOORS_FLOOR_PARALLEL) {
int end = Math.min(i + UPDATE_FLOORS_FLOOR_PARALLEL, delFloorIds.size());
List<Callable<Integer>> batch = new ArrayList<>();
for (int j = i; j < end; j++) {
final String delFloorId = delFloorIds.get(j);
batch.add(() -> FeignThreadLocalUtil.callWithContext(context,
() -> delOneFloorStep(delFloorId, param, ruleMap, context)));
}
List<Future<Integer>> futures;
try {
futures = this.elevatorRemoteBoundedExecutor.getThreadPoolExecutor().invokeAll(batch);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260540", "updateFloors 被中断");
}
for (Future<Integer> f : futures) {
int inc;
try {
inc = f.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260540", "updateFloors 被中断");
} catch (ExecutionException e) {
Throwable c = e.getCause();
if (c instanceof ServiceException) {
throw (ServiceException)c;
}
throw new ServiceException(c != null ? c.getMessage() : e.getMessage());
}
if (inc > 0) {
advanceBindProgressOne(param.getTaskId());
}
}
}
}
private void advanceBindProgressOne(String taskId) throws ServiceException {
AcsDeviceTaskDTO task = this.acsDeviceTaskDao.getById(taskId);
if (task == null) {
this.logger.error("updateFloors 任务不存在 taskId={}", taskId);
throw new ServiceException("设备任务不存在");
}
AcsDeviceTaskAddDto addDto = new AcsDeviceTaskAddDto();
addDto.setId(task.getId());
addDto.setBindDevices(Integer.valueOf(task.getBindDevices().intValue() + 1));
this.acsDeviceTaskDao.updateBingDevices(addDto);
}
/**
* @return 1 本层已执行远程步骤且应推进 bind 计数;0 任务已停止跳过
*/
private int addOneFloorStep(AcsPassRuleImageResultDto addFloor, AcsRestructureBindingParam param,
CloudwalkCallContext context) throws ServiceException {
AcsDeviceTaskDTO task = this.acsDeviceTaskDao.getById(param.getTaskId());
if (task == null) {
this.logger.error("updateFloors 任务不存在 taskId={}", param.getTaskId());
throw new ServiceException("设备任务不存在");
}
if (task.getIsStop().intValue() != 0) {
return 0;
}
if (!ObjectUtils.isEmpty(param.getPersonId())) {
AcsPersonAddParam addParam = new AcsPersonAddParam();
addParam.setPersonIds(Collections.singletonList(param.getPersonId()));
addParam.setParentId(param.getParentId());
addParam.setZoneId(addFloor.getZoneId());
addParam.setZoneName(addFloor.getZoneName());
CloudwalkResult<Boolean> addResult = this.personRuleService.add(addParam, context);
requireTaskStepSuccess(addResult, "personRuleService.add");
} else {
AcsPassRuleNewParam ruleParam = new AcsPassRuleNewParam();
ruleParam.setParentId(param.getParentId());
ruleParam.setZoneId(addFloor.getZoneId());
ruleParam.setZoneName(addFloor.getZoneName());
if (!ObjectUtils.isEmpty(param.getLabelId())) {
ruleParam.setIncludeLabels(Collections.singletonList(param.getLabelId()));
ruleParam.setRuleName(addFloor.getZoneName() + param.getLabelName());
}
if (!ObjectUtils.isEmpty(param.getOrgId())) {
ruleParam.setIncludeOrganizations(Collections.singletonList(param.getOrgId()));
ruleParam.setRuleName(addFloor.getZoneName() + param.getOrgName());
}
CloudwalkResult<Boolean> addRuleResult = this.imageRuleRefService.addOnlyRule(ruleParam, context);
requireTaskStepSuccess(addRuleResult, "imageRuleRefService.addOnlyRule");
}
return 1;
}
private int delOneFloorStep(String delFloorId, AcsRestructureBindingParam param, Map<String, String> ruleMap,
CloudwalkCallContext context) throws ServiceException {
AcsDeviceTaskDTO task = this.acsDeviceTaskDao.getById(param.getTaskId());
if (task == null) {
this.logger.error("updateFloors 任务不存在 taskId={}", param.getTaskId());
throw new ServiceException("设备任务不存在");
}
if (task.getIsStop().intValue() != 0) {
return 0;
}
if (!ObjectUtils.isEmpty(param.getPersonId())) {
AcsPersonDeleteParam delParam = new AcsPersonDeleteParam();
delParam.setParentId(param.getParentId());
delParam.setZoneId(delFloorId);
delParam.setPersonIds(Collections.singletonList(param.getPersonId()));
CloudwalkResult<Boolean> delResult = this.personRuleService.delete(delParam, context);
requireTaskStepSuccess(delResult, "personRuleService.delete");
} else {
String baseName = ruleMap.getOrDefault(delFloorId, "");
String ruleName = "";
if (!ObjectUtils.isEmpty(param.getLabelName())) {
ruleName = baseName + param.getLabelName();
}
if (!ObjectUtils.isEmpty(param.getOrgName())) {
ruleName = baseName + param.getOrgName();
}
String ruleId;
try {
ruleId = this.imageRuleRefDao.getByRuleName(ruleName, delFloorId);
} catch (DataAccessException e) {
this.logger.error("updateFloors getByRuleName 失败 delFloorId={} {}", delFloorId, e.getMessage());
throw new ServiceException("76260540", e.getMessage());
}
if (!ObjectUtils.isEmpty(ruleId)) {
AcsPassRuleDeleteParam deleteParam = new AcsPassRuleDeleteParam();
deleteParam.setIds(Collections.singletonList(ruleId));
deleteParam.setZoneId(delFloorId);
deleteParam.setParentId(param.getParentId());
CloudwalkResult<Boolean> delRuleResult = this.imageRuleRefService.delete(deleteParam, context);
requireTaskStepSuccess(delRuleResult, "imageRuleRefService.delete");
} else {
AcsPassRuleDeleteDto dto = new AcsPassRuleDeleteDto();
dto.setZoneId(delFloorId);
dto.setLabelId(param.getLabelId());
dto.setOrgId(param.getOrgId());
try {
this.imageRuleRefDao.deleteByOrgAndLabel(dto);
} catch (DataAccessException e) {
this.logger.error("updateFloors deleteByOrgAndLabel 失败 delFloorId={} {}", delFloorId,
e.getMessage());
throw new ServiceException("76260540", e.getMessage());
}
}
}
return 1;
}
/**
* 约定 §2.2:异步任务内对业务服务返回的 {@link CloudwalkResult} 须校验成功后再推进进度(避免失败仍递增 bindDevices)。
*/
private void requireTaskStepSuccess(CloudwalkResult<?> result, String op) throws ServiceException {
if (result == null || !result.isSuccess()) {
String code = result != null ? result.getCode() : "76260540";
String msg = result != null ? result.getMessage() : op + " 返回为空";
this.logger.error("updateFloors 步骤失败 op={} code={} msg={}", op, code, msg);
throw new ServiceException(code, msg);
}
}
}
@@ -0,0 +1,935 @@
package cn.cloudwalk.elevator.device.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreAddParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
import cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonDetailParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService;
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.cacheable.AcsAreaTreeCacheableService;
import cn.cloudwalk.elevator.common.service.AcsApplicationService;
import cn.cloudwalk.elevator.device.dao.AcsDeviceTaskDao;
import cn.cloudwalk.elevator.device.dao.AcsElevatorDeviceDao;
import cn.cloudwalk.elevator.device.dao.DeviceImageStoreDao;
import cn.cloudwalk.elevator.device.dto.AcsDeviceTaskAddDto;
import cn.cloudwalk.elevator.device.dto.AcsDeviceTaskDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceAddDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceEditDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceListDto;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceQueryByIdDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceQueryDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceQueryFoDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceResultDTO;
import cn.cloudwalk.elevator.device.param.AcsDeviceQueryParam;
import cn.cloudwalk.elevator.device.param.AcsDeviceRestructureTaskParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceAddParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceEditParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceQueryByIdParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceQueryParam;
import cn.cloudwalk.elevator.device.param.AcsRestructureBindingParam;
import cn.cloudwalk.elevator.device.param.AcsRestructureQueryParam;
import cn.cloudwalk.elevator.device.result.AcsDeviceNewResult;
import cn.cloudwalk.elevator.device.result.AcsDeviceRestructureResult;
import cn.cloudwalk.elevator.device.result.AcsLabelElevatorResult;
import cn.cloudwalk.elevator.device.service.AcsDeviceTaskService;
import cn.cloudwalk.elevator.device.service.AcsElevatorDeviceService;
import cn.cloudwalk.elevator.device.setting.impl.AcsDeviceImageStoreAppBindServiceImpl;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppBindParam;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppUnbindParam;
import cn.cloudwalk.elevator.device.setting.service.AcsDeviceImageStoreAppBindService;
import cn.cloudwalk.elevator.passrule.dao.AcsPassRuleDao;
import cn.cloudwalk.elevator.passrule.dao.ImageRuleRefDao;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageResultDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleLabelResultDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleQueryDto;
import cn.cloudwalk.elevator.passrule.impl.AbstractAcsPassService;
import cn.cloudwalk.elevator.passrule.service.AcsPassRuleService;
import cn.cloudwalk.elevator.util.CollectionUtils;
import cn.cloudwalk.elevator.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;
@Repository
public class AcsElevatorDeviceServiceImpl extends AbstractAcsPassService implements AcsElevatorDeviceService {
@Value("${floor.building.id}")
private String floorBuildingId;
@Resource
private ImageStoreService imageStoreService;
@Resource
private AcsElevatorDeviceDao acsElevatorDeviceDao;
@Resource
private AcsPassRuleDao acsPassRuleDao;
@Resource
private ImageRuleRefDao imageRuleRefDao;
@Autowired
private AcsDeviceTaskService acsDeviceTaskService;
@Resource
private AcsDeviceTaskDao acsDeviceTaskDao;
@Resource
private DeviceImageStoreDao deviceImageStoreDao;
@Resource
private PersonService personService;
@Resource
private AcsDeviceImageStoreAppBindService acsDeviceImageStoreAppBindService;
@Resource
private AcsDeviceImageStoreAppBindServiceImpl acsDeviceImageStoreAppBindServiceImpl;
@Resource
private DeviceService deviceService;
@Autowired
private AcsApplicationService acsApplicationService;
@Resource
private AcsPassRuleService acsPassRuleService;
@Resource
private AcsAreaTreeCacheableService acsAreaTreeCacheableService;
protected final Logger logger = LoggerFactory.getLogger(getClass());
public Integer add(AcsElevatorDeviceAddParam param, CloudwalkCallContext context) throws ServiceException {
AcsElevatorDeviceAddDTO dto =
(AcsElevatorDeviceAddDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceAddDTO.class);
try {
Long createTime = Long.valueOf(System.currentTimeMillis());
dto.setCreateTime(createTime);
dto.setLastUpdateTime(createTime);
String currentBuildingId = dto.getCurrentBuildingId();
if (dto.getDeleteFlag() == null) {
dto.setDeleteFlag(Integer.valueOf(1));
}
if (StringUtils.isNotBlank(currentBuildingId)) {
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(currentBuildingId);
if (ObjectUtils.isEmpty(imageStoreId)) {
String bigImageStoreId = addImageStore(param, context);
this.deviceImageStoreDao.save(currentBuildingId, bigImageStoreId);
} else {
String applicationId =
this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
DeviceImageStoreAppBindParam bindParam = new DeviceImageStoreAppBindParam();
bindParam.setImageStoreId(imageStoreId);
bindParam.setDeviceId(param.getDeviceId());
bindParam.setApplicationId(applicationId);
this.acsDeviceImageStoreAppBindService.bindDeviceAndImageStore(bindParam, context);
}
}
return this.acsElevatorDeviceDao.add(dto);
} catch (Exception e) {
this.logger.error("保存派梯设备信息失败,原因:", e);
throw new ServiceException(e);
}
}
public Integer edit(AcsElevatorDeviceEditParam param, CloudwalkCallContext context) throws ServiceException {
AcsElevatorDeviceEditDTO dto =
(AcsElevatorDeviceEditDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceEditDTO.class);
try {
AcsElevatorDeviceQueryByIdDTO deviceQueryByIdDTO = new AcsElevatorDeviceQueryByIdDTO();
deviceQueryByIdDTO.setId(param.getId());
AcsElevatorDeviceResultDTO deviceResultDTO = this.acsElevatorDeviceDao.getById(deviceQueryByIdDTO);
String oldImageStoreId = this.deviceImageStoreDao.getByBuildingId(deviceResultDTO.getCurrentBuildingId());
if (deviceResultDTO != null && StringUtils.isNotBlank(deviceResultDTO.getCurrentFloorId())) {
if (!deviceResultDTO.getCurrentBuildingId().equals(param.getCurrentBuildingId())) {
String applicationId =
this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
DeviceImageStoreAppUnbindParam unbindParam = new DeviceImageStoreAppUnbindParam();
unbindParam.setApplicationId(applicationId);
unbindParam.setImageStoreId(oldImageStoreId);
unbindParam.setDeviceId(deviceResultDTO.getDeviceId());
unbindParam.setDeviceCode(deviceResultDTO.getDeviceCode());
this.acsDeviceImageStoreAppBindService.unbindAppImageStoreDeviceNotDeleteImage(unbindParam,
context);
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(param.getCurrentBuildingId());
if (ObjectUtils.isEmpty(imageStoreId)) {
AcsElevatorDeviceAddParam addParam = (AcsElevatorDeviceAddParam)BeanCopyUtils
.copyProperties(param, AcsElevatorDeviceAddParam.class);
String bigImageStoreId = addImageStore(addParam, context);
this.deviceImageStoreDao.save(param.getCurrentBuildingId(), bigImageStoreId);
} else {
DeviceImageStoreAppBindParam bindParam = new DeviceImageStoreAppBindParam();
bindParam.setImageStoreId(imageStoreId);
bindParam.setDeviceId(deviceResultDTO.getDeviceId());
bindParam.setApplicationId(applicationId);
this.acsDeviceImageStoreAppBindService.bindDeviceAndImageStore(bindParam, context);
}
}
}
Long nowTime = Long.valueOf(System.currentTimeMillis());
dto.setLastUpdateTime(nowTime);
return this.acsElevatorDeviceDao.edit(dto);
} catch (Exception e) {
this.logger.error("更新派梯设备信息失败,原因:", e);
throw new ServiceException(e);
}
}
public Integer delete(List<String> ids, CloudwalkCallContext context) throws ServiceException {
try {
String applicationId = this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
for (String id : ids) {
AcsElevatorDeviceQueryByIdDTO byIdDTO = new AcsElevatorDeviceQueryByIdDTO();
byIdDTO.setId(id);
AcsElevatorDeviceResultDTO deviceResultDTO = this.acsElevatorDeviceDao.getById(byIdDTO);
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(deviceResultDTO.getCurrentBuildingId());
DeviceImageStoreAppUnbindParam unbindParam = new DeviceImageStoreAppUnbindParam();
unbindParam.setApplicationId(applicationId);
unbindParam.setImageStoreId(imageStoreId);
unbindParam.setDeviceId(deviceResultDTO.getDeviceId());
unbindParam.setDeviceCode(deviceResultDTO.getDeviceCode());
this.acsDeviceImageStoreAppBindService.unbindAppImageStoreDeviceNotDeleteImage(unbindParam, context);
}
int result = this.acsElevatorDeviceDao.delete(ids).intValue();
return Integer.valueOf(1);
} catch (Exception e) {
this.logger.error("更新派梯设备信息失败,原因:", e);
throw new ServiceException(e);
}
}
public String getBuildingId(AcsElevatorDeviceQueryParam param) throws ServiceException {
AcsElevatorDeviceQueryDTO dto =
(AcsElevatorDeviceQueryDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceQueryDTO.class);
return this.acsElevatorDeviceDao.getBuildingId(dto);
}
public String getBusinessId(AcsElevatorDeviceQueryParam param) throws ServiceException {
AcsElevatorDeviceQueryDTO dto =
(AcsElevatorDeviceQueryDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceQueryDTO.class);
return this.acsElevatorDeviceDao.getBusinessId(dto);
}
public CloudwalkResult<CloudwalkPageAble<AcsElevatorDeviceResultDTO>> get(AcsElevatorDeviceQueryParam param,
CloudwalkCallContext context) throws ServiceException {
AcsElevatorDeviceQueryDTO dto =
(AcsElevatorDeviceQueryDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceQueryDTO.class);
dto.setBusinessId(context.getCompany().getCompanyId());
CloudwalkPageInfo page = new CloudwalkPageInfo(param.getCurrentPage(), param.getRowsOfPage());
try {
CloudwalkPageAble<AcsElevatorDeviceResultDTO> deviceList = this.acsElevatorDeviceDao.page(dto, page);
return CloudwalkResult.success(deviceList);
} catch (Exception e) {
this.logger.error("分页查询派梯设备失败,失败原因:", e);
throw new ServiceException("76260108", getMessage("76260108"));
}
}
public CloudwalkResult<CloudwalkPageAble<DeviceResult>> devicePage(AcsDeviceQueryParam param,
CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
try {
DeviceQueryParam queryParam = new DeviceQueryParam();
if (!ObjectUtils.isEmpty(param.getDeviceName())) {
queryParam.setDeviceName(param.getDeviceName());
}
if (!ObjectUtils.isEmpty(param.getAreaId())) {
queryParam.setAreaIds(Collections.singletonList(param.getAreaId()));
}
if (!ObjectUtils.isEmpty(param.getDeviceCategoryId())) {
queryParam.setDeviceTypeCategoryId(param.getDeviceCategoryId());
}
queryParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<List<DeviceResult>> pageResult = this.deviceService.list(queryParam, context);
List<DeviceResult> result = new ArrayList<>();
if (!pageResult.isSuccess() || CollectionUtils.isEmpty((Collection)pageResult.getData())) {
return CloudwalkResult.success(new CloudwalkPageAble(result, pageInfo, 0L));
}
List<DeviceResult> deviceResult = deviceFilter((List<DeviceResult>)pageResult.getData(), context);
if (CollectionUtils.isEmpty(deviceResult)) {
return CloudwalkResult.success(new CloudwalkPageAble(result, pageInfo, 0L));
}
Map<String, String> areaMap = getAllAreaMap(context);
result =
page(convertDeviceNewResult(deviceResult, areaMap), pageInfo.getPageSize(), pageInfo.getCurrentPage());
return CloudwalkResult.success(new CloudwalkPageAble(result, pageInfo, deviceResult.size()));
} catch (Exception e) {
this.logger.error("分页查询设备异常,原因:", e);
throw new ServiceException(e);
}
}
public List<AcsElevatorDeviceQueryFoDTO> getFo(AcsElevatorDeviceQueryParam param) throws ServiceException {
AcsElevatorDeviceQueryDTO dto =
(AcsElevatorDeviceQueryDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceQueryDTO.class);
List<AcsElevatorDeviceResultDTO> deviceList = this.acsElevatorDeviceDao.get(dto);
List<AcsElevatorDeviceQueryFoDTO> deviceFoList = new ArrayList<>();
for (AcsElevatorDeviceResultDTO resultDTO : deviceList) {
AcsElevatorDeviceQueryFoDTO foDto =
(AcsElevatorDeviceQueryFoDTO)BeanCopyUtils.copyProperties(resultDTO, AcsElevatorDeviceQueryFoDTO.class);
deviceFoList.add(foDto);
}
return deviceFoList;
}
public AcsElevatorDeviceResultDTO getById(AcsElevatorDeviceQueryByIdParam param, CloudwalkCallContext var2)
throws ServiceException {
AcsElevatorDeviceQueryByIdDTO dto =
(AcsElevatorDeviceQueryByIdDTO)BeanCopyUtils.copyProperties(param, AcsElevatorDeviceQueryByIdDTO.class);
AcsElevatorDeviceResultDTO resultDTO = this.acsElevatorDeviceDao.getById(dto);
if (resultDTO != null && StringUtils.isNotBlank(resultDTO.getDeviceId())) {
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
deviceQueryParam.setId(resultDTO.getId());
CloudwalkResult<List<DeviceResult>> result = this.deviceService.list(deviceQueryParam, var2);
List<DeviceResult> list = (List<DeviceResult>)result.getData();
if (list != null && list.size() > 0) {
DeviceResult deviceResult = list.get(0);
if (deviceResult != null) {
String id = deviceResult.getId();
Long lastHeartbeatTime = deviceResult.getLastHeartbeatTime();
String status = deviceResult.getOnlineStatus();
resultDTO.setStatusString(status);
resultDTO.setLastHeartbeatTime(lastHeartbeatTime);
}
}
}
return resultDTO;
}
public AcsElevatorDeviceResultDTO getByDeciveCode(String deviceCode) throws ServiceException {
return this.acsElevatorDeviceDao.getByDeciveCode(deviceCode);
}
public CloudwalkResult listUnbindFloors(AcsRestructureQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
List<AcsPassRuleImageResultDto> floorList;
List<AcsDeviceRestructureResult> results = new ArrayList<>();
if (!ObjectUtils.isEmpty(param.getPersonId())) {
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
dto.setPersonId(param.getPersonId());
PersonDetailParam detailParam = new PersonDetailParam();
detailParam.setId(param.getPersonId());
detailParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<PersonResult> detail = this.personService.detail(detailParam, context);
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getLabelIds())) {
dto.setIncludeLabels(((PersonResult)detail.getData()).getLabelIds());
}
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getOrganizationIds())) {
dto.setIncludeOrganizations(((PersonResult)detail.getData()).getOrganizationIds());
}
floorList = this.imageRuleRefDao.listByPersonInfo(dto);
} else {
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
if (!ObjectUtils.isEmpty(param.getLabelId())) {
dto.setIncludeLabels(Collections.singletonList(param.getLabelId()));
}
if (!ObjectUtils.isEmpty(param.getOrgId())) {
dto.setIncludeOrganizations(Collections.singletonList(param.getOrgId()));
}
floorList = this.imageRuleRefDao.listByRestructure(dto);
}
List<String> floorIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(floorList)) {
floorList.forEach(floor -> floorIds.add(floor.getZoneId()));
}
AcsPassRuleQueryDto queryDto = new AcsPassRuleQueryDto();
queryDto.setZoneIds(floorIds);
return CloudwalkResult.success(this.imageRuleRefDao.listByNotZoneIds(queryDto));
} catch (Exception e) {
this.logger.error("查询未绑定的派梯楼层异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult listFloors(AcsRestructureQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
List<AcsPassRuleImageResultDto> floorList;
List<AcsPassRuleImageResultDto> unBindFloors;
ArrayList<AcsDeviceRestructureResult> results = new ArrayList<>();
AcsPassRuleImageDto dto;
if (!ObjectUtils.isEmpty(param.getPersonId())) {
dto = new AcsPassRuleImageDto();
dto.setPersonId(param.getPersonId());
PersonDetailParam detailParam = new PersonDetailParam();
detailParam.setId(param.getPersonId());
detailParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult detail = this.personService.detail(detailParam, context);
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getLabelIds())) {
dto.setIncludeLabels(((PersonResult)detail.getData()).getLabelIds());
}
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getOrganizationIds())) {
dto.setIncludeOrganizations(((PersonResult)detail.getData()).getOrganizationIds());
}
floorList = this.imageRuleRefDao.listByPersonInfo(dto);
} else {
dto = new AcsPassRuleImageDto();
if (!ObjectUtils.isEmpty(param.getLabelId())) {
dto.setIncludeLabels(Collections.singletonList(param.getLabelId()));
}
if (!ObjectUtils.isEmpty(param.getOrgId())) {
dto.setIncludeOrganizations(Collections.singletonList(param.getOrgId()));
}
floorList = this.imageRuleRefDao.listByRestructure(dto);
}
AcsElevatorDeviceListDto listDto = new AcsElevatorDeviceListDto();
ArrayList<String> floorIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(floorList)) {
floorList.forEach(floor -> floorIds.add(floor.getZoneId()));
}
AcsPassRuleQueryDto queryDto = new AcsPassRuleQueryDto();
if (!ObjectUtils.isEmpty(param.getZoneId())) {
if (floorIds.contains(param.getZoneId())) {
return CloudwalkResult.success(results);
}
queryDto.setZoneId(param.getZoneId());
unBindFloors = this.imageRuleRefDao.listByNotZoneIds(queryDto);
} else {
queryDto.setZoneIds(floorIds);
unBindFloors = this.imageRuleRefDao.listByNotZoneIds(queryDto);
}
ArrayList<String> unBindFloorIds = new ArrayList<>();
if (CollectionUtils.isEmpty(unBindFloors)) {
return CloudwalkResult.success(results);
}
unBindFloors.forEach(floor -> unBindFloorIds.add(floor.getZoneId()));
if (!ObjectUtils.isEmpty(param.getZoneId())) {
listDto.setCurrentFloorId(param.getZoneId());
} else {
listDto.setCurrentFloorIds(unBindFloorIds);
}
List deviceList = this.acsElevatorDeviceDao.listByZoneIds(listDto);
ArrayList<String> deviceIds = new ArrayList<>();
HashMap<String, DeviceResult> mapDevice = new HashMap<>();
if (!CollectionUtils.isEmpty(deviceList)) {
deviceList.forEach(device -> deviceIds.add(((AcsElevatorDeviceResultDTO)device).getDeviceId()));
DeviceQueryParam queryParam = new DeviceQueryParam();
queryParam.setBusinessId(context.getCompany().getCompanyId());
queryParam.setIds(deviceIds);
CloudwalkResult resultList = this.deviceService.list(queryParam, context);
List list = (List)resultList.getData();
if (list != null && list.size() > 0) {
for (Object o : list) {
DeviceResult dr = (DeviceResult)o;
mapDevice.put(dr.getId(), dr);
}
}
}
for (AcsPassRuleImageResultDto floor2 : unBindFloors) {
AcsDeviceRestructureResult result = new AcsDeviceRestructureResult();
result.setZoneId(floor2.getZoneId());
result.setZoneName(floor2.getZoneName());
if (!CollectionUtils.isEmpty(deviceList)) {
result.setParentId(((AcsElevatorDeviceResultDTO)deviceList.get(0)).getCurrentBuildingId());
} else {
result.setParentId(this.floorBuildingId);
}
String online = "";
String offline = "";
if (!CollectionUtils.isEmpty(deviceList)) {
for (int i = 0; i < deviceList.size(); ++i) {
DeviceResult deviceResult;
if (!floor2.getZoneId()
.equals(((AcsElevatorDeviceResultDTO)deviceList.get(i)).getCurrentFloorId())
|| ObjectUtils.isEmpty((deviceResult =
mapDevice.get(((AcsElevatorDeviceResultDTO)deviceList.get(i)).getDeviceId())))) {
continue;
}
if ("2".equals(deviceResult.getOnlineStatus())) {
if ("".equals(online)) {
online = online + deviceResult.getDeviceName();
continue;
}
online = online + "," + deviceResult.getDeviceName();
continue;
}
offline = "".equals(offline) ? offline + deviceResult.getDeviceName()
: offline + ',' + deviceResult.getDeviceName();
}
}
result.setOnlineDevices(online);
result.setOfflineDevices(offline);
results.add(result);
}
return CloudwalkResult.success(results);
} catch (Exception e) {
this.logger.error("查询未绑定的派梯楼层异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult listCondition(AcsRestructureQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
List<AcsPassRuleImageResultDto> floorList;
AcsPassRuleImageDto dto;
ArrayList<AcsDeviceRestructureResult> results = new ArrayList<>();
if (!ObjectUtils.isEmpty(param.getBusinessId())) {
context.getCompany().setCompanyId(param.getBusinessId());
}
if (!ObjectUtils.isEmpty(param.getPersonId())) {
dto = new AcsPassRuleImageDto();
dto.setPersonId(param.getPersonId());
PersonDetailParam detailParam = new PersonDetailParam();
detailParam.setId(param.getPersonId());
detailParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult detail = this.personService.detail(detailParam, context);
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getLabelIds())) {
dto.setIncludeLabels(((PersonResult)detail.getData()).getLabelIds());
}
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getOrganizationIds())) {
dto.setIncludeOrganizations(((PersonResult)detail.getData()).getOrganizationIds());
}
floorList = this.imageRuleRefDao.listByPersonInfo(dto);
} else {
dto = new AcsPassRuleImageDto();
if (!ObjectUtils.isEmpty(param.getLabelId())) {
dto.setIncludeLabels(Collections.singletonList(param.getLabelId()));
}
if (!ObjectUtils.isEmpty(param.getOrgId())) {
dto.setIncludeOrganizations(Collections.singletonList(param.getOrgId()));
}
floorList = this.imageRuleRefDao.listByRestructure(dto);
}
if (CollectionUtils.isEmpty(floorList)) {
return CloudwalkResult.success(results);
}
AcsElevatorDeviceListDto listDto = new AcsElevatorDeviceListDto();
ArrayList<String> floorIds = new ArrayList<>();
floorList.forEach(floor -> floorIds.add(floor.getZoneId()));
if (!ObjectUtils.isEmpty(param.getZoneId())) {
if (!floorIds.contains(param.getZoneId())) {
return CloudwalkResult.success(results);
}
listDto.setCurrentFloorIds(Collections.singletonList(param.getZoneId()));
} else {
listDto.setCurrentFloorIds(floorIds);
}
List deviceList = this.acsElevatorDeviceDao.listByZoneIds(listDto);
if (!CollectionUtils.isEmpty(deviceList)) {
ArrayList<String> deviceIds = new ArrayList<>();
deviceList.forEach(device -> deviceIds.add(((AcsElevatorDeviceResultDTO)device).getDeviceId()));
HashMap<String, DeviceResult> mapDevice = new HashMap<>();
DeviceQueryParam queryParam = new DeviceQueryParam();
queryParam.setBusinessId(context.getCompany().getCompanyId());
queryParam.setIds(deviceIds);
CloudwalkResult resultList = this.deviceService.list(queryParam, context);
List list = (List)resultList.getData();
if (list != null && list.size() > 0) {
for (Object o : list) {
DeviceResult dr = (DeviceResult)o;
mapDevice.put(dr.getId(), dr);
}
}
for (AcsPassRuleImageResultDto floor2 : floorList) {
if (!ObjectUtils.isEmpty(param.getZoneId()) && !param.getZoneId().equals(floor2.getZoneId())) {
continue;
}
AcsDeviceRestructureResult result = new AcsDeviceRestructureResult();
result.setZoneId(floor2.getZoneId());
result.setZoneName(floor2.getZoneName());
result.setParentId(this.floorBuildingId);
String online = "";
String offline = "";
for (int i = 0; i < deviceList.size(); ++i) {
if (!floor2.getZoneId()
.equals(((AcsElevatorDeviceResultDTO)deviceList.get(i)).getCurrentFloorId())) {
continue;
}
DeviceResult deviceResult =
mapDevice.get(((AcsElevatorDeviceResultDTO)deviceList.get(i)).getDeviceId());
result.setParentId(((AcsElevatorDeviceResultDTO)deviceList.get(i)).getCurrentBuildingId());
if (ObjectUtils.isEmpty(deviceResult)) {
continue;
}
if ("2".equals(deviceResult.getOnlineStatus())) {
if ("".equals(online)) {
online = online + deviceResult.getDeviceName();
continue;
}
online = online + "," + deviceResult.getDeviceName();
continue;
}
offline = "".equals(offline) ? offline + deviceResult.getDeviceName()
: offline + ',' + deviceResult.getDeviceName();
}
result.setOnlineDevices(online);
result.setOfflineDevices(offline);
results.add(result);
}
return CloudwalkResult.success(results);
}
if (!ObjectUtils.isEmpty(param.getZoneId())) {
for (AcsPassRuleImageResultDto floor3 : floorList) {
if (!floor3.getZoneId().equals(param.getZoneId())) {
continue;
}
AcsDeviceRestructureResult result = new AcsDeviceRestructureResult();
result.setZoneId(floor3.getZoneId());
result.setZoneName(floor3.getZoneName());
result.setParentId(this.floorBuildingId);
results.add(result);
return CloudwalkResult.success(results);
}
return CloudwalkResult.success(results);
}
for (AcsPassRuleImageResultDto floor4 : floorList) {
AcsDeviceRestructureResult result = new AcsDeviceRestructureResult();
result.setZoneId(floor4.getZoneId());
result.setZoneName(floor4.getZoneName());
result.setParentId(this.floorBuildingId);
results.add(result);
}
return CloudwalkResult.success(results);
} catch (Exception e) {
this.logger.error("根据机构id、标签id、人员id查询派梯设备异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult listConditionByLabelIds(AcsRestructureQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
List<AcsLabelElevatorResult> results = new ArrayList<>();
if (CollectionUtils.isEmpty(param.getLabelIds())) {
return CloudwalkResult.success(null);
}
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
dto.setIncludeLabels(param.getLabelIds());
List<AcsPassRuleLabelResultDto> floorList = this.imageRuleRefDao.listFloorsByRestructure(dto);
Map<String, List<AcsPassRuleLabelResultDto>> maps = new HashMap<>();
if (CollectionUtils.isEmpty(floorList)) {
for (String label : param.getLabelIds()) {
AcsLabelElevatorResult result = new AcsLabelElevatorResult();
result.setLabelId(label);
result.setDetails(null);
results.add(result);
}
} else {
for (AcsPassRuleLabelResultDto resultDto : floorList) {
List<AcsPassRuleLabelResultDto> dtos = maps.get(resultDto.getLabelId());
if (!CollectionUtils.isEmpty(dtos)) {
dtos.add(resultDto);
maps.put(resultDto.getLabelId(), dtos);
continue;
}
List<AcsPassRuleLabelResultDto> dtoList = new ArrayList<>();
dtoList.add(resultDto);
maps.put(resultDto.getLabelId(), dtoList);
}
for (String label : param.getLabelIds()) {
List<AcsPassRuleLabelResultDto> dtoList = maps.get(label);
AcsLabelElevatorResult result = new AcsLabelElevatorResult();
result.setLabelId(label);
if (!CollectionUtils.isEmpty(dtoList)) {
result.setDetails(dtoList);
} else {
result.setDetails(null);
}
results.add(result);
}
}
return CloudwalkResult.success(results);
} catch (Exception e) {
this.logger.error("根据标签id集合查询派梯楼层权限异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult<String> bindingFloors(AcsRestructureBindingParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
if (!ObjectUtils.isEmpty(param.getLabelId())) {
dto.setIncludeLabels(Collections.singletonList(param.getLabelId()));
}
if (!ObjectUtils.isEmpty(param.getOrgId())) {
dto.setIncludeOrganizations(Collections.singletonList(param.getOrgId()));
}
List<AcsPassRuleImageResultDto> floorList = this.imageRuleRefDao.listByRestructure(dto);
List<String> floorIds = new ArrayList<>();
Map<String, AcsPassRuleImageResultDto> zoneMap = new HashMap<>();
for (AcsPassRuleImageResultDto resultDto : floorList) {
floorIds.add(resultDto.getZoneId());
zoneMap.put(resultDto.getZoneId(), resultDto);
}
List<AcsPassRuleImageResultDto> addFloors = new ArrayList<>();
List<String> delFloorIds = new ArrayList<>();
List<String> addFloorIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(floorList)) {
for (AcsPassRuleImageResultDto floor : floorList) {
if (!param.getZoneIds().contains(floor.getZoneId())) {
delFloorIds.add(floor.getZoneId());
}
}
for (String zoneId : param.getZoneIds()) {
if (!floorIds.contains(zoneId)) {
addFloorIds.add(zoneId);
}
}
if (!CollectionUtils.isEmpty(addFloorIds)) {
addFloors.addAll(this.imageRuleRefDao.listZoneInfoByIds(addFloorIds));
}
} else {
addFloors.addAll(this.imageRuleRefDao.listZoneInfoByIds(param.getZoneIds()));
}
if (!CollectionUtils.isEmpty(addFloors) || !CollectionUtils.isEmpty(delFloorIds)) {
String taskId = genUUID();
AcsDeviceTaskAddDto addDto = new AcsDeviceTaskAddDto();
addDto.setId(taskId);
addDto.setAllDevices(Integer.valueOf(addFloors.size() + delFloorIds.size()));
addDto.setBindDevices(Integer.valueOf(0));
addDto.setIsStop(Integer.valueOf(0));
this.acsDeviceTaskDao.insert(addDto);
param.setTaskId(taskId);
this.acsDeviceTaskService.updateFloors(param, addFloors, delFloorIds, context);
return CloudwalkResult.success(taskId);
}
return CloudwalkResult.success(null);
} catch (Exception e) {
this.logger.error("根据机构id、标签id、人员id查询派梯设备异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult<String> bindingPerson(AcsRestructureBindingParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
dto.setPersonId(param.getPersonId());
PersonDetailParam detailParam = new PersonDetailParam();
detailParam.setId(param.getPersonId());
detailParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<PersonResult> detail = this.personService.detail(detailParam, context);
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getLabelIds())) {
dto.setIncludeLabels(((PersonResult)detail.getData()).getLabelIds());
}
if (!CollectionUtils.isEmpty(((PersonResult)detail.getData()).getLabelIds())) {
dto.setIncludeOrganizations(((PersonResult)detail.getData()).getOrganizationIds());
}
List<AcsPassRuleImageResultDto> floorList = this.imageRuleRefDao.listByPersonInfo(dto);
List<String> floorIds = new ArrayList<>();
Map<String, AcsPassRuleImageResultDto> zoneMap = new HashMap<>();
floorList.forEach(floor -> floorIds.add(floor.getZoneId()));
for (AcsPassRuleImageResultDto resultDto : floorList) {
floorIds.add(resultDto.getZoneId());
zoneMap.put(resultDto.getZoneId(), resultDto);
}
List<AcsPassRuleImageResultDto> addFloors = new ArrayList<>();
List<String> delFloorIds = new ArrayList<>();
List<String> addFloorIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(floorList)) {
for (AcsPassRuleImageResultDto floor : floorList) {
if (!param.getZoneIds().contains(floor.getZoneId())) {
delFloorIds.add(floor.getZoneId());
}
}
for (String zoneId : param.getZoneIds()) {
if (!floorIds.contains(zoneId)) {
addFloorIds.add(zoneId);
}
}
if (!CollectionUtils.isEmpty(addFloorIds)) {
addFloors.addAll(this.imageRuleRefDao.listZoneInfoByIds(addFloorIds));
}
} else {
addFloors.addAll(this.imageRuleRefDao.listZoneInfoByIds(param.getZoneIds()));
}
if (!CollectionUtils.isEmpty(addFloors) || !CollectionUtils.isEmpty(delFloorIds)) {
String taskId = genUUID();
AcsDeviceTaskAddDto addDto = new AcsDeviceTaskAddDto();
addDto.setId(taskId);
addDto.setAllDevices(Integer.valueOf(addFloors.size() + delFloorIds.size()));
addDto.setBindDevices(Integer.valueOf(0));
addDto.setIsStop(Integer.valueOf(0));
this.acsDeviceTaskDao.insert(addDto);
param.setTaskId(taskId);
this.acsDeviceTaskService.updateFloors(param, addFloors, delFloorIds, context);
return CloudwalkResult.success(taskId);
}
return CloudwalkResult.success(null);
} catch (Exception e) {
this.logger.error("根人员批量绑定派梯楼层异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult<AcsDeviceTaskDTO> getTask(AcsDeviceRestructureTaskParam param, CloudwalkCallContext context)
throws ServiceException {
try {
return CloudwalkResult.success(this.acsDeviceTaskDao.getById(param.getTaskId()));
} catch (Exception e) {
this.logger.error("根据任务id查询任务详情异常,原因:", e);
throw new ServiceException(e);
}
}
public CloudwalkResult<Boolean> setTaskStop(AcsDeviceRestructureTaskParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsDeviceTaskAddDto dto = new AcsDeviceTaskAddDto();
dto.setId(param.getTaskId());
dto.setIsStop(Integer.valueOf(1));
this.acsDeviceTaskDao.updateIsStop(dto);
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (Exception e) {
this.logger.error("编辑任务进程异常,原因:", e);
throw new ServiceException(e);
}
}
private String addImageStore(AcsElevatorDeviceAddParam param, CloudwalkCallContext context)
throws ServiceException {
ImageStoreAddParam imageStoreAddParam = new ImageStoreAddParam();
String applicationId = this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
imageStoreAddParam.setName(param.getCurrentBuilding() + "-默认图库");
imageStoreAddParam.setType(Short.valueOf((short)1));
imageStoreAddParam.setSourceApplicationId(applicationId);
imageStoreAddParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<String> imageStoreId = this.imageStoreService.add(imageStoreAddParam, context);
if (!imageStoreId.isSuccess()) {
this.logger.info("远程调用新增图库失败,原因:" + imageStoreId.getMessage());
throw new ServiceException(imageStoreId.getCode(), imageStoreId.getMessage());
}
this.logger.info("远程调用新增图库出参:imageStoreId=[{}]", imageStoreId.getData());
DeviceImageStoreAppBindParam appBindParam = new DeviceImageStoreAppBindParam();
appBindParam.setImageStoreId((String)imageStoreId.getData());
appBindParam.setApplicationId(applicationId);
this.acsDeviceImageStoreAppBindService.bindAppImageStoreDevice(appBindParam, context);
try {
DeviceImageStoreAppBindParam bindParam = new DeviceImageStoreAppBindParam();
bindParam.setImageStoreId((String)imageStoreId.getData());
bindParam.setDeviceId(param.getDeviceId());
bindParam.setApplicationId(applicationId);
this.acsDeviceImageStoreAppBindService.bindDeviceAndImageStore(bindParam, context);
} catch (ServiceException e) {
this.logger.error("图库关联失败,图库id={},原因:{}", imageStoreId.getData(), e.getMessage());
ImageStoreDelParam delParam = new ImageStoreDelParam();
delParam.setId((String)imageStoreId.getData());
delParam.setBusinessId(context.getCompany().getCompanyId());
this.logger.info("回滚删除图库开始,delParam={},context={}", JSONObject.toJSON(delParam),
JSONObject.toJSON(context));
CloudwalkResult<Boolean> deleteResult = this.imageStoreService.delete(delParam, context);
this.logger.info("删除图库:图库id={},结果:{}", imageStoreId, deleteResult.getMessage());
throw new ServiceException(e.getCode(), e.getMessage());
}
return (String)imageStoreId.getData();
}
private List<DeviceResult> deviceFilter(List<DeviceResult> pageResult, CloudwalkCallContext context)
throws ServiceException {
List<AcsDeviceNewResult> acsDeviceNewResults = getAcsDeviceIds(context);
List<String> acsDeviceIds = (List<String>)acsDeviceNewResults.stream().map(AcsDeviceNewResult::getDeviceId)
.collect(Collectors.toList());
List<String> deviceIds =
(List<String>)pageResult.stream().map(DeviceResult::getId).collect(Collectors.toList());
List<String> newList = CollectionUtils.removeList(deviceIds, acsDeviceIds);
List<DeviceResult> newDeviceResultList = new ArrayList<>();
Map<String, DeviceResult> deviceResultMap =
(Map<String, DeviceResult>)pageResult.stream().collect(Collectors.toMap(DeviceResult::getId, d -> d));
for (String id : newList) {
newDeviceResultList.add(deviceResultMap.get(id));
}
return newDeviceResultList;
}
private List<AcsDeviceNewResult> getAcsDeviceIds(CloudwalkCallContext context) throws ServiceException {
List<AcsElevatorDeviceResultDTO> acsDeviceList;
List<AcsDeviceNewResult> acsDeviceNewResultList = new ArrayList<>();
AcsElevatorDeviceQueryDTO dto = new AcsElevatorDeviceQueryDTO();
dto.setBusinessId(context.getCompany().getCompanyId());
try {
acsDeviceList = this.acsElevatorDeviceDao.get(dto);
} catch (ServiceException e) {
throw new ServiceException("76260007", getMessage("76260007"));
}
Map<String, String> areaMap = getAllAreaMap(context);
if (CollectionUtils.isNotEmpty(acsDeviceList)) {
List<String> deviceIds = (List<String>)acsDeviceList.stream().map(AcsElevatorDeviceResultDTO::getDeviceId)
.collect(Collectors.toList());
DeviceQueryParam queryParam = new DeviceQueryParam();
queryParam.setIds(deviceIds);
queryParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<List<DeviceResult>> deviceResult = this.deviceService.list(queryParam, context);
if (deviceResult.isSuccess()) {
if (CollectionUtils.isNotEmpty((Collection)deviceResult.getData())) {
acsDeviceNewResultList =
convertDeviceNewResult((Collection<DeviceResult>)deviceResult.getData(), areaMap);
}
} else {
this.logger.error("查询设备信息列表失败,原因={}", deviceResult.getMessage());
throw new ServiceException("查询设备信息列表失败");
}
}
return acsDeviceNewResultList;
}
protected Map<String, String> getAllAreaMap(CloudwalkCallContext context) {
DeviceAreaTreeParam areaTreeParam = new DeviceAreaTreeParam();
areaTreeParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<List<AreaTreeResult>> areaTree = this.acsAreaTreeCacheableService.tree(areaTreeParam, context);
Map<String, String> areaMap = new HashMap<>();
getAreaMap((List<AreaTreeResult>)areaTree.getData(), areaMap);
return areaMap;
}
protected void getAreaMap(List<AreaTreeResult> areaTreeResultList, Map<String, String> areaMap) {
for (AreaTreeResult areaTree : areaTreeResultList) {
areaMap.put(areaTree.getId(), areaTree.getName());
if (areaTree.getChildren() != null) {
getAreaMap(areaTree.getChildren(), areaMap);
}
}
}
protected List<AcsDeviceNewResult> convertDeviceNewResult(Collection<DeviceResult> datas,
Map<String, String> areaMap) {
List<AcsDeviceNewResult> result = new ArrayList<>();
for (DeviceResult data : datas) {
AcsDeviceNewResult acsDeviceResult = new AcsDeviceNewResult();
BeanCopyUtils.copyProperties(data, acsDeviceResult);
acsDeviceResult.setId(data.getId());
acsDeviceResult.setDeviceId(data.getId());
acsDeviceResult.setDeviceStatus(Integer.valueOf(data.getStatus()));
acsDeviceResult.setDeviceOnlineStatus(Integer.valueOf(data.getOnlineStatus()));
acsDeviceResult.setAddress(getAddress(data));
acsDeviceResult.setAreaName(areaMap.get(data.getAreaId()));
result.add(acsDeviceResult);
}
return result;
}
protected String getAddress(DeviceResult data) {
StringBuffer sb = new StringBuffer();
if (StringUtils.isNotBlank(data.getDistrictMergeName())) {
sb.append(data.getDistrictMergeName());
}
if (StringUtils.isNotBlank(data.getAreaName())) {
sb.append(" ");
sb.append(data.getAreaName());
}
return sb.toString().trim();
}
private List<DeviceResult> page(List<AcsDeviceNewResult> dataList, int pageSize, int currentPage) {
List<DeviceResult> currentPageList = new ArrayList<>();
if (dataList != null && dataList.size() > 0) {
int currIdx = (currentPage > 1) ? ((currentPage - 1) * pageSize) : 0;
for (int i = 0; i < pageSize && i < dataList.size() - currIdx; i++) {
AcsDeviceNewResult data = dataList.get(currIdx + i);
DeviceResult deviceResult = (DeviceResult)BeanCopyUtils.copyProperties(data, DeviceResult.class);
currentPageList.add(deviceResult);
}
}
return currentPageList;
}
}
@@ -0,0 +1,6 @@
/**
* 设备域服务层:电梯设备查询/编辑、设备任务(含楼层变更)、设备侧设置与图库应用绑定等编排。
* <p>
* 同包名在 data 模块中承担 DAO/Mapper;此处仅放接口、入参出参与 {@code impl} 实现,表结构见 data 包说明。
*/
package cn.cloudwalk.elevator.device;
@@ -0,0 +1,34 @@
package cn.cloudwalk.elevator.device.param;
import cn.cloudwalk.cloud.page.CloudwalkBasePageForm;
import java.io.Serializable;
public class AcsDeviceQueryParam extends CloudwalkBasePageForm implements Serializable {
private String deviceName;
private String deviceCategoryId;
private String areaId;
public String getDeviceName() {
return this.deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceCategoryId() {
return this.deviceCategoryId;
}
public void setDeviceCategoryId(String deviceCategoryId) {
this.deviceCategoryId = deviceCategoryId;
}
public String getAreaId() {
return this.areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
}
@@ -0,0 +1,43 @@
package cn.cloudwalk.elevator.device.param;
import java.io.Serializable;
public class AcsDeviceRestructureTaskParam implements Serializable {
private static final long serialVersionUID = -7349123760464380004L;
private String taskId;
public String toString() {
return "AcsDeviceRestructureTaskParam(taskId=" + getTaskId() + ")";
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $taskId = getTaskId();
return result * 59 + (($taskId == null) ? 43 : $taskId.hashCode());
}
protected boolean canEqual(Object other) {
return other instanceof AcsDeviceRestructureTaskParam;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof AcsDeviceRestructureTaskParam))
return false;
AcsDeviceRestructureTaskParam other = (AcsDeviceRestructureTaskParam)o;
if (!other.canEqual(this))
return false;
Object this$taskId = getTaskId(), other$taskId = other.getTaskId();
return !((this$taskId == null) ? (other$taskId != null) : !this$taskId.equals(other$taskId));
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskId() {
return this.taskId;
}
}
@@ -0,0 +1,157 @@
package cn.cloudwalk.elevator.device.param;
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;
public class AcsElevatorDeviceAddParam extends CloudwalkBaseTimes implements Serializable {
private String businessId;
@NotEmpty
private String deviceId;
@NotEmpty
private String deviceCode;
@NotNull
private String deviceName;
private String deviceTypeName;
private String elevatorFloorList;
@NotNull
private String currentFloorId;
private String currentFloor;
private String currentBuilding;
private String currentBuildingId;
private String areaName;
private Integer status;
private Integer deleteFlag;
private String areaId;
private String elevatorFloorIdList;
public String getElevatorFloorIdList() {
return this.elevatorFloorIdList;
}
public void setElevatorFloorIdList(String elevatorFloorIdList) {
this.elevatorFloorIdList = elevatorFloorIdList;
}
public String getAreaId() {
return this.areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getBusinessId() {
return this.businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceCode() {
return this.deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getDeviceName() {
return this.deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getElevatorFloorList() {
return this.elevatorFloorList;
}
public void setElevatorFloorList(String elevatorFloorList) {
this.elevatorFloorList = elevatorFloorList;
}
public String getCurrentFloorId() {
return this.currentFloorId;
}
public void setCurrentFloorId(String currentFloorId) {
this.currentFloorId = currentFloorId;
}
public String getCurrentFloor() {
return this.currentFloor;
}
public void setCurrentFloor(String currentFloor) {
this.currentFloor = currentFloor;
}
public String getCurrentBuilding() {
return this.currentBuilding;
}
public void setCurrentBuilding(String currentBuilding) {
this.currentBuilding = currentBuilding;
}
public String getAreaName() {
return this.areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getDeleteFlag() {
return this.deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public String getCurrentBuildingId() {
return this.currentBuildingId;
}
public void setCurrentBuildingId(String currentBuildingId) {
this.currentBuildingId = currentBuildingId;
}
public String toString() {
return "AcsElevatorDeviceAddDTO{businessId='" + this.businessId + '\'' + ", deviceId='" + this.deviceId + '\''
+ ", deviceCode='" + this.deviceCode + '\'' + ", deviceName='" + this.deviceName + '\''
+ ", deviceTypeName='" + this.deviceTypeName + '\'' + ", elevatorFloorList='" + this.elevatorFloorList
+ '\'' + ", currentFloorId='" + this.currentFloorId + '\'' + ", currentFloor='" + this.currentFloor + '\''
+ ", currentBuilding='" + this.currentBuilding + '\'' + ", areaName='" + this.areaName + '\'' + ", status="
+ this.status + ", deleteFlag=" + this.deleteFlag + '}';
}
}
@@ -0,0 +1,123 @@
package cn.cloudwalk.elevator.device.param;
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
public class AcsElevatorDeviceEditParam extends CloudwalkBaseTimes implements Serializable {
private String elevatorFloorList;
@NotNull
private String currentFloorId;
private String currentFloor;
private String currentBuilding;
private String currentBuildingId;
private String areaId;
private String elevatorFloorIdList;
private String businessId;
private String deviceId;
private String deviceCode;
private String deviceName;
private String deviceTypeName;
public String getBusinessId() {
return this.businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceCode() {
return this.deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getDeviceName() {
return this.deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getElevatorFloorIdList() {
return this.elevatorFloorIdList;
}
public void setElevatorFloorIdList(String elevatorFloorIdList) {
this.elevatorFloorIdList = elevatorFloorIdList;
}
public String getAreaId() {
return this.areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getElevatorFloorList() {
return this.elevatorFloorList;
}
public void setElevatorFloorList(String elevatorFloorList) {
this.elevatorFloorList = elevatorFloorList;
}
public String getCurrentFloorId() {
return this.currentFloorId;
}
public void setCurrentFloorId(String currentFloorId) {
this.currentFloorId = currentFloorId;
}
public String getCurrentFloor() {
return this.currentFloor;
}
public void setCurrentFloor(String currentFloor) {
this.currentFloor = currentFloor;
}
public String getCurrentBuilding() {
return this.currentBuilding;
}
public void setCurrentBuilding(String currentBuilding) {
this.currentBuilding = currentBuilding;
}
public String getCurrentBuildingId() {
return this.currentBuildingId;
}
public void setCurrentBuildingId(String currentBuildingId) {
this.currentBuildingId = currentBuildingId;
}
public String toString() {
return "AcsElevatorDeviceAddDTO{, elevatorFloorList='" + this.elevatorFloorList + '\'' + ", currentFloorId='"
+ this.currentFloorId + '\'' + ", currentFloor='" + this.currentFloor + '\'' + ", currentBuilding='"
+ this.currentBuilding + '\'' + '}';
}
}
@@ -0,0 +1,27 @@
package cn.cloudwalk.elevator.device.param;
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
public class AcsElevatorDeviceListParam extends CloudwalkBaseTimes implements Serializable {
private String businessId;
@NotNull
private String currentFloorId;
public String getBusinessId() {
return this.businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getCurrentFloorId() {
return this.currentFloorId;
}
public void setCurrentFloorId(String currentFloorId) {
this.currentFloorId = currentFloorId;
}
}
@@ -0,0 +1,16 @@
package cn.cloudwalk.elevator.device.param;
import cn.cloudwalk.cloud.page.CloudwalkBasePageForm;
import java.io.Serializable;
public class AcsElevatorDeviceQueryByIdParam extends CloudwalkBasePageForm implements Serializable {
private String id;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
}
@@ -0,0 +1,91 @@
package cn.cloudwalk.elevator.device.param;
import cn.cloudwalk.cloud.page.CloudwalkBasePageForm;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.NotNull;
public class AcsElevatorDeviceQueryParam extends CloudwalkBasePageForm implements Serializable {
@NotNull
private String deviceName;
private String deviceTypeName;
private String areaName;
private String deviceId;
private String deviceCode;
private List<String> areaIds;
private Integer status;
private Integer onlineStatus;
private String ip;
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getOnlineStatus() {
return this.onlineStatus;
}
public void setOnlineStatus(Integer onlineStatus) {
this.onlineStatus = onlineStatus;
}
public String getIp() {
return this.ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public List<String> getAreaIds() {
return this.areaIds;
}
public void setAreaIds(List<String> areaIds) {
this.areaIds = areaIds;
}
public String getDeviceName() {
return this.deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getAreaName() {
return this.areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public String getDeviceCode() {
return this.deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
}
@@ -0,0 +1,111 @@
package cn.cloudwalk.elevator.device.param;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
public class AcsRestructureBindingParam implements Serializable {
private String parentId;
private String orgId;
private String orgName;
private String labelId;
private String labelName;
private String personId;
private List<String> zoneIds;
private String taskId;
public void setParentId(String parentId) {
this.parentId = parentId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public void setLabelId(String labelId) {
this.labelId = labelId;
}
public void setLabelName(String labelName) {
this.labelName = labelName;
}
public void setPersonId(String personId) {
this.personId = personId;
}
public void setZoneIds(List<String> zoneIds) {
this.zoneIds = zoneIds;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AcsRestructureBindingParam)) {
return false;
}
AcsRestructureBindingParam other = (AcsRestructureBindingParam)o;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(parentId, other.parentId) && Objects.equals(orgId, other.orgId)
&& Objects.equals(orgName, other.orgName) && Objects.equals(labelId, other.labelId)
&& Objects.equals(labelName, other.labelName) && Objects.equals(personId, other.personId)
&& Objects.equals(zoneIds, other.zoneIds) && Objects.equals(taskId, other.taskId);
}
protected boolean canEqual(Object other) {
return other instanceof AcsRestructureBindingParam;
}
public int hashCode() {
return Objects.hash(parentId, orgId, orgName, labelId, labelName, personId, zoneIds, taskId);
}
public String toString() {
return "AcsRestructureBindingParam(parentId=" + getParentId() + ", orgId=" + getOrgId() + ", orgName="
+ getOrgName() + ", labelId=" + getLabelId() + ", labelName=" + getLabelName() + ", personId="
+ getPersonId() + ", zoneIds=" + getZoneIds() + ", taskId=" + getTaskId() + ")";
}
public String getParentId() {
return this.parentId;
}
public String getOrgId() {
return this.orgId;
}
public String getOrgName() {
return this.orgName;
}
public String getLabelId() {
return this.labelId;
}
public String getLabelName() {
return this.labelName;
}
public String getPersonId() {
return this.personId;
}
public List<String> getZoneIds() {
return this.zoneIds;
}
public String getTaskId() {
return this.taskId;
}
}
@@ -0,0 +1,92 @@
package cn.cloudwalk.elevator.device.param;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
public class AcsRestructureQueryParam implements Serializable {
private String orgId;
private String labelId;
private List<String> labelIds;
private String personId;
private String zoneId;
private String businessId;
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public void setLabelId(String labelId) {
this.labelId = labelId;
}
public void setLabelIds(List<String> labelIds) {
this.labelIds = labelIds;
}
public void setPersonId(String personId) {
this.personId = personId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AcsRestructureQueryParam)) {
return false;
}
AcsRestructureQueryParam other = (AcsRestructureQueryParam)o;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(orgId, other.orgId) && Objects.equals(labelId, other.labelId)
&& Objects.equals(labelIds, other.labelIds) && Objects.equals(personId, other.personId)
&& Objects.equals(zoneId, other.zoneId) && Objects.equals(businessId, other.businessId);
}
protected boolean canEqual(Object other) {
return other instanceof AcsRestructureQueryParam;
}
public int hashCode() {
return Objects.hash(orgId, labelId, labelIds, personId, zoneId, businessId);
}
public String toString() {
return "AcsRestructureQueryParam(orgId=" + getOrgId() + ", labelId=" + getLabelId() + ", labelIds="
+ getLabelIds() + ", personId=" + getPersonId() + ", zoneId=" + getZoneId() + ", businessId="
+ getBusinessId() + ")";
}
public String getOrgId() {
return this.orgId;
}
public String getLabelId() {
return this.labelId;
}
public List<String> getLabelIds() {
return this.labelIds;
}
public String getPersonId() {
return this.personId;
}
public String getZoneId() {
return this.zoneId;
}
public String getBusinessId() {
return this.businessId;
}
}
@@ -0,0 +1,178 @@
package cn.cloudwalk.elevator.device.result;
import java.io.Serializable;
public class AcsDeviceNewResult implements Serializable {
private static final long serialVersionUID = -3535840233209237358L;
private String id;
private String deviceId;
private String deviceName;
private String deviceCode;
private String deviceTypeId;
private String deviceTypeCode;
private String deviceTypeName;
private Integer deviceStatus;
private Integer deviceOnlineStatus;
private String address;
private String imageStoreId;
private int identifyType;
private String areaId;
private String areaName;
private Long lastHeartbeatTime;
private Integer deviceOpenStatus;
private String deviceTypeCategoryId;
private String status;
private String onlineStatus;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getAreaId() {
return this.areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getAreaName() {
return this.areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceName() {
return this.deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceCode() {
return this.deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getDeviceTypeId() {
return this.deviceTypeId;
}
public void setDeviceTypeId(String deviceTypeId) {
this.deviceTypeId = deviceTypeId;
}
public String getDeviceTypeCode() {
return this.deviceTypeCode;
}
public void setDeviceTypeCode(String deviceTypeCode) {
this.deviceTypeCode = deviceTypeCode;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public Integer getDeviceStatus() {
return this.deviceStatus;
}
public void setDeviceStatus(Integer deviceStatus) {
this.deviceStatus = deviceStatus;
}
public Integer getDeviceOnlineStatus() {
return this.deviceOnlineStatus;
}
public void setDeviceOnlineStatus(Integer deviceOnlineStatus) {
this.deviceOnlineStatus = deviceOnlineStatus;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getImageStoreId() {
return this.imageStoreId;
}
public void setImageStoreId(String imageStoreId) {
this.imageStoreId = imageStoreId;
}
public int getIdentifyType() {
return this.identifyType;
}
public void setIdentifyType(int identifyType) {
this.identifyType = identifyType;
}
public Long getLastHeartbeatTime() {
return this.lastHeartbeatTime;
}
public void setLastHeartbeatTime(Long lastHeartbeatTime) {
this.lastHeartbeatTime = lastHeartbeatTime;
}
public Integer getDeviceOpenStatus() {
return this.deviceOpenStatus;
}
public void setDeviceOpenStatus(Integer deviceOpenStatus) {
this.deviceOpenStatus = deviceOpenStatus;
}
public String getDeviceTypeCategoryId() {
return this.deviceTypeCategoryId;
}
public void setDeviceTypeCategoryId(String deviceTypeCategoryId) {
this.deviceTypeCategoryId = deviceTypeCategoryId;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public String getOnlineStatus() {
return this.onlineStatus;
}
public void setOnlineStatus(String onlineStatus) {
this.onlineStatus = onlineStatus;
}
}
@@ -0,0 +1,99 @@
package cn.cloudwalk.elevator.device.result;
public class AcsDeviceRestructureResult {
private String parentId;
private String zoneId;
private String zoneName;
private String onlineDevices;
private String offlineDevices;
public void setParentId(String parentId) {
this.parentId = parentId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setOnlineDevices(String onlineDevices) {
this.onlineDevices = onlineDevices;
}
public void setOfflineDevices(String offlineDevices) {
this.offlineDevices = offlineDevices;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof AcsDeviceRestructureResult))
return false;
AcsDeviceRestructureResult other = (AcsDeviceRestructureResult)o;
if (!other.canEqual(this))
return false;
Object this$parentId = getParentId(), other$parentId = other.getParentId();
if ((this$parentId == null) ? (other$parentId != null) : !this$parentId.equals(other$parentId))
return false;
Object this$zoneId = getZoneId(), other$zoneId = other.getZoneId();
if ((this$zoneId == null) ? (other$zoneId != null) : !this$zoneId.equals(other$zoneId))
return false;
Object this$zoneName = getZoneName(), other$zoneName = other.getZoneName();
if ((this$zoneName == null) ? (other$zoneName != null) : !this$zoneName.equals(other$zoneName))
return false;
Object this$onlineDevices = getOnlineDevices(), other$onlineDevices = other.getOnlineDevices();
if ((this$onlineDevices == null) ? (other$onlineDevices != null)
: !this$onlineDevices.equals(other$onlineDevices))
return false;
Object this$offlineDevices = getOfflineDevices(), other$offlineDevices = other.getOfflineDevices();
return !((this$offlineDevices == null) ? (other$offlineDevices != null)
: !this$offlineDevices.equals(other$offlineDevices));
}
protected boolean canEqual(Object other) {
return other instanceof AcsDeviceRestructureResult;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $parentId = getParentId();
result = result * 59 + (($parentId == null) ? 43 : $parentId.hashCode());
Object $zoneId = getZoneId();
result = result * 59 + (($zoneId == null) ? 43 : $zoneId.hashCode());
Object $zoneName = getZoneName();
result = result * 59 + (($zoneName == null) ? 43 : $zoneName.hashCode());
Object $onlineDevices = getOnlineDevices();
result = result * 59 + (($onlineDevices == null) ? 43 : $onlineDevices.hashCode());
Object $offlineDevices = getOfflineDevices();
return result * 59 + (($offlineDevices == null) ? 43 : $offlineDevices.hashCode());
}
public String toString() {
return "AcsDeviceRestructureResult(parentId=" + getParentId() + ", zoneId=" + getZoneId() + ", zoneName="
+ getZoneName() + ", onlineDevices=" + getOnlineDevices() + ", offlineDevices=" + getOfflineDevices() + ")";
}
public String getParentId() {
return this.parentId;
}
public String getZoneId() {
return this.zoneId;
}
public String getZoneName() {
return this.zoneName;
}
public String getOnlineDevices() {
return this.onlineDevices;
}
public String getOfflineDevices() {
return this.offlineDevices;
}
}
@@ -0,0 +1,208 @@
package cn.cloudwalk.elevator.device.result;
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
import java.io.Serializable;
public class AcsElevatorDeviceListResult extends CloudwalkBaseTimes implements Serializable {
private String businessId;
private String deviceId;
private String deviceCode;
private String deviceName;
private String deviceTypeName;
private String elevatorFloorList;
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
private String currentFloorId;
private String currentFloor;
private String currentBuilding;
private String currentBuildingId;
private String areaName;
private Integer status;
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public void setElevatorFloorList(String elevatorFloorList) {
this.elevatorFloorList = elevatorFloorList;
}
public void setCurrentFloorId(String currentFloorId) {
this.currentFloorId = currentFloorId;
}
public void setCurrentFloor(String currentFloor) {
this.currentFloor = currentFloor;
}
public void setCurrentBuilding(String currentBuilding) {
this.currentBuilding = currentBuilding;
}
public void setCurrentBuildingId(String currentBuildingId) {
this.currentBuildingId = currentBuildingId;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public void setStatus(Integer status) {
this.status = status;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof AcsElevatorDeviceListResult))
return false;
AcsElevatorDeviceListResult other = (AcsElevatorDeviceListResult)o;
if (!other.canEqual(this))
return false;
Object this$businessId = getBusinessId(), other$businessId = other.getBusinessId();
if ((this$businessId == null) ? (other$businessId != null) : !this$businessId.equals(other$businessId))
return false;
Object this$deviceId = getDeviceId(), other$deviceId = other.getDeviceId();
if ((this$deviceId == null) ? (other$deviceId != null) : !this$deviceId.equals(other$deviceId))
return false;
Object this$deviceCode = getDeviceCode(), other$deviceCode = other.getDeviceCode();
if ((this$deviceCode == null) ? (other$deviceCode != null) : !this$deviceCode.equals(other$deviceCode))
return false;
Object this$deviceName = getDeviceName(), other$deviceName = other.getDeviceName();
if ((this$deviceName == null) ? (other$deviceName != null) : !this$deviceName.equals(other$deviceName))
return false;
Object this$deviceTypeName = getDeviceTypeName(), other$deviceTypeName = other.getDeviceTypeName();
if ((this$deviceTypeName == null) ? (other$deviceTypeName != null)
: !this$deviceTypeName.equals(other$deviceTypeName))
return false;
Object this$elevatorFloorList = getElevatorFloorList(), other$elevatorFloorList = other.getElevatorFloorList();
if ((this$elevatorFloorList == null) ? (other$elevatorFloorList != null)
: !this$elevatorFloorList.equals(other$elevatorFloorList))
return false;
Object this$currentFloorId = getCurrentFloorId(), other$currentFloorId = other.getCurrentFloorId();
if ((this$currentFloorId == null) ? (other$currentFloorId != null)
: !this$currentFloorId.equals(other$currentFloorId))
return false;
Object this$currentFloor = getCurrentFloor(), other$currentFloor = other.getCurrentFloor();
if ((this$currentFloor == null) ? (other$currentFloor != null) : !this$currentFloor.equals(other$currentFloor))
return false;
Object this$currentBuilding = getCurrentBuilding(), other$currentBuilding = other.getCurrentBuilding();
if ((this$currentBuilding == null) ? (other$currentBuilding != null)
: !this$currentBuilding.equals(other$currentBuilding))
return false;
Object this$currentBuildingId = getCurrentBuildingId(), other$currentBuildingId = other.getCurrentBuildingId();
if ((this$currentBuildingId == null) ? (other$currentBuildingId != null)
: !this$currentBuildingId.equals(other$currentBuildingId))
return false;
Object this$areaName = getAreaName(), other$areaName = other.getAreaName();
if ((this$areaName == null) ? (other$areaName != null) : !this$areaName.equals(other$areaName))
return false;
Object this$status = getStatus(), other$status = other.getStatus();
return !((this$status == null) ? (other$status != null) : !this$status.equals(other$status));
}
protected boolean canEqual(Object other) {
return other instanceof AcsElevatorDeviceListResult;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $businessId = getBusinessId();
result = result * 59 + (($businessId == null) ? 43 : $businessId.hashCode());
Object $deviceId = getDeviceId();
result = result * 59 + (($deviceId == null) ? 43 : $deviceId.hashCode());
Object $deviceCode = getDeviceCode();
result = result * 59 + (($deviceCode == null) ? 43 : $deviceCode.hashCode());
Object $deviceName = getDeviceName();
result = result * 59 + (($deviceName == null) ? 43 : $deviceName.hashCode());
Object $deviceTypeName = getDeviceTypeName();
result = result * 59 + (($deviceTypeName == null) ? 43 : $deviceTypeName.hashCode());
Object $elevatorFloorList = getElevatorFloorList();
result = result * 59 + (($elevatorFloorList == null) ? 43 : $elevatorFloorList.hashCode());
Object $currentFloorId = getCurrentFloorId();
result = result * 59 + (($currentFloorId == null) ? 43 : $currentFloorId.hashCode());
Object $currentFloor = getCurrentFloor();
result = result * 59 + (($currentFloor == null) ? 43 : $currentFloor.hashCode());
Object $currentBuilding = getCurrentBuilding();
result = result * 59 + (($currentBuilding == null) ? 43 : $currentBuilding.hashCode());
Object $currentBuildingId = getCurrentBuildingId();
result = result * 59 + (($currentBuildingId == null) ? 43 : $currentBuildingId.hashCode());
Object $areaName = getAreaName();
result = result * 59 + (($areaName == null) ? 43 : $areaName.hashCode());
Object $status = getStatus();
return result * 59 + (($status == null) ? 43 : $status.hashCode());
}
public String toString() {
return "AcsElevatorDeviceListResult(businessId=" + getBusinessId() + ", deviceId=" + getDeviceId()
+ ", deviceCode=" + getDeviceCode() + ", deviceName=" + getDeviceName() + ", deviceTypeName="
+ getDeviceTypeName() + ", elevatorFloorList=" + getElevatorFloorList() + ", currentFloorId="
+ getCurrentFloorId() + ", currentFloor=" + getCurrentFloor() + ", currentBuilding=" + getCurrentBuilding()
+ ", currentBuildingId=" + getCurrentBuildingId() + ", areaName=" + getAreaName() + ", status="
+ getStatus() + ")";
}
public String getBusinessId() {
return this.businessId;
}
public String getDeviceId() {
return this.deviceId;
}
public String getDeviceCode() {
return this.deviceCode;
}
public String getDeviceName() {
return this.deviceName;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public String getElevatorFloorList() {
return this.elevatorFloorList;
}
public String getCurrentFloorId() {
return this.currentFloorId;
}
public String getCurrentFloor() {
return this.currentFloor;
}
public String getCurrentBuilding() {
return this.currentBuilding;
}
public String getCurrentBuildingId() {
return this.currentBuildingId;
}
public String getAreaName() {
return this.areaName;
}
public Integer getStatus() {
return this.status;
}
}
@@ -0,0 +1,115 @@
package cn.cloudwalk.elevator.device.result;
import java.io.Serializable;
public class AcsElevatorDeviceResult implements Serializable {
private static final long serialVersionUID = -90554404684210529L;
private String businessId;
private String deviceId;
private String deviceCode;
private String deviceName;
private String deviceTypeName;
private String elevatorFloorList;
private String currentFloorId;
private String currentFloor;
private String currentBuilding;
private String currentBuildingId;
private String areaName;
private Integer status;
public String getBusinessId() {
return this.businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceCode() {
return this.deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getElevatorFloorList() {
return this.elevatorFloorList;
}
public void setElevatorFloorList(String elevatorFloorList) {
this.elevatorFloorList = elevatorFloorList;
}
public String getCurrentFloorId() {
return this.currentFloorId;
}
public void setCurrentFloorId(String currentFloorId) {
this.currentFloorId = currentFloorId;
}
public String getCurrentFloor() {
return this.currentFloor;
}
public void setCurrentFloor(String currentFloor) {
this.currentFloor = currentFloor;
}
public String getCurrentBuilding() {
return this.currentBuilding;
}
public void setCurrentBuilding(String currentBuilding) {
this.currentBuilding = currentBuilding;
}
public String getCurrentBuildingId() {
return this.currentBuildingId;
}
public void setCurrentBuildingId(String currentBuildingId) {
this.currentBuildingId = currentBuildingId;
}
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getDeviceName() {
return this.deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getAreaName() {
return this.areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
}
@@ -0,0 +1,52 @@
package cn.cloudwalk.elevator.device.result;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleLabelResultDto;
import java.util.List;
import java.util.Objects;
public class AcsLabelElevatorResult {
private String labelId;
private List<AcsPassRuleLabelResultDto> details;
public void setLabelId(String labelId) {
this.labelId = labelId;
}
public void setDetails(List<AcsPassRuleLabelResultDto> details) {
this.details = details;
}
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AcsLabelElevatorResult)) {
return false;
}
AcsLabelElevatorResult other = (AcsLabelElevatorResult)o;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(labelId, other.labelId) && Objects.equals(details, other.details);
}
protected boolean canEqual(Object other) {
return other instanceof AcsLabelElevatorResult;
}
public int hashCode() {
return Objects.hash(labelId, details);
}
public String toString() {
return "AcsLabelElevatorResult(labelId=" + getLabelId() + ", details=" + getDetails() + ")";
}
public String getLabelId() {
return this.labelId;
}
public List<AcsPassRuleLabelResultDto> getDetails() {
return this.details;
}
}
@@ -0,0 +1,68 @@
package cn.cloudwalk.elevator.device.result;
public class KeyValueResult {
private String key;
private Long time;
private String keyA;
public void setKey(String key) {
this.key = key;
}
public void setTime(Long time) {
this.time = time;
}
public void setKeyA(String keyA) {
this.keyA = keyA;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof KeyValueResult))
return false;
KeyValueResult other = (KeyValueResult)o;
if (!other.canEqual(this))
return false;
Object this$key = getKey(), other$key = other.getKey();
if ((this$key == null) ? (other$key != null) : !this$key.equals(other$key))
return false;
Object this$time = getTime(), other$time = other.getTime();
if ((this$time == null) ? (other$time != null) : !this$time.equals(other$time))
return false;
Object this$keyA = getKeyA(), other$keyA = other.getKeyA();
return !((this$keyA == null) ? (other$keyA != null) : !this$keyA.equals(other$keyA));
}
protected boolean canEqual(Object other) {
return other instanceof KeyValueResult;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $key = getKey();
result = result * 59 + (($key == null) ? 43 : $key.hashCode());
Object $time = getTime();
result = result * 59 + (($time == null) ? 43 : $time.hashCode());
Object $keyA = getKeyA();
return result * 59 + (($keyA == null) ? 43 : $keyA.hashCode());
}
public String toString() {
return "KeyValueResult(key=" + getKey() + ", time=" + getTime() + ", keyA=" + getKeyA() + ")";
}
public String getKey() {
return this.key;
}
public Long getTime() {
return this.time;
}
public String getKeyA() {
return this.keyA;
}
}
@@ -0,0 +1,13 @@
package cn.cloudwalk.elevator.device.service;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.elevator.device.param.AcsRestructureBindingParam;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageResultDto;
import java.util.List;
public interface AcsDeviceTaskService {
void updateFloors(AcsRestructureBindingParam paramAcsRestructureBindingParam,
List<AcsPassRuleImageResultDto> paramList, List<String> paramList1,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
}
@@ -0,0 +1,74 @@
package cn.cloudwalk.elevator.device.service;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.device.dto.AcsDeviceTaskDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceQueryFoDTO;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceResultDTO;
import cn.cloudwalk.elevator.device.param.AcsDeviceQueryParam;
import cn.cloudwalk.elevator.device.param.AcsDeviceRestructureTaskParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceAddParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceEditParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceQueryByIdParam;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceQueryParam;
import cn.cloudwalk.elevator.device.param.AcsRestructureBindingParam;
import cn.cloudwalk.elevator.device.param.AcsRestructureQueryParam;
import java.util.List;
public interface AcsElevatorDeviceService {
Integer add(AcsElevatorDeviceAddParam paramAcsElevatorDeviceAddParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
Integer edit(AcsElevatorDeviceEditParam paramAcsElevatorDeviceEditParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
Integer delete(List<String> paramList, CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
String getBuildingId(AcsElevatorDeviceQueryParam paramAcsElevatorDeviceQueryParam) throws ServiceException;
String getBusinessId(AcsElevatorDeviceQueryParam paramAcsElevatorDeviceQueryParam) throws ServiceException;
CloudwalkResult<CloudwalkPageAble<AcsElevatorDeviceResultDTO>> get(
AcsElevatorDeviceQueryParam paramAcsElevatorDeviceQueryParam, CloudwalkCallContext paramCloudwalkCallContext)
throws ServiceException;
CloudwalkResult<CloudwalkPageAble<DeviceResult>> devicePage(AcsDeviceQueryParam paramAcsDeviceQueryParam,
CloudwalkPageInfo paramCloudwalkPageInfo, CloudwalkCallContext paramCloudwalkCallContext)
throws ServiceException;
List<AcsElevatorDeviceQueryFoDTO> getFo(AcsElevatorDeviceQueryParam paramAcsElevatorDeviceQueryParam)
throws ServiceException;
AcsElevatorDeviceResultDTO getById(AcsElevatorDeviceQueryByIdParam paramAcsElevatorDeviceQueryByIdParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
AcsElevatorDeviceResultDTO getByDeciveCode(String paramString) throws ServiceException;
CloudwalkResult listUnbindFloors(AcsRestructureQueryParam paramAcsRestructureQueryParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult listFloors(AcsRestructureQueryParam paramAcsRestructureQueryParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult listCondition(AcsRestructureQueryParam paramAcsRestructureQueryParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult listConditionByLabelIds(AcsRestructureQueryParam paramAcsRestructureQueryParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<String> bindingFloors(AcsRestructureBindingParam paramAcsRestructureBindingParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<String> bindingPerson(AcsRestructureBindingParam paramAcsRestructureBindingParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<AcsDeviceTaskDTO> getTask(AcsDeviceRestructureTaskParam paramAcsDeviceRestructureTaskParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<Boolean> setTaskStop(AcsDeviceRestructureTaskParam paramAcsDeviceRestructureTaskParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
}
@@ -0,0 +1,160 @@
package cn.cloudwalk.elevator.device.setting.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreAddParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreDelParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.application.service.ApplicationImageStoreService;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceImageStoreParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceImageStoreService;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.common.AbstractAcsDeviceService;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppBindParam;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppUnbindParam;
import cn.cloudwalk.elevator.device.setting.service.AcsDeviceImageStoreAppBindService;
import cn.cloudwalk.elevator.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class AcsDeviceImageStoreAppBindServiceImpl extends AbstractAcsDeviceService
implements AcsDeviceImageStoreAppBindService {
@Resource
private ApplicationImageStoreService applicationImageStoreService;
@Resource
private DeviceImageStoreService deviceImageStoreService;
@Resource
private ImageStoreService imageStoreService;
public CloudwalkResult<Boolean> bindAppImageStoreDevice(DeviceImageStoreAppBindParam param,
CloudwalkCallContext context) throws ServiceException {
bindApplicationImageStore(param, context);
return CloudwalkResult.success(Boolean.valueOf(true));
}
public CloudwalkResult<Boolean> bindDeviceAndImageStore(DeviceImageStoreAppBindParam param,
CloudwalkCallContext context) throws ServiceException {
try {
bindDeviceImageStore(param, context);
} catch (ServiceException e) {
this.logger.error("设备图库关联失败,图库id={},原因:{}", param.getImageStoreId(), e.getMessage());
throw new ServiceException("设备图库关联失败");
}
return CloudwalkResult.success(Boolean.valueOf(true));
}
private void bindApplicationImageStore(DeviceImageStoreAppBindParam param, CloudwalkCallContext context)
throws ServiceException {
ApplicationImageStoreAddParam applicationImageStoreAddParam = new ApplicationImageStoreAddParam();
applicationImageStoreAddParam.setApplicationId(param.getApplicationId());
applicationImageStoreAddParam.setImageStoreId(param.getImageStoreId());
CloudwalkResult<Boolean> applicationImageStoreAddResult =
this.applicationImageStoreService.add(applicationImageStoreAddParam, context);
if (!applicationImageStoreAddResult.isSuccess()) {
this.logger.error("添加应用图库关联失败,原因:{}", applicationImageStoreAddResult.getMessage());
throw new ServiceException(applicationImageStoreAddResult.getCode(),
"添加应用图库关联失败,原因:" + applicationImageStoreAddResult.getMessage());
}
}
private void bindDeviceImageStore(DeviceImageStoreAppBindParam param, CloudwalkCallContext context)
throws ServiceException {
DeviceImageStoreParam imageStoreSaveParam = new DeviceImageStoreParam();
imageStoreSaveParam.setDeviceId(param.getDeviceId());
imageStoreSaveParam.setImageStoreId(param.getImageStoreId());
CloudwalkResult<Boolean> saveDeviceResult = this.deviceImageStoreService.add(imageStoreSaveParam, context);
if (!saveDeviceResult.isSuccess()) {
this.logger.error("绑定设备与图库失败,设备id={},图库id={},原因:{}",
new Object[] {param.getDeviceId(), param.getImageStoreId(), saveDeviceResult.getMessage()});
throw new ServiceException("绑定设备与图库失败");
}
}
public CloudwalkResult<Boolean> unbindAppImageStoreDevice(DeviceImageStoreAppUnbindParam param,
CloudwalkCallContext context) throws ServiceException {
deviceUnBindImageStore(context, param.getDeviceId(), param.getImageStoreId(), param.getDeviceCode());
applicationUnBindImageStore(param.getApplicationId(), param.getImageStoreId(), context);
List<ImageStoreListResult> imageStoreList =
getImageStoreResult(param.getImageStoreId(), param.getDeviceCode(), context);
if (!CollectionUtils.isEmpty(imageStoreList)) {
deleteImageStore(param.getImageStoreId(), context);
}
return CloudwalkResult.success(Boolean.valueOf(true));
}
public CloudwalkResult<Boolean> deleteImageStore(DeviceImageStoreAppUnbindParam param, CloudwalkCallContext context)
throws ServiceException {
applicationUnBindImageStore(param.getApplicationId(), param.getImageStoreId(), context);
deleteImageStore(param.getImageStoreId(), context);
return CloudwalkResult.success(Boolean.valueOf(true));
}
public CloudwalkResult<Boolean> unbindAppImageStoreDeviceNotDeleteImage(DeviceImageStoreAppUnbindParam param,
CloudwalkCallContext context) throws ServiceException {
deviceUnBindImageStore(context, param.getDeviceId(), param.getImageStoreId(), param.getDeviceCode());
return CloudwalkResult.success(Boolean.valueOf(true));
}
private List<ImageStoreListResult> getImageStoreResult(String imageStoreId, String deviceCode,
CloudwalkCallContext context) throws ServiceException {
ImageStoreQueryParam imageStoreQueryParam = new ImageStoreQueryParam();
imageStoreQueryParam.setIds(Collections.singletonList(imageStoreId));
imageStoreQueryParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<List<ImageStoreListResult>> imageStoreList =
this.imageStoreService.list(imageStoreQueryParam, context);
if (!imageStoreList.isSuccess()) {
this.logger.error("查询设备图库失败,设备编号:{},图库id:{},原因:{}",
new Object[] {deviceCode, imageStoreId, imageStoreList.getMessage()});
throw new ServiceException("查询设备图库失败,设备编号:{}" + deviceCode);
}
return (List<ImageStoreListResult>)imageStoreList.getData();
}
private void deviceUnBindImageStore(CloudwalkCallContext context, String deviceId, String imageStoreId,
String deviceCode) throws ServiceException {
DeviceImageStoreParam deviceImageStoreParam = new DeviceImageStoreParam();
deviceImageStoreParam.setDeviceId(deviceId);
deviceImageStoreParam.setImageStoreId(imageStoreId);
CloudwalkResult<Boolean> deleteDeviceImageStoreResult =
this.deviceImageStoreService.delete(deviceImageStoreParam, context);
this.logger.info("删除设备图库关联:图库id={},结果:{}", imageStoreId, deleteDeviceImageStoreResult.getMessage());
if (!deleteDeviceImageStoreResult.isSuccess()) {
this.logger.error("删除设备图库关联失败,设备编号:{},图库id:{},原因:{}",
new Object[] {deviceCode, imageStoreId, deleteDeviceImageStoreResult.getMessage()});
throw new ServiceException("删除设备图库关联失败,设备编号:" + deviceCode);
}
}
private void deleteImageStore(String imageStoreId, CloudwalkCallContext context) throws ServiceException {
ImageStoreDelParam imageStoreDelParam = new ImageStoreDelParam();
imageStoreDelParam.setId(imageStoreId);
imageStoreDelParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<Boolean> deleteImageStoreResult = this.imageStoreService.delete(imageStoreDelParam, context);
if (!deleteImageStoreResult.isSuccess()) {
this.logger.error("删除图库失败,图库id:{},原因:{}", imageStoreId, deleteImageStoreResult.getMessage());
throw new ServiceException("删除图库失败");
}
}
public void applicationUnBindImageStore(String applicationId, String imageStoreId, CloudwalkCallContext context)
throws ServiceException {
ApplicationImageStoreDelParam applicationImageStoreDelParam = new ApplicationImageStoreDelParam();
applicationImageStoreDelParam.setApplicationId(applicationId);
applicationImageStoreDelParam.setImageStoreId(imageStoreId);
CloudwalkResult<Boolean> deleteApplicationImageStoreResult =
this.applicationImageStoreService.delete(applicationImageStoreDelParam, context);
this.logger.info("删除应用图库关联:图库id={},应用id={},结果:{}",
new Object[] {imageStoreId, applicationId, deleteApplicationImageStoreResult.getMessage()});
if (!deleteApplicationImageStoreResult.isSuccess()) {
this.logger.error("应用与图库解绑失败,应用id:{},图库id:{},原因:{}",
new Object[] {applicationId, imageStoreId, deleteApplicationImageStoreResult.getMessage()});
throw new ServiceException("应用与图库解绑失败");
}
}
}
@@ -0,0 +1,74 @@
package cn.cloudwalk.elevator.device.setting.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceSettingQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceSettingResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceSettingService;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.common.AbstractAcsDeviceService;
import cn.cloudwalk.elevator.device.setting.param.AcsDeviceTemperatureSettingParam;
import cn.cloudwalk.elevator.device.setting.result.AcsDeviceSettingResult;
import cn.cloudwalk.elevator.device.setting.result.AcsSettingAttr;
import cn.cloudwalk.elevator.device.setting.service.AcsDeviceSettingService;
import cn.cloudwalk.elevator.em.AcsDeviceSettingEnum;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AcsDeviceSettingServiceImpl extends AbstractAcsDeviceService implements AcsDeviceSettingService {
@Autowired
private DeviceSettingService deviceSettingService;
public CloudwalkResult<AcsDeviceSettingResult> getTemperatureSetting(AcsDeviceTemperatureSettingParam param,
CloudwalkCallContext context) throws ServiceException {
AcsDeviceSettingResult result = new AcsDeviceSettingResult();
result.setDeviceId(param.getDeviceId());
DeviceSettingQueryParam deviceSettingQueryParam = new DeviceSettingQueryParam();
deviceSettingQueryParam.setDeviceIds(Lists.newArrayList(param.getDeviceId()));
deviceSettingQueryParam.setHasDefault(Short.valueOf((short)0));
CloudwalkResult<List<DeviceSettingResult>> deviceSettingQueryResult =
this.deviceSettingService.query(deviceSettingQueryParam);
if (deviceSettingQueryResult.isSuccess()) {
if (CollectionUtils.isNotEmpty((Collection)deviceSettingQueryResult.getData())) {
DeviceSettingResult deviceSettingResult =
((List<DeviceSettingResult>)deviceSettingQueryResult.getData()).get(0);
List<DeviceSettingResult.DeviceSettings> settingResult = deviceSettingResult.getSettings();
if (CollectionUtils.isNotEmpty(settingResult)) {
List<AcsSettingAttr> acsSettingAttrs = new ArrayList<>();
recursionSettingAttr(acsSettingAttrs, settingResult);
List<AcsSettingAttr> attrs = (List<AcsSettingAttr>)acsSettingAttrs.stream()
.filter(s -> (AcsDeviceSettingEnum.TEMP_MIN.getCode().equals(s.getCode())
|| AcsDeviceSettingEnum.TEMP_STATE.getCode().equals(s.getCode())
|| AcsDeviceSettingEnum.TEMP_THRESHOLD.getCode().equals(s.getCode())))
.collect(Collectors.toList());
result.setAttrs(attrs);
}
}
return CloudwalkResult.success(result);
}
return CloudwalkResult.fail(deviceSettingQueryResult.getCode(), deviceSettingQueryResult.getMessage());
}
private void recursionSettingAttr(List<AcsSettingAttr> acsSettingAttrs,
List<DeviceSettingResult.DeviceSettings> deviceSettings) {
if (CollectionUtils.isNotEmpty(deviceSettings))
for (DeviceSettingResult.DeviceSettings deviceSetting : deviceSettings) {
AcsSettingAttr acsSettingAttr = new AcsSettingAttr();
acsSettingAttr.setName(deviceSetting.getSettingAttrName());
acsSettingAttr.setValue(deviceSetting.getSettingAttrValue());
acsSettingAttr.setRemark(deviceSetting.getSettingAttrRemark());
acsSettingAttr.setCode(deviceSetting.getSettingAttrCode());
acsSettingAttr.setId(deviceSetting.getId());
acsSettingAttr.setParentId(deviceSetting.getSettingParentId());
acsSettingAttrs.add(acsSettingAttr);
recursionSettingAttr(acsSettingAttrs, deviceSetting.getChild());
}
}
}
@@ -0,0 +1,17 @@
package cn.cloudwalk.elevator.device.setting.param;
import java.io.Serializable;
import org.hibernate.validator.constraints.NotBlank;
public class AcsDeviceTemperatureSettingParam implements Serializable {
@NotBlank(message = "76260003")
private String deviceId;
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
}
@@ -0,0 +1,34 @@
package cn.cloudwalk.elevator.device.setting.param;
import java.io.Serializable;
public class DeviceImageStoreAppBindParam implements Serializable {
private static final long serialVersionUID = -5165610910023828727L;
private String applicationId;
private String imageStoreId;
private String deviceId;
public String getApplicationId() {
return this.applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getImageStoreId() {
return this.imageStoreId;
}
public void setImageStoreId(String imageStoreId) {
this.imageStoreId = imageStoreId;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
}
@@ -0,0 +1,42 @@
package cn.cloudwalk.elevator.device.setting.param;
import java.io.Serializable;
public class DeviceImageStoreAppUnbindParam implements Serializable {
private String applicationId;
private String imageStoreId;
private String deviceId;
private String deviceCode;
public String getApplicationId() {
return this.applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getImageStoreId() {
return this.imageStoreId;
}
public void setImageStoreId(String imageStoreId) {
this.imageStoreId = imageStoreId;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceCode() {
return this.deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.elevator.device.setting.result;
import java.io.Serializable;
import java.util.List;
public class AcsDeviceSettingResult implements Serializable {
private static final long serialVersionUID = -6934487366934322212L;
private String deviceId;
private List<AcsSettingAttr> attrs;
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public List<AcsSettingAttr> getAttrs() {
return this.attrs;
}
public void setAttrs(List<AcsSettingAttr> attrs) {
this.attrs = attrs;
}
}
@@ -0,0 +1,61 @@
package cn.cloudwalk.elevator.device.setting.result;
import java.io.Serializable;
public class AcsSettingAttr implements Serializable {
private static final long serialVersionUID = 1670487736253830287L;
private String name;
private String value;
private String remark;
private String code;
private String id;
private String parentId;
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
public String getRemark() {
return this.remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.elevator.device.setting.service;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppBindParam;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppUnbindParam;
public interface AcsDeviceImageStoreAppBindService {
CloudwalkResult<Boolean> bindAppImageStoreDevice(DeviceImageStoreAppBindParam paramDeviceImageStoreAppBindParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<Boolean> bindDeviceAndImageStore(DeviceImageStoreAppBindParam paramDeviceImageStoreAppBindParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<Boolean> unbindAppImageStoreDevice(
DeviceImageStoreAppUnbindParam paramDeviceImageStoreAppUnbindParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<Boolean> deleteImageStore(DeviceImageStoreAppUnbindParam paramDeviceImageStoreAppUnbindParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
CloudwalkResult<Boolean> unbindAppImageStoreDeviceNotDeleteImage(
DeviceImageStoreAppUnbindParam paramDeviceImageStoreAppUnbindParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
}
@@ -0,0 +1,13 @@
package cn.cloudwalk.elevator.device.setting.service;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.device.setting.param.AcsDeviceTemperatureSettingParam;
import cn.cloudwalk.elevator.device.setting.result.AcsDeviceSettingResult;
public interface AcsDeviceSettingService {
CloudwalkResult<AcsDeviceSettingResult> getTemperatureSetting(
AcsDeviceTemperatureSettingParam paramAcsDeviceTemperatureSettingParam,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
}
@@ -0,0 +1,12 @@
package cn.cloudwalk.elevator.downloadcenter;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.elevator.downloadcenter.param.AcsFileFinishParam;
public interface AcsDownloadCenterService {
String createDownload(String paramString, CloudwalkCallContext paramCloudwalkCallContext);
boolean finishDownload(AcsFileFinishParam paramAcsFileFinishParam, CloudwalkCallContext paramCloudwalkCallContext);
int queryDownloadStatus(String paramString, CloudwalkCallContext paramCloudwalkCallContext);
}
@@ -0,0 +1,81 @@
package cn.cloudwalk.elevator.downloadcenter.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileFinishParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileGetParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileInitParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.file.result.FileDetail;
import cn.cloudwalk.client.cwoscomponent.intelligent.file.service.FileService;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.common.AbstractCloudwalkService;
import cn.cloudwalk.elevator.common.service.AcsApplicationService;
import cn.cloudwalk.elevator.config.FeignThreadLocalUtil;
import cn.cloudwalk.elevator.downloadcenter.AcsDownloadCenterService;
import cn.cloudwalk.elevator.downloadcenter.param.AcsFileFinishParam;
import cn.cloudwalk.elevator.export.AcsFileStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AcsDownloadCenterServiceImpl extends AbstractCloudwalkService implements AcsDownloadCenterService {
@Autowired
private FileService fileService;
@Autowired
private AcsApplicationService acsApplicationService;
public String createDownload(String fileName, CloudwalkCallContext context) {
try {
FileInitParam fileInitParam = new FileInitParam();
fileInitParam.setFileName(fileName);
context.setApplicationId(this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId()));
fileInitParam.setApplicationId(context.getApplicationId());
FeignThreadLocalUtil.setRequestHeader(context);
CloudwalkResult<String> result = this.fileService.init(fileInitParam, context);
if ("00000000".equals(result.getCode())) {
return (String)result.getData();
}
this.logger.error("下载任务初始化失败:code={},message={}", result.getCode(), result.getMessage());
throw new RuntimeException("下载任务创建失败!");
} catch (ServiceException e) {
this.logger.error("下载任务初始化接口错误", (Throwable)e);
throw new RuntimeException("下载任务创建失败!");
} finally {
FeignThreadLocalUtil.remove();
}
}
public boolean finishDownload(AcsFileFinishParam param, CloudwalkCallContext context) {
try {
FeignThreadLocalUtil.setRequestHeader(context);
FileFinishParam fileFinishParam =
(FileFinishParam)BeanCopyUtils.copyProperties(param, FileFinishParam.class);
CloudwalkResult<Boolean> result = this.fileService.finish(fileFinishParam, context);
if ("00000000".equals(result.getCode())) {
return true;
}
this.logger.error("下载任务完成失败:code={},message={}", result.getCode(), result.getMessage());
} catch (ServiceException e) {
this.logger.error("下载任务完成接口错误", (Throwable)e);
} finally {
FeignThreadLocalUtil.remove();
}
return false;
}
public int queryDownloadStatus(String fileId, CloudwalkCallContext context) {
try {
FileGetParam fileGetParam = new FileGetParam();
fileGetParam.setFileId(fileId);
CloudwalkResult<FileDetail> result = this.fileService.get(fileGetParam, context);
if ("00000000".equals(result.getCode())) {
return ((FileDetail)result.getData()).getStatus().intValue();
}
this.logger.error("下载任务初始化失败:code={},message={}", result.getCode(), result.getMessage());
} catch (ServiceException e) {
this.logger.error("下载任务完成接口错误", (Throwable)e);
}
return AcsFileStatusEnum.PRODUCING.getCode().intValue();
}
}
@@ -0,0 +1,61 @@
package cn.cloudwalk.elevator.downloadcenter.param;
import java.io.Serializable;
public class AcsFileFinishParam implements Serializable {
private static final long serialVersionUID = 4334332744642479052L;
private String fileId;
private Long fileSize;
private String filePath;
private Integer fileStatus;
private String errorCode;
private String errorMessage;
public String getFileId() {
return this.fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public Long getFileSize() {
return this.fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getFilePath() {
return this.filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public Integer getFileStatus() {
return this.fileStatus;
}
public void setFileStatus(Integer fileStatus) {
this.fileStatus = fileStatus;
}
public String getErrorCode() {
return this.errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMessage() {
return this.errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
@@ -0,0 +1,537 @@
package cn.cloudwalk.elevator.export;
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartAppendParam;
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartFinishParam;
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartInitParam;
import cn.cloudwalk.client.davinci.portal.file.result.FilePartResult;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.common.AbstractCloudwalkService;
import cn.cloudwalk.elevator.config.FeignThreadLocalUtil;
import cn.cloudwalk.elevator.downloadcenter.AcsDownloadCenterService;
import cn.cloudwalk.elevator.downloadcenter.param.AcsFileFinishParam;
import cn.cloudwalk.elevator.export.utils.ExcelUtil;
import cn.cloudwalk.elevator.storage.AcsFileStorageService;
import cn.cloudwalk.elevator.util.CollectionUtils;
import cn.cloudwalk.elevator.util.DateUtils;
import cn.cloudwalk.intelligent.davinci.common.exception.DavinciServiceException;
import cn.cloudwalk.intelligent.davinci.storage.bean.file.dto.FileRemoveDTO;
import cn.cloudwalk.intelligent.davinci.storage.manager.FileStorageManager;
import cn.cloudwalk.intelligent.lock.annotation.RequiredLock;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import java.io.ByteArrayOutputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
public abstract class AcsAbstractExportAsyncService<T, R> extends AbstractCloudwalkService {
protected static final Logger LOGGER = LoggerFactory.getLogger(AcsAbstractExportAsyncService.class);
private static final Integer FILE_PART_BATCH_SIZE = Integer.valueOf(5242881);
@Value("${cloudwalk.access-control.export-max-record:1000}")
private long EXPORT_MAX_RECORD;
@Autowired
private AcsFileStorageService acsFileStorageService;
@Autowired
private AcsDownloadCenterService acsDownloadCenterService;
@Resource
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private FileStorageManager fileStorageManager;
@RequiredLock(
name = "T(cn.cloudwalk.elevator.config.AcsLockConstants).LOCK_EXPORT_BUSINESSID_PREFIX.concat(#context.company.companyId)",
lockWaitTime = 5000L)
public CloudwalkResult<Boolean> startExportTask(T param, Class<R> clazz, String fileName,
CloudwalkCallContext context) throws ServiceException {
String cacheKey = "acs_export_prefix:#" + context.getCompany().getCompanyId();
try {
String taskId = (String)this.redisTemplate.opsForValue().get(cacheKey);
if (StringUtils.isNotBlank(taskId)) {
return CloudwalkResult.fail("76260308", getMessage("76260308"));
}
String exportFileName = StringUtils.isNotBlank(fileName) ? fileName : getDefaultFileName();
ExportRecordContext.Builder builder = new ExportRecordContext.Builder();
ExportRecordContext exportRecordContext = builder.withFileName(exportFileName)
.withTaskStatus(AcsFileStatusEnum.PRODUCING.getCode().intValue()).build();
CompletableFuture.runAsync(() -> {
try {
String fileId = this.acsDownloadCenterService.createDownload(exportFileName, context);
this.redisTemplate.opsForValue().set(cacheKey, fileId, 5L, TimeUnit.MINUTES);
exportRecordContext.setFileId(fileId);
} catch (Exception e) {
LOGGER.info("导出时,初始化导出任务失败,原因:", e);
this.redisTemplate.delete(cacheKey);
throw new CompletionException(e);
}
}).thenAccept(n -> {
try {
export((T)param, clazz, exportRecordContext, (ExcelCallback)null, context);
} catch (Exception e) {
LOGGER.info("导出时异常,原因=[{}]", e.getMessage(), e);
throw new CompletionException(e);
} finally {
FeignThreadLocalUtil.remove();
this.redisTemplate.delete(cacheKey);
}
}).whenComplete((n, e) -> {
if (null != e) {
LOGGER.error("异步导出任务运行失败,原因:", e);
AcsFileFinishParam fileFinishParam = new AcsFileFinishParam();
if (e.getCause() instanceof ServiceException) {
ServiceException serviceException = (ServiceException)e.getCause();
fileFinishParam.setErrorCode(serviceException.getCode());
fileFinishParam.setErrorMessage(serviceException.getMessage());
} else {
fileFinishParam.setErrorCode("76260000");
fileFinishParam.setErrorMessage(getMessage("76260000"));
}
fileFinishParam.setFileId(exportRecordContext.getFileId());
fileFinishParam.setFileStatus(AcsFileStatusEnum.FAIL.getCode());
this.acsDownloadCenterService.finishDownload(fileFinishParam, context);
} else if (AcsFileStatusEnum.CANCELED.getCode().intValue() != exportRecordContext.getTaskStatus()) {
LOGGER.info("异步导出成功。[{}]", exportRecordContext.toString());
AcsFileFinishParam fileFinishParam = new AcsFileFinishParam();
fileFinishParam.setFileId(exportRecordContext.getFileId());
fileFinishParam.setFilePath(exportRecordContext.getFilePath());
fileFinishParam.setFileSize(exportRecordContext.getFileSize());
fileFinishParam.setFileStatus(AcsFileStatusEnum.FINISH.getCode());
this.acsDownloadCenterService.finishDownload(fileFinishParam, context);
} else if (StringUtils.isNotBlank(exportRecordContext.getFilePath())) {
FileRemoveDTO fileRemoveDTO = new FileRemoveDTO();
fileRemoveDTO.setFileList(Lists.newArrayList(exportRecordContext.getFilePath()));
try {
this.fileStorageManager.remove(fileRemoveDTO);
} catch (DavinciServiceException e1) {
this.logger.error("删除文件失败,fileId=[{}],原因:", exportRecordContext.getFileId(), e1);
}
}
});
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (Exception e) {
this.logger.error("异步导出任务异常,原因:", e);
throw new ServiceException(e);
}
}
private void export(T param, Class<R> clazz, ExportRecordContext exportRecordContext, ExcelCallback callback,
CloudwalkCallContext context) throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
String sheetName = exportRecordContext.getFileName();
FeignThreadLocalUtil.setRequestHeader(context);
int startPage = 1;
int pageSize = 100;
long maxPageSize = this.EXPORT_MAX_RECORD / 100L;
PageInfo pageInfo = new PageInfo();
List<R> list = getList(param, context, startPage, 100, pageInfo);
Long totalRows = Long.valueOf(pageInfo.getTotal());
Long totalPages = Long.valueOf(pageInfo.getPages());
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
int sheetSize = 65536;
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<>();
for (Field field : allFields) {
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (attr != null && attr.isExport()) {
fields.add(field);
}
}
long listSize =
(this.EXPORT_MAX_RECORD < totalRows.longValue()) ? this.EXPORT_MAX_RECORD : totalRows.longValue();
int startRow = 0;
int sheetNo = (int)listSize / sheetSize;
for (int index = 0; index <= sheetNo; index++) {
HSSFSheet sheet = workbook.createSheet();
workbook.setSheetName(index, sheetName + index);
ExcelUtil.createRowHeard(sheet, fields, workbook, startRow);
while (true) {
if (isCancelDownload(exportRecordContext, context)) {
output.close();
return;
}
if (CollectionUtils.isEmpty(list)) {
list = getList(param, context, startPage, 100, pageInfo);
}
createRowContent(sheet, fields, workbook, list, (startPage - 1) * 100,
(startPage - 1) * 100 + list.size(), startRow + 1);
if (null != callback) {
callback.call(workbook, sheet);
}
startPage++;
if (startPage > totalPages.longValue() || startPage > maxPageSize) {
break;
}
list = new ArrayList<>();
}
}
output.flush();
workbook.write(output);
output.close();
byte[] fileByte = output.toByteArray();
exportRecordContext.setFileSize(Long.valueOf(fileByte.length));
String filePath =
fileStore(exportRecordContext.getFileName() + ".xls", fileByte, exportRecordContext, context);
exportRecordContext.setFilePath(filePath);
} catch (Exception e) {
throw new Exception("将list数据源的数据导入到excel表单异常!", e);
}
}
private boolean isCancelDownload(ExportRecordContext exportRecordContext, CloudwalkCallContext context) {
int taskStatus = this.acsDownloadCenterService.queryDownloadStatus(exportRecordContext.getFileId(), context);
if (AcsFileStatusEnum.CANCELED.getCode().intValue() == taskStatus) {
this.logger.info("导出任务已取消,fileID=[{}]", exportRecordContext.getFileId());
exportRecordContext.setTaskStatus(taskStatus);
return true;
}
return false;
}
private ArrayList<R> getList(T param, CloudwalkCallContext context, int startPage, int pageSize, PageInfo pageInfo)
throws ServiceException {
CloudwalkPageInfo cloudwalkPageInfo = new CloudwalkPageInfo(startPage, pageSize);
CloudwalkPageAble<R> dataPage = queryPage(param, cloudwalkPageInfo, context);
pageInfo.setTotal(dataPage.getTotalRows());
pageInfo.setPages((int)dataPage.getTotalPages());
return Lists.newArrayList(dataPage.getDatas());
}
private int getColumnSize(Class clazz) {
Field[] allFields = clazz.getDeclaredFields();
int size = 0;
for (Field field : allFields) {
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (attr != null && attr.isExport()) {
size++;
}
}
return size;
}
private void setRow1(HSSFWorkbook workBook, HSSFSheet sheet, String row1Str) {
HSSFCellStyle cellStyle1 = workBook.createCellStyle();
HSSFFont font1 = workBook.createFont();
font1.setFontHeightInPoints((short)15);
font1.setBold(Boolean.TRUE.booleanValue());
cellStyle1.setAlignment(HorizontalAlignment.LEFT);
cellStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
HSSFRichTextString row1String = new HSSFRichTextString(row1Str);
row1String.applyFont(0, row1Str.length(), (Font)font1);
sheet.getRow(0).getCell(0).setCellValue((RichTextString)row1String);
sheet.getRow(0).getCell(0).setCellStyle(cellStyle1);
}
private String fileStore(String fileName, byte[] bytes, ExportRecordContext exportRecordContext,
CloudwalkCallContext context) throws ServiceException {
int size = bytes.length;
LOGGER.info("文件大小为: {}", Integer.valueOf(size));
FilePartInitParam param = new FilePartInitParam();
param.setFileName(fileName);
LOGGER.info("文件分片初始化开始");
CloudwalkResult<FilePartResult> result = this.acsFileStorageService.filePartInit(param);
if (result.isSuccess()) {
LOGGER.info("文件分片初始化结束,uploadId = {}, filePath = {}", ((FilePartResult)result.getData()).getUploadId(),
((FilePartResult)result.getData()).getFilePath());
FilePartResult filePartResult = (FilePartResult)result.getData();
int times = 0;
while (true) {
if (isCancelDownload(exportRecordContext, context)) {
return ((FilePartResult)result.getData()).getFilePath();
}
int start = times++ * FILE_PART_BATCH_SIZE.intValue();
int end =
(start + FILE_PART_BATCH_SIZE.intValue() > size) ? size : (start + FILE_PART_BATCH_SIZE.intValue());
byte[] trunk = Arrays.copyOfRange(bytes, start, end);
LOGGER.info("第{}个分片开始追加,uploadId = {}, filePath = {}, size ; {}", new Object[] {Integer.valueOf(times),
filePartResult.getUploadId(), filePartResult.getFilePath(), Integer.valueOf(trunk.length)});
FilePartAppendParam<byte[]> appendParam = new FilePartAppendParam();
appendParam.setFilePath(filePartResult.getFilePath());
appendParam.setPartNumber(Integer.valueOf(times));
appendParam.setUploadId(filePartResult.getUploadId());
appendParam.setContent(trunk);
this.acsFileStorageService.filePartAppend(appendParam);
LOGGER.info("第{}个分片完成追加,uploadId = {}, filePath = {}",
new Object[] {Integer.valueOf(times), filePartResult.getUploadId(), filePartResult.getFilePath()});
if (end >= size) {
LOGGER.info("追加完成,准备结束,uploadId = {}, filePath = {}", filePartResult.getUploadId(),
filePartResult.getFilePath());
FilePartFinishParam finishParam = new FilePartFinishParam();
finishParam.setFilePath(filePartResult.getFilePath());
finishParam.setUploadId(filePartResult.getUploadId());
finishParam.setFileSize(Long.valueOf(size));
finishParam.setReturnType(Integer.valueOf(1));
CloudwalkResult<String> finishResult = this.acsFileStorageService.filePartFinish(finishParam);
LOGGER.info("结束完成,uploadId = {}, filePath = {}, finishFilePath = {}", new Object[] {
filePartResult.getUploadId(), filePartResult.getFilePath(), finishResult.getData()});
if (finishResult.isSuccess()) {
return ((String)finishResult.getData()).split("=")[1];
}
}
}
}
throw new ServiceException(result.getCode(), result.getMessage());
}
protected ThreadPoolTaskExecutor getExportExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(30);
executor.setThreadNamePrefix("Export-Pool-Executor");
executor.setQueueCapacity(25);
executor.initialize();
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
return executor;
}
private static class ExportRecordContext {
private String fileId;
private String filePath;
private String fileName;
private Long fileSize;
private int taskStatus;
private ExportRecordContext() {}
public int getTaskStatus() {
return this.taskStatus;
}
public void setTaskStatus(int taskStatus) {
this.taskStatus = taskStatus;
}
public String getFileId() {
return this.fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getFilePath() {
return this.filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFileName() {
return this.fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Long getFileSize() {
return this.fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String toString() {
return "ExportRecordContext{fileId='" + this.fileId + '\'' + ", filePath='" + this.filePath + '\''
+ ", fileName='" + this.fileName + '\'' + ", fileSize=" + this.fileSize + ", taskStatus="
+ this.taskStatus + '}';
}
private static class Builder {
private String fileId;
private String filePath;
private String fileName;
private Long fileSize;
private int taskStatus;
private Builder() {}
public Builder withTaskStatus(int taskStatus) {
this.taskStatus = taskStatus;
return this;
}
public Builder withFileId(String fileId) {
this.fileId = fileId;
return this;
}
public Builder withFilePath(String filePath) {
this.filePath = filePath;
return this;
}
public Builder withFileName(String fileName) {
this.fileName = fileName;
return this;
}
public Builder withFileSize(Long fileSize) {
this.fileSize = fileSize;
return this;
}
public AcsAbstractExportAsyncService.ExportRecordContext build() {
AcsAbstractExportAsyncService.ExportRecordContext context =
new AcsAbstractExportAsyncService.ExportRecordContext();
context.setFileId(this.fileId);
context.setFileSize(this.fileSize);
context.setFilePath(this.filePath);
context.setFileName(this.fileName);
context.setTaskStatus(this.taskStatus);
return context;
}
}
}
private static class Builder {
private String fileId;
private String filePath;
public AcsAbstractExportAsyncService.ExportRecordContext build() {
AcsAbstractExportAsyncService.ExportRecordContext context =
new AcsAbstractExportAsyncService.ExportRecordContext();
context.setFileId(this.fileId);
context.setFileSize(this.fileSize);
context.setFilePath(this.filePath);
context.setFileName(this.fileName);
context.setTaskStatus(this.taskStatus);
return context;
}
private String fileName;
private Long fileSize;
private int taskStatus;
private Builder() {}
public Builder withTaskStatus(int taskStatus) {
this.taskStatus = taskStatus;
return this;
}
public Builder withFileId(String fileId) {
this.fileId = fileId;
return this;
}
public Builder withFilePath(String filePath) {
this.filePath = filePath;
return this;
}
public Builder withFileName(String fileName) {
this.fileName = fileName;
return this;
}
public Builder withFileSize(Long fileSize) {
this.fileSize = fileSize;
return this;
}
}
private <T> void createRowContent(HSSFSheet sheet, List<Field> fields, HSSFWorkbook workbook, List<T> list,
int startNo, int endNo, int rowIndex) throws Exception {
String value = null;
int hwPicType = 0;
byte[] picByte = null;
int listIndex = 0;
for (int i = startNo; i < endNo; i++) {
HSSFRow row = sheet.createRow(i + 1);
T vo = list.get(listIndex);
listIndex++;
for (int j = 0; j < fields.size(); j++) {
Field field = fields.get(j);
field.setAccessible(true);
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
int col = j;
if (StringUtils.isNotBlank(attr.column())) {
col = ExcelUtil.getExcelCol(attr.column());
}
if (attr.isExport()) {
HSSFCell cell = row.createCell(col);
Class<?> classType = field.getType();
if (field.get(vo) != null) {
value = null;
if (classType.isAssignableFrom(Date.class)) {
value = DateUtils.formatDate((Date)field.get(vo), "yyyy-MM-dd HH:mm:ss");
}
if (classType.isAssignableFrom(Long.class) && attr.isDate()) {
value = DateUtils.formatDate(new Date(((Long)field.get(vo)).longValue()),
"yyyy-MM-dd HH:mm:ss");
}
if (attr.isPic()) {
try {
if (field.getType().equals(String.class)) {
picByte = ExcelUtil.getBytesByUrl((String)field.get(vo));
}
picByte = (byte[])field.get(vo);
} catch (Exception exception) {
}
hwPicType = 5;
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 1020, 250, (short)col, row.getRowNum(),
(short)col, row.getRowNum());
patriarch.createPicture(anchor, workbook.addPicture(picByte, hwPicType));
row.setHeight((short)1000);
} else {
cell.setCellValue((field.get(vo) == null) ? ""
: ((value == null) ? String.valueOf(field.get(vo)) : value));
}
}
}
}
}
}
public CloudwalkResult<Long> exportCount() throws ServiceException {
try {
return CloudwalkResult.success(Long.valueOf(this.EXPORT_MAX_RECORD));
} catch (Exception e) {
this.logger.error("获取最大导出记录失败", e);
throw new ServiceException(e);
}
}
protected abstract CloudwalkPageAble<R> queryPage(T paramT, CloudwalkPageInfo paramCloudwalkPageInfo,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
protected abstract CloudwalkResult<String> createLocalFile(T paramT, String paramString,
CloudwalkCallContext paramCloudwalkCallContext) throws ServiceException;
protected abstract String getDefaultFileName();
protected abstract String getDefaultFileTitleName();
}
@@ -0,0 +1,31 @@
package cn.cloudwalk.elevator.export;
public enum AcsFileStatusEnum {
FINISH(Integer.valueOf(0), "已完成"), PRODUCING(Integer.valueOf(1), "生成中"), DELETED(Integer.valueOf(2), "已删除"),
CANCELED(Integer.valueOf(3), "已取消"), EXPIRED(Integer.valueOf(4), "已过期"), FAIL(Integer.valueOf(5), "失败");
private Integer code;
private String message;
AcsFileStatusEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
public static AcsFileStatusEnum getEnumByCode(Integer code) {
for (AcsFileStatusEnum item : values()) {
if (code.equals(item.getCode())) {
return item;
}
}
return null;
}
public Integer getCode() {
return this.code;
}
public String getMessage() {
return this.message;
}
}
@@ -0,0 +1,24 @@
package cn.cloudwalk.elevator.export;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface ExcelAttribute {
String name();
String column() default "";
String[] combo() default {};
boolean isExport() default true;
boolean isMark() default false;
boolean isDate() default false;
boolean isPic() default false;
}
@@ -0,0 +1,9 @@
package cn.cloudwalk.elevator.export;
import cn.cloudwalk.cloud.exception.ServiceException;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public interface ExcelCallback {
void call(HSSFWorkbook paramHSSFWorkbook, HSSFSheet paramHSSFSheet) throws ServiceException;
}
@@ -0,0 +1,72 @@
package cn.cloudwalk.elevator.export.impl;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceResultDTO;
import cn.cloudwalk.elevator.device.param.AcsElevatorDeviceQueryParam;
import cn.cloudwalk.elevator.device.service.AcsElevatorDeviceService;
import cn.cloudwalk.elevator.export.AcsAbstractExportAsyncService;
import cn.cloudwalk.elevator.export.result.ElevatorDeviceRecordExcelResult;
import cn.cloudwalk.elevator.util.CollectionUtils;
import cn.cloudwalk.elevator.util.DateUtils;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class ElevatorDeviceExportService
extends AcsAbstractExportAsyncService<AcsElevatorDeviceQueryParam, ElevatorDeviceRecordExcelResult> {
@Resource
private AcsElevatorDeviceService elevatorDeviceService;
protected CloudwalkPageAble<ElevatorDeviceRecordExcelResult> queryPage(AcsElevatorDeviceQueryParam param,
CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
param.setCurrentPage(pageInfo.getCurrentPage());
param.setRowsOfPage(pageInfo.getPageSize());
CloudwalkResult<CloudwalkPageAble<AcsElevatorDeviceResultDTO>> result =
this.elevatorDeviceService.get(param, context);
if (result.isSuccess()) {
CloudwalkPageAble<AcsElevatorDeviceResultDTO> data =
(CloudwalkPageAble<AcsElevatorDeviceResultDTO>)result.getData();
if (CollectionUtils.isNotEmpty(data.getDatas())) {
List<ElevatorDeviceRecordExcelResult> targetList =
BeanCopyUtils.copy(data.getDatas(), ElevatorDeviceRecordExcelResult.class);
for (ElevatorDeviceRecordExcelResult item : targetList) {
if (Objects.equals(item.getStatus(), Integer.valueOf(1))) {
item.setDeviceOnlineStatus("禁用");
continue;
}
if (Objects.equals(item.getOnlineStatus(), Integer.valueOf(2))) {
item.setDeviceOnlineStatus("在线");
continue;
}
if (Objects.equals(item.getOnlineStatus(), Integer.valueOf(3))) {
item.setDeviceOnlineStatus("离线");
}
}
return new CloudwalkPageAble(targetList, pageInfo,
((CloudwalkPageAble)result.getData()).getTotalRows());
}
}
throw new ServiceException(result.getCode(), result.getMessage());
}
protected CloudwalkResult<String> createLocalFile(AcsElevatorDeviceQueryParam param, String fileName,
CloudwalkCallContext context) throws ServiceException {
return null;
}
protected String getDefaultFileName() {
return "派梯设备导出" + DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
}
protected String getDefaultFileTitleName() {
return "派梯设备";
}
}
@@ -0,0 +1,154 @@
package cn.cloudwalk.elevator.export.result;
import cn.cloudwalk.elevator.export.ExcelAttribute;
import java.io.Serializable;
import java.util.Objects;
public class ElevatorDeviceRecordExcelResult implements Serializable {
@ExcelAttribute(name = "设备名称", column = "A")
private String deviceName;
@ExcelAttribute(name = "设备编号", column = "B")
private String deviceCode;
@ExcelAttribute(name = "设备型号", column = "C")
private String deviceTypeName;
@ExcelAttribute(name = "安装区域", column = "D")
private String areaName;
@ExcelAttribute(name = "当前楼层", column = "E")
private String currentFloor;
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
@ExcelAttribute(name = "派梯楼层", column = "F")
private String elevatorFloorList;
@ExcelAttribute(name = "设备状态", column = "G")
private String deviceOnlineStatus;
@ExcelAttribute(name = "设备IP", column = "H")
private String ip;
@ExcelAttribute(name = "最后心跳", column = "I", isDate = true)
private Long lastHeartbeatTime;
private Integer status;
private Integer onlineStatus;
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public void setCurrentFloor(String currentFloor) {
this.currentFloor = currentFloor;
}
public void setElevatorFloorList(String elevatorFloorList) {
this.elevatorFloorList = elevatorFloorList;
}
public void setDeviceOnlineStatus(String deviceOnlineStatus) {
this.deviceOnlineStatus = deviceOnlineStatus;
}
public void setIp(String ip) {
this.ip = ip;
}
public void setLastHeartbeatTime(Long lastHeartbeatTime) {
this.lastHeartbeatTime = lastHeartbeatTime;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setOnlineStatus(Integer onlineStatus) {
this.onlineStatus = onlineStatus;
}
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ElevatorDeviceRecordExcelResult)) {
return false;
}
ElevatorDeviceRecordExcelResult other = (ElevatorDeviceRecordExcelResult)o;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(deviceName, other.deviceName) && Objects.equals(deviceCode, other.deviceCode)
&& Objects.equals(deviceTypeName, other.deviceTypeName) && Objects.equals(areaName, other.areaName)
&& Objects.equals(currentFloor, other.currentFloor)
&& Objects.equals(elevatorFloorList, other.elevatorFloorList)
&& Objects.equals(deviceOnlineStatus, other.deviceOnlineStatus) && Objects.equals(ip, other.ip)
&& Objects.equals(lastHeartbeatTime, other.lastHeartbeatTime) && Objects.equals(status, other.status)
&& Objects.equals(onlineStatus, other.onlineStatus);
}
protected boolean canEqual(Object other) {
return other instanceof ElevatorDeviceRecordExcelResult;
}
public int hashCode() {
return Objects.hash(deviceName, deviceCode, deviceTypeName, areaName, currentFloor, elevatorFloorList,
deviceOnlineStatus, ip, lastHeartbeatTime, status, onlineStatus);
}
public String toString() {
return "ElevatorDeviceRecordExcelResult(deviceName=" + getDeviceName() + ", deviceCode=" + getDeviceCode()
+ ", deviceTypeName=" + getDeviceTypeName() + ", areaName=" + getAreaName() + ", currentFloor="
+ getCurrentFloor() + ", elevatorFloorList=" + getElevatorFloorList() + ", deviceOnlineStatus="
+ getDeviceOnlineStatus() + ", ip=" + getIp() + ", lastHeartbeatTime=" + getLastHeartbeatTime()
+ ", status=" + getStatus() + ", onlineStatus=" + getOnlineStatus() + ")";
}
public String getDeviceName() {
return this.deviceName;
}
public String getDeviceCode() {
return this.deviceCode;
}
public String getDeviceTypeName() {
return this.deviceTypeName;
}
public String getAreaName() {
return this.areaName;
}
public String getCurrentFloor() {
return this.currentFloor;
}
public String getElevatorFloorList() {
return this.elevatorFloorList;
}
public String getDeviceOnlineStatus() {
return this.deviceOnlineStatus;
}
public String getIp() {
return this.ip;
}
public Long getLastHeartbeatTime() {
return this.lastHeartbeatTime;
}
public Integer getStatus() {
return this.status;
}
public Integer getOnlineStatus() {
return this.onlineStatus;
}
}
@@ -0,0 +1,478 @@
package cn.cloudwalk.elevator.export.utils;
import cn.cloudwalk.elevator.export.ExcelAttribute;
import cn.cloudwalk.elevator.export.ExcelCallback;
import cn.cloudwalk.elevator.util.DateUtils;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.DVConstraint;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExcelUtil {
public static final String FONT_CODE = "1";
private static final int BUF_SIZE = 8096;
private static Logger logger = LoggerFactory.getLogger(ExcelUtil.class);
private static String EXPORT_KEY = "isExport";
private static String ANNOTATION_FIELD = "memberValues";
public static <T> List<T> getExcelToList(String sheetName, Integer startNo, InputStream input, Class<T> clazz)
throws Exception {
List<T> list = new ArrayList<>();
try (Workbook book = WorkbookFactory.create(input)) {
Sheet sheet = null;
if (StringUtils.isNotBlank(sheetName)) {
sheet = book.getSheet(sheetName);
}
if (sheet == null) {
sheet = book.getSheetAt(0);
}
int rows = sheet.getLastRowNum();
int startLine = 1;
if (null != startNo && startNo.intValue() >= 0) {
startLine = startNo.intValue();
}
if (rows > 0) {
Field[] allFields = clazz.getDeclaredFields();
Map<String, Field> fieldsMap = getStringFieldMap(allFields);
Row firstRow = sheet.getRow(sheet.getFirstRowNum() + startLine - 1);
for (int i = sheet.getFirstRowNum() + startLine; i <= rows; i++) {
Row row = sheet.getRow(i);
if (row != null) {
Iterator<Cell> cells = row.cellIterator();
T entity = null;
boolean isNull = true;
while (cells.hasNext()) {
Cell cell = cells.next();
String fieldName = firstRow.getCell(cell.getColumnIndex()).getStringCellValue();
if (!fieldsMap.containsKey(fieldName)) {
continue;
}
cell.setCellType(CellType.STRING);
String c = cell.getStringCellValue();
if (StringUtils.isNotEmpty(c)) {
isNull = false;
}
entity = (entity == null) ? clazz.newInstance() : entity;
Field field = fieldsMap.get(fieldName);
Class<?> fieldType = field.getType();
if (fieldType == null) {
continue;
}
setValue(entity, c, field, fieldType);
}
if (entity != null && !isNull)
list.add(entity);
}
}
}
} catch (Exception e) {
throw new Exception("将excel表单数据源的数据导入到list异常!", e);
}
return list;
}
private static <T> void setValue(T entity, String c, Field field, Class<?> fieldType)
throws IllegalAccessException {
if (String.class == fieldType) {
field.set(entity, String.valueOf(c));
} else if (BigDecimal.class == fieldType) {
field.set(entity, BigDecimal.valueOf(Double.valueOf(c).doubleValue()));
} else if (int.class == fieldType || Integer.class == fieldType) {
field.set(entity, Integer.valueOf(Integer.parseInt(c)));
} else if (long.class == fieldType || Long.class == fieldType) {
field.set(entity, Long.valueOf(c));
} else if (float.class == fieldType || Float.class == fieldType) {
field.set(entity, Float.valueOf(c));
} else if (short.class == fieldType || Short.class == fieldType) {
field.set(entity, Short.valueOf(c));
} else if (double.class == fieldType || Double.class == fieldType) {
field.set(entity, Double.valueOf(c));
}
}
private static Map<String, Field> getStringFieldMap(Field[] allFields) {
Map<String, Field> fieldsMap = new HashMap<>(allFields.length);
for (Field field : allFields) {
if (field.isAnnotationPresent((Class)ExcelAttribute.class)) {
ExcelAttribute attribute = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (!StringUtils.isBlank(attribute.name())) {
field.setAccessible(true);
fieldsMap.put(attribute.name(), field);
}
}
}
return fieldsMap;
}
public static <T> boolean matchExcel(String sheetName, InputStream input, Class<T> clazz) throws Exception {
try {
HSSFWorkbook book = new HSSFWorkbook(input);
HSSFSheet sheet = null;
if (StringUtils.isNotBlank(sheetName)) {
sheet = book.getSheet(sheetName);
}
if (sheet == null) {
sheet = book.getSheetAt(0);
}
int rows = sheet.getLastRowNum();
if (rows > 0) {
Field[] allFields = clazz.getDeclaredFields();
Map<String, Field> fieldsMap = getStringFieldMap(allFields);
HSSFRow firstRow = sheet.getRow(sheet.getFirstRowNum());
Iterator<Cell> cells = firstRow.cellIterator();
while (cells.hasNext()) {
Cell cell = cells.next();
String fieldName = firstRow.getCell(cell.getColumnIndex()).getStringCellValue();
if (!fieldsMap.containsKey(fieldName)) {
return false;
}
}
} else {
return false;
}
} catch (Exception e) {
throw new Exception("将excel表单数据源的数据导入到list异常!", e);
}
return true;
}
public static <T> boolean getListToExcel(List<T> list, List<T> listHead, String sheetName, OutputStream output,
Class<T> clazz) throws Exception {
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<>();
for (Field field : allFields) {
if (field.isAnnotationPresent((Class)ExcelAttribute.class)) {
fields.add(field);
}
}
HSSFSheet sheet = workbook.createSheet();
workbook.setSheetName(0, sheetName);
createRowContent(sheet, fields, workbook, listHead, 0, listHead.size(), 0);
createRowHeard(sheet, fields, workbook, 1);
createRowContent(sheet, fields, workbook, list, 0, list.size(), 2);
output.flush();
workbook.write(output);
output.close();
return Boolean.TRUE.booleanValue();
} catch (Exception e) {
throw new Exception("将list数据源的数据导入到excel表单异常!", e);
}
}
public static <T> boolean getListToExcel(List<T> list, String sheetName, OutputStream output, Class<T> clazz)
throws Exception {
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
int sheetSize = 65536;
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<>();
for (Field field : allFields) {
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (attr != null && attr.isExport()) {
fields.add(field);
}
}
int listSize = 0;
if (list != null && list.size() > 0) {
listSize = list.size();
}
int sheetNo = listSize / sheetSize;
for (int index = 0; index <= sheetNo; index++) {
HSSFSheet sheet = workbook.createSheet();
workbook.setSheetName(index, sheetName + index);
createRowHeard(sheet, fields, workbook, 2);
int startNo = index * sheetSize;
int endNo = Math.min(startNo + sheetSize, listSize);
createRowContent(sheet, fields, workbook, list, startNo, endNo, 3);
}
output.flush();
workbook.write(output);
output.close();
return Boolean.TRUE.booleanValue();
} catch (Exception e) {
throw new Exception("将list数据源的数据导入到excel表单异常!", e);
}
}
public static <T> boolean getListToExcel(List<T> list, String sheetName, OutputStream output, Class<T> clazz,
Integer startRow, ExcelCallback callback) throws Exception {
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
int sheetSize = 65536;
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<>();
for (Field field : allFields) {
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (attr != null && attr.isExport()) {
fields.add(field);
}
}
int listSize = 0;
if (list != null && list.size() > 0) {
listSize = list.size();
}
int sheetNo = listSize / sheetSize;
for (int index = 0; index <= sheetNo; index++) {
HSSFSheet sheet = workbook.createSheet();
workbook.setSheetName(index, sheetName + index);
createRowHeard(sheet, fields, workbook, startRow.intValue());
int startNo = index * sheetSize;
int endNo = Math.min(startNo + sheetSize, listSize);
createRowContent(sheet, fields, workbook, list, startNo, endNo, startRow.intValue() + 1);
if (null != callback) {
callback.call(workbook, sheet);
}
}
output.flush();
workbook.write(output);
output.close();
return Boolean.TRUE.booleanValue();
} catch (Exception e) {
throw new Exception("将list数据源的数据导入到excel表单异常!", e);
}
}
private static <T> void createRowContent(HSSFSheet sheet, List<Field> fields, HSSFWorkbook workbook, List<T> list,
int startNo, int endNo, int rowIndex) throws Exception {
String value = null;
int hwPicType = 0;
byte[] picByte = null;
for (int i = startNo; i < endNo; i++) {
HSSFRow row = sheet.createRow(i - startNo + rowIndex);
T vo = list.get(i);
for (int j = 0; j < fields.size(); j++) {
Field field = fields.get(j);
field.setAccessible(true);
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
int col = j;
if (StringUtils.isNotBlank(attr.column())) {
col = getExcelCol(attr.column());
}
if (attr.isExport()) {
HSSFCell cell = row.createCell(col);
Class<?> classType = field.getType();
if (field.get(vo) != null) {
value = null;
if (classType.isAssignableFrom(Date.class)) {
value = DateUtils.formatDate((Date)field.get(vo), "yyyy-MM-dd HH:mm:ss");
}
if (classType.isAssignableFrom(Long.class) && attr.isDate()) {
value = DateUtils.formatDate(new Date(((Long)field.get(vo)).longValue()),
"yyyy-MM-dd HH:mm:ss");
}
if (attr.isPic()) {
try {
if (field.getType().equals(String.class)) {
picByte = getBytesByUrl((String)field.get(vo));
}
picByte = (byte[])field.get(vo);
} catch (Exception exception) {
}
hwPicType = 5;
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 1020, 250, (short)col, row.getRowNum(),
(short)col, row.getRowNum());
patriarch.createPicture(anchor, workbook.addPicture(picByte, hwPicType));
row.setHeight((short)1000);
} else {
cell.setCellValue((field.get(vo) == null) ? ""
: ((value == null) ? String.valueOf(field.get(vo)) : value));
}
}
}
}
}
}
public static void createRowHeard(HSSFSheet sheet, List<Field> fields, HSSFWorkbook workbook, int index) {
HSSFRow row = sheet.createRow(index);
for (int i = 0; i < fields.size(); i++) {
int col = i;
Field field = fields.get(i);
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (StringUtils.isNotBlank(attr.column())) {
col = getExcelCol(attr.column());
}
HSSFCell cell = row.createCell(col);
HSSFCellStyle cellStyle = createCellStyle(workbook, attr.isMark() ? "2" : "1");
cell.setCellStyle(cellStyle);
sheet.setColumnWidth(i,
(int)((((attr.name().getBytes()).length <= 4) ? 6 : (attr.name().getBytes()).length) * 1.5D * 256.0D));
cell.setCellType(CellType.STRING);
cell.setCellValue(attr.name());
}
}
private static HSSFCellStyle createCellStyle(HSSFWorkbook workbook, String type) {
HSSFFont font = workbook.createFont();
HSSFCellStyle cellStyle = workbook.createCellStyle();
font.setFontName("Arail narrow");
font.setBold(true);
if ("1".equals(type)) {
font.setColor(IndexedColors.RED.getIndex());
cellStyle.setFont(font);
} else {
font.setColor((short)10);
cellStyle.setFont(font);
}
return cellStyle;
}
public static int getExcelCol(String col) {
col = col.toUpperCase();
int count = -1;
char[] cs = col.toCharArray();
for (int i = 0; i < cs.length; i++) {
count = (int)(count + (cs[i] - 64) * Math.pow(26.0D, cs.length - 1.0D - i));
}
return count;
}
public static HSSFSheet setHSSFPrompt(HSSFSheet sheet, String promptTitle, String promptContent, int firstRow,
int endRow, int firstCol, int endCol) {
DVConstraint constraint = DVConstraint.createCustomFormulaConstraint("DD1");
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
HSSFDataValidation dataValidationView = new HSSFDataValidation(regions, (DataValidationConstraint)constraint);
dataValidationView.createPromptBox(promptTitle, promptContent);
sheet.addValidationData((DataValidation)dataValidationView);
return sheet;
}
public static HSSFSheet setHSSFValidation(HSSFSheet sheet, String[] textlist, int firstRow, int endRow,
int firstCol, int endCol) {
DVConstraint constraint = DVConstraint.createExplicitListConstraint(textlist);
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
HSSFDataValidation dataValidationList = new HSSFDataValidation(regions, (DataValidationConstraint)constraint);
sheet.addValidationData((DataValidation)dataValidationList);
return sheet;
}
public static byte[] getBytesByUrl(String imgUrl) throws Exception {
if (StringUtils.isEmpty(imgUrl)) {
return null;
}
BufferedInputStream bis = null;
ByteArrayOutputStream bos = null;
try {
URL url = new URL(imgUrl);
HttpURLConnection http = (HttpURLConnection)url.openConnection();
http.setConnectTimeout(3000);
http.connect();
bis = new BufferedInputStream(http.getInputStream());
bos = new ByteArrayOutputStream();
byte[] buf = new byte[8096];
int size;
while ((size = bis.read(buf)) != -1) {
bos.write(buf, 0, size);
}
http.disconnect();
return bos.toByteArray();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
logger.error("流关闭失败,原因:" + e.getMessage(), e);
}
}
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
logger.error("流关闭失败,原因:" + e.getMessage(), e);
}
}
}
}
public static void setExcelAttribute(ExcelAttribute excelAttribute, String key, Object obj, boolean isExport) {
if (excelAttribute == null) {
return;
}
InvocationHandler invocationHandler = Proxy.getInvocationHandler(excelAttribute);
Field value = null;
try {
value = invocationHandler.getClass().getDeclaredField(ANNOTATION_FIELD);
} catch (Exception e) {
logger.warn("反射获取ExcelAttribute注解的成员字段异常", e);
}
if (value == null) {
return;
}
value.setAccessible(true);
Map<String, Object> memberValues = null;
try {
memberValues = (Map<String, Object>)value.get(invocationHandler);
} catch (Exception e) {
logger.warn("反射获取ExcelAttribute注解的成员值异常", e);
}
if (memberValues == null) {
return;
}
if (obj != null) {
memberValues.put(key, obj);
}
if (!isExport) {
memberValues.put(EXPORT_KEY, Boolean.valueOf(isExport));
}
}
public static <T> boolean appendListToExcel(InputStream inputStream, List<T> list, int sheetIndex,
OutputStream output, Class<T> clazz, Integer startRow) throws Exception {
try (HSSFWorkbook workbook = new HSSFWorkbook(inputStream)) {
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<>();
for (Field field : allFields) {
ExcelAttribute attr = field.<ExcelAttribute>getAnnotation(ExcelAttribute.class);
if (attr != null && attr.isExport()) {
fields.add(field);
}
}
HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
createRowContent(sheet, fields, workbook, list, 0, list.size(), startRow.intValue());
output.flush();
workbook.write(IOUtils.buffer(output));
return Boolean.TRUE.booleanValue();
} catch (IOException e) {
throw new Exception("将list数据源的数据导入到excel表单异常!", e);
} finally {
output.close();
}
}
}
@@ -0,0 +1,37 @@
package cn.cloudwalk.elevator.export.utils;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FolderUtils {
private static Logger logger = LoggerFactory.getLogger(FolderUtils.class);
public static void deleteFolder(String path) {
File file = new File(path);
if (file.exists()) {
File[] files = file.listFiles();
int len = files.length;
for (int i = 0; i < len; i++) {
if (files[i].isDirectory()) {
deleteFolder(files[i].getPath());
} else {
doDelete(files[i]);
}
}
doDelete(file);
}
}
public static void deleteFile(String path) {
File file = new File(path);
if (file.exists()) {
doDelete(file);
}
}
public static void doDelete(File file) {
if (file.exists() && !file.delete())
logger.error("文件删除失败");
}
}
@@ -0,0 +1,25 @@
package cn.cloudwalk.elevator.mqtt.client;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.mqtt.fallback.MqttFeignClientFallback;
import cn.cloudwalk.elevator.mqtt.param.MqttSendMessageParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* 设备第三方 MQTT 发布入口:向指定 topic 推送 JSON 载荷(由 {@code /mqtt/publish} 落到底层 broker)。
*/
@FeignClient(name = "${feign.mqtt.name:cloudwalk-device-thirdparty}", path = "/mqtt",
fallback = MqttFeignClientFallback.class)
public interface MqttFeignClient {
/**
* 发布一条 MQTT 消息。
*
* @param paramMqttSendMessageParam topic 与 body(通常为业务侧 JSON 字符串)
* @return 是否投递成功,由下游服务定义成功语义
*/
@RequestMapping(value = {"/publish"}, method = {RequestMethod.POST})
CloudwalkResult<Boolean> publish(MqttSendMessageParam paramMqttSendMessageParam) throws ServiceException;
}
@@ -0,0 +1,23 @@
package cn.cloudwalk.elevator.mqtt.fallback;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.elevator.mqtt.client.MqttFeignClient;
import cn.cloudwalk.elevator.mqtt.param.MqttSendMessageParam;
import org.springframework.stereotype.Component;
/**
* {@link MqttFeignClient} 熔断/降级:调用失败时抛出运行时异常,促使上层按失败处理(不伪造成功投递)。
*/
@Component
public class MqttFeignClientFallback implements MqttFeignClient {
/**
* {@inheritDoc}
*
* @implSpec 不返回降级业务结果,直接抛错以暴露下游不可用
*/
@Override
public CloudwalkResult<Boolean> publish(MqttSendMessageParam param) throws ServiceException {
throw new RuntimeException("mqtt发送数据失败");
}
}
@@ -0,0 +1,87 @@
package cn.cloudwalk.elevator.mqtt.impl;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.common.AbstractAcsDeviceService;
import cn.cloudwalk.elevator.mqtt.client.MqttFeignClient;
import cn.cloudwalk.elevator.mqtt.param.AcsElevatorRecordMqttParam;
import cn.cloudwalk.elevator.mqtt.param.MqttSendMessageParam;
import cn.cloudwalk.elevator.mqtt.service.MqttService;
import cn.cloudwalk.elevator.record.dao.AcsRecogRecordDao;
import cn.cloudwalk.elevator.record.dto.AcsElevatorRecordAddDTO;
import cn.cloudwalk.elevator.record.dto.AcsRecogRecordPageDTO;
import cn.cloudwalk.elevator.record.dto.AcsRecogRecordResultDTO;
import cn.cloudwalk.elevator.util.DateUtils;
import com.alibaba.fastjson.JSON;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* {@link MqttService} 实现:先短暂休眠以便识别明细入库,再按通行流水查人名、访客标签,向 {@code businessId + ELEVATOR_RECORD_SUFFIX} topic 推送 JSON。
*/
@Component
public class MqttServiceImpl extends AbstractAcsDeviceService implements MqttService {
/** 人员标签中表示「访客」的编码,与识别记录里 {@code personLabelIds} 包含关系判断一致。 */
private static final String VISITOR_LABEL_CODE = "1";
/** 与 {@link #VISITOR_LABEL_CODE} 对应的展示名,当前实现未参与逻辑,仅作文档对齐。 */
private static final String VISITOR_LABEL_NAME = "访客";
/** MQTT topic 后缀,与 {@code businessId} 拼接为完整 topic。 */
private static final String ELEVATOR_RECORD_SUFFIX = "_elevator_record";
@Qualifier("cn.cloudwalk.elevator.mqtt.client.MqttFeignClient")
@Resource
private MqttFeignClient mqttFeignClient;
@Resource
private AcsRecogRecordDao acsRecogRecordDao;
/**
* {@inheritDoc}
* <p>
* 异常在方法内记录日志后吞掉(除中断转 {@link ServiceException}),避免异步线程因下游偶发错误反复未捕获终止。
*/
@Override
@Async
public void sendInfoToOne(AcsElevatorRecordAddDTO addDTO) throws ServiceException {
this.logger.info("防止人员识别记录未入库即开始推送消息,休眠10秒");
try {
TimeUnit.SECONDS.sleep(10L);
} catch (InterruptedException e) {
this.logger.error("休眠失败,失败原因:{}", e.getMessage());
throw new ServiceException(e.getMessage());
}
try {
AcsRecogRecordPageDTO recordPageDTO = new AcsRecogRecordPageDTO();
recordPageDTO.setLogId(addDTO.getRecognitionFaceId());
recordPageDTO.setStartTime(DateUtils.todayStart());
recordPageDTO.setEndTime(DateUtils.todayEnd());
List<AcsRecogRecordResultDTO> recogRecordResultDTOS = this.acsRecogRecordDao.page(recordPageDTO);
if (!CollectionUtils.isEmpty(recogRecordResultDTOS)) {
AcsRecogRecordResultDTO acsRecogRecordResultDTO = recogRecordResultDTOS.get(0);
AcsElevatorRecordMqttParam acsElevatorRecordMqttParam =
(AcsElevatorRecordMqttParam)BeanCopyUtils.copyProperties(addDTO, AcsElevatorRecordMqttParam.class);
acsElevatorRecordMqttParam.setOpenDoorId(addDTO.getId());
acsElevatorRecordMqttParam.setPersonName(acsRecogRecordResultDTO.getPersonName());
if (StringUtils.isNotBlank(acsRecogRecordResultDTO.getPersonLabelIds())
&& acsRecogRecordResultDTO.getPersonLabelIds().contains(VISITOR_LABEL_CODE)) {
acsElevatorRecordMqttParam.setIsVisitor(Boolean.TRUE);
}
CloudwalkResult<Boolean> publish = this.mqttFeignClient
.publish(MqttSendMessageParam.builder().topic(addDTO.getBusinessId() + ELEVATOR_RECORD_SUFFIX)
.data(JSON.toJSONString(acsElevatorRecordMqttParam)).build());
if (publish.isSuccess()) {
this.logger.info("推送数据成功!!!,数据,{}", JSON.toJSONString(acsElevatorRecordMqttParam));
} else {
this.logger.debug("推送数据失败!!!");
}
}
} catch (Exception e) {
this.logger.error("发送消息失败 param:{} {}", addDTO, e.getMessage());
}
}
}
@@ -0,0 +1,6 @@
/**
* 电梯识别记录 MQTT 推送:经 {@code cloudwalk-device-thirdparty} 等下游将消息发布到业务 topic,供大屏/第三方订阅。
* <p>
* 与 {@code record} 域协作:在人员识别记录落库后异步组装载荷并调用发布接口。
*/
package cn.cloudwalk.elevator.mqtt;
@@ -0,0 +1,82 @@
package cn.cloudwalk.elevator.mqtt.param;
/**
* 推送到 MQTT 的电梯记录载荷:在 {@link cn.cloudwalk.elevator.record.dto.AcsElevatorRecordAddDTO} 基础上补全人名、开门流水 id、是否访客等,序列化为
* {@code data} 字段内容。
*/
public class AcsElevatorRecordMqttParam {
private String openDoorId;
private String openDoorType;
private String srcFloor;
public void setOpenDoorId(String openDoorId) {
this.openDoorId = openDoorId;
}
private String destFloor;
private String dispatchElevatorNo;
private Long dispatchElevatorTime;
private String personName;
public void setOpenDoorType(String openDoorType) {
this.openDoorType = openDoorType;
}
public void setSrcFloor(String srcFloor) {
this.srcFloor = srcFloor;
}
public void setDestFloor(String destFloor) {
this.destFloor = destFloor;
}
public void setDispatchElevatorNo(String dispatchElevatorNo) {
this.dispatchElevatorNo = dispatchElevatorNo;
}
public void setDispatchElevatorTime(Long dispatchElevatorTime) {
this.dispatchElevatorTime = dispatchElevatorTime;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public void setIsVisitor(Boolean isVisitor) {
this.isVisitor = isVisitor;
}
public String getOpenDoorId() {
return this.openDoorId;
}
public String getOpenDoorType() {
return this.openDoorType;
}
public String getSrcFloor() {
return this.srcFloor;
}
public String getDestFloor() {
return this.destFloor;
}
public String getDispatchElevatorNo() {
return this.dispatchElevatorNo;
}
public Long getDispatchElevatorTime() {
return this.dispatchElevatorTime;
}
public String getPersonName() {
return this.personName;
}
private Boolean isVisitor = Boolean.valueOf(false);
public Boolean getIsVisitor() {
return this.isVisitor;
}
}
@@ -0,0 +1,61 @@
package cn.cloudwalk.elevator.mqtt.param;
import java.beans.ConstructorProperties;
/**
* Feign 发布请求体:MQTT topic 与一条 JSON 字符串形式的业务数据。
*/
public class MqttSendMessageParam {
private String topic;
private String data;
@ConstructorProperties({"topic", "data"})
MqttSendMessageParam(String topic, String data) {
this.topic = topic;
this.data = data;
}
public static MqttSendMessageParamBuilder builder() {
return new MqttSendMessageParamBuilder();
}
public static class MqttSendMessageParamBuilder {
private String topic;
public MqttSendMessageParamBuilder topic(String topic) {
this.topic = topic;
return this;
}
private String data;
public MqttSendMessageParamBuilder data(String data) {
this.data = data;
return this;
}
public MqttSendMessageParam build() {
return new MqttSendMessageParam(this.topic, this.data);
}
public String toString() {
return "MqttSendMessageParam.MqttSendMessageParamBuilder(topic=" + this.topic + ", data=" + this.data + ")";
}
}
public void setTopic(String topic) {
this.topic = topic;
}
public void setData(String data) {
this.data = data;
}
public String getTopic() {
return this.topic;
}
public String getData() {
return this.data;
}
}
@@ -0,0 +1,19 @@
package cn.cloudwalk.elevator.mqtt.service;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.elevator.record.dto.AcsElevatorRecordAddDTO;
/**
* 将单条电梯通行/识别结果异步推送到 MQTT(供订阅方如大屏展示),与落库存在时序上的缓冲(实现内会短暂休眠后查库补全人名等)。
*/
public interface MqttService {
/**
* 按一条待写入或已关联的识别记录,组装业务 topic 与 JSON 后发起 {@link cn.cloudwalk.elevator.mqtt.client.MqttFeignClient#publish}。
* <p>
* 异步方法:调用方不应依赖其完成时刻做强一致逻辑。
*
* @param paramAcsElevatorRecordAddDTO 电梯识别记录主数据(需含 businessId、recognition 关联键等,供拼 topic 与反查人员)
* @throws ServiceException 睡眠被中断等不可恢复情况
*/
void sendInfoToOne(AcsElevatorRecordAddDTO paramAcsElevatorRecordAddDTO) throws ServiceException;
}
@@ -0,0 +1,7 @@
/**
* 电梯应用业务编排层({@code cw-elevator-application-service}):领域服务接口与实现、远程调用、异步与任务推进。
* <p>
* 与 {@code cw-elevator-application-data} 的持久化、{@code cw-elevator-application-web} 的 HTTP 入口分工协作; 本模块内可依赖对外 Feign 契约(如
* {@code intelligent-cwoscomponent-interface}),但不应向上依赖 Web 层。
*/
package cn.cloudwalk.elevator;
@@ -0,0 +1,63 @@
package cn.cloudwalk.elevator.passrule.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonData;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStorePersonResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.common.AbstractCloudwalkService;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
public class AbstractAcsPassService extends AbstractCloudwalkService {
@Resource
private ImageStoreService imageStoreService;
protected ImageStoreDetailResult getImageStoreDetail(String imageStoreId, CloudwalkCallContext context)
throws ServiceException {
ImageStoreQueryParam param = new ImageStoreQueryParam();
param.setId(imageStoreId);
param.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<ImageStoreDetailResult> imageStoreDetail = this.imageStoreService.detail(param, context);
if (!imageStoreDetail.isSuccess()) {
this.logger.error("远程调用查询图库详情失败,原因:" + imageStoreDetail.getMessage());
throw new ServiceException("远程调用查询图库详情失败");
}
return (ImageStoreDetailResult)imageStoreDetail.getData();
}
protected ImageStoreEditParam getEditParamByImageStore(ImageStoreDetailResult imageStoreDetail) {
ImageStoreEditParam param = new ImageStoreEditParam();
BeanCopyUtils.copyProperties(imageStoreDetail, param);
param.setIncludeOrganizations((List)imageStoreDetail.getIncludeOrganizations().stream()
.map(OrganizationResult::getId).collect(Collectors.toList()));
param.setIncludeLabels(
(List)imageStoreDetail.getIncludeLabels().stream().map(LabelResult::getId).collect(Collectors.toList()));
param.setIncludePersons(getImageStorePersonData(imageStoreDetail.getIncludePersons()));
param.setExcludeLabels(
(List)imageStoreDetail.getExcludeLabels().stream().map(LabelResult::getId).collect(Collectors.toList()));
param.setExcludePersons((List)imageStoreDetail.getExcludePersons().stream().map(ImgStorePersonResult::getId)
.collect(Collectors.toList()));
return param;
}
private List<ImageStorePersonData> getImageStorePersonData(List<ImgStorePersonResult> imgStorePersonResults) {
List<ImageStorePersonData> personDataList = new ArrayList<>();
for (ImgStorePersonResult personResult : imgStorePersonResults) {
ImageStorePersonData personData = new ImageStorePersonData();
BeanCopyUtils.copyProperties(personResult, personData);
personData.setObjectId(personResult.getId());
personDataList.add(personData);
}
return personDataList;
}
}
@@ -0,0 +1,576 @@
package cn.cloudwalk.elevator.passrule.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreAddParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStorePersonService;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
import cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService;
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.DataAccessException;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.common.service.AcsApplicationService;
import cn.cloudwalk.elevator.config.FeignThreadLocalUtil;
import cn.cloudwalk.elevator.device.dao.AcsElevatorDeviceDao;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceListDto;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceResultDTO;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppBindParam;
import cn.cloudwalk.elevator.device.setting.param.DeviceImageStoreAppUnbindParam;
import cn.cloudwalk.elevator.device.setting.service.AcsDeviceImageStoreAppBindService;
import cn.cloudwalk.elevator.em.AcsPassTypeEnum;
import cn.cloudwalk.elevator.passrule.dao.AcsPassRuleDao;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleAddDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleDeleteDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleEditDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageResultDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleIsDefaultDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleQueryDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleResultDto;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleDeleteParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleEditParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleFloorParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleImageParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleIsDefaultParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleNewParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleQueryParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassTimeCycleParam;
import cn.cloudwalk.elevator.passrule.result.AcsPassRuleDetailResult;
import cn.cloudwalk.elevator.passrule.result.AcsPassRuleFloorResult;
import cn.cloudwalk.elevator.passrule.result.AcsPassRuleResult;
import cn.cloudwalk.elevator.passrule.service.AcsPassRuleService;
import cn.cloudwalk.elevator.person.param.AcsPersonQueryParam;
import cn.cloudwalk.elevator.person.result.AcsPersonResult;
import cn.cloudwalk.elevator.person.service.AcsPersonService;
import cn.cloudwalk.elevator.util.CollectionUtils;
import cn.cloudwalk.elevator.zone.param.ZoneNextTreeParam;
import cn.cloudwalk.elevator.zone.result.ZoneTreeResult;
import cn.cloudwalk.elevator.zone.service.ZoneService;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
@Service
public class AcsPassRuleServiceImpl extends AbstractAcsPassService implements AcsPassRuleService {
/** 约定 §3.3 / §3.4:与 {@code ninca.elevator.remote-io.pool} 默认 core 对齐 */
private static final int REMOTE_IO_PARALLEL = 6;
@Resource
private ImageStoreService imageStoreService;
@Resource
private ImageStorePersonService imageStorePersonService;
@Resource
private PersonService personService;
@Resource
private ZoneService zoneService;
@Autowired
private AcsApplicationService acsApplicationService;
@Autowired
private AcsPersonService acsPersonService;
@Resource
private AcsPassRuleDao acsPassRuleDao;
@Resource
private AcsDeviceImageStoreAppBindService acsDeviceImageStoreAppBindService;
@Resource
private AcsElevatorDeviceDao acsElevatorDeviceDao;
@Autowired
@Qualifier("elevatorRemoteBoundedExecutor")
private ThreadPoolTaskExecutor elevatorRemoteBoundedExecutor;
public CloudwalkResult<List<AcsPassRuleFloorResult>> listFloor(AcsPassRuleFloorParam param,
CloudwalkCallContext context) throws ServiceException {
ZoneNextTreeParam treeParam = new ZoneNextTreeParam();
treeParam.setParentId(param.getZoneId());
CloudwalkResult<List<ZoneTreeResult>> zoneTree = this.zoneService.tree(treeParam, context);
if (!zoneTree.isSuccess()) {
this.logger.info("远程调用查询区域树状图失败,原因:" + zoneTree.getMessage());
throw new ServiceException(zoneTree.getCode(), zoneTree.getMessage());
}
try {
List<AcsPassRuleFloorResult> passRuleResults = new ArrayList<>();
if (!CollectionUtils.isEmpty((Collection)zoneTree.getData())) {
for (ZoneTreeResult zoneTreeResult : zoneTree.getData()) {
getZoneTypeIsThree(zoneTreeResult, passRuleResults);
}
} else {
return CloudwalkResult.success(passRuleResults);
}
for (AcsPassRuleFloorResult passRuleResult : passRuleResults) {
AcsElevatorDeviceListDto dto = new AcsElevatorDeviceListDto();
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setCurrentFloorId(passRuleResult.getId());
List<AcsElevatorDeviceResultDTO> deviceList = this.acsElevatorDeviceDao.listByZoneId(dto);
passRuleResult.setDeviceNumber(Integer.valueOf(deviceList.size()));
}
int floorCount = passRuleResults.size();
long[] personTotals = new long[floorCount];
for (int i = 0; i < floorCount;) {
int end = Math.min(i + REMOTE_IO_PARALLEL, floorCount);
List<Callable<Void>> batch = new ArrayList<>();
for (int j = i; j < end; j++) {
final int idx = j;
final String zoneId = passRuleResults.get(j).getId();
batch.add(() -> {
personTotals[idx] = pagePersonTotalRowsForZone(zoneId, context);
return null;
});
}
List<Future<Void>> floorFutures;
try {
floorFutures = this.elevatorRemoteBoundedExecutor.getThreadPoolExecutor().invokeAll(batch);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260520", getMessage("76260520"));
}
for (Future<Void> fu : floorFutures) {
try {
fu.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260520", getMessage("76260520"));
} catch (ExecutionException e) {
Throwable c = e.getCause();
if (c instanceof ServiceException) {
throw (ServiceException)c;
}
throw new ServiceException("76260520", getMessage("76260520"));
}
}
i = end;
}
for (int k = 0; k < floorCount; k++) {
passRuleResults.get(k).setPersonNumber(Long.valueOf(personTotals[k]));
}
return CloudwalkResult.success(passRuleResults);
} catch (DataAccessException e) {
this.logger.error("查询所有楼层信息失败");
throw new ServiceException("76260520", getMessage("76260520"));
}
}
public CloudwalkResult<String> getIsDefaultByZoneId(AcsPassRuleIsDefaultParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsPassRuleIsDefaultDto dto = new AcsPassRuleIsDefaultDto();
dto.setZoneId(param.getZoneId());
dto.setBusinessId(context.getCompany().getCompanyId());
return CloudwalkResult.success(this.acsPassRuleDao.getIsDefaultByZoneId(dto));
} catch (DataAccessException e) {
this.logger.error("根据楼层id获取默认图库id失败");
throw new ServiceException("76260524", getMessage("76260524"));
}
}
@CloudwalkParamsValidate(argsIndexs = {0, 1})
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
public CloudwalkResult<String> add(AcsPassRuleNewParam param, CloudwalkCallContext context)
throws ServiceException {
String imageStoreId = addImageStore(param, context);
AcsPassRuleAddDto dto = new AcsPassRuleAddDto();
dto.setId(genUUID());
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setName(param.getRuleName());
dto.setImageStoreId(imageStoreId);
dto.setZoneId(param.getZoneId());
dto.setZoneName(param.getZoneName());
dto.setBeginDate(param.getStartTime());
dto.setEndDate(param.getEndTime());
dto.setIsDefault(param.getIsDefault());
try {
this.acsPassRuleDao.insert(dto);
return CloudwalkResult.success(imageStoreId);
} catch (DataAccessException e) {
this.logger.error("添加通行规则失败");
throw new ServiceException("76260505", getMessage("76260505"));
}
}
private String addImageStore(AcsPassRuleNewParam param, CloudwalkCallContext context) throws ServiceException {
ImageStoreAddParam imageStoreAddParam = new ImageStoreAddParam();
String applicationId = this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
BeanCopyUtils.copyProperties(param, imageStoreAddParam);
imageStoreAddParam.setExpiryBeginDate(param.getStartTime());
imageStoreAddParam.setExpiryEndDate(param.getEndTime());
imageStoreAddParam.setName(param.getZoneName() + "-" + param.getRuleName());
imageStoreAddParam.setType(Short.valueOf((short)1));
imageStoreAddParam.setSourceApplicationId(applicationId);
imageStoreAddParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<String> imageStoreId = this.imageStoreService.add(imageStoreAddParam, context);
if (!imageStoreId.isSuccess()) {
this.logger.info("远程调用新增图库失败,原因:" + imageStoreId.getMessage());
throw new ServiceException(imageStoreId.getCode(), imageStoreId.getMessage());
}
AcsElevatorDeviceListDto dto = new AcsElevatorDeviceListDto();
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setCurrentFloorId(param.getZoneId());
List<AcsElevatorDeviceResultDTO> deviceList = null;
try {
deviceList = this.acsElevatorDeviceDao.listByZoneId(dto);
} catch (DataAccessException e) {
this.logger.error("根据楼层id获取设备信息失败,原因是:{}", e.getMessage());
}
DeviceImageStoreAppBindParam appBindParam = new DeviceImageStoreAppBindParam();
appBindParam.setImageStoreId((String)imageStoreId.getData());
appBindParam.setApplicationId(applicationId);
this.acsDeviceImageStoreAppBindService.bindAppImageStoreDevice(appBindParam, context);
if (!CollectionUtils.isEmpty(deviceList)) {
final String newImageStoreId = (String)imageStoreId.getData();
for (int i = 0; i < deviceList.size();) {
int end = Math.min(i + REMOTE_IO_PARALLEL, deviceList.size());
List<Callable<Void>> bindBatch = new ArrayList<>();
for (int j = i; j < end; j++) {
final AcsElevatorDeviceResultDTO device = deviceList.get(j);
bindBatch.add(() -> {
FeignThreadLocalUtil.callWithContext(context, () -> {
DeviceImageStoreAppBindParam bindParam = new DeviceImageStoreAppBindParam();
bindParam.setImageStoreId(newImageStoreId);
bindParam.setDeviceId(device.getDeviceId());
bindParam.setApplicationId(applicationId);
this.acsDeviceImageStoreAppBindService.bindDeviceAndImageStore(bindParam, context);
return null;
});
return null;
});
}
List<Future<Void>> bindFutures;
try {
bindFutures = this.elevatorRemoteBoundedExecutor.getThreadPoolExecutor().invokeAll(bindBatch);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260505", getMessage("76260505"));
}
for (Future<Void> f : bindFutures) {
try {
f.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServiceException("76260505", getMessage("76260505"));
} catch (ExecutionException e) {
Throwable c = e.getCause();
if (c instanceof ServiceException) {
ServiceException se = (ServiceException)c;
this.logger.error("图库关联失败,图库id={},原因:{}", newImageStoreId, se.getMessage());
rollbackImageStoreAfterBindFailure(newImageStoreId, context);
throw new ServiceException(se.getCode(), se.getMessage());
}
this.logger.error("图库关联失败,图库id={},原因:{}", newImageStoreId, e.getMessage());
rollbackImageStoreAfterBindFailure(newImageStoreId, context);
throw new ServiceException("76260505", getMessage("76260505"));
}
}
i = end;
}
}
return (String)imageStoreId.getData();
}
@CloudwalkParamsValidate(argsIndexs = {0, 1})
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
public CloudwalkResult<Boolean> update(AcsPassRuleEditParam param, CloudwalkCallContext context)
throws ServiceException {
checkDefaultRule(Collections.singletonList(param.getId()), context);
AcsPassRuleEditDto dto = new AcsPassRuleEditDto();
BeanCopyUtils.copyProperties(param, context, dto);
dto.setValidDateCron(null);
dto.setValidDateJson(null);
dto.setBeginDate(param.getStartTime());
dto.setEndDate(param.getEndTime());
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setName(param.getRuleName());
try {
this.acsPassRuleDao.update(dto);
List<AcsPassRuleResultDto> ruleList = getRuleByIds(Collections.singletonList(dto.getId()), context);
updateImageStore(param, ruleList.get(0), context);
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (DataAccessException e) {
this.logger.error("编辑通行规则编辑失败");
throw new ServiceException("76260506", getMessage("76260506"));
}
}
private List<AcsPassRuleResultDto> checkDefaultRule(List<String> ruleIds, CloudwalkCallContext context)
throws ServiceException {
List<AcsPassRuleResultDto> resultDtoList = getRuleByIds(ruleIds, context);
for (AcsPassRuleResultDto resultDto : resultDtoList) {
if (!ObjectUtils.isEmpty(resultDto.getIsDefault()) && resultDto.getIsDefault().intValue() == 1) {
throw new ServiceException("门禁默认规则不可编辑和删除");
}
}
return resultDtoList;
}
private void updateImageStore(AcsPassRuleEditParam param, AcsPassRuleResultDto ruleResultDto,
CloudwalkCallContext context) throws ServiceException {
ImageStoreDetailResult imageStoreDetail = getImageStoreDetail(ruleResultDto.getImageStoreId(), context);
ImageStoreEditParam imageStoreEditParam = getEditParamByImageStore(imageStoreDetail);
BeanCopyUtils.copyProperties(ruleResultDto, imageStoreEditParam);
BeanCopyUtils.copyProperties(param, imageStoreEditParam);
imageStoreEditParam.setName(param.getZoneName() + "-" + param.getRuleName());
imageStoreEditParam.setExpiryBeginDate(param.getStartTime());
imageStoreEditParam.setExpiryEndDate(param.getEndTime());
imageStoreEditParam.setValidDateCron(null);
imageStoreEditParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<Boolean> result = this.imageStoreService.edit(imageStoreEditParam, context);
if (!result.isSuccess()) {
this.logger.info("远程调用编辑图库失败:原因:" + result.getMessage());
throw new ServiceException(result.getCode(), result.getMessage());
}
}
private List<AcsPassRuleResultDto> getRuleByIds(List<String> ruleIds, CloudwalkCallContext context)
throws ServiceException {
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
dto.setIds(ruleIds);
dto.setBusinessId(context.getCompany().getCompanyId());
try {
return this.acsPassRuleDao.list(dto);
} catch (DataAccessException e) {
this.logger.error("通行规则查询失败");
throw new ServiceException("通行规则查询失败");
}
}
@CloudwalkParamsValidate(argsIndexs = {0, 1})
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
public CloudwalkResult<Boolean> delete(AcsPassRuleDeleteParam param, CloudwalkCallContext context)
throws ServiceException {
List<AcsPassRuleResultDto> resultDtos = checkDefaultRule(param.getIds(), context);
String applicationId = this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
AcsElevatorDeviceListDto deviceListDto = new AcsElevatorDeviceListDto();
deviceListDto.setBusinessId(context.getCompany().getCompanyId());
deviceListDto.setCurrentFloorId(param.getZoneId());
List<AcsElevatorDeviceResultDTO> deviceList = null;
try {
deviceList = this.acsElevatorDeviceDao.listByZoneId(deviceListDto);
} catch (DataAccessException e) {
this.logger.error("根据楼层id获取设备信息失败,原因是:{}", e.getMessage());
}
for (AcsPassRuleResultDto acsPassRuleResultDto : resultDtos) {
if (!CollectionUtils.isEmpty(deviceList)) {
for (AcsElevatorDeviceResultDTO device : deviceList) {
DeviceImageStoreAppUnbindParam deviceImageStoreAppUnbindParam =
new DeviceImageStoreAppUnbindParam();
deviceImageStoreAppUnbindParam.setApplicationId(applicationId);
deviceImageStoreAppUnbindParam.setDeviceId(device.getDeviceId());
deviceImageStoreAppUnbindParam.setDeviceCode(device.getDeviceCode());
deviceImageStoreAppUnbindParam.setImageStoreId(acsPassRuleResultDto.getImageStoreId());
this.acsDeviceImageStoreAppBindService.unbindAppImageStoreDevice(deviceImageStoreAppUnbindParam,
context);
}
continue;
}
DeviceImageStoreAppUnbindParam unbindParam = new DeviceImageStoreAppUnbindParam();
unbindParam.setApplicationId(applicationId);
unbindParam.setImageStoreId(acsPassRuleResultDto.getImageStoreId());
this.acsDeviceImageStoreAppBindService.deleteImageStore(unbindParam, context);
}
AcsPassRuleDeleteDto dto = new AcsPassRuleDeleteDto();
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setIds(param.getIds());
try {
this.acsPassRuleDao.delete(dto);
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (DataAccessException e) {
this.logger.error("通行规则删除失败");
throw new ServiceException("76260507", getMessage("76260507"));
}
}
@CloudwalkParamsValidate(argsIndexs = {0, 1})
public CloudwalkResult<AcsPassRuleDetailResult> detail(AcsPassRuleQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
BeanCopyUtils.copyProperties(param, dto);
dto.setBusinessId(context.getCompany().getCompanyId());
List<AcsPassRuleResultDto> passRuleResult = this.acsPassRuleDao.list(dto);
if (CollectionUtils.isEmpty(passRuleResult)) {
return CloudwalkResult.fail("76260517", getMessage("76260517"));
}
AcsPassRuleDetailResult result = coverRuleDetailResult(passRuleResult.get(0), context);
return CloudwalkResult.success(result);
} catch (DataAccessException e) {
this.logger.error("查询通行规则详情失败");
throw new ServiceException("76260508", getMessage("76260508"));
}
}
private List<AcsPassRuleResult> coverRulePageResult(List<AcsPassRuleResultDto> passRuleResultDtos,
CloudwalkCallContext context, boolean needDetail) throws ServiceException {
List<AcsPassRuleResult> results = new ArrayList<>();
Map<String, ImageStoreListResult> imageStoreResultMap = null;
if (needDetail) {
List<String> imageStoreIds = (List<String>)passRuleResultDtos.stream()
.map(AcsPassRuleResultDto::getImageStoreId).collect(Collectors.toList());
List<ImageStoreListResult> imageStoreListResult = getImageStorePageResult(imageStoreIds, context);
imageStoreResultMap = (Map<String, ImageStoreListResult>)imageStoreListResult.stream()
.collect(Collectors.toMap(ImageStoreListResult::getId, r -> r));
}
for (AcsPassRuleResultDto dto : passRuleResultDtos) {
AcsPassRuleResult result = new AcsPassRuleResult();
BeanCopyUtils.copyProperties(dto, result);
result.setRuleName(dto.getName());
result.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
if (dto.getBeginDate() != null || dto.getEndDate() != null) {
result.setPassType(AcsPassTypeEnum.AUTO_PASS.getCode());
}
if (needDetail && imageStoreResultMap.containsKey(dto.getImageStoreId())) {
ImageStoreListResult imageStoreListResult = imageStoreResultMap.get(dto.getImageStoreId());
result.setPersonSum(imageStoreListResult.getPersonNum().intValue());
result.setIncludeOrganizations(imageStoreListResult.getIncludeOrganizations());
result.setIncludeLabels(imageStoreListResult.getIncludeLabels());
result.setExcludeLabels(imageStoreListResult.getExcludeLabels());
}
results.add(result);
}
return results;
}
private List<ImageStoreListResult> getImageStorePageResult(List<String> imageStoreIds, CloudwalkCallContext context)
throws ServiceException {
ImageStoreQueryParam param = new ImageStoreQueryParam();
param.setIds(imageStoreIds);
param.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<List<ImageStoreListResult>> imageStoreResult = this.imageStoreService.list(param, context);
if (!imageStoreResult.isSuccess()) {
this.logger.info("远程调用分页查询图库失败,原因:" + imageStoreResult.getMessage());
throw new ServiceException(imageStoreResult.getCode(), imageStoreResult.getMessage());
}
return (List<ImageStoreListResult>)imageStoreResult.getData();
}
private AcsPassRuleDetailResult coverRuleDetailResult(AcsPassRuleResultDto dto, CloudwalkCallContext context)
throws ServiceException {
AcsPassRuleDetailResult result = new AcsPassRuleDetailResult();
BeanCopyUtils.copyProperties(dto, result);
result.setRuleName(dto.getName());
ImageStoreDetailResult imageStoreDetailResult = getImageStoreDetail(dto.getImageStoreId(), context);
result.setIncludeOrganizations(imageStoreDetailResult.getIncludeOrganizations());
result.setIncludeLabels(imageStoreDetailResult.getIncludeLabels());
result.setExcludeLabels(imageStoreDetailResult.getExcludeLabels());
List<AcsPassTimeCycleParam> timeCycleParams =
JSONObject.parseArray(dto.getValidDateJson(), AcsPassTimeCycleParam.class);
result.setPassableCycle(timeCycleParams);
result.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
if (dto.getBeginDate() != null || dto.getEndDate() != null) {
result.setPassType(AcsPassTypeEnum.AUTO_PASS.getCode());
}
return result;
}
@CloudwalkParamsValidate(argsIndexs = {0, 1})
public CloudwalkResult<CloudwalkPageAble<AcsPassRuleResult>> page(AcsPassRuleQueryParam param,
CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
try {
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
dto.setZoneId(param.getZoneId());
dto.setBusinessId(context.getCompany().getCompanyId());
CloudwalkPageAble<AcsPassRuleResultDto> passRuleResult = this.acsPassRuleDao.page(dto, page);
if (CollectionUtils.isEmpty(passRuleResult.getDatas()) && ObjectUtils.isEmpty(param.getIsDefault())) {
AcsPassRuleNewParam ruleNewParam = new AcsPassRuleNewParam();
ruleNewParam.setZoneId(param.getZoneId());
ruleNewParam.setZoneName(param.getZoneName());
ruleNewParam.setRuleName("默认规则");
ruleNewParam.setIsDefault(Integer.valueOf(1));
add(ruleNewParam, context);
passRuleResult = this.acsPassRuleDao.page(dto, page);
}
List<AcsPassRuleResult> results =
coverRulePageResult((List<AcsPassRuleResultDto>)passRuleResult.getDatas(), context, true);
return CloudwalkResult.success(new CloudwalkPageAble(results, page, passRuleResult.getTotalRows()));
} catch (DataAccessException e) {
this.logger.error("分页查询通行规则失败");
throw new ServiceException("76260508", getMessage("76260508"));
}
}
public CloudwalkResult<List<AcsPassRuleResult>> list(AcsPassRuleQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
BeanCopyUtils.copyProperties(param, dto);
dto.setBusinessId(context.getCompany().getCompanyId());
List<AcsPassRuleResultDto> passRuleResult = this.acsPassRuleDao.list(dto);
return CloudwalkResult.success(coverRulePageResult(passRuleResult, context, false));
} catch (DataAccessException e) {
this.logger.error("查询通行规则失败");
throw new ServiceException("76260508", getMessage("76260508"));
}
}
public CloudwalkResult<List<AcsPassRuleImageResultDto>> listByImageId(AcsPassRuleImageParam param,
CloudwalkCallContext context) throws ServiceException {
try {
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
BeanCopyUtils.copyProperties(param, dto);
List<AcsPassRuleImageResultDto> resultDtos = this.acsPassRuleDao.listByImageId(dto);
return CloudwalkResult.success(resultDtos);
} catch (DataAccessException e) {
this.logger.error("根据图库id集合查询对应楼层信息失败");
throw new ServiceException("76260526", getMessage("76260526"));
}
}
private long pagePersonTotalRowsForZone(String zoneId, CloudwalkCallContext context) throws Exception {
return FeignThreadLocalUtil.callWithContext(context, () -> {
AcsPersonQueryParam personParam = new AcsPersonQueryParam();
personParam.setZoneId(zoneId);
CloudwalkPageInfo pageInfo = new CloudwalkPageInfo(1, 1);
CloudwalkResult<CloudwalkPageAble<AcsPersonResult>> page =
this.acsPersonService.page(personParam, pageInfo, context);
if (!page.isSuccess()) {
this.logger.info("远程调用查询通行人员分页失败,原因:" + page.getMessage());
throw new ServiceException(page.getCode(), page.getMessage());
}
if (ObjectUtils.isEmpty(page.getData())) {
return 0L;
}
return ((CloudwalkPageAble)page.getData()).getTotalRows();
});
}
private void rollbackImageStoreAfterBindFailure(String imageStoreIdValue, CloudwalkCallContext context)
throws ServiceException {
ImageStoreDelParam delParam = new ImageStoreDelParam();
delParam.setId(imageStoreIdValue);
delParam.setBusinessId(context.getCompany().getCompanyId());
this.logger.info("回滚删除图库开始,delParam={},context={}", JSONObject.toJSON(delParam), JSONObject.toJSON(context));
CloudwalkResult<Boolean> deleteResult = this.imageStoreService.delete(delParam, context);
this.logger.info("删除图库:图库id={},结果:{}", imageStoreIdValue, deleteResult.getMessage());
}
private void getZoneTypeIsThree(ZoneTreeResult zoneTreeResult, List<AcsPassRuleFloorResult> passRuleResults) {
if ("FLOOR".equals(zoneTreeResult.getType())) {
AcsPassRuleFloorResult result = new AcsPassRuleFloorResult();
result.setId(zoneTreeResult.getId());
result.setName(zoneTreeResult.getName());
result.setUnitNumber(zoneTreeResult.getUnitCount());
passRuleResults.add(result);
} else if (!CollectionUtils.isEmpty(zoneTreeResult.getChildren())) {
for (ZoneTreeResult treeResult : zoneTreeResult.getChildren())
getZoneTypeIsThree(treeResult, passRuleResults);
}
}
}
@@ -0,0 +1,810 @@
package cn.cloudwalk.elevator.passrule.impl;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonData;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.UpdateGroupPersonRefParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStorePersonResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStorePersonResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStorePersonService;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.param.LabelDetailParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.param.LabelQueryParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelDetailResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.service.LabelService;
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.param.OrganizationListParam;
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.service.OrganizationService;
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.exception.DataAccessException;
import cn.cloudwalk.cloud.exception.ServiceException;
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
import cn.cloudwalk.elevator.device.dao.AcsElevatorDeviceDao;
import cn.cloudwalk.elevator.device.dao.DeviceImageStoreDao;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceListByBuildingIdDto;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceListDto;
import cn.cloudwalk.elevator.device.dto.AcsElevatorDeviceResultDTO;
import cn.cloudwalk.elevator.em.AcsPassTypeEnum;
import cn.cloudwalk.elevator.passrule.dao.ImageRuleRefDao;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleImageResultDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRulePersonListDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRulePersonListResultDto;
import cn.cloudwalk.elevator.passrule.dto.AcsPassRuleQueryDto;
import cn.cloudwalk.elevator.passrule.dto.ImageRuleRefAddDto;
import cn.cloudwalk.elevator.passrule.dto.ImageRuleRefListResult;
import cn.cloudwalk.elevator.passrule.dto.ImageRuleRefResultDto;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleDeleteParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleEditParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleFloorParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleImageParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleNewParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRulePersonListParam;
import cn.cloudwalk.elevator.passrule.param.AcsPassRuleQueryParam;
import cn.cloudwalk.elevator.passrule.result.AcsPassRuleFloorResult;
import cn.cloudwalk.elevator.passrule.result.ImageRuleRefDetailResult;
import cn.cloudwalk.elevator.passrule.result.ImageRuleRefPageResult;
import cn.cloudwalk.elevator.passrule.service.ImageRuleRefService;
import cn.cloudwalk.elevator.person.param.AcsPersonQueryParam;
import cn.cloudwalk.elevator.person.result.AcsPersonResult;
import cn.cloudwalk.elevator.person.service.PersonRuleService;
import cn.cloudwalk.elevator.util.CollectionUtils;
import cn.cloudwalk.elevator.zone.param.ZoneQueryParam;
import cn.cloudwalk.elevator.zone.result.ZoneResult;
import cn.cloudwalk.elevator.zone.service.ZoneService;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
@Service
public class ImageRuleRefServiceImpl extends AbstractAcsPassService implements ImageRuleRefService {
@Autowired
private ImageStorePersonService imageStorePersonService;
@Autowired
private OrganizationService organizationService;
@Autowired
private LabelService labelService;
@Resource
private ImageRuleRefDao imageRuleRefDao;
@Resource
private DeviceImageStoreDao deviceImageStoreDao;
@Resource
private ImageStoreService imageStoreService;
@Resource
private ZoneService zoneService;
@Resource
private AcsElevatorDeviceDao acsElevatorDeviceDao;
@Resource
private PersonRuleService personRuleService;
public CloudwalkResult<CloudwalkPageAble<ImageRuleRefPageResult>> page(AcsPassRuleQueryParam param,
CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
try {
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
dto.setZoneId(param.getZoneId());
dto.setBusinessId(context.getCompany().getCompanyId());
CloudwalkPageAble<ImageRuleRefResultDto> passRuleResult = this.imageRuleRefDao.page(dto, page);
if (CollectionUtils.isEmpty(passRuleResult.getDatas()) && ObjectUtils.isEmpty(param.getIsDefault())) {
AcsPassRuleNewParam ruleNewParam = new AcsPassRuleNewParam();
ruleNewParam.setZoneId(param.getZoneId());
ruleNewParam.setZoneName(param.getZoneName());
ruleNewParam.setRuleName("默认规则");
ruleNewParam.setIsDefault(Integer.valueOf(1));
ruleNewParam.setParentId(param.getParentId());
addOnlyRule(ruleNewParam, context);
passRuleResult = this.imageRuleRefDao.page(dto, page);
}
List<ImageRuleRefPageResult> results = coverRulePageResult(
(List<ImageRuleRefResultDto>)passRuleResult.getDatas(), param.getParentId(), context);
return CloudwalkResult.success(new CloudwalkPageAble(results, page, passRuleResult.getTotalRows()));
} catch (Exception e) {
this.logger.error("分页查询通行规则失败", e);
throw new ServiceException("76260508", getMessage("76260508"));
}
}
public CloudwalkResult<CloudwalkPageAble<AcsPassRuleFloorResult>> listFloor(AcsPassRuleFloorParam param,
CloudwalkCallContext context) throws ServiceException {
ZoneQueryParam queryParam = new ZoneQueryParam();
queryParam.setParentId(param.getZoneId());
queryParam.setRowsOfPage(param.getRowsOfPage());
queryParam.setCurrentPage(param.getCurrentPage());
CloudwalkResult<CloudwalkPageAble<ZoneResult>> zonePageData = this.zoneService.page(queryParam, context);
if (!zonePageData.isSuccess()) {
this.logger.info("远程调用分页查询区域失败,原因:" + zonePageData.getMessage());
throw new ServiceException(zonePageData.getCode(), zonePageData.getMessage());
}
try {
CloudwalkPageInfo page = new CloudwalkPageInfo(param.getCurrentPage(), param.getRowsOfPage());
CloudwalkPageAble<AcsPassRuleFloorResult> ruleFloorResult = null;
if (!ObjectUtils.isEmpty(zonePageData.getData())
&& !CollectionUtils.isEmpty(((CloudwalkPageAble)zonePageData.getData()).getDatas())) {
List<AcsPassRuleFloorResult> resultList = BeanCopyUtils
.copy(((CloudwalkPageAble)zonePageData.getData()).getDatas(), AcsPassRuleFloorResult.class);
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(param.getZoneId());
for (AcsPassRuleFloorResult floorResult : resultList) {
AcsElevatorDeviceListDto dto = new AcsElevatorDeviceListDto();
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setCurrentFloorId(floorResult.getId());
List<AcsElevatorDeviceResultDTO> deviceList = this.acsElevatorDeviceDao.listByZoneId(dto);
floorResult.setDeviceNumber(Integer.valueOf(deviceList.size()));
Long number = Long.valueOf(0L);
floorResult.setPersonNumber(number);
if (!ObjectUtils.isEmpty(imageStoreId)) {
AcsPersonQueryParam personQueryParam = new AcsPersonQueryParam();
personQueryParam.setImageStoreId(imageStoreId);
personQueryParam.setZoneId(floorResult.getId());
personQueryParam.setParentId(param.getZoneId());
CloudwalkPageInfo pageInfo = new CloudwalkPageInfo(1, 10);
CloudwalkResult<CloudwalkPageAble<AcsPersonResult>> result =
this.personRuleService.page(personQueryParam, pageInfo, context);
floorResult.setPersonNumber(Long.valueOf(((CloudwalkPageAble)result.getData()).getTotalRows()));
}
}
ruleFloorResult =
new CloudwalkPageAble(resultList, page, ((CloudwalkPageAble)zonePageData.getData()).getTotalRows());
}
return CloudwalkResult.success(ruleFloorResult);
} catch (DataAccessException e) {
this.logger.error("查询所有楼层信息失败", (Throwable)e);
throw new ServiceException("76260520", getMessage("76260520"));
}
}
public CloudwalkResult<List<AcsPassRuleImageResultDto>> listByPersonInfo(AcsPassRuleImageParam param,
CloudwalkCallContext context) throws ServiceException {
try {
AcsPassRuleImageDto dto = new AcsPassRuleImageDto();
BeanCopyUtils.copyProperties(param, dto);
List<AcsPassRuleImageResultDto> resultDtos = this.imageRuleRefDao.listByPersonInfo(dto);
return CloudwalkResult.success(resultDtos);
} catch (DataAccessException e) {
this.logger.error("根据人员id、标签集合、机构集合获取楼层权限失败", (Throwable)e);
throw new ServiceException("76260526", getMessage("76260526"));
}
}
public CloudwalkResult<List<AcsPassRulePersonListResultDto>> listByPersonList(AcsPassRulePersonListParam param,
CloudwalkCallContext context) throws ServiceException {
try {
AcsPassRulePersonListDto dto = new AcsPassRulePersonListDto();
List<String> personIds = new ArrayList<>();
List<String> labelIds = new ArrayList<>();
List<String> orgIds = new ArrayList<>();
for (AcsPassRuleImageParam imageParam : param.getPersonList()) {
personIds.add(imageParam.getPersonId());
if (!CollectionUtils.isEmpty(imageParam.getIncludeLabels())) {
labelIds.addAll(imageParam.getIncludeLabels());
}
if (!CollectionUtils.isEmpty(imageParam.getIncludeOrganizations())) {
orgIds.addAll(imageParam.getIncludeOrganizations());
}
}
dto.setPersonIds(personIds);
dto.setIncludeLabels(labelIds);
dto.setIncludeOrganizations(orgIds);
List<ImageRuleRefResultDto> resultDtos = this.imageRuleRefDao.listByPersonList(dto);
Map<String, List<ImageRuleRefResultDto>> personIdMap = new HashMap<>();
Map<String, List<ImageRuleRefResultDto>> labelIdMap = new HashMap<>();
Map<String, List<ImageRuleRefResultDto>> orgIdMap = new HashMap<>();
for (ImageRuleRefResultDto resultDto : resultDtos) {
if (!ObjectUtils.isEmpty(resultDto.getPersonId())) {
List<ImageRuleRefResultDto> personList = personIdMap.get(resultDto.getPersonId());
if (!CollectionUtils.isEmpty(personList)) {
personList.add(resultDto);
continue;
}
List<ImageRuleRefResultDto> personListDto = new ArrayList<>();
personListDto.add(resultDto);
personIdMap.put(resultDto.getPersonId(), personListDto);
continue;
}
if (!ObjectUtils.isEmpty(resultDto.getIncludeLabels())) {
List<ImageRuleRefResultDto> labelList = labelIdMap.get(resultDto.getIncludeLabels());
if (!CollectionUtils.isEmpty(labelList)) {
labelList.add(resultDto);
continue;
}
List<ImageRuleRefResultDto> labelListDto = new ArrayList<>();
labelListDto.add(resultDto);
labelIdMap.put(resultDto.getIncludeLabels(), labelListDto);
continue;
}
if (!ObjectUtils.isEmpty(resultDto.getIncludeOrganizations())) {
List<ImageRuleRefResultDto> orgList = orgIdMap.get(resultDto.getIncludeOrganizations());
if (!CollectionUtils.isEmpty(orgList)) {
orgList.add(resultDto);
continue;
}
List<ImageRuleRefResultDto> orgListDto = new ArrayList<>();
orgListDto.add(resultDto);
orgIdMap.put(resultDto.getIncludeOrganizations(), orgListDto);
}
}
List<AcsPassRulePersonListResultDto> returnList = new ArrayList<>();
for (AcsPassRuleImageParam imageParam : param.getPersonList()) {
List<String> zoneIdList = this.imageRuleRefDao.listPersonDelByPersonId(imageParam.getPersonId());
AcsPassRulePersonListResultDto listResultDto = new AcsPassRulePersonListResultDto();
listResultDto.setPersonId(imageParam.getPersonId());
List<AcsPassRuleImageResultDto> zoneList = new ArrayList<>();
List<String> listZoneIds = new ArrayList<>();
List<ImageRuleRefResultDto> personMapDto = personIdMap.get(imageParam.getPersonId());
if (!CollectionUtils.isEmpty(personMapDto)) {
for (ImageRuleRefResultDto resultDto : personMapDto) {
if (!zoneIdList.contains(resultDto.getZoneId())) {
listZoneIds.add(resultDto.getZoneId());
AcsPassRuleImageResultDto result = new AcsPassRuleImageResultDto();
result.setZoneId(resultDto.getZoneId());
result.setZoneName(resultDto.getZoneName());
zoneList.add(result);
}
}
}
if (!CollectionUtils.isEmpty(imageParam.getIncludeLabels())) {
for (String labelId : imageParam.getIncludeLabels()) {
List<ImageRuleRefResultDto> labelMapDto = labelIdMap.get(labelId);
if (!CollectionUtils.isEmpty(labelMapDto)) {
for (ImageRuleRefResultDto resultDto : labelMapDto) {
if (!zoneIdList.contains(resultDto.getZoneId())
&& !listZoneIds.contains(resultDto.getZoneId())) {
listZoneIds.add(resultDto.getZoneId());
AcsPassRuleImageResultDto result = new AcsPassRuleImageResultDto();
result.setZoneId(resultDto.getZoneId());
result.setZoneName(resultDto.getZoneName());
zoneList.add(result);
}
}
}
}
}
if (!CollectionUtils.isEmpty(imageParam.getIncludeOrganizations())) {
for (String orgId : imageParam.getIncludeOrganizations()) {
List<ImageRuleRefResultDto> orgMapDto = orgIdMap.get(orgId);
if (!CollectionUtils.isEmpty(orgMapDto)) {
for (ImageRuleRefResultDto resultDto : orgMapDto) {
if (!zoneIdList.contains(resultDto.getZoneId())
&& !listZoneIds.contains(resultDto.getZoneId())) {
listZoneIds.add(resultDto.getZoneId());
AcsPassRuleImageResultDto result = new AcsPassRuleImageResultDto();
result.setZoneId(resultDto.getZoneId());
result.setZoneName(resultDto.getZoneName());
zoneList.add(result);
}
}
}
}
}
listResultDto.setZoneList(zoneList);
returnList.add(listResultDto);
}
return CloudwalkResult.success(returnList);
} catch (DataAccessException e) {
this.logger.error("根据人员id、标签集合、机构集合批量获取楼层权限失败", (Throwable)e);
throw new ServiceException("76260526", getMessage("76260526"));
}
}
public CloudwalkResult<ImageRuleRefDetailResult> detail(AcsPassRuleQueryParam param, CloudwalkCallContext context)
throws ServiceException {
try {
ImageRuleRefResultDto byId = this.imageRuleRefDao.getById(param.getId());
List<String> includeLabels = new ArrayList<>();
List<String> includeOrganizations = new ArrayList<>();
List<ImageRuleRefResultDto> child =
this.imageRuleRefDao.listByParentRule(Collections.singletonList(param.getId()));
if (!CollectionUtils.isEmpty(child)) {
for (ImageRuleRefResultDto resultDto : child) {
if (!ObjectUtils.isEmpty(resultDto.getIncludeLabels())) {
includeLabels.add(resultDto.getIncludeLabels());
continue;
}
if (!ObjectUtils.isEmpty(resultDto.getIncludeOrganizations())) {
includeOrganizations.add(resultDto.getIncludeOrganizations());
}
}
}
ImageRuleRefDetailResult result =
(ImageRuleRefDetailResult)BeanCopyUtils.copyProperties(byId, ImageRuleRefDetailResult.class);
result.setRuleName(byId.getName());
if (!CollectionUtils.isEmpty(includeLabels)) {
Map<String, LabelDetailResult> labelById = loadLabelDetailMap(context);
List<LabelDetailResult> labelDetailResultList = new ArrayList<>();
fillLabelDetailsFromMap(includeLabels, labelById, labelDetailResultList, context);
result.setIncludeLabels(labelDetailResultList);
}
if (!CollectionUtils.isEmpty(includeOrganizations)) {
OrganizationListParam orgParam = new OrganizationListParam();
orgParam.setIds(includeOrganizations);
CloudwalkResult<List<OrganizationResult>> orglist = this.organizationService.list(orgParam, context);
result.setIncludeOrganizations((List)orglist.getData());
}
return CloudwalkResult.success(result);
} catch (DataAccessException e) {
this.logger.error("查询通行规则详情失败", (Throwable)e);
throw new ServiceException("76260508", getMessage("76260508"));
}
}
@CloudwalkParamsValidate(argsIndexs = {0, 1})
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
public CloudwalkResult<Boolean> addOnlyRule(AcsPassRuleNewParam param, CloudwalkCallContext context)
throws ServiceException {
try {
AcsElevatorDeviceListByBuildingIdDto buildingIdDto = new AcsElevatorDeviceListByBuildingIdDto();
buildingIdDto.setCurrentBuildingId(param.getParentId());
buildingIdDto.setBusinessId(context.getCompany().getCompanyId());
List<AcsElevatorDeviceResultDTO> deviceList = this.acsElevatorDeviceDao.listBuBuildingId(buildingIdDto);
if (CollectionUtils.isEmpty(deviceList)) {
return CloudwalkResult.fail("76260527", getMessage("76260527"));
}
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(param.getParentId());
ImageRuleRefAddDto addDto = createAddDto(param, context);
this.imageRuleRefDao.insert(addDto);
if (!ObjectUtils.isEmpty(param.getIsDefault()) && param.getIsDefault().intValue() == 1) {
return CloudwalkResult.success(Boolean.valueOf(true));
}
ImageStoreQueryParam queryParam = new ImageStoreQueryParam();
queryParam.setId(imageStoreId);
queryParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<ImageStoreDetailResult> imageDetail = this.imageStoreService.detail(queryParam, context);
ImageStoreEditParam editParam =
(ImageStoreEditParam)BeanCopyUtils.copyProperties(imageDetail.getData(), ImageStoreEditParam.class);
editParam.setImageStoreId(((ImageStoreDetailResult)imageDetail.getData()).getId());
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getIncludePersons())) {
List<ImageStorePersonData> includePersons = new ArrayList<>();
for (ImgStorePersonResult personResult : ((ImageStoreDetailResult)imageDetail.getData())
.getIncludePersons()) {
ImageStorePersonData data = new ImageStorePersonData();
data.setObjectId(personResult.getId());
includePersons.add(data);
}
editParam.setIncludePersons(includePersons);
}
List<String> oldIncludeLabels = new ArrayList<>();
List<String> oldIncludeOrganizations = new ArrayList<>();
List<String> includeLabels = new ArrayList<>();
List<String> includeOrganizations = new ArrayList<>();
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getIncludeLabels())) {
for (LabelResult labelResult : ((ImageStoreDetailResult)imageDetail.getData()).getIncludeLabels()) {
oldIncludeLabels.add(labelResult.getId());
}
}
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getIncludeOrganizations())) {
for (OrganizationResult organizationResult : ((ImageStoreDetailResult)imageDetail.getData())
.getIncludeOrganizations()) {
oldIncludeOrganizations.add(organizationResult.getId());
}
}
if (!CollectionUtils.isEmpty(param.getIncludeLabels())) {
for (String label : param.getIncludeLabels()) {
ImageRuleRefAddDto dto = createAddDto(param, context);
dto.setParentRule(addDto.getId());
dto.setIncludeLabels(label);
this.imageRuleRefDao.insert(dto);
if (!oldIncludeLabels.contains(label)) {
includeLabels.add(label);
}
}
}
if (!CollectionUtils.isEmpty(param.getIncludeOrganizations())) {
for (String org : param.getIncludeOrganizations()) {
ImageRuleRefAddDto dto = createAddDto(param, context);
dto.setParentRule(addDto.getId());
dto.setIncludeOrganizations(org);
this.imageRuleRefDao.insert(dto);
if (!oldIncludeOrganizations.contains(org)) {
includeOrganizations.add(org);
}
}
}
if (!CollectionUtils.isEmpty(includeLabels) || !CollectionUtils.isEmpty(includeOrganizations)) {
includeLabels.addAll(oldIncludeLabels);
includeOrganizations.addAll(oldIncludeOrganizations);
editParam.setIncludeLabels(includeLabels);
editParam.setIncludeOrganizations(includeOrganizations);
editParam.setBusinessId(context.getCompany().getCompanyId());
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getExcludePersons())) {
List<String> excPersonIds = new ArrayList<>();
for (ImgStorePersonResult personResult : ((ImageStoreDetailResult)imageDetail.getData())
.getExcludePersons()) {
excPersonIds.add(personResult.getId());
}
editParam.setExcludePersons(excPersonIds);
}
CloudwalkResult<Boolean> edit = this.imageStoreService.edit(editParam, context);
if (ObjectUtils.isEmpty(edit.getData()) || !((Boolean)edit.getData()).booleanValue()) {
throw new ServiceException(edit.getCode(), edit.getMessage());
}
}
UpdateGroupPersonRefParam refParam = new UpdateGroupPersonRefParam();
refParam.setImageStoreId(imageStoreId);
refParam.setBusinessId(context.getCompany().getCompanyId());
refParam.setLabelIds(param.getIncludeLabels());
refParam.setOrganizationIds(param.getIncludeOrganizations());
this.imageStorePersonService.updateGroupPersonRef(refParam, context);
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (DataAccessException e) {
this.logger.error("添加通行规则失败", (Throwable)e);
throw new ServiceException("76260505", getMessage("76260505"));
}
}
public CloudwalkResult<Boolean> update(AcsPassRuleEditParam param, CloudwalkCallContext context)
throws ServiceException {
checkDefaultRule(param.getId());
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(param.getParentId());
ImageStoreQueryParam queryParam = new ImageStoreQueryParam();
queryParam.setId(imageStoreId);
queryParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult<ImageStoreDetailResult> imageDetail = this.imageStoreService.detail(queryParam, context);
ImageStoreEditParam editParam =
(ImageStoreEditParam)BeanCopyUtils.copyProperties(imageDetail.getData(), ImageStoreEditParam.class);
editParam.setImageStoreId(imageStoreId);
List<String> oldIncludeLabels = new ArrayList<>();
List<String> oldIncludeOrganizations = new ArrayList<>();
List<String> includeLabels = new ArrayList<>();
List<String> includeOrganizations = new ArrayList<>();
List<String> includeLabels2 = new ArrayList<>();
List<String> includeOrganizations2 = new ArrayList<>();
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getIncludeLabels())) {
for (LabelResult labelResult : ((ImageStoreDetailResult)imageDetail.getData()).getIncludeLabels()) {
oldIncludeLabels.add(labelResult.getId());
}
}
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getIncludeOrganizations())) {
for (OrganizationResult organizationResult : ((ImageStoreDetailResult)imageDetail.getData())
.getIncludeOrganizations()) {
oldIncludeOrganizations.add(organizationResult.getId());
}
}
try {
List<ImageRuleRefResultDto> oldRule =
this.imageRuleRefDao.listByParentRule(Collections.singletonList(param.getId()));
List<String> updateLabels = new ArrayList<>(param.getIncludeLabels());
List<String> updateOrgIds = new ArrayList<>(param.getIncludeOrganizations());
Boolean isTrue = Boolean.valueOf(true);
if (!CollectionUtils.isEmpty(oldRule)) {
for (ImageRuleRefResultDto dto : oldRule) {
if (!ObjectUtils.isEmpty(dto.getIncludeLabels())
&& !updateLabels.contains(dto.getIncludeLabels())) {
updateLabels.add(dto.getIncludeLabels());
isTrue = Boolean.valueOf(false);
}
if (!ObjectUtils.isEmpty(dto.getIncludeOrganizations())
&& !updateOrgIds.contains(dto.getIncludeOrganizations())) {
updateOrgIds.add(dto.getIncludeOrganizations());
isTrue = Boolean.valueOf(false);
}
}
}
this.imageRuleRefDao.deleteById(param.getId());
ImageRuleRefAddDto addDto = createUpdateDto(param, context);
this.imageRuleRefDao.insert(addDto);
if (!CollectionUtils.isEmpty(param.getIncludeLabels())) {
for (String label : param.getIncludeLabels()) {
ImageRuleRefAddDto dto = createUpdateDto(param, context);
dto.setIncludeLabels(label);
dto.setParentRule(addDto.getId());
this.imageRuleRefDao.insert(dto);
if (!editParam.getIncludeLabels().contains(label)) {
includeLabels.add(label);
includeLabels2.add(label);
}
}
}
if (!CollectionUtils.isEmpty(param.getExcludeLabels())) {
for (String label : param.getExcludeLabels()) {
ImageRuleRefAddDto dto = createUpdateDto(param, context);
dto.setExcludeLabels(label);
dto.setParentRule(addDto.getId());
this.imageRuleRefDao.insert(dto);
}
}
if (!CollectionUtils.isEmpty(param.getIncludeOrganizations())) {
for (String org : param.getIncludeOrganizations()) {
ImageRuleRefAddDto dto = createUpdateDto(param, context);
dto.setIncludeOrganizations(org);
dto.setParentRule(addDto.getId());
this.imageRuleRefDao.insert(dto);
if (!editParam.getIncludeOrganizations().contains(org)) {
includeOrganizations.add(org);
includeOrganizations2.add(org);
}
}
}
if (!CollectionUtils.isEmpty(includeLabels) || !CollectionUtils.isEmpty(includeOrganizations)) {
includeLabels.addAll(oldIncludeLabels);
includeOrganizations.addAll(oldIncludeOrganizations);
editParam.setIncludeLabels(includeLabels);
editParam.setIncludeOrganizations(includeOrganizations);
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getExcludePersons())) {
List<String> excPersonIds = new ArrayList<>();
for (ImgStorePersonResult personResult : ((ImageStoreDetailResult)imageDetail.getData())
.getExcludePersons()) {
excPersonIds.add(personResult.getId());
}
editParam.setExcludePersons(excPersonIds);
}
if (!CollectionUtils.isEmpty(((ImageStoreDetailResult)imageDetail.getData()).getIncludePersons())) {
List<ImageStorePersonData> includePersons = new ArrayList<>();
for (ImgStorePersonResult personResult : ((ImageStoreDetailResult)imageDetail.getData())
.getIncludePersons()) {
ImageStorePersonData personData = new ImageStorePersonData();
personData.setObjectId(personResult.getId());
includePersons.add(personData);
}
editParam.setIncludePersons(includePersons);
}
editParam.setBusinessId(context.getCompany().getCompanyId());
CloudwalkResult cloudwalkResult = this.imageStoreService.edit(editParam, context);
}
if (!isTrue.booleanValue()) {
UpdateGroupPersonRefParam refParam = new UpdateGroupPersonRefParam();
refParam.setImageStoreId(imageStoreId);
refParam.setBusinessId(context.getCompany().getCompanyId());
refParam.setLabelIds(updateLabels);
refParam.setOrganizationIds(updateOrgIds);
this.imageStorePersonService.updateGroupPersonRef(refParam, context);
}
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (DataAccessException e) {
this.logger.error("添加通行规则失败", (Throwable)e);
throw new ServiceException("76260505", getMessage("76260505"));
}
}
public CloudwalkResult<Boolean> delete(AcsPassRuleDeleteParam param, CloudwalkCallContext context)
throws ServiceException {
try {
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(param.getParentId());
for (String id : param.getIds()) {
checkDefaultRule(id);
List<String> includeLabels = new ArrayList<>();
List<String> includeOrganizations = new ArrayList<>();
List<ImageRuleRefResultDto> child =
this.imageRuleRefDao.listByParentRule(Collections.singletonList(id));
if (!CollectionUtils.isEmpty(child)) {
for (ImageRuleRefResultDto resultDto : child) {
if (!ObjectUtils.isEmpty(resultDto.getIncludeLabels())) {
includeLabels.add(resultDto.getIncludeLabels());
continue;
}
if (!ObjectUtils.isEmpty(resultDto.getIncludeOrganizations())) {
includeOrganizations.add(resultDto.getIncludeOrganizations());
}
}
}
this.imageRuleRefDao.deleteById(id);
UpdateGroupPersonRefParam refParam = new UpdateGroupPersonRefParam();
refParam.setBusinessId(context.getCompany().getCompanyId());
refParam.setImageStoreId(imageStoreId);
refParam.setLabelIds(includeLabels);
refParam.setOrganizationIds(includeOrganizations);
this.imageStorePersonService.updateGroupPersonRef(refParam, context);
}
return CloudwalkResult.success(Boolean.valueOf(true));
} catch (DataAccessException e) {
this.logger.error("通行规则删除失败", (Throwable)e);
throw new ServiceException("76260507", getMessage("76260507"));
}
}
private List<ImageRuleRefPageResult> coverRulePageResult(List<ImageRuleRefResultDto> datas, String parentId,
CloudwalkCallContext context) throws Exception {
List<ImageRuleRefPageResult> detailResultList = new ArrayList<>();
if (CollectionUtils.isEmpty(datas)) {
return detailResultList;
}
Map<String, LabelDetailResult> labelById = loadLabelDetailMap(context);
List<String> personSum =
this.imageRuleRefDao.countPersonIdByZoneId(((ImageRuleRefResultDto)datas.get(0)).getZoneId());
for (ImageRuleRefResultDto data : datas) {
ImageRuleRefPageResult detailResult = new ImageRuleRefPageResult();
AcsPersonQueryParam personQueryParam = new AcsPersonQueryParam();
BeanCopyUtils.copyProperties(data, detailResult);
detailResult.setRuleName(data.getName());
detailResult.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
if (data.getIsDefault().intValue() == 1) {
detailResult.setPersonSum(personSum.size());
} else {
personQueryParam.setDelPersonIds(personSum);
List<String> includeLabels = new ArrayList<>();
List<String> includeOrganizations = new ArrayList<>();
List<ImageRuleRefResultDto> child =
this.imageRuleRefDao.listByParentRule(Collections.singletonList(data.getId()));
if (!CollectionUtils.isEmpty(child)) {
for (ImageRuleRefResultDto resultDto : child) {
if (!ObjectUtils.isEmpty(resultDto.getIncludeLabels())) {
includeLabels.add(resultDto.getIncludeLabels());
continue;
}
if (!ObjectUtils.isEmpty(resultDto.getIncludeOrganizations())) {
includeOrganizations.add(resultDto.getIncludeOrganizations());
}
}
String imageStoreId = this.deviceImageStoreDao.getByBuildingId(parentId);
personQueryParam.setImageStoreId(imageStoreId);
personQueryParam.setLabelIds(includeLabels);
personQueryParam.setOrganizationIds(includeOrganizations);
if (!CollectionUtils.isEmpty(personQueryParam.getOrganizationIds())
&& !CollectionUtils.isEmpty(personQueryParam.getLabelIds())) {
personQueryParam.setIsElevator(Integer.valueOf(3));
} else if (!CollectionUtils.isEmpty(personQueryParam.getOrganizationIds())) {
personQueryParam.setIsElevator(Integer.valueOf(1));
} else if (!CollectionUtils.isEmpty(personQueryParam.getLabelIds())) {
personQueryParam.setIsElevator(Integer.valueOf(2));
}
CloudwalkPageInfo page = new CloudwalkPageInfo(1, 10);
CloudwalkPageAble<ImageStorePersonResult> pageResult =
getImageStorePerson(personQueryParam, page, context);
List<String> delPerson = this.imageRuleRefDao.listPersonDelByZoneId(data.getZoneId());
if (!ObjectUtils.isEmpty(pageResult.getDatas())) {
detailResult.setPersonSum(Math.toIntExact(pageResult.getTotalRows()) - delPerson.size());
} else {
detailResult.setPersonSum(0);
}
if (!CollectionUtils.isEmpty(includeLabels)) {
List<LabelDetailResult> labelDetailResultList = new ArrayList<>();
fillLabelDetailsFromMap(includeLabels, labelById, labelDetailResultList, context);
detailResult.setIncludeLabels(labelDetailResultList);
}
if (!CollectionUtils.isEmpty(includeOrganizations)) {
OrganizationListParam orgParam = new OrganizationListParam();
orgParam.setIds(includeOrganizations);
CloudwalkResult<List<OrganizationResult>> orglist =
this.organizationService.list(orgParam, context);
detailResult.setIncludeOrganizations((List)orglist.getData());
}
}
}
detailResultList.add(detailResult);
}
return detailResultList;
}
/**
* 一次 {@link LabelService#getAll} 建 id→详情索引,避免规则详情/分页组装时对 {@link LabelService#detail} 的 N 次远程调用。 若某 id
* 不在全量列表中(数据不同步),回退单次 detail。
*/
private Map<String, LabelDetailResult> loadLabelDetailMap(CloudwalkCallContext context) throws ServiceException {
CloudwalkResult<List<LabelDetailResult>> all = this.labelService.getAll(new LabelQueryParam(), context);
if (all == null || !all.isSuccess() || all.getData() == null) {
return Collections.emptyMap();
}
Map<String, LabelDetailResult> map = new HashMap<>(Math.max(16, all.getData().size() * 2));
for (LabelDetailResult row : all.getData()) {
if (row != null && row.getId() != null) {
map.put(row.getId(), row);
}
}
return map;
}
private void fillLabelDetailsFromMap(List<String> labelIds, Map<String, LabelDetailResult> labelById,
List<LabelDetailResult> out, CloudwalkCallContext context) throws ServiceException {
if (CollectionUtils.isEmpty(labelIds)) {
return;
}
for (String labelId : labelIds) {
LabelDetailResult cached = (labelById != null) ? labelById.get(labelId) : null;
if (cached != null) {
out.add(cached);
continue;
}
LabelDetailParam p = new LabelDetailParam();
p.setId(labelId);
CloudwalkResult<LabelDetailResult> detail = this.labelService.detail(p, context);
if (detail != null && detail.isSuccess() && detail.getData() != null) {
out.add(detail.getData());
}
}
}
private CloudwalkPageAble<ImageStorePersonResult> getImageStorePerson(AcsPersonQueryParam param,
CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
CloudwalkPageAble<ImageStorePersonResult> results = new CloudwalkPageAble();
ImageStorePersonQueryParam imageStorePersonQueryParam = new ImageStorePersonQueryParam();
imageStorePersonQueryParam.setImageStoreId(param.getImageStoreId());
imageStorePersonQueryParam.setOrganizationIds(param.getOrganizationIds());
imageStorePersonQueryParam.setLabelIds(param.getLabelIds());
imageStorePersonQueryParam.setCurrentPage(pageInfo.getCurrentPage());
imageStorePersonQueryParam.setRowsOfPage(pageInfo.getPageSize());
imageStorePersonQueryParam.setIsElevator(param.getIsElevator());
imageStorePersonQueryParam.setDelPersonIds(param.getDelPersonIds());
CloudwalkResult<CloudwalkPageAble<ImageStorePersonResult>> pageResult =
this.imageStorePersonService.page(imageStorePersonQueryParam, context);
if (!pageResult.isSuccess()) {
this.logger.error("远程调用查询图库人员失败,原因:[{}]", pageResult.getMessage());
throw new ServiceException(pageResult.getCode(), pageResult.getMessage());
}
if (!CollectionUtils.isEmpty(((CloudwalkPageAble)pageResult.getData()).getDatas())) {
results = (CloudwalkPageAble<ImageStorePersonResult>)pageResult.getData();
}
return results;
}
private ImageRuleRefListResult refListByZoneId(String zoneId) {
ImageRuleRefListResult listResult = new ImageRuleRefListResult();
List<String> includeLabels = new ArrayList<>();
List<String> includeOrganizations = new ArrayList<>();
List<String> parentRuleList = this.imageRuleRefDao.listRuleByZoneIdExtDefault(zoneId);
if (!CollectionUtils.isEmpty(parentRuleList)) {
List<ImageRuleRefResultDto> child = this.imageRuleRefDao.listByParentRule(parentRuleList);
if (!CollectionUtils.isEmpty(child)) {
for (ImageRuleRefResultDto resultDto : child) {
if (!ObjectUtils.isEmpty(resultDto.getIncludeLabels())) {
includeLabels.add(resultDto.getExcludeLabels());
continue;
}
if (!ObjectUtils.isEmpty(resultDto.getIncludeOrganizations())) {
includeOrganizations.add(resultDto.getIncludeOrganizations());
}
}
}
}
listResult.setIncludeLabels(includeLabels);
listResult.setIncludeOrganizations(includeOrganizations);
return listResult;
}
private ImageRuleRefAddDto createAddDto(AcsPassRuleNewParam param, CloudwalkCallContext context) {
ImageRuleRefAddDto dto = new ImageRuleRefAddDto();
dto.setId(genUUID());
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setName(param.getRuleName());
dto.setZoneId(param.getZoneId());
dto.setZoneName(param.getZoneName());
dto.setStartTime(param.getStartTime());
dto.setEndTime(param.getEndTime());
if (!ObjectUtils.isEmpty(param.getIsDefault())) {
dto.setIsDefault(param.getIsDefault());
} else {
dto.setIsDefault(Integer.valueOf(0));
}
dto.setCreateTime(Long.valueOf(System.currentTimeMillis()));
dto.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
return dto;
}
private ImageRuleRefAddDto createUpdateDto(AcsPassRuleEditParam param, CloudwalkCallContext context) {
ImageRuleRefAddDto dto = new ImageRuleRefAddDto();
dto.setId(genUUID());
dto.setBusinessId(context.getCompany().getCompanyId());
dto.setName(param.getRuleName());
dto.setZoneId(param.getZoneId());
dto.setZoneName(param.getZoneName());
dto.setStartTime(param.getStartTime());
dto.setEndTime(param.getEndTime());
dto.setCreateTime(Long.valueOf(System.currentTimeMillis()));
dto.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
dto.setIsDefault(Integer.valueOf(0));
return dto;
}
private ImageRuleRefResultDto checkDefaultRule(String id) throws ServiceException {
try {
ImageRuleRefResultDto resultDto = this.imageRuleRefDao.getById(id);
if (!ObjectUtils.isEmpty(resultDto.getIsDefault()) && resultDto.getIsDefault().intValue() == 1) {
throw new ServiceException("派梯默认规则不可编辑和删除");
}
return resultDto;
} catch (DataAccessException e) {
throw new ServiceException("派梯默认规则不可编辑和删除");
}
}
}
@@ -0,0 +1,6 @@
/**
* 通行/人员规则与图库规则引用:规则增删、与区域/标签/组织维度的组合,及与设备任务的协作。
* <p>
* 与 {@code person} 包在“按人下发”和“按规则下发”两种路径上常共同出现在设备任务流中。
*/
package cn.cloudwalk.elevator.passrule;
@@ -0,0 +1,37 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
import org.hibernate.validator.constraints.NotEmpty;
public class AcsPassRuleDeleteParam implements Serializable {
private static final long serialVersionUID = -40026518356914854L;
@NotEmpty(message = "76260515")
private List<String> ids;
private String zoneId;
private String parentId;
public List<String> getIds() {
return this.ids;
}
public void setIds(List<String> ids) {
this.ids = ids;
}
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
}
@@ -0,0 +1,112 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotBlank;
public class AcsPassRuleEditParam implements Serializable {
private static final long serialVersionUID = 924203126937866288L;
@NotBlank(message = "76260515")
private String id;
private String parentId;
private String zoneId;
private String zoneName;
@NotBlank(message = "76260514")
@Size(min = 1, max = 32, message = "76260518")
private String ruleName;
private String oldName;
private List<String> includeOrganizations;
private List<String> includeLabels;
private List<String> excludeLabels;
private Long startTime;
private Long endTime;
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getOldName() {
return this.oldName;
}
public void setOldName(String oldName) {
this.oldName = oldName;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return this.zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getRuleName() {
return this.ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public List<String> getIncludeOrganizations() {
return this.includeOrganizations;
}
public void setIncludeOrganizations(List<String> includeOrganizations) {
this.includeOrganizations = includeOrganizations;
}
public List<String> getIncludeLabels() {
return this.includeLabels;
}
public void setIncludeLabels(List<String> includeLabels) {
this.includeLabels = includeLabels;
}
public List<String> getExcludeLabels() {
return this.excludeLabels;
}
public void setExcludeLabels(List<String> excludeLabels) {
this.excludeLabels = excludeLabels;
}
public Long getStartTime() {
return this.startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return this.endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
}
@@ -0,0 +1,17 @@
package cn.cloudwalk.elevator.passrule.param;
import cn.cloudwalk.cloud.page.CloudwalkBasePageForm;
import java.io.Serializable;
public class AcsPassRuleFloorParam extends CloudwalkBasePageForm implements Serializable {
private static final long serialVersionUID = 137892620174267456L;
private String zoneId;
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
}
@@ -0,0 +1,53 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
public class AcsPassRuleImageParam implements Serializable {
private static final long serialVersionUID = -52687427633888290L;
private List<String> imageStoreIds;
private String businessId;
private String personId;
private List<String> includeOrganizations;
private List<String> includeLabels;
public List<String> getImageStoreIds() {
return this.imageStoreIds;
}
public void setImageStoreIds(List<String> imageStoreIds) {
this.imageStoreIds = imageStoreIds;
}
public String getBusinessId() {
return this.businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getPersonId() {
return this.personId;
}
public void setPersonId(String personId) {
this.personId = personId;
}
public List<String> getIncludeOrganizations() {
return this.includeOrganizations;
}
public void setIncludeOrganizations(List<String> includeOrganizations) {
this.includeOrganizations = includeOrganizations;
}
public List<String> getIncludeLabels() {
return this.includeLabels;
}
public void setIncludeLabels(List<String> includeLabels) {
this.includeLabels = includeLabels;
}
}
@@ -0,0 +1,16 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
public class AcsPassRuleIsDefaultParam implements Serializable {
private static final long serialVersionUID = 137892620174267456L;
private String zoneId;
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
}
@@ -0,0 +1,102 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotBlank;
public class AcsPassRuleNewParam implements Serializable {
private static final long serialVersionUID = 137892620174267456L;
private String parentId;
private String zoneId;
private String zoneName;
@NotBlank(message = "76260514")
@Size(min = 1, max = 32, message = "76260518")
private String ruleName;
private List<String> includeLabels;
private List<String> includeOrganizations;
private List<String> excludeLabels;
private Long startTime;
private Long endTime;
private Integer isDefault;
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return this.zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getRuleName() {
return this.ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public List<String> getIncludeLabels() {
return this.includeLabels;
}
public void setIncludeLabels(List<String> includeLabels) {
this.includeLabels = includeLabels;
}
public List<String> getIncludeOrganizations() {
return this.includeOrganizations;
}
public void setIncludeOrganizations(List<String> includeOrganizations) {
this.includeOrganizations = includeOrganizations;
}
public List<String> getExcludeLabels() {
return this.excludeLabels;
}
public void setExcludeLabels(List<String> excludeLabels) {
this.excludeLabels = excludeLabels;
}
public Long getStartTime() {
return this.startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return this.endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
public Integer getIsDefault() {
return this.isDefault;
}
public void setIsDefault(Integer isDefault) {
this.isDefault = isDefault;
}
}
@@ -0,0 +1,18 @@
package cn.cloudwalk.elevator.passrule.param;
import cn.cloudwalk.cloud.page.CloudwalkBasePageForm;
import java.io.Serializable;
import java.util.List;
public class AcsPassRulePersonListParam extends CloudwalkBasePageForm implements Serializable {
private static final long serialVersionUID = -52687427633888290L;
private List<AcsPassRuleImageParam> personList;
public List<AcsPassRuleImageParam> getPersonList() {
return this.personList;
}
public void setPersonList(List<AcsPassRuleImageParam> personList) {
this.personList = personList;
}
}
@@ -0,0 +1,61 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
public class AcsPassRuleQueryParam implements Serializable {
private static final long serialVersionUID = -31004388036379268L;
private String id;
private String parentId;
private String zoneId;
private String zoneName;
private String imageStoreId;
private Integer isDefault;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getImageStoreId() {
return this.imageStoreId;
}
public void setImageStoreId(String imageStoreId) {
this.imageStoreId = imageStoreId;
}
public String getZoneName() {
return this.zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public Integer getIsDefault() {
return this.isDefault;
}
public void setIsDefault(Integer isDefault) {
this.isDefault = isDefault;
}
}
@@ -0,0 +1,48 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotBlank;
public class AcsPassTimeAddParam implements Serializable {
private static final long serialVersionUID = 8600793178515359164L;
@NotBlank(message = "76260512")
@Size(min = 1, max = 64, message = "76260519")
private String passableTimeName;
private Long beginDate;
private Long endDate;
private List<AcsPassTimeCycleParam> passableCycle;
public String getPassableTimeName() {
return this.passableTimeName;
}
public void setPassableTimeName(String passableTimeName) {
this.passableTimeName = passableTimeName;
}
public Long getBeginDate() {
return this.beginDate;
}
public void setBeginDate(Long beginDate) {
this.beginDate = beginDate;
}
public Long getEndDate() {
return this.endDate;
}
public void setEndDate(Long endDate) {
this.endDate = endDate;
}
public List<AcsPassTimeCycleParam> getPassableCycle() {
return this.passableCycle;
}
public void setPassableCycle(List<AcsPassTimeCycleParam> passableCycle) {
this.passableCycle = passableCycle;
}
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
public class AcsPassTimeCycleParam implements Serializable {
private static final long serialVersionUID = 9084516985152275888L;
private int weekday;
private List<AcsPassTimeParam> time;
public int getWeekday() {
return this.weekday;
}
public void setWeekday(int weekday) {
this.weekday = weekday;
}
public List<AcsPassTimeParam> getTime() {
return this.time;
}
public void setTime(List<AcsPassTimeParam> time) {
this.time = time;
}
}
@@ -0,0 +1,19 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
import org.hibernate.validator.constraints.NotEmpty;
public class AcsPassTimeDeleteParam implements Serializable {
private static final long serialVersionUID = -1142611457619464538L;
@NotEmpty(message = "76260513")
private List<String> ids;
public List<String> getIds() {
return this.ids;
}
public void setIds(List<String> ids) {
this.ids = ids;
}
}
@@ -0,0 +1,58 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotBlank;
public class AcsPassTimeEditParam implements Serializable {
private static final long serialVersionUID = -8271994630899900554L;
@NotBlank(message = "76260513")
private String id;
@NotBlank(message = "76260512")
@Size(min = 1, max = 64, message = "76260519")
private String passableTimeName;
private Long beginDate;
private Long endDate;
private List<AcsPassTimeCycleParam> passableCycle;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getPassableTimeName() {
return this.passableTimeName;
}
public void setPassableTimeName(String passableTimeName) {
this.passableTimeName = passableTimeName;
}
public Long getBeginDate() {
return this.beginDate;
}
public void setBeginDate(Long beginDate) {
this.beginDate = beginDate;
}
public Long getEndDate() {
return this.endDate;
}
public void setEndDate(Long endDate) {
this.endDate = endDate;
}
public List<AcsPassTimeCycleParam> getPassableCycle() {
return this.passableCycle;
}
public void setPassableCycle(List<AcsPassTimeCycleParam> passableCycle) {
this.passableCycle = passableCycle;
}
}
@@ -0,0 +1,25 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
public class AcsPassTimeParam implements Serializable {
private static final long serialVersionUID = 7496987389322298594L;
private String beginTime;
private String endTime;
public String getBeginTime() {
return this.beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
public String getEndTime() {
return this.endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}
@@ -0,0 +1,18 @@
package cn.cloudwalk.elevator.passrule.param;
import java.io.Serializable;
import org.hibernate.validator.constraints.NotBlank;
public class AcsPassTimeQueryParam implements Serializable {
private static final long serialVersionUID = 7311660131290856391L;
@NotBlank(message = "76260513")
private String id;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
}
@@ -0,0 +1,136 @@
package cn.cloudwalk.elevator.passrule.result;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult;
import cn.cloudwalk.elevator.passrule.param.AcsPassTimeCycleParam;
import java.util.List;
public class AcsPassRuleDetailResult {
private static final long serialVersionUID = -90554404684210529L;
private String id;
private String ruleName;
private String imageStoreId;
private String zoneId;
private String zoneName;
private Long beginDate;
private Long endDate;
private String validDateCron;
private String validDateJson;
private List<LabelResult> excludeLabels;
private List<OrganizationResult> includeOrganizations;
private List<LabelResult> includeLabels;
private List<AcsPassTimeCycleParam> passableCycle;
private Integer passType;
public String getRuleName() {
return this.ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getImageStoreId() {
return this.imageStoreId;
}
public void setImageStoreId(String imageStoreId) {
this.imageStoreId = imageStoreId;
}
public Long getBeginDate() {
return this.beginDate;
}
public void setBeginDate(Long beginDate) {
this.beginDate = beginDate;
}
public Long getEndDate() {
return this.endDate;
}
public void setEndDate(Long endDate) {
this.endDate = endDate;
}
public String getValidDateCron() {
return this.validDateCron;
}
public void setValidDateCron(String validDateCron) {
this.validDateCron = validDateCron;
}
public String getValidDateJson() {
return this.validDateJson;
}
public void setValidDateJson(String validDateJson) {
this.validDateJson = validDateJson;
}
public List<LabelResult> getExcludeLabels() {
return this.excludeLabels;
}
public void setExcludeLabels(List<LabelResult> excludeLabels) {
this.excludeLabels = excludeLabels;
}
public List<OrganizationResult> getIncludeOrganizations() {
return this.includeOrganizations;
}
public void setIncludeOrganizations(List<OrganizationResult> includeOrganizations) {
this.includeOrganizations = includeOrganizations;
}
public List<LabelResult> getIncludeLabels() {
return this.includeLabels;
}
public void setIncludeLabels(List<LabelResult> includeLabels) {
this.includeLabels = includeLabels;
}
public List<AcsPassTimeCycleParam> getPassableCycle() {
return this.passableCycle;
}
public void setPassableCycle(List<AcsPassTimeCycleParam> passableCycle) {
this.passableCycle = passableCycle;
}
public Integer getPassType() {
return this.passType;
}
public void setPassType(Integer passType) {
this.passType = passType;
}
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return this.zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
}
@@ -0,0 +1,101 @@
package cn.cloudwalk.elevator.passrule.result;
import java.io.Serializable;
public class AcsPassRuleFloorResult implements Serializable {
private static final long serialVersionUID = -90554404684210529L;
private String id;
private String name;
private Integer deviceNumber;
private Integer unitNumber;
private Long personNumber;
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setDeviceNumber(Integer deviceNumber) {
this.deviceNumber = deviceNumber;
}
public void setUnitNumber(Integer unitNumber) {
this.unitNumber = unitNumber;
}
public void setPersonNumber(Long personNumber) {
this.personNumber = personNumber;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof AcsPassRuleFloorResult))
return false;
AcsPassRuleFloorResult other = (AcsPassRuleFloorResult)o;
if (!other.canEqual(this))
return false;
Object this$id = getId(), other$id = other.getId();
if ((this$id == null) ? (other$id != null) : !this$id.equals(other$id))
return false;
Object this$name = getName(), other$name = other.getName();
if ((this$name == null) ? (other$name != null) : !this$name.equals(other$name))
return false;
Object this$deviceNumber = getDeviceNumber(), other$deviceNumber = other.getDeviceNumber();
if ((this$deviceNumber == null) ? (other$deviceNumber != null) : !this$deviceNumber.equals(other$deviceNumber))
return false;
Object this$unitNumber = getUnitNumber(), other$unitNumber = other.getUnitNumber();
if ((this$unitNumber == null) ? (other$unitNumber != null) : !this$unitNumber.equals(other$unitNumber))
return false;
Object this$personNumber = getPersonNumber(), other$personNumber = other.getPersonNumber();
return !((this$personNumber == null) ? (other$personNumber != null)
: !this$personNumber.equals(other$personNumber));
}
protected boolean canEqual(Object other) {
return other instanceof AcsPassRuleFloorResult;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $id = getId();
result = result * 59 + (($id == null) ? 43 : $id.hashCode());
Object $name = getName();
result = result * 59 + (($name == null) ? 43 : $name.hashCode());
Object $deviceNumber = getDeviceNumber();
result = result * 59 + (($deviceNumber == null) ? 43 : $deviceNumber.hashCode());
Object $unitNumber = getUnitNumber();
result = result * 59 + (($unitNumber == null) ? 43 : $unitNumber.hashCode());
Object $personNumber = getPersonNumber();
return result * 59 + (($personNumber == null) ? 43 : $personNumber.hashCode());
}
public String toString() {
return "AcsPassRuleFloorResult(id=" + getId() + ", name=" + getName() + ", deviceNumber=" + getDeviceNumber()
+ ", unitNumber=" + getUnitNumber() + ", personNumber=" + getPersonNumber() + ")";
}
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public Integer getDeviceNumber() {
return this.deviceNumber;
}
public Integer getUnitNumber() {
return this.unitNumber;
}
public Long getPersonNumber() {
return this.personNumber;
}
}
@@ -0,0 +1,155 @@
package cn.cloudwalk.elevator.passrule.result;
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStorePersonResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult;
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult;
import java.io.Serializable;
import java.util.List;
public class AcsPassRuleResult implements Serializable {
private static final long serialVersionUID = -90554404684210529L;
private String id;
private String ruleName;
private int personSum;
private String imageStoreId;
private String passableTimeName;
private String zoneId;
private Long beginDate;
private Long endDate;
private String validDateCron;
private String validDateJson;
private List<LabelResult> excludeLabels;
private List<OrganizationResult> includeOrganizations;
private List<LabelResult> includeLabels;
private List<ImgStorePersonResult> includePersons;
private Integer passType;
private Integer isDefault;
public String getRuleName() {
return this.ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public int getPersonSum() {
return this.personSum;
}
public void setPersonSum(int personSum) {
this.personSum = personSum;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getImageStoreId() {
return this.imageStoreId;
}
public void setImageStoreId(String imageStoreId) {
this.imageStoreId = imageStoreId;
}
public String getZoneId() {
return this.zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public Long getBeginDate() {
return this.beginDate;
}
public void setBeginDate(Long beginDate) {
this.beginDate = beginDate;
}
public Long getEndDate() {
return this.endDate;
}
public void setEndDate(Long endDate) {
this.endDate = endDate;
}
public String getValidDateCron() {
return this.validDateCron;
}
public void setValidDateCron(String validDateCron) {
this.validDateCron = validDateCron;
}
public String getValidDateJson() {
return this.validDateJson;
}
public void setValidDateJson(String validDateJson) {
this.validDateJson = validDateJson;
}
public List<LabelResult> getExcludeLabels() {
return this.excludeLabels;
}
public void setExcludeLabels(List<LabelResult> excludeLabels) {
this.excludeLabels = excludeLabels;
}
public List<OrganizationResult> getIncludeOrganizations() {
return this.includeOrganizations;
}
public void setIncludeOrganizations(List<OrganizationResult> includeOrganizations) {
this.includeOrganizations = includeOrganizations;
}
public List<LabelResult> getIncludeLabels() {
return this.includeLabels;
}
public void setIncludeLabels(List<LabelResult> includeLabels) {
this.includeLabels = includeLabels;
}
public String getPassableTimeName() {
return this.passableTimeName;
}
public void setPassableTimeName(String passableTimeName) {
this.passableTimeName = passableTimeName;
}
public List<ImgStorePersonResult> getIncludePersons() {
return this.includePersons;
}
public void setIncludePersons(List<ImgStorePersonResult> includePersons) {
this.includePersons = includePersons;
}
public Integer getPassType() {
return this.passType;
}
public void setPassType(Integer passType) {
this.passType = passType;
}
public Integer getIsDefault() {
return this.isDefault;
}
public void setIsDefault(Integer isDefault) {
this.isDefault = isDefault;
}
}

Some files were not shown because too many files have changed in this diff Show More