WorkCamera/.kiro/specs/work-camera-2.0/tasks.md
2026-01-05 21:20:55 +08:00

217 lines
8.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Implementation Plan: 随工水印相机 2.0
## Overview
本实现计划分为五个阶段:后端 COS 集成、前端上传改造、导出 API 开发、CS 客户端开发、历史数据迁移。采用增量开发方式,每个阶段完成后进行验证。
## Tasks
- [x] 1. 后端 COS 集成与配置
- [x] 1.1 添加腾讯云 COS SDK 依赖
-`ZR.Common` 项目中添加 `Tencent.QCloud.Cos.Sdk` NuGet 包
- _Requirements: 1.1_
- [x] 1.2 创建 COS 配置模型
-`Infrastructure/Model/OptionsSetting.cs` 中添加 `TencentCOS` 配置类
- 包含 AppId, Region, SecretId, SecretKey, BucketName, DomainUrl, MaxSize, DurationSecond, Prefixes
- _Requirements: 1.1_
- [x] 1.3 更新 appsettings.json 配置
- 添加 TencentCOS 配置节
- _Requirements: 1.1_
- [x] 1.4 创建 CosService 服务类
- 创建 `ZR.Common/CosService.cs`
- 实现 `GetUploadUrls` 方法生成预签名 URL
- 实现 `GetTempCredentials` 方法获取临时密钥
- _Requirements: 1.1, 1.2, 1.3, 1.4, 1.5_
- [x] 1.5 编写 CosService 单元测试
- 测试 URL 生成逻辑
- 测试目录路径格式
- _Requirements: 1.1, 1.2, 1.4, 1.5_
- [x] 2. COS 预签名 URL 接口
- [x] 2.1 创建 COS 相关 DTO
-`ZR.Model/Business/Dto` 中创建 `CosUploadUrlsRequest.cs`
- 创建 `CosUploadUrlsResponse.cs`
- _Requirements: 1.1, 1.2_
- [x] 2.2 创建 CosController
-`ZR.Admin.WebApi/Controllers` 中创建 `CosController.cs`
- 实现 `POST /api/cos/getUploadUrls` 接口
- 实现 `GET /api/cos/getTempCredentials` 接口
- _Requirements: 1.1, 1.2, 1.3_
- [x] 2.3 编写属性测试 - URL 生成完整性
- **Property 1: Pre-signed URL Generation Completeness**
- **Validates: Requirements 1.1, 1.2, 1.4, 1.5**
- [x] 3. Checkpoint - COS 集成验证
- 确保 COS 配置正确加载
- 确保预签名 URL 接口可正常调用
- 确保所有测试通过,如有问题请询问用户
- [x] 4. 工作记录 V3 接口
- [x] 4.1 创建 V3 DTO
-`ZR.Model/Business/Dto` 中创建 `CamRecordWorkV3Dto.cs`
- 包含 ImageUrls 字段替代 Image/Images
- _Requirements: 3.1, 3.2_
- [x] 4.2 实现 V3 保存接口
-`CommonController.cs` 中添加 `AddCamWorkRecordV3` 方法
- 路由: `POST /addworkrecordv3`
- 验证 COS URL 格式
- 复用现有数据库存储逻辑
- _Requirements: 3.1, 3.2, 3.3, 3.4, 3.5_
- [x] 4.3 编写属性测试 - COS URL 验证
- **Property 2: COS URL Validation**
- **Validates: Requirements 3.3**
- [x] 4.4 编写属性测试 - V3 记录保存完整性
- **Property 3: V3 Record Save Integrity**
- **Validates: Requirements 3.1, 3.4**
- [x] 5. Checkpoint - V3 接口验证
- 确保 V3 接口可正常保存记录
- 确保图片 URL 正确存储
- 确保所有测试通过,如有问题请询问用户
- [x] 6. 数据导出 API
- [x] 6.1 创建导出查询 DTO
-`ZR.Model/Business/Dto` 中创建 `WorkRecordExportQueryDto.cs`
- 创建 `WorkRecordExportDto.cs`
- _Requirements: 4.1, 4.3, 4.4_
- [x] 6.2 创建导出 Service
-`ZR.Service/Business` 中创建 `WorkRecordExportService.cs`
- 实现分页查询逻辑
- 实现过滤逻辑(日期、部门、人员、内容)
- _Requirements: 4.1, 4.2, 4.3, 4.4_
- [x] 6.3 创建导出 Controller
-`ZR.Admin.WebApi/Controllers` 中创建 `WorkRecordExportController.cs`
- 实现 `GET /api/workrecord/export/list` 接口
- 添加认证要求
- _Requirements: 4.1, 4.2, 4.3, 4.4, 4.5_
- [x] 6.4 编写属性测试 - 分页一致性
- **Property 4: Export Pagination Consistency**
- **Validates: Requirements 4.1, 4.2, 4.4**
- [x] 6.5 编写属性测试 - 过滤准确性
- **Property 5: Export Filter Accuracy**
- **Validates: Requirements 4.3**
- [x] 7. Checkpoint - 导出 API 验证
- 确保分页查询正常工作
- 确保过滤条件正确应用
- 确保所有测试通过,如有问题请询问用户
- [x] 8. 历史数据迁移 API
- [x] 8.1 创建迁移相关 DTO
-`ZR.Model/Business/Dto` 中创建 `MigrationQueryDto.cs`
- 创建 `MigrationRecordDto.cs`
- 创建 `MigrationUpdateDto.cs`
- _Requirements: 10.1, 10.2, 10.3_
- [x] 8.2 创建迁移 Service
-`ZR.Service/Business` 中创建 `WorkRecordMigrationService.cs`
- 实现待迁移记录查询(根据 URL 域名判断)
- 实现 URL 更新逻辑
- _Requirements: 10.1, 10.2, 10.3, 10.4_
- [x] 8.3 创建迁移 Controller
-`ZR.Admin.WebApi/Controllers` 中创建 `WorkRecordMigrationController.cs`
- 实现 `GET /api/workrecord/migration/list` 接口
- 实现 `POST /api/workrecord/migration/update` 接口
- _Requirements: 10.1, 10.2, 10.3, 10.4_
- [x] 8.4 编写属性测试 - 迁移列表过滤
- **Property 6: Migration List Filter**
- **Validates: Requirements 10.1, 10.2**
- [x] 8.5 编写属性测试 - 迁移 URL 更新完整性
- **Property 7: Migration URL Update Integrity**
- **Validates: Requirements 10.3, 10.4**
- [x] 9. Checkpoint - 后端 API 完成验证
- 确保所有后端 API 正常工作
- 确保所有测试通过,如有问题请询问用户
- [x] 10. 前端 UniApp 上传改造
- [x] 10.1 创建 COS 上传服务
-`uniapp/WorkCameraf/common` 中创建 `cosUpload.js`
- 实现获取预签名 URL 方法
- 实现直传 COS 方法PUT 请求)
- _Requirements: 2.1, 2.2, 2.3, 2.4_
- [x] 10.2 修改 server.js 添加 V3 接口调用
- 添加 `addWatermarkRecordV3` 方法
- 调用 `/addworkrecordv3` 接口
- _Requirements: 3.1, 3.2_
- [x] 10.3 修改上传流程
- 修改拍照后的上传逻辑
- 先获取预签名 URL
- 并发上传到 COS最多 3 个并发)
- 上传成功后调用 V3 接口保存记录
- _Requirements: 2.1, 2.2, 2.3, 2.4, 3.1_
- [x] 11. Checkpoint - 前端上传验证
- 确保前端可正常上传图片到 COS
- 确保工作记录正确保存
- 如有问题请询问用户
- [x] 12. CS 客户端项目搭建
- [x] 12.1 创建 WinForms 项目
- 创建 `WorkCameraExport` 解决方案
- 配置 .NET 8 AOT 单文件发布
- 添加 EPPlus、SixLabors.ImageSharp 依赖
- _Requirements: 5.1, 7.3, 7.4_
- [x] 12.2 创建 API 服务类
- 创建 `Services/ApiService.cs`
- 实现登录、查询、迁移等 API 调用
- _Requirements: 5.1, 5.2, 4.1_
- [x] 12.3 创建 COS 服务类
- 创建 `Services/CosService.cs`
- 实现图片上传到 COS
- _Requirements: 9.2_
- [x] 13. CS 客户端登录模块
- [x] 13.1 创建登录窗体
- 创建 `Forms/LoginForm.cs`
- 包含服务器地址、用户名、密码输入
- 实现记住登录状态功能
- _Requirements: 5.1, 5.2, 5.3, 5.4_
- [x] 14. CS 客户端导出模块
- [x] 14.1 创建主窗体
- 创建 `Forms/MainForm.cs`
- 包含查询条件区域(日期、部门、人员、内容)
- 包含数据预览区域
- 包含导出进度区域
- _Requirements: 6.1, 6.2, 6.3, 7.5_
- [x] 14.2 创建 Excel 服务类
- 创建 `Services/ExcelService.cs`
- 实现 Excel 生成逻辑
- 实现图片嵌入逻辑100x60 像素50% 压缩)
- _Requirements: 7.3, 7.4_
- [x] 14.3 实现导出功能
- 实现分页获取数据
- 实现并发下载图片(最多 5 个并发)
- 实现进度显示
- 实现取消功能
- _Requirements: 7.1, 7.2, 7.5, 7.6, 7.7_
- [x] 15. CS 客户端迁移模块
- [x] 15.1 创建迁移窗体
- 创建 `Forms/MigrationForm.cs`
- 包含筛选条件区域
- 包含待迁移记录列表
- 包含迁移进度区域
- _Requirements: 8.1, 8.2, 8.3, 8.4_
- [x] 15.2 实现迁移功能
- 实现下载原图片
- 实现上传到 COS
- 实现调用 API 更新 URL
- 实现进度显示和取消功能
- _Requirements: 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7_
- [x] 16. Final Checkpoint - 全功能验证
- 确保所有功能正常工作
- 确保所有测试通过
- 如有问题请询问用户
## Notes
- All tasks are required for complete implementation
- Each task references specific requirements for traceability
- Checkpoints ensure incremental validation
- Property tests validate universal correctness properties
- 后端使用 C# / .NET 8
- 前端使用 UniApp (Vue.js)
- CS 客户端使用 WinForms + .NET 8 AOT