WorkCamera/client/README.md
2026-01-10 14:45:55 +08:00

230 lines
6.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.

# 随工水印相机导出工具 (WorkCameraExport)
Windows 桌面应用程序,用于管理和导出工作现场拍摄的水印照片记录。
## 功能特性
### 工作记录管理
- 查询、浏览工作记录(支持按日期、部门、地址、内容、人员等筛选)
- 编辑工作记录信息
- 查看记录关联的照片
### 数据导出
- 导出工作记录到 Excel含嵌入图片
- 按月份下载照片并打包成 ZIP
- ZIP 按目录结构分类:当日照片、参与人员、工作内容、部门
### 月报表
- 生成月度工作统计报表
- 导出月报表 Excel
### 其他功能
- 用户登录 / 自动登录
- 网络状态监控
- 图片下载压缩处理
- 历史数据迁移
## 技术栈
- .NET 8 Windows Forms
- EPPlusExcel 生成)
- SixLabors.ImageSharp图片处理
- 腾讯云 COS SDK云存储
## 项目结构
```
WorkCameraExport/
├── Forms/ # 窗体界面
│ ├── LoginForm # 登录窗体
│ ├── HomeForm # 主页(统计信息)
│ ├── WorkRecordForm # 工作记录管理
│ ├── MonthReportForm # 月报表
│ ├── MigrationForm # 数据迁移
│ ├── SettingsForm # 设置
│ └── ImageViewerForm # 图片查看器
├── Services/ # 业务服务
│ ├── ApiService # API 调用
│ ├── ExportService # 导出服务
│ ├── ImageService # 图片处理
│ ├── ExcelService # Excel 生成
│ ├── ConfigService # 配置管理
│ ├── LogService # 日志服务
│ └── CosService # 腾讯云 COS
├── Models/ # 数据模型
└── Properties/ # 项目属性
```
## 开发环境
- Visual Studio 2022
- .NET 8 SDK
- Windows 10/11
## 构建与发布
```bash
# 构建
dotnet build
# 发布单文件可执行程序
dotnet publish -c Release
```
## 配置说明
应用配置文件位于用户目录下,首次运行时自动创建。
主要配置项:
- 服务器地址
- 图片下载并发数
- 图片压缩质量
- 自动清理临时文件
## 工作记录导出流程
### 1. 导出全部数据
```
点击"导出全部" → 构建查询条件 → 分页获取所有数据 → 下载图片 → 生成 Excel
WorkRecordForm.ExportAllAsync()
ExportService.ExportWorkRecordsAsync(query, outputPath, progress)
FetchAllRecordsAsync() // 分页获取数据
循环调用 API: GET /business/CamWorkrecord/list?pageNum=X&pageSize=50&...
DownloadImagesAsync() // 并发下载图片
ExcelService.ExportWorkRecordsToExcelAsync() // 生成 Excel
```
### 2. 导出选中数据
```
勾选记录 → 点击"导出选中" → 逐个获取记录详情 → 下载图片 → 生成 Excel
WorkRecordForm.ExportSelectedAsync(ids)
ExportService.ExportWorkRecordsByIdsAsync(ids, outputPath, progress)
循环调用 API: GET /business/CamWorkrecord/{id} // 获取每条记录详情
DownloadImagesAsync() // 并发下载图片
ExcelService.ExportWorkRecordsToExcelAsync() // 生成 Excel
```
### API 接口汇总
| 接口 | 方法 | 说明 |
|------|------|------|
| `/business/CamWorkrecord/list` | GET | 分页查询工作记录列表 |
| `/business/CamWorkrecord/{id}` | GET | 获取单条工作记录详情 |
| `/business/CamWorkrecord` | POST | 新增工作记录 |
| `/business/CamWorkrecord` | PUT | 更新工作记录 |
| `/business/CamWorkrecord/{id}` | DELETE | 删除工作记录 |
| `/business/CamWorkers/list` | GET | 获取月报表数据 |
| `/api/workrecord/monthImages` | GET | 获取指定月份的所有图片 |
| `/api/workrecord/statistics` | GET | 获取统计信息 |
| `/api/cos/getTempCredentials` | GET | 获取 COS 临时密钥 |
| `/api/workrecord/migration/list` | GET | 查询待迁移记录 |
| `/api/workrecord/migration/update` | POST | 更新迁移后的 URL |
### 查询参数说明
工作记录查询 (`/business/CamWorkrecord/list`):
- `pageNum` - 页码
- `pageSize` - 每页数量
- `startDate` - 开始日期
- `endDate` - 结束日期
- `deptName` - 部门名称
- `address` - 地址
- `content` - 工作内容
- `workerName` - 人员名称
- `statusName` - 状态
月报表查询 (`/business/CamWorkers/list`):
- `yearMonth` - 月份 (YYYY-MM)
- `workerName` - 人员名称
---
## 月报表功能流程
### 1. 查询月报表
```
用户选择月份 → 调用 API 获取数据 → 显示到表格
MonthReportForm.LoadDataAsync()
ApiService.GetMonthlyReportAsync(query)
返回 List<MonthlyReportDto>(月份、部门、人员、工作天数)
```
### 2. 导出月报表 Excel
```
点击"导出 Excel" → 生成文件名 → 调用导出服务 → 保存文件
MonthReportForm.ExportExcelAsync()
ExportService.ExportMonthlyReportAsync(data, outputPath)
ExcelService.ExportMonthlyReportToExcelAsync()
生成 Excel序号、时间、部门、人员、工作天数
保存到 PathService.ExportDirectory
```
### 3. 下载照片 ZIP
```
点击"下载照片" → 获取月份图片列表 → 并发下载图片 → 按目录结构保存 → 打包 ZIP
MonthReportForm.DownloadPhotosZipAsync()
ExportService.DownloadPhotosZipAsync(yearMonth, outputPath, progress)
ApiService.GetMonthImagesAsync(yearMonth) // 获取图片列表
ImageService.DownloadImageAsync() // 逐个下载
CreateDirectoryStructure() // 创建目录结构
ZipFile.CreateFromDirectory() // 打包
```
### ZIP 目录结构
```
workfiles/
└── {yyyyMM}/
└── {yyyyMMdd}/
├── 当日照片/ # 当天所有照片
├── 参与人员/
│ ├── {人员A}/ # 按人员分类
│ └── {人员B}/
├── 工作内容/
│ └── {工作内容}/ # 按工作内容分类
└── 部门/
└── {部门名称}/ # 按部门分类
```
### 数据模型
| 模型 | 用途 |
|------|------|
| MonthReportQueryDto | 查询条件(月份、人员名称) |
| MonthlyReportDto | 月报表数据(月份、部门、人员、工作天数) |
| MonthImageDto | 月份图片记录ID、日期、部门、内容、人员、图片URL列表 |
## 版本历史
- v2.0.0 - 当前版本