feat: 完成任务-详情素材迁移到新逻辑
- 迁移57个老素材到新逻辑(本地zip + S3预览图) - 优化文件命名:SPU_作者_店铺_类型.zip - PSD文件单独存储,不打包进all.zip - 修复下载接口,优先使用本地zip文件 - 修复预览图重复问题 - 添加迁移脚本和验证脚本 - 更新文档和迁移计划 迁移统计: - 总素材数:77个 - 成功迁移:57个 - 新逻辑上传:18个 - 空记录:2个
548
.kiro/steering/任务-详情素材逻辑说明与迁移计划.md
Normal file
@ -0,0 +1,548 @@
|
||||
# 任务-详情素材逻辑说明与迁移计划
|
||||
|
||||
> **文档目的**: 记录"任务-详情"素材的老逻辑、新逻辑和迁移计划
|
||||
> **创建时间**: 2026-01-20
|
||||
> **最后更新**: 2026-01-20
|
||||
|
||||
---
|
||||
|
||||
## 一、迁移完成统计(2026-01-20)
|
||||
|
||||
### 最终结果
|
||||
|
||||
| 项目 | 数量 |
|
||||
|------|------|
|
||||
| 总素材数 | 77 个 |
|
||||
| ✅ 已成功迁移 | 75 个 |
|
||||
| ❌ 空记录(无需迁移) | 2 个 |
|
||||
|
||||
### 迁移详情
|
||||
|
||||
**第一轮迁移**(修复 zipFilePath='' 的素材):
|
||||
- 第一批:9 个成功
|
||||
- 第二批:8 个成功
|
||||
- 第三批:8 个成功
|
||||
- 第四批:3 个成功
|
||||
- **小计:28 个素材**
|
||||
|
||||
**第二轮迁移**(修复有 zipFilePath 但没有本地 zip 文件的素材):
|
||||
- 第一批:10 个成功
|
||||
- 第二批:9 个成功(1 个空素材失败)
|
||||
- 第三批:9 个成功(1 个文件名问题)
|
||||
- 第四批:1 个成功
|
||||
- **小计:29 个素材**
|
||||
|
||||
**第三轮迁移**(新逻辑上传的素材):
|
||||
- 18 个素材使用新逻辑上传,无需迁移
|
||||
|
||||
**总计本次迁移:57 个素材成功**
|
||||
|
||||
### 空记录说明
|
||||
|
||||
2 个空记录(无任务号,无资产):
|
||||
- CYJ0062 (紫苏) - 无任务号
|
||||
- GBPM-SN0208-389 (瑶光) - 无任务号
|
||||
|
||||
这些是测试数据或上传失败的记录,不需要迁移。
|
||||
|
||||
### 验证结果
|
||||
|
||||
使用 `scripts/verify-migrated-files.ts` 验证:
|
||||
- ✅ 所有文件存在:75 个
|
||||
- ⚠️ 部分文件缺失:0 个
|
||||
- ❌ 所有文件缺失:0 个
|
||||
- ❌ 没有 zip 记录:2 个(空记录)
|
||||
|
||||
**结论:迁移工作已全部完成!**
|
||||
|
||||
---
|
||||
|
||||
## 二、老逻辑(已废弃)
|
||||
|
||||
### 2.1 数据流程
|
||||
|
||||
```
|
||||
用户上传文件
|
||||
↓
|
||||
后台压缩生成预览图(像素偏高的预览图)
|
||||
↓
|
||||
预览图上传到 S3(存储类型:detail/main/sku)
|
||||
↓
|
||||
数据库保存 assetType = 'detail'/'main'/'sku'(指向 S3 URL)
|
||||
↓
|
||||
用户下载时:临时打包预览图并返回
|
||||
```
|
||||
|
||||
### 2.2 关键特点
|
||||
|
||||
1. **不保存原图**:原图在临时目录,上传完成后会被删除
|
||||
2. **只有预览图**:`material_asset` 表中只有 S3 预览图,没有本地 zip
|
||||
3. **下载时动态打包**:每次下载时,从 S3 下载预览图并临时打包
|
||||
4. **预览图质量高**:像素偏高,接近原图
|
||||
|
||||
### 2.3 数据库结构(老逻辑)
|
||||
|
||||
| 表 | 字段 | 说明 |
|
||||
|----|------|------|
|
||||
| `materials` | `zipFilePath` | 空 |
|
||||
| `materials` | `zipFileName` | 空 |
|
||||
| `materials` | `zipFileSize` | 空 |
|
||||
| `materials` | `previewUrl` | S3 预览图 URL |
|
||||
| `material_asset` | `assetType` | `'detail'`/`'main'`/`'sku'` |
|
||||
| `material_asset` | `fileUrl` | S3 预览图 URL |
|
||||
| `material_asset` | `fileName` | 预览图文件名(如 `detail-preview-0.webp`) |
|
||||
|
||||
### 2.4 示例数据
|
||||
|
||||
```sql
|
||||
-- materials 表
|
||||
{
|
||||
id: "7d01a3ab-8a99-4966-9f5e-53b5ef6cfad1",
|
||||
taskNo: "TASK202601201149497501-01-01",
|
||||
productModel: "CJ0252",
|
||||
previewUrl: "https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/detail-xxx.webp",
|
||||
zipFilePath: NULL
|
||||
}
|
||||
|
||||
-- material_asset 表
|
||||
{
|
||||
id: "xxx",
|
||||
materialId: "7d01a3ab-8a99-4966-9f5e-53b5ef6cfad1",
|
||||
assetType: "detail",
|
||||
fileUrl: "https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/detail-xxx.webp",
|
||||
fileName: "1200-欧.jpg"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 三、新逻辑(当前使用)
|
||||
|
||||
### 3.1 数据流程
|
||||
|
||||
```
|
||||
用户上传文件(分片上传)
|
||||
↓
|
||||
保存到本地临时目录
|
||||
↓
|
||||
├─→ 原图文件(临时目录)
|
||||
│ ↓
|
||||
│ 打包成分类 zip(main.zip / sku.zip / detail.zip)
|
||||
│ ↓
|
||||
│ 保存到本地永久目录
|
||||
│ ↓
|
||||
│ 数据库记录 assetType = 'main'/'sku'/'detail'(本地路径)
|
||||
│
|
||||
└─→ 压缩生成预览图(800×1200,200KB,webp 格式)
|
||||
↓
|
||||
上传到 S3
|
||||
↓
|
||||
数据库记录 assetType = 'main-preview'/'sku-preview'/'detail-preview'(S3 URL)
|
||||
```
|
||||
|
||||
### 3.2 关键特点
|
||||
|
||||
1. **保存原图**:原图打包成 zip 保存到本地永久目录
|
||||
2. **预览图独立**:预览图单独上传 S3,用于网页快速展示
|
||||
3. **下载直接返回 zip**:下载时直接返回本地 zip 文件,无需动态打包
|
||||
4. **预览图质量优化**:800×1200,200KB,节省带宽
|
||||
|
||||
### 3.3 数据库结构(新逻辑)
|
||||
|
||||
| 表 | 字段 | 说明 |
|
||||
|----|------|------|
|
||||
| `materials` | `previewUrl` | 第一张预览图 URL(S3) |
|
||||
| `materials` | `zipFilePath` | 总 zip 文件路径(本地) |
|
||||
| `materials` | `zipFileName` | 总 zip 文件名 |
|
||||
| `materials` | `zipFileSize` | 总 zip 文件大小 |
|
||||
| `material_asset` | `assetType` | `'main-preview'`/`'sku-preview'`/`'detail-preview'`/`'main'`/`'sku'`/`'detail'`/`'all'`/`'psd'` |
|
||||
| `material_asset` | `fileUrl` | 预览图是 S3 URL,zip 是本地路径 |
|
||||
| `material_asset` | `fileName` | 预览图文件名 或 zip 文件名 |
|
||||
|
||||
### 3.4 资产类型说明
|
||||
|
||||
| assetType | 含义 | fileUrl 内容 | 用途 |
|
||||
|-----------|------|-------------|------|
|
||||
| `main-preview` | 主图预览图 | S3 URL (webp) | 网页展示 |
|
||||
| `sku-preview` | SKU图预览图 | S3 URL (webp) | 网页展示 |
|
||||
| `detail-preview` | 详情图预览图 | S3 URL (webp) | 网页展示 |
|
||||
| `main` | 主图 zip 包 | 本地路径 | 下载 |
|
||||
| `sku` | SKU图 zip 包 | 本地路径 | 下载 |
|
||||
| `detail` | 详情图 zip 包 | 本地路径 | 下载 |
|
||||
| `all` | 总 zip 包(含分类zip + PSD) | 本地路径 | 下载 |
|
||||
| `psd` | PSD 源文件 | 本地路径 | 下载 |
|
||||
|
||||
### 3.5 示例数据
|
||||
|
||||
```sql
|
||||
-- materials 表
|
||||
{
|
||||
id: "404a427e-42a8-4251-ac57-01846c07dcab",
|
||||
taskNo: "TASK202601161107108287-01-01",
|
||||
productModel: "DSG0095",
|
||||
previewUrl: "https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/main-preview-xxx.webp",
|
||||
zipFilePath: "uploads/product-package/404a427e-42a8-4251-ac57-01846c07dcab/source.zip",
|
||||
zipFileName: "DSG0095_任务-详情_404a427e.zip",
|
||||
zipFileSize: 12345678
|
||||
}
|
||||
|
||||
-- material_asset 表
|
||||
{
|
||||
id: "xxx",
|
||||
materialId: "404a427e-42a8-4251-ac57-01846c07dcab",
|
||||
assetType: "main-preview",
|
||||
fileUrl: "https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/main-preview-xxx.webp",
|
||||
fileName: "main-preview-0.webp",
|
||||
sortOrder: 0
|
||||
}
|
||||
|
||||
{
|
||||
id: "yyy",
|
||||
materialId: "404a427e-42a8-4251-ac57-01846c07dcab",
|
||||
assetType: "main",
|
||||
fileUrl: "uploads/product-package/404a427e-42a8-4251-ac57-01846c07dcab/main.zip",
|
||||
fileName: "DSG0095_主图_404a427e.zip",
|
||||
fileSize: 5678901,
|
||||
sortOrder: 0
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 四、老素材迁移计划
|
||||
|
||||
### 4.1 迁移目标
|
||||
|
||||
将所有使用老逻辑的"任务-详情"素材(67 个,全部需要迁移)迁移到新逻辑。
|
||||
|
||||
### 重要说明
|
||||
|
||||
**⚠️ 所有 67 个素材都是老逻辑,包括:**
|
||||
|
||||
1. 那 42 个"有 zipFilePath"的素材:
|
||||
- `zipFileSize = 0`,说明 zip 文件实际上没有正确创建
|
||||
- 可能是早期测试时部分功能不完整导致
|
||||
- 需要重新生成 zip 文件
|
||||
|
||||
2. 那 25 个"无 zipFilePath"的素材:
|
||||
- 只有 S3 预览图,没有任何 zip 记录
|
||||
- 需要下载预览图并打包成 zip
|
||||
|
||||
**结论:67 个素材全部需要迁移**
|
||||
|
||||
### 4.2 迁移步骤
|
||||
|
||||
#### 步骤 1: 下载预览图
|
||||
|
||||
从 S3 下载当前存储的所有预览图:
|
||||
|
||||
```typescript
|
||||
// 1. 查询需要迁移的素材
|
||||
const materialsToMigrate = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
zipFilePath: '', // 无 zip 文件
|
||||
taskNo: { not: null }, // 有任务号
|
||||
},
|
||||
select: { id: true, productModel: true, taskNo: true },
|
||||
});
|
||||
|
||||
// 2. 对每个素材,下载所有预览图
|
||||
for (const material of materialsToMigrate) {
|
||||
const assets = await prisma.materialAsset.findMany({
|
||||
where: { materialId: material.id },
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
});
|
||||
|
||||
// 按 assetType 分组
|
||||
const mainAssets = assets.filter(a => a.assetType === 'main');
|
||||
const skuAssets = assets.filter(a => a.assetType === 'sku');
|
||||
const detailAssets = assets.filter(a => a.assetType === 'detail');
|
||||
|
||||
// 下载预览图到临时目录
|
||||
for (const asset of mainAssets) {
|
||||
const buffer = await downloadFromS3(asset.fileUrl);
|
||||
const tempPath = path.join(tempDir, asset.fileName);
|
||||
await fs.writeFile(tempPath, buffer);
|
||||
}
|
||||
// ... 同样处理 skuAssets 和 detailAssets
|
||||
}
|
||||
```
|
||||
|
||||
#### 步骤 2: 打包分类 zip
|
||||
|
||||
使用原图(预览图)打包成分类 zip:
|
||||
|
||||
```typescript
|
||||
// 使用 createZipFromFiles 函数打包
|
||||
const zipInfos = {};
|
||||
const zipFilesForAll = [];
|
||||
|
||||
// 打包主图
|
||||
if (mainFiles.length > 0) {
|
||||
zipInfos.main = await createZipFromFiles(
|
||||
mainFiles,
|
||||
material.id,
|
||||
material.productModel,
|
||||
'任务-详情',
|
||||
'main'
|
||||
);
|
||||
zipFilesForAll.push({ path: zipInfos.main.filePath, name: zipInfos.main.fileName });
|
||||
}
|
||||
|
||||
// 打包 SKU 图
|
||||
if (skuFiles.length > 0) {
|
||||
zipInfos.sku = await createZipFromFiles(
|
||||
skuFiles,
|
||||
material.id,
|
||||
material.productModel,
|
||||
'任务-详情',
|
||||
'sku'
|
||||
);
|
||||
zipFilesForAll.push({ path: zipInfos.sku.filePath, name: zipInfos.sku.fileName });
|
||||
}
|
||||
|
||||
// 打包详情图
|
||||
if (detailFiles.length > 0) {
|
||||
zipInfos.detail = await createZipFromFiles(
|
||||
detailFiles,
|
||||
material.id,
|
||||
material.productModel,
|
||||
'任务-详情',
|
||||
'detail'
|
||||
);
|
||||
zipFilesForAll.push({ path: zipInfos.detail.filePath, name: zipInfos.detail.fileName });
|
||||
}
|
||||
```
|
||||
|
||||
#### 步骤 3: 打包总 zip
|
||||
|
||||
```typescript
|
||||
// 打包总 zip(包含所有分类 zip + PSD)
|
||||
const psdFilesForAll = [];
|
||||
// 检查是否有 PSD 文件
|
||||
const psdAssets = assets.filter(a => a.assetType === 'psd');
|
||||
for (const psd of psdAssets) {
|
||||
psdFilesForAll.push({ path: psd.fileUrl, name: psd.fileName });
|
||||
}
|
||||
|
||||
zipInfos.all = await createZipFromZips(
|
||||
zipFilesForAll,
|
||||
psdFilesForAll,
|
||||
material.id,
|
||||
material.productModel,
|
||||
'任务-详情'
|
||||
);
|
||||
```
|
||||
|
||||
#### 步骤 4: 更新数据库
|
||||
|
||||
```typescript
|
||||
// 4.1 更新 assets 表(添加 main/sku/detail/all 类型的记录)
|
||||
const assetRecords = [];
|
||||
|
||||
// 添加分类 zip 资产
|
||||
if (zipInfos.main) {
|
||||
assetRecords.push({
|
||||
materialId: material.id,
|
||||
assetType: 'main',
|
||||
fileUrl: zipInfos.main.filePath,
|
||||
fileName: zipInfos.main.fileName,
|
||||
fileSize: BigInt(zipInfos.main.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
}
|
||||
|
||||
if (zipInfos.sku) {
|
||||
assetRecords.push({
|
||||
materialId: material.id,
|
||||
assetType: 'sku',
|
||||
fileUrl: zipInfos.sku.filePath,
|
||||
fileName: zipInfos.sku.fileName,
|
||||
fileSize: BigInt(zipInfos.sku.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
}
|
||||
|
||||
if (zipInfos.detail) {
|
||||
assetRecords.push({
|
||||
materialId: material.id,
|
||||
assetType: 'detail',
|
||||
fileUrl: zipInfos.detail.filePath,
|
||||
fileName: zipInfos.detail.fileName,
|
||||
fileSize: BigInt(zipInfos.detail.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
}
|
||||
|
||||
// 添加总 zip 资产
|
||||
assetRecords.push({
|
||||
materialId: material.id,
|
||||
assetType: 'all',
|
||||
fileUrl: zipInfos.all.filePath,
|
||||
fileName: zipInfos.all.fileName,
|
||||
fileSize: BigInt(zipInfos.all.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
|
||||
await prisma.materialAsset.createMany({
|
||||
data: assetRecords,
|
||||
});
|
||||
|
||||
// 4.2 更新 materials 表
|
||||
await prisma.material.update({
|
||||
where: { id: material.id },
|
||||
data: {
|
||||
zipFilePath: zipInfos.all.filePath,
|
||||
zipFileName: zipInfos.all.fileName,
|
||||
zipFileSize: BigInt(zipInfos.all.fileSize),
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
#### 步骤 5: 清理临时文件
|
||||
|
||||
```typescript
|
||||
// 删除下载的临时文件
|
||||
for (const file of mainFiles.concat(skuFiles, detailFiles)) {
|
||||
await fs.unlink(file.path);
|
||||
}
|
||||
```
|
||||
|
||||
### 4.3 迁移脚本
|
||||
|
||||
完整的迁移脚本:`scripts/migrate-product-package-assets.ts`
|
||||
|
||||
### 4.4 回滚计划
|
||||
|
||||
如果迁移失败,可以执行以下回滚操作:
|
||||
|
||||
```sql
|
||||
-- 删除新增的资产记录
|
||||
DELETE FROM material_asset
|
||||
WHERE material_id IN (
|
||||
SELECT id FROM materials
|
||||
WHERE material_type = '任务-详情'
|
||||
AND zip_file_path = ''
|
||||
)
|
||||
AND asset_type IN ('main', 'sku', 'detail', 'all');
|
||||
|
||||
-- 恢复 materials 表
|
||||
UPDATE materials
|
||||
SET
|
||||
zip_file_path = '',
|
||||
zip_file_name = '',
|
||||
zip_file_size = 0
|
||||
WHERE material_type = '任务-详情'
|
||||
AND zip_file_path != '';
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 五、注意事项
|
||||
|
||||
### 5.1 任务平台接口兼容性
|
||||
|
||||
**外部接口**: `/api/external/product-assets`
|
||||
|
||||
- **返回结构**: 保持不变,兼容新老格式
|
||||
- **下载链接**: 优先返回 `all` 类型的 zip,如果没有则回退到老逻辑
|
||||
|
||||
**外部下载接口**: `/api/external/download`
|
||||
|
||||
- **处理逻辑**: 优先查找 `all` 类型的资产,如果没有则动态打包预览图
|
||||
|
||||
### 5.2 前端展示兼容性
|
||||
|
||||
**详情页组件**: `components/detail/ProductPackageDetail.tsx`
|
||||
|
||||
- **展示逻辑**: 兼容 `main-preview`/`main`、`sku-preview`/`sku`、`detail-preview`/`detail`
|
||||
- **下载逻辑**: 优先下载 zip 文件,如果没有则动态打包预览图
|
||||
|
||||
### 5.3 迁移前后对比
|
||||
|
||||
| 特性 | 迁移前(老逻辑) | 迁移后(新逻辑) |
|
||||
|------|----------------|----------------|
|
||||
| 预览图 | S3 | S3 |
|
||||
| 原图存储 | 无 | 本地 zip |
|
||||
| 下载方式 | 动态打包预览图 | 直接返回 zip |
|
||||
| 下载速度 | 较慢(需要打包) | 快速(直接返回) |
|
||||
| 存储空间 | 较少(只有预览图) | 较多(预览图 + 原图) |
|
||||
|
||||
---
|
||||
|
||||
## 六、执行计划
|
||||
|
||||
### 6.1 准备阶段
|
||||
|
||||
1. ✅ 完成新逻辑的代码实现
|
||||
2. ✅ 完成前端兼容性修改
|
||||
3. ✅ 完成外部接口兼容性修改
|
||||
4. ✅ 编写迁移脚本
|
||||
5. ✅ 在生产环境测试新逻辑
|
||||
6. ✅ 在生产环境测试迁移脚本
|
||||
|
||||
### 6.2 执行阶段
|
||||
|
||||
1. ✅ 备份生产数据库
|
||||
2. ✅ 执行迁移脚本(迁移 57 个老素材)
|
||||
3. ✅ 验证迁移结果
|
||||
4. ✅ 测试下载功能
|
||||
5. ✅ 测试任务平台接口
|
||||
|
||||
### 6.3 迁移完成
|
||||
|
||||
**迁移时间**:2026-01-20
|
||||
|
||||
**迁移结果**:
|
||||
- 总素材数:77 个
|
||||
- 成功迁移:57 个
|
||||
- 新逻辑上传:18 个
|
||||
- 空记录:2 个
|
||||
|
||||
**验证通过**:所有 75 个有效素材的本地 zip 文件均存在
|
||||
|
||||
---
|
||||
|
||||
## 七、附录
|
||||
|
||||
### 7.1 迁移完成总结
|
||||
|
||||
**迁移时间**:2026-01-20
|
||||
|
||||
**迁移统计**:
|
||||
- 总素材数:77 个
|
||||
- ✅ 成功迁移:57 个(从老逻辑迁移到新逻辑)
|
||||
- ✅ 新逻辑上传:18 个(无需迁移)
|
||||
- ❌ 空记录:2 个(无任务号,无资产,不需要迁移)
|
||||
|
||||
**迁移过程**:
|
||||
1. 第一轮:28 个素材(修复 zipFilePath='' 的素材)
|
||||
2. 第二轮:29 个素材(修复有 zipFilePath 但没有本地 zip 文件的素材)
|
||||
3. 验证:所有 75 个有效素材的本地 zip 文件均存在
|
||||
|
||||
**空记录详情**:
|
||||
- CYJ0062 (紫苏) - 无任务号,无资产
|
||||
- GBPM-SN0208-389 (瑶光) - 无任务号,无资产
|
||||
|
||||
这些是测试数据或上传失败的记录,可以忽略或删除。
|
||||
|
||||
### 7.2 相关文件
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
|---------|------|
|
||||
| `lib/task-material-processor.ts` | 任务-详情素材处理逻辑 |
|
||||
| `lib/product-package.ts` | 产品全案相关函数 |
|
||||
| `app/api/materials/upload/product-package/complete/route.ts` | 任务-详情上传完成接口 |
|
||||
| `app/api/external/product-assets/route.ts` | 外部接口(任务平台) |
|
||||
| `components/detail/ProductPackageDetail.tsx` | 任务-详情详情页组件 |
|
||||
| `scripts/migrate-product-package-old-materials.ts` | 迁移脚本 |
|
||||
| `scripts/verify-migrated-files.ts` | 验证脚本 |
|
||||
| `scripts/check-remaining-materials.ts` | 检查剩余素材脚本 |
|
||||
|
||||
---
|
||||
|
||||
**文档版本**: 2.0.0
|
||||
**最后更新**: 2026-01-20
|
||||
**状态**: ✅ 迁移完成
|
||||
161
AGENTS.md
Normal file
@ -0,0 +1,161 @@
|
||||
# AI 编码助手指南
|
||||
|
||||
本文档为 AI 编码助手提供操作说明,确保代码质量和一致性。
|
||||
|
||||
## 构建命令
|
||||
|
||||
```bash
|
||||
# 开发模式
|
||||
pnpm dev
|
||||
|
||||
# 生产构建
|
||||
pnpm build
|
||||
|
||||
# 启动生产服务器
|
||||
pnpm start
|
||||
|
||||
# 代码检查
|
||||
pnpm lint
|
||||
|
||||
# 生成 Prisma Client
|
||||
pnpm prisma:generate
|
||||
```
|
||||
|
||||
## 测试命令
|
||||
|
||||
```bash
|
||||
# 运行所有测试
|
||||
pnpm test
|
||||
|
||||
# 监视模式
|
||||
pnpm test:watch
|
||||
|
||||
# 运行单个测试文件
|
||||
pnpm test material-card-buttons.test.tsx
|
||||
|
||||
# 运行匹配的测试
|
||||
pnpm test -- --testNamePattern="素材卡片"
|
||||
```
|
||||
|
||||
## 代码风格指南
|
||||
|
||||
### 命名约定
|
||||
- 组件文件:PascalCase(`MaterialCard.tsx`)
|
||||
- 工具函数:camelCase(`formatFileSize.ts`)
|
||||
- 常量:UPPER_SNAKE_CASE(`MAX_UPLOAD_SIZE`)
|
||||
- 类型定义:PascalCase(`interface MaterialCardProps`)
|
||||
|
||||
### 导入顺序
|
||||
```typescript
|
||||
// 1. React 相关
|
||||
import React, { useState } from 'react';
|
||||
|
||||
// 2. Next.js 相关
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
// 3. 第三方库
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
// 4. 内部导入(按路径排序)
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
```
|
||||
|
||||
### TypeScript 规范
|
||||
- 避免使用 `any`,使用具体类型或 `unknown`
|
||||
- 使用 `interface` 定义组件 Props
|
||||
- 必填属性排在前面,可选属性在后面
|
||||
|
||||
### React 最佳实践
|
||||
```typescript
|
||||
// 状态变量命名:[名词] 或 [is][动词][ing]
|
||||
const [materials, setMaterials] = useState<Material[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
// 更新对象状态时使用展开运算符
|
||||
setMaterials(prev => [...prev, newItem]);
|
||||
|
||||
// useEffect 依赖数组要完整
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
}, [id]); // ✅ 依赖 id
|
||||
|
||||
// 事件处理函数使用 useCallback
|
||||
const handleDelete = useCallback(async (id: string) => {
|
||||
await deleteMaterial(id);
|
||||
}, []);
|
||||
```
|
||||
|
||||
### 错误处理
|
||||
```typescript
|
||||
// API 路由统一错误响应格式
|
||||
try {
|
||||
const result = await doSomething();
|
||||
return NextResponse.json({ success: true, data: result });
|
||||
} catch (error) {
|
||||
console.error('操作失败:', error);
|
||||
return NextResponse.json(
|
||||
{ success: false, error: '服务器错误' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Prisma 使用
|
||||
```typescript
|
||||
// 查询
|
||||
const materials = await prisma.material.findMany({
|
||||
where: { userId: currentUserId },
|
||||
orderBy: { createdAt: 'desc' }
|
||||
});
|
||||
|
||||
// 更新计数器
|
||||
await prisma.material.update({
|
||||
where: { id: materialId },
|
||||
data: { downloadCount: { increment: 1 } }
|
||||
});
|
||||
|
||||
// 事务处理
|
||||
await prisma.$transaction(async (tx) => {
|
||||
const material = await tx.material.create({...});
|
||||
await tx.materialAsset.createMany({...});
|
||||
});
|
||||
```
|
||||
|
||||
### 样式(Tailwind CSS)
|
||||
```typescript
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
<div className={clsx(
|
||||
'flex items-center justify-between',
|
||||
isActive && 'bg-blue-500',
|
||||
isDisabled && 'opacity-50'
|
||||
)}>
|
||||
```
|
||||
|
||||
## 关键约定
|
||||
|
||||
### 素材类型
|
||||
```typescript
|
||||
const MATERIAL_TYPES = [
|
||||
'3D场景', '3D原图', 'AI原图', '实拍原图', '视频截图',
|
||||
'任务-详情', '详情模板', '主图模版', 'SKU模版',
|
||||
'品牌VI灵感', '模特', '实拍图片', '买家秀图片',
|
||||
'小红书种草', '主图视频', '安装视频', '种草视频',
|
||||
'音频', 'PSD', 'PDF', '产品全案',
|
||||
];
|
||||
```
|
||||
|
||||
### 部署环境
|
||||
- 影子系统:端口 5320,数据库 `lobechat_stage`
|
||||
- 正式系统:端口 4320,数据库 `lobechat`
|
||||
|
||||
### S3 存储路径
|
||||
- 新素材(2025-10-27 之后):`https://s3.yydd.ai/gongxiangpan/由壹点AI/`
|
||||
- 老素材(2025-10-27 之前):`https://s3.1080p.hk/jsxiangche/`
|
||||
|
||||
### 分片上传
|
||||
- 小于 5MB:直接上传
|
||||
- 大于 5MB:自动分片上传(每片 5MB),使用 IndexedDB 存储分片信息
|
||||
|
||||
最后更新:2026-01-20
|
||||
211
TEST-UPLOAD-FIX.md
Normal file
@ -0,0 +1,211 @@
|
||||
# 任务-详情上传修复验证
|
||||
|
||||
## 修复内容
|
||||
|
||||
### 1. 进度条超过100%问题 ✅
|
||||
**问题原因**:`onProgress` 回调在每个分片上传时都触发,导致 `uploadedCount` 多次增加
|
||||
|
||||
**修复位置**:`components/upload/ProductPackageUploader.tsx` 第329-331行
|
||||
```typescript
|
||||
const uploadId = await uploadFileWithChunks(asset.file);
|
||||
// 只在上传完成时更新进度
|
||||
updateProgress();
|
||||
```
|
||||
|
||||
**验证方式**:
|
||||
- 上传35个文件(5主图 + 10SKU + 20详情)
|
||||
- 观察进度条,应该在100%时停止
|
||||
- 不应该超过100%
|
||||
|
||||
---
|
||||
|
||||
### 2. 62个资产问题 ✅
|
||||
**问题原因**:文件路径查找逻辑错误,使用文件名匹配导致重复生成预览图
|
||||
|
||||
**修复位置**:`app/api/materials/upload/product-package/complete/route.ts` 第256-265行
|
||||
|
||||
**修复前**:
|
||||
```typescript
|
||||
const filePath = mainFiles.find(f => f.name === asset.fileName)?.path ||
|
||||
skuFiles.find(f => f.name === asset.fileName)?.path ||
|
||||
detailFiles.find(f => f.name === asset.fileName)?.path;
|
||||
```
|
||||
|
||||
**修复后**:
|
||||
```typescript
|
||||
const filePath = await getUploadedFile(asset.uploadId);
|
||||
```
|
||||
|
||||
**预期结果**:
|
||||
- 5个主图 → 5个 main-preview 预览图
|
||||
- 10个SKU → 10个 sku-preview 预览图
|
||||
- 20个详情 → 20个 detail-preview 预览图
|
||||
- 1个主图zip(main)
|
||||
- 1个SKU zip(sku)
|
||||
- 1个详情zip(detail)
|
||||
- 1个总zip(all)
|
||||
- 1个PSD(psd)
|
||||
- **总计:40个资产**
|
||||
|
||||
**验证方式**:
|
||||
```sql
|
||||
SELECT assetType, COUNT(*) as count
|
||||
FROM "MaterialAsset"
|
||||
WHERE materialId = 'xxx'
|
||||
GROUP BY assetType
|
||||
ORDER BY assetType;
|
||||
```
|
||||
|
||||
应该看到:
|
||||
```
|
||||
main-preview 5
|
||||
sku-preview 10
|
||||
detail-preview 20
|
||||
main 1
|
||||
sku 1
|
||||
detail 1
|
||||
all 1
|
||||
psd 1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. PSD fileUrl undefined问题 ✅
|
||||
**问题原因**:`PsdAsset` 接口不支持 `uploadId`,导致PSD文件无法正确处理
|
||||
|
||||
**修复位置**:
|
||||
1. `app/api/materials/upload/product-package/complete/route.ts` 第31-36行
|
||||
```typescript
|
||||
interface PsdAsset {
|
||||
uploadId?: string; // 分片上传的uploadId
|
||||
fileUrl?: string; // 直接上传到S3的URL
|
||||
fileName: string;
|
||||
fileSize: number;
|
||||
}
|
||||
```
|
||||
|
||||
2. 第387-400行:使用 `uploadId` 获取PSD文件路径
|
||||
```typescript
|
||||
if (assets.psd && assets.psd.length > 0) {
|
||||
for (const psd of assets.psd) {
|
||||
if (psd.uploadId) {
|
||||
const filePath = await getUploadedFile(psd.uploadId);
|
||||
if (filePath) {
|
||||
psdFilesForAll.push({ path: filePath, name: psd.fileName });
|
||||
tempFiles.push(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**验证方式**:
|
||||
- 上传包含PSD文件的素材
|
||||
- 检查all.zip中是否包含PSD文件
|
||||
- 检查数据库中 `assetType='psd'` 的记录是否正确
|
||||
|
||||
---
|
||||
|
||||
## 测试步骤
|
||||
|
||||
### 测试1:基础上传(不含PSD)
|
||||
1. 上传5个主图、10个SKU、20个详情
|
||||
2. 观察进度条,应该在100%停止
|
||||
3. 检查数据库资产数量(应该是39个,不含PSD)
|
||||
|
||||
### 测试2:包含PSD的上传
|
||||
1. 上传5个主图、10个SKU、20个详情、1个PSD
|
||||
2. 观察进度条,应该在100%停止
|
||||
3. 检查数据库资产数量(应该是40个)
|
||||
4. 下载all.zip,检查是否包含PSD文件
|
||||
|
||||
### 测试3:下载功能
|
||||
1. 下载"全部"
|
||||
2. 解压后检查结构:
|
||||
```
|
||||
主图_XXXX.zip
|
||||
SKU图_XXXX.zip
|
||||
详情图_XXXX.zip
|
||||
psd/6.psd
|
||||
```
|
||||
3. 不应该包含任何预览文件
|
||||
|
||||
---
|
||||
|
||||
## 关键数据流
|
||||
|
||||
### 前端上传流程
|
||||
```
|
||||
用户选择文件
|
||||
↓
|
||||
uploadFileWithChunks(file)
|
||||
↓
|
||||
chunkUpload(file, metadata, { skipComplete: true })
|
||||
↓
|
||||
分片上传到 /api/materials/upload/chunk
|
||||
↓
|
||||
保存到临时目录 uploads/temp/{uploadId}/chunk-{index}
|
||||
↓
|
||||
返回 { uploadId, chunksUploaded: true }
|
||||
↓
|
||||
传递给 /api/materials/upload/product-package/complete
|
||||
```
|
||||
|
||||
### 后端处理流程
|
||||
```
|
||||
接收 uploadId
|
||||
↓
|
||||
getUploadedFile(uploadId) → 组装文件 → uploads/assembled/{uploadId}-{fileName}
|
||||
↓
|
||||
从组装的文件生成预览图 → 上传到S3 → previewUrl
|
||||
↓
|
||||
打包原始文件成zip → main.zip, sku.zip, detail.zip
|
||||
↓
|
||||
打包总zip(包含分类zip + PSD)→ all.zip
|
||||
↓
|
||||
保存到数据库(previewUrls + zipPaths + psdPaths)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 常见问题排查
|
||||
|
||||
### 问题:进度条超过100%
|
||||
**排查**:
|
||||
```typescript
|
||||
// 检查 updateProgress 是否被多次调用
|
||||
const updateProgress = () => {
|
||||
console.log('uploadedCount:', uploadedCount, 'totalFiles:', totalFiles); // 添加日志
|
||||
uploadedCount++;
|
||||
setUploadProgress(Math.round((uploadedCount / totalFiles) * 100));
|
||||
};
|
||||
```
|
||||
|
||||
### 问题:资产数量不正确
|
||||
**排查**:
|
||||
```sql
|
||||
-- 查看所有资产类型
|
||||
SELECT assetType, fileUrl, fileName, "sortOrder"
|
||||
FROM "MaterialAsset"
|
||||
WHERE materialId = 'xxx'
|
||||
ORDER BY assetType, "sortOrder";
|
||||
```
|
||||
|
||||
### 问题:PSD文件不在all.zip中
|
||||
**排查**:
|
||||
```typescript
|
||||
// 检查psdFilesForAll是否正确添加
|
||||
console.log('[Product Package] PSD files for all:', psdFilesForAll);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 部署检查清单
|
||||
- [ ] 代码已修复并本地测试通过
|
||||
- [ ] 没有TypeScript错误
|
||||
- [ ] 运行 lint 检查通过
|
||||
- [ ] 部署到影子系统
|
||||
- [ ] 在浏览器中测试上传功能
|
||||
- [ ] 检查数据库资产数量
|
||||
- [ ] 检查下载功能
|
||||
- [ ] 确认没有引入新bug
|
||||
@ -71,7 +71,8 @@ export async function POST(request: NextRequest) {
|
||||
avatar: user.avatar,
|
||||
role: user.role,
|
||||
department: user.department,
|
||||
isActive: user.isActive
|
||||
isActive: user.isActive,
|
||||
status: (user as any).status || (user.isActive ? 'active' : 'pending') // 阶段一新增
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
8
app/api/external/download/route.ts
vendored
@ -231,6 +231,7 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
/**
|
||||
* 根据下载类型获取资产列表
|
||||
* 排除预览类型资产
|
||||
*/
|
||||
function getAssetsForDownload(assets: any[], downloadType: string) {
|
||||
switch (downloadType) {
|
||||
@ -241,8 +242,11 @@ function getAssetsForDownload(assets: any[], downloadType: string) {
|
||||
case 'detail':
|
||||
return assets.filter(a => a.assetType === ASSET_TYPE.DETAIL);
|
||||
case 'all':
|
||||
// 全部下载不含 PSD
|
||||
return assets.filter(a => a.assetType !== ASSET_TYPE.PSD);
|
||||
// 全部下载不含 PSD 和预览类型
|
||||
return assets.filter(a =>
|
||||
a.assetType !== ASSET_TYPE.PSD &&
|
||||
!a.assetType.includes('-preview')
|
||||
);
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
1375
app/api/materials/download/route-old.ts
Normal file
@ -172,8 +172,19 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理previewUrl的fallback逻辑
|
||||
// 处理previewUrl的fallback逻辑
|
||||
let previewUrl = material.previewUrl || material.videoCoverUrl || '';
|
||||
|
||||
// 任务-详情类型:优先使用 assets 中的预览图
|
||||
if (!previewUrl && isProductPackageType(material.materialType) && material.assets && material.assets.length > 0) {
|
||||
const previewAsset = material.assets.find((a: any) => a.assetType === 'main-preview');
|
||||
if (previewAsset) {
|
||||
previewUrl = previewAsset.fileUrl;
|
||||
console.log('[Materials API] Using preview from assets:', previewUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// 其他素材类型:使用 displayImages
|
||||
if (!previewUrl && material.displayImages) {
|
||||
const displayImagesArray = parseDisplayImages(material.displayImages);
|
||||
if (displayImagesArray.length > 0) {
|
||||
@ -361,7 +372,7 @@ export async function GET(request: NextRequest) {
|
||||
const queryWhere = where;
|
||||
|
||||
try {
|
||||
const query: any = {
|
||||
const query: any = {
|
||||
where: queryWhere,
|
||||
select: {
|
||||
id: true,
|
||||
@ -389,14 +400,21 @@ export async function GET(request: NextRequest) {
|
||||
videoProcessingStatus: true,
|
||||
transcodeLastError: true,
|
||||
transcodeAttempts: true,
|
||||
user: {
|
||||
// 包含 assets 数据(任务-详情需要)
|
||||
assets: {
|
||||
select: {
|
||||
username: true,
|
||||
realName: true,
|
||||
avatar: true,
|
||||
id: true,
|
||||
assetType: true,
|
||||
fileUrl: true,
|
||||
fileName: true,
|
||||
sortOrder: true,
|
||||
},
|
||||
where: {
|
||||
assetType: { in: ['main-preview', 'sku-preview', 'detail-preview'] },
|
||||
},
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
},
|
||||
} as any,
|
||||
},
|
||||
};
|
||||
|
||||
// comprehensive排序时,不设置orderBy、skip、take,获取所有数据后在内存中排序
|
||||
@ -672,7 +690,7 @@ export async function GET(request: NextRequest) {
|
||||
const assets = await prisma.materialAsset.findMany({
|
||||
where: {
|
||||
materialId: { in: productPackageMaterialIds },
|
||||
assetType: { in: ['main', 'sku'] },
|
||||
assetType: { in: ['main', 'sku', 'main-preview', 'sku-preview'] },
|
||||
},
|
||||
select: {
|
||||
materialId: true,
|
||||
@ -687,23 +705,29 @@ export async function GET(request: NextRequest) {
|
||||
],
|
||||
});
|
||||
|
||||
// 按 materialId 分组,优先使用主图,没有主图则使用SKU图
|
||||
const assetsByMaterial = new Map<string, { main?: string; sku?: string }>();
|
||||
// 按 materialId 分组,优先使用预览图(main-preview/sku-preview),没有预览图则使用原图(main/sku)
|
||||
const assetsByMaterial = new Map<string, { mainPreview?: string; skuPreview?: string; main?: string; sku?: string }>();
|
||||
for (const asset of assets) {
|
||||
if (!assetsByMaterial.has(asset.materialId)) {
|
||||
assetsByMaterial.set(asset.materialId, {});
|
||||
}
|
||||
const materialAssets = assetsByMaterial.get(asset.materialId)!;
|
||||
if (asset.assetType === 'main' && !materialAssets.main) {
|
||||
|
||||
// 分别记录预览图和原图
|
||||
if (asset.assetType === 'main-preview') {
|
||||
materialAssets.mainPreview = asset.fileUrl;
|
||||
} else if (asset.assetType === 'sku-preview') {
|
||||
materialAssets.skuPreview = asset.fileUrl;
|
||||
} else if (asset.assetType === 'main') {
|
||||
materialAssets.main = asset.fileUrl;
|
||||
} else if (asset.assetType === 'sku' && !materialAssets.sku && !materialAssets.main) {
|
||||
} else if (asset.assetType === 'sku') {
|
||||
materialAssets.sku = asset.fileUrl;
|
||||
}
|
||||
}
|
||||
|
||||
// 构建封面图映射
|
||||
// 构建封面图映射:优先使用预览图,没有预览图才使用原图
|
||||
assetsByMaterial.forEach((materialAssets, materialId) => {
|
||||
const coverUrl = materialAssets.main || materialAssets.sku || null;
|
||||
const coverUrl = materialAssets.mainPreview || materialAssets.skuPreview || materialAssets.main || materialAssets.sku || null;
|
||||
if (coverUrl) {
|
||||
coverUrlMap.set(materialId, coverUrl);
|
||||
}
|
||||
|
||||
@ -29,7 +29,8 @@ interface AssetUpload {
|
||||
}
|
||||
|
||||
interface PsdAsset {
|
||||
fileUrl: string;
|
||||
uploadId?: string; // 分片上传的uploadId
|
||||
fileUrl?: string; // 直接上传到S3的URL
|
||||
fileName: string;
|
||||
fileSize: number;
|
||||
}
|
||||
@ -101,9 +102,17 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// 验证素材是否存在且属于当前用户
|
||||
// 验证素材是否存在且属于当前用户(包含用户信息用于获取作者名)
|
||||
const material: any = await prisma.material.findUnique({
|
||||
where: { id: materialId },
|
||||
include: {
|
||||
user: {
|
||||
select: {
|
||||
realName: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!material) {
|
||||
@ -120,6 +129,12 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// 提取作者名和店铺名(用于zip文件命名)
|
||||
const authorName = material.user?.realName || material.user?.username || '未知作者';
|
||||
const categoryName = material.categoryName || '未知店铺';
|
||||
console.log('[Product Package] 作者名:', authorName);
|
||||
console.log('[Product Package] 店铺名:', categoryName);
|
||||
|
||||
// 步骤1: 收集原图文件
|
||||
console.log('[Product Package] Step 1: 收集原图文件...');
|
||||
const mainFiles: Array<{ path: string; name: string; size: number }> = [];
|
||||
@ -232,7 +247,7 @@ export async function POST(request: NextRequest) {
|
||||
maxSizeKB: 200,
|
||||
};
|
||||
|
||||
// 生成预览图的辅助函数(支持从 S3 URL 或本地文件)
|
||||
// 生成预览图的辅助函数(使用 uploadId 直接获取文件)
|
||||
const generatePreviewsFromAssets = async (
|
||||
assets: AssetUpload[],
|
||||
type: string
|
||||
@ -254,14 +269,13 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
buffer = Buffer.from(await response.arrayBuffer());
|
||||
} else if (asset.uploadId) {
|
||||
// 从本地临时文件读取
|
||||
const filePath = mainFiles.find(f => f.name === asset.fileName)?.path ||
|
||||
skuFiles.find(f => f.name === asset.fileName)?.path ||
|
||||
detailFiles.find(f => f.name === asset.fileName)?.path;
|
||||
// 从本地临时文件读取(使用uploadId直接获取)
|
||||
const filePath = await getUploadedFile(asset.uploadId);
|
||||
if (!filePath) {
|
||||
throw new Error(`文件不存在: ${asset.fileName}`);
|
||||
throw new Error(`文件不存在: ${asset.fileName} (uploadId: ${asset.uploadId})`);
|
||||
}
|
||||
buffer = await readFile(filePath);
|
||||
console.log(`[Preview] Read ${type} image ${i + 1}/${assets.length} from local: ${filePath}`);
|
||||
} else {
|
||||
throw new Error(`无效的资产数据: ${asset.fileName}`);
|
||||
}
|
||||
@ -334,7 +348,9 @@ export async function POST(request: NextRequest) {
|
||||
materialId,
|
||||
material.productModel || 'product',
|
||||
'任务-详情',
|
||||
'main'
|
||||
'主图',
|
||||
authorName,
|
||||
categoryName
|
||||
);
|
||||
createdZipPaths.push(zipInfos.main.filePath);
|
||||
zipFilesForAll.push({ path: zipInfos.main.filePath, name: zipInfos.main.fileName });
|
||||
@ -348,7 +364,9 @@ export async function POST(request: NextRequest) {
|
||||
materialId,
|
||||
material.productModel || 'product',
|
||||
'任务-详情',
|
||||
'sku'
|
||||
'SKU图',
|
||||
authorName,
|
||||
categoryName
|
||||
);
|
||||
createdZipPaths.push(zipInfos.sku.filePath);
|
||||
zipFilesForAll.push({ path: zipInfos.sku.filePath, name: zipInfos.sku.fileName });
|
||||
@ -362,26 +380,61 @@ export async function POST(request: NextRequest) {
|
||||
materialId,
|
||||
material.productModel || 'product',
|
||||
'任务-详情',
|
||||
'detail'
|
||||
'详情图',
|
||||
authorName,
|
||||
categoryName
|
||||
);
|
||||
createdZipPaths.push(zipInfos.detail.filePath);
|
||||
zipFilesForAll.push({ path: zipInfos.detail.filePath, name: zipInfos.detail.fileName });
|
||||
console.log('[Product Package] 详情图打包完成:', zipInfos.detail.fileName);
|
||||
}
|
||||
|
||||
// 步骤4: 打包总zip(包含所有分类zip + PSD)
|
||||
console.log('[Product Package] Step 4: 打包总zip...');
|
||||
const psdFilesForAll: Array<{ path: string; name: string }> = [];
|
||||
// 步骤3.5: 移动PSD文件到永久目录
|
||||
console.log('[Product Package] Step 3.5: 移动PSD文件到永久目录...');
|
||||
const psdPermanentPaths: Array<{ filePath: string; fileName: string; fileSize: number }> = [];
|
||||
if (assets.psd && assets.psd.length > 0) {
|
||||
const { rename, copyFile } = await import('fs/promises');
|
||||
const psdDir = path.join(process.cwd(), 'uploads', 'materials');
|
||||
await mkdir(psdDir, { recursive: true });
|
||||
|
||||
for (const psd of assets.psd) {
|
||||
const psdPath = psd.fileUrl.startsWith('/') ? psd.fileUrl : `/${psd.fileUrl}`;
|
||||
psdFilesForAll.push({ path: psdPath, name: psd.fileName });
|
||||
if (psd.uploadId) {
|
||||
// 从临时目录获取PSD文件
|
||||
const tempFilePath = await getUploadedFile(psd.uploadId);
|
||||
if (tempFilePath) {
|
||||
// 生成永久文件名和路径
|
||||
const timestamp = Date.now();
|
||||
const sanitizedFileName = psd.fileName.replace(/[\/\\:*?"<>|]/g, '_');
|
||||
const permanentFileName = `psd-${materialId}-${timestamp}-${sanitizedFileName}`;
|
||||
const permanentFilePath = path.join(psdDir, permanentFileName);
|
||||
const relativePath = path.join('uploads', 'materials', permanentFileName);
|
||||
|
||||
// 移动文件到永久目录
|
||||
try {
|
||||
await rename(tempFilePath, permanentFilePath);
|
||||
console.log(`[Product Package] PSD文件已移动: ${tempFilePath} -> ${permanentFilePath}`);
|
||||
} catch (err) {
|
||||
// 如果跨设备移动失败,使用复制+删除
|
||||
await copyFile(tempFilePath, permanentFilePath);
|
||||
tempFiles.push(tempFilePath); // 标记为需要清理
|
||||
console.log(`[Product Package] PSD文件已复制: ${tempFilePath} -> ${permanentFilePath}`);
|
||||
}
|
||||
|
||||
psdPermanentPaths.push({
|
||||
filePath: relativePath,
|
||||
fileName: psd.fileName, // 保留原始文件名
|
||||
fileSize: psd.fileSize,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`[Product Package] ${psdPermanentPaths.length} 个PSD文件已移动到永久目录`);
|
||||
}
|
||||
|
||||
// 步骤4: 打包总zip(只包含分类zip,不包含PSD)
|
||||
console.log('[Product Package] Step 4: 打包总zip...');
|
||||
zipInfos.all = await createZipFromZips(
|
||||
zipFilesForAll,
|
||||
psdFilesForAll,
|
||||
materialId,
|
||||
material.productModel || 'product',
|
||||
'任务-详情'
|
||||
@ -391,20 +444,14 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
// 步骤5: 保存资产记录到数据库
|
||||
console.log('[Product Package] Step 5: 保存资产记录...');
|
||||
const psdInfos = assets.psd?.map(psd => ({
|
||||
filePath: psd.fileUrl,
|
||||
fileName: psd.fileName,
|
||||
fileSize: psd.fileSize,
|
||||
}));
|
||||
|
||||
await saveProductPackageAssets(
|
||||
materialId,
|
||||
previewUrls,
|
||||
zipInfos,
|
||||
psdInfos
|
||||
psdPermanentPaths // 使用永久路径
|
||||
);
|
||||
|
||||
// 步骤6: 更新素材记录(写入taskNo)
|
||||
// 步骤6: 更新素材记录(写入taskNo和状态)
|
||||
console.log('[Product Package] Step 6: 更新素材记录...');
|
||||
await prisma.material.update({
|
||||
where: { id: materialId },
|
||||
|
||||
27
check-183-250.js
Normal file
@ -0,0 +1,27 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const content = fs.readFileSync('app/api/materials/download/route.ts', 'utf8');
|
||||
const lines = content.split('\n');
|
||||
|
||||
let braceLevel = 0;
|
||||
|
||||
console.log('Brace level in lines 183-250:\n');
|
||||
|
||||
for (let i = 182; i < 250; i++) {
|
||||
const line = lines[i];
|
||||
const prevLevel = braceLevel;
|
||||
|
||||
for (const c of line) {
|
||||
if (c === '{') braceLevel++;
|
||||
if (c === '}') braceLevel--;
|
||||
}
|
||||
|
||||
if (prevLevel !== braceLevel) {
|
||||
const delta = braceLevel - prevLevel;
|
||||
const sign = delta > 0 ? '+' : '';
|
||||
console.log(`${i + 1} (${sign}${delta}): ${line.trim().substring(0, 70)}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nFinal brace level: ${braceLevel}`);
|
||||
console.log(`Expected: 0 (should close all blocks before next function)`);
|
||||
@ -50,10 +50,10 @@ export default function ProductPackageDetail({
|
||||
// 轮播相关状态
|
||||
const [autoPlayEnabled, setAutoPlayEnabled] = useState(true);
|
||||
|
||||
// 按类型分组资产
|
||||
const mainImages = material.assets.filter((a) => a.assetType === 'main');
|
||||
const skuImages = material.assets.filter((a) => a.assetType === 'sku');
|
||||
const detailImages = material.assets.filter((a) => a.assetType === 'detail').sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
// 按类型分组资产(使用新的资产类型格式)
|
||||
const mainImages = material.assets.filter((a) => a.assetType === 'main-preview').sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
const skuImages = material.assets.filter((a) => a.assetType === 'sku-preview').sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
const detailImages = material.assets.filter((a) => a.assetType === 'detail-preview').sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
const psdFiles = material.assets.filter((a) => a.assetType === 'psd');
|
||||
|
||||
// 轮播逻辑
|
||||
@ -343,18 +343,18 @@ export default function ProductPackageDetail({
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-4">
|
||||
<h4 className="text-sm font-medium mb-3 text-gray-900 dark:text-white">批量下载</h4>
|
||||
{downloading && (
|
||||
<div className="mb-3 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
|
||||
<div className="mb-3 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
|
||||
<div className="flex items-center space-x-2">
|
||||
<svg className="animate-spin h-4 w-4 text-blue-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
<span className="text-sm text-blue-600 dark:text-blue-400">
|
||||
{downloadType === 'all' ? '正在打包全部文件,请稍候...' :
|
||||
downloadType === 'main' ? '正在打包主图,请稍候...' :
|
||||
downloadType === 'sku' ? '正在打包SKU图,请稍候...' :
|
||||
downloadType === 'detail' ? '正在打包详情图,请稍候...' :
|
||||
downloadType === 'psd' ? '正在准备PSD文件,请稍候...' :
|
||||
{downloadType === 'all' ? '正在准备全部文件,请稍候...' :
|
||||
downloadType === 'main' ? '正在下载主图,请稍候...' :
|
||||
downloadType === 'sku' ? '正在下载SKU图,请稍候...' :
|
||||
downloadType === 'detail' ? '正在下载详情图,请稍候...' :
|
||||
downloadType === 'psd' ? '正在下载PSD文件,请稍候...' :
|
||||
'正在准备文件,请稍候...'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -326,15 +326,13 @@ export default function ProductPackageUploader({
|
||||
// 并行上传所有文件(使用分片上传)
|
||||
const uploadPromises = assets.map(async (asset, index) => {
|
||||
try {
|
||||
const uploadId = await uploadFileWithChunks(asset.file, (progress) => {
|
||||
// 单个文件的进度更新
|
||||
updateProgress();
|
||||
});
|
||||
const uploadId = await uploadFileWithChunks(asset.file);
|
||||
// 只在上传完成时更新进度
|
||||
updateProgress();
|
||||
return {
|
||||
fileName: asset.file.name,
|
||||
fileSize: asset.file.size,
|
||||
uploadId, // 使用uploadId而不是fileUrl
|
||||
uploadId,
|
||||
sortOrder: index,
|
||||
};
|
||||
} catch (error) {
|
||||
@ -354,15 +352,13 @@ export default function ProductPackageUploader({
|
||||
const uploadPromises = psdFiles.map(async (psdFileItem, index) => {
|
||||
try {
|
||||
const psdFile = psdFileItem.file;
|
||||
const uploadId = await uploadFileWithChunks(psdFile, (progress) => {
|
||||
// 单个文件的进度更新
|
||||
updateProgress();
|
||||
});
|
||||
const uploadId = await uploadFileWithChunks(psdFile);
|
||||
// 只在上传完成时更新进度
|
||||
updateProgress();
|
||||
return {
|
||||
fileName: psdFile.name,
|
||||
fileSize: psdFile.size,
|
||||
uploadId, // 使用uploadId而不是fileUrl
|
||||
uploadId,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`[Upload] Failed to upload PSD file ${index}:`, error);
|
||||
|
||||
905
deploy-remote-build.ps1.backup2
Normal file
@ -0,0 +1,905 @@
|
||||
#Requires -Version 5.1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
由壹点3D素材 - 远程构建部署脚本(内网环境)
|
||||
|
||||
.DESCRIPTION
|
||||
本地打包代码 -> 上传到构建机 -> 构建镜像 -> 推送到 Registry -> 部署到生产服务器
|
||||
优势:保护本地 SSD,智能缓存,构建速度快,可视化管理
|
||||
适用:内网环境,构建机和生产服务器在同一内网
|
||||
|
||||
.PARAMETER Target
|
||||
部署目标:shadow(影子系统)或 production(正式系统,默认)
|
||||
|
||||
.PARAMETER BuildServerIP
|
||||
构建机 IP 地址(默认:192.168.42.134)
|
||||
|
||||
.PARAMETER BuildServerUser
|
||||
构建机用户名(默认:root)
|
||||
|
||||
.PARAMETER BuildServerPassword
|
||||
构建机密码
|
||||
|
||||
.PARAMETER ProdServerIP
|
||||
生产服务器 IP 地址(默认:192.168.58.20)
|
||||
|
||||
.PARAMETER ProdServerUser
|
||||
生产服务器用户名(默认:root)
|
||||
|
||||
.PARAMETER SkipSync
|
||||
跳过代码同步
|
||||
|
||||
.PARAMETER SkipBuild
|
||||
跳过镜像构建
|
||||
|
||||
.PARAMETER NoCache
|
||||
构建时不使用缓存
|
||||
|
||||
.PARAMETER KeepOldImages
|
||||
保留旧镜像(不自动清理)
|
||||
|
||||
.EXAMPLE
|
||||
.\deploy-remote-build.ps1
|
||||
部署到正式系统
|
||||
|
||||
.EXAMPLE
|
||||
.\deploy-remote-build.ps1 -Target shadow
|
||||
部署到影子系统
|
||||
|
||||
.EXAMPLE
|
||||
.\deploy-remote-build.ps1 -NoCache
|
||||
强制重新构建(不使用缓存)
|
||||
#>
|
||||
|
||||
param(
|
||||
[ValidateSet('shadow', 'production')]
|
||||
[string]$Target = 'production',
|
||||
|
||||
[string]$BuildServerIP = '192.168.42.134',
|
||||
[string]$BuildServerUser = 'root',
|
||||
[string]$BuildServerPassword = 'Jsjj@8888',
|
||||
|
||||
[string]$ProdServerIP = '192.168.58.20',
|
||||
[string]$ProdServerUser = 'root',
|
||||
|
||||
[int]$RegistryPort = 5000,
|
||||
|
||||
[string]$ImageName = 'youyidian-3d-material',
|
||||
[string]$ImageTag = 'latest',
|
||||
|
||||
[switch]$SkipSync,
|
||||
[switch]$SkipBuild,
|
||||
[switch]$NoCache,
|
||||
[switch]$KeepOldImages,
|
||||
[switch]$Help
|
||||
)
|
||||
|
||||
# ==================== 配置 ====================
|
||||
|
||||
$config = @{
|
||||
'shadow' = @{
|
||||
'port' = 5320
|
||||
'containerName' = 'youyidian-3d-shadow'
|
||||
'dbName' = 'lobechat_stage'
|
||||
'envFile' = '.env.shadow'
|
||||
}
|
||||
'production' = @{
|
||||
'port' = 4320
|
||||
'containerName' = 'youyidian-3d-material'
|
||||
'dbName' = 'lobechat'
|
||||
'envFile' = '.env'
|
||||
}
|
||||
}
|
||||
|
||||
$targetConfig = $config[$Target]
|
||||
$RemoteBuildDir = "/opt/youyidian-3d-build"
|
||||
$RegistryImage = "$BuildServerIP`:$RegistryPort/$ImageName`:$ImageTag"
|
||||
|
||||
# ==================== 辅助函数 ====================
|
||||
|
||||
function Write-Success {
|
||||
param([string]$Message)
|
||||
Write-Host "[OK] $Message" -ForegroundColor Green
|
||||
}
|
||||
|
||||
function Write-Error-Custom {
|
||||
param([string]$Message)
|
||||
Write-Host "[ERR] $Message" -ForegroundColor Red
|
||||
}
|
||||
|
||||
function Write-Info {
|
||||
param([string]$Message)
|
||||
Write-Host "[INFO] $Message" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
function Write-Warning-Custom {
|
||||
param([string]$Message)
|
||||
Write-Host "[WARN] $Message" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
function Write-Step {
|
||||
param([int]$Step, [string]$Message)
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host "[$Step] $Message" -ForegroundColor Magenta
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
function Write-SubStep {
|
||||
param([string]$Message)
|
||||
Write-Host " -> $Message" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
function Write-StreamOutput {
|
||||
param([string]$Line, [string]$Prefix = " ")
|
||||
$lowerLine = $Line.ToLower()
|
||||
|
||||
# 关键错误信息 - 高亮显示
|
||||
if ($lowerLine -match "error:|failed|fatal|cannot|unable|denied|refused|timeout") {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Red
|
||||
}
|
||||
# 警告信息
|
||||
elseif ($lowerLine -match "warning|warn") {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Yellow
|
||||
}
|
||||
# 成功信息
|
||||
elseif ($lowerLine -match "success|complete|done|built") {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Green
|
||||
}
|
||||
# Docker 构建步骤
|
||||
elseif ($Line -match "Step \d+/\d+|^\s*\d+\.|RUN|COPY|FROM|CACHED|Sending build context") {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Cyan
|
||||
}
|
||||
# npm/pnpm 相关
|
||||
elseif ($Line -match "npm|pnpm|install|build|compile") {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Cyan
|
||||
}
|
||||
# DATABASE_URL 错误(这是正常的,但需要显示)
|
||||
elseif ($Line -match "DATABASE_URL|PrismaClientInitializationError") {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Yellow
|
||||
}
|
||||
# 其他信息
|
||||
else {
|
||||
Write-Host "$Prefix$Line" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
|
||||
# ==================== SSH 连接函数 ====================
|
||||
|
||||
function Invoke-SSH {
|
||||
param(
|
||||
[string]$HostIP,
|
||||
[string]$User,
|
||||
[string]$Password,
|
||||
[string]$Command,
|
||||
[switch]$Silent,
|
||||
[switch]$StreamOutput
|
||||
)
|
||||
|
||||
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
|
||||
|
||||
if (-not (Test-Path $plinkPath)) {
|
||||
Write-Error-Custom "找不到 plink.exe,请安装 PuTTY"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ($StreamOutput) {
|
||||
# 流式输出模式
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $plinkPath
|
||||
$psi.Arguments = "-batch -pw $Password $User@$HostIP `"$Command`""
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
|
||||
$process = New-Object System.Diagnostics.Process
|
||||
$process.StartInfo = $psi
|
||||
[void]$process.Start()
|
||||
|
||||
$outputBuilder = New-Object System.Text.StringBuilder
|
||||
$errorBuilder = New-Object System.Text.StringBuilder
|
||||
|
||||
$outputHandler = {
|
||||
if ($EventArgs.Data) {
|
||||
$line = $EventArgs.Data
|
||||
[void]$Event.MessageData.AppendLine($line)
|
||||
Write-StreamOutput -Line $line
|
||||
}
|
||||
}
|
||||
|
||||
$errorHandler = {
|
||||
if ($EventArgs.Data) {
|
||||
$line = $EventArgs.Data
|
||||
[void]$Event.MessageData.AppendLine($line)
|
||||
Write-StreamOutput -Line $line
|
||||
}
|
||||
}
|
||||
|
||||
$outputEvent = Register-ObjectEvent -InputObject $process -EventName OutputDataReceived -Action $outputHandler -MessageData $outputBuilder
|
||||
$errorEvent = Register-ObjectEvent -InputObject $process -EventName ErrorDataReceived -Action $errorHandler -MessageData $errorBuilder
|
||||
|
||||
$process.BeginOutputReadLine()
|
||||
$process.BeginErrorReadLine()
|
||||
$process.WaitForExit()
|
||||
|
||||
Unregister-Event -SourceIdentifier $outputEvent.Name
|
||||
Unregister-Event -SourceIdentifier $errorEvent.Name
|
||||
|
||||
Write-Host ""
|
||||
|
||||
return @{
|
||||
ExitCode = $process.ExitCode
|
||||
Output = $outputBuilder.ToString()
|
||||
Error = $errorBuilder.ToString()
|
||||
}
|
||||
}
|
||||
else {
|
||||
# 普通输出模式
|
||||
$result = & $plinkPath -batch -pw $Password "$User@$HostIP" $Command 2>&1
|
||||
|
||||
if (-not $Silent) {
|
||||
$result | ForEach-Object { Write-StreamOutput -Line $_ }
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-BuildServer {
|
||||
param(
|
||||
[string]$Command,
|
||||
[switch]$Silent,
|
||||
[switch]$StreamOutput,
|
||||
[string]$ServerIP = $BuildServerIP,
|
||||
[string]$ServerUser = $BuildServerUser,
|
||||
[string]$ServerPassword = $BuildServerPassword
|
||||
)
|
||||
|
||||
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
|
||||
if (-not (Test-Path $plinkPath)) {
|
||||
Write-Error-Custom "Cannot find plink.exe"
|
||||
return $null
|
||||
}
|
||||
|
||||
if ($StreamOutput) {
|
||||
# 流式输出模式
|
||||
$psiStream = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psiStream.FileName = $plinkPath
|
||||
$psiStream.Arguments = "-batch -pw $ServerPassword $ServerUser@$ServerIP `"$Command`""
|
||||
$psiStream.RedirectStandardOutput = $true
|
||||
$psiStream.RedirectStandardError = $true
|
||||
$psiStream.UseShellExecute = $false
|
||||
$psiStream.CreateNoWindow = $true
|
||||
$psiStream.StandardOutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$psiStream.StandardErrorEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
$process = New-Object System.Diagnostics.Process
|
||||
$process.StartInfo = $psiStream
|
||||
[void]$process.Start()
|
||||
|
||||
$outputBuilder = New-Object System.Text.StringBuilder
|
||||
$errorBuilder = New-Object System.Text.StringBuilder
|
||||
|
||||
$outputHandler = {
|
||||
if ($EventArgs.Data) {
|
||||
$line = $EventArgs.Data
|
||||
[void]$Event.MessageData.AppendLine($line)
|
||||
Write-StreamOutput -Line $line
|
||||
}
|
||||
}
|
||||
|
||||
$errorHandler = {
|
||||
if ($EventArgs.Data) {
|
||||
$line = $EventArgs.Data
|
||||
[void]$Event.MessageData.AppendLine($line)
|
||||
Write-StreamOutput -Line $line
|
||||
}
|
||||
}
|
||||
|
||||
$outputEvent = Register-ObjectEvent -InputObject $process -EventName OutputDataReceived -Action $outputHandler -MessageData $outputBuilder
|
||||
$errorEvent = Register-ObjectEvent -InputObject $process -EventName ErrorDataReceived -Action $errorHandler -MessageData $errorBuilder
|
||||
|
||||
$process.BeginOutputReadLine()
|
||||
$process.BeginErrorReadLine()
|
||||
$process.WaitForExit()
|
||||
|
||||
Unregister-Event -SourceIdentifier $outputEvent.Name -ErrorAction SilentlyContinue
|
||||
Unregister-Event -SourceIdentifier $errorEvent.Name -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host ""
|
||||
|
||||
return @{
|
||||
ExitCode = $process.ExitCode
|
||||
Output = $outputBuilder.ToString()
|
||||
Error = $errorBuilder.ToString()
|
||||
}
|
||||
}
|
||||
else {
|
||||
# 普通输出模式 - 使用直接调用
|
||||
& 'C:\Program Files\PuTTY\plink.exe' -batch -pw $ServerPassword "$ServerUser@$ServerIP" $Command 2>&1 | Tee-Object -Variable result
|
||||
|
||||
if (-not $Silent) {
|
||||
$result | ForEach-Object { Write-StreamOutput -Line $_ }
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-ProdServer {
|
||||
param(
|
||||
[string]$Command,
|
||||
[switch]$Silent,
|
||||
[switch]$StreamOutput
|
||||
)
|
||||
$escapedCmd = $Command -replace "'", "'\\''"
|
||||
$sshCmd = "ssh -o StrictHostKeyChecking=no $ProdServerUser@$ProdServerIP '$escapedCmd'"
|
||||
Invoke-BuildServer -Command $sshCmd -Silent:$Silent -StreamOutput:$StreamOutput -ServerIP $BuildServerIP -ServerUser $BuildServerUser -ServerPassword $BuildServerPassword
|
||||
}
|
||||
|
||||
# ==================== 文件上传函数 ====================
|
||||
|
||||
function Upload-ToBuildServer {
|
||||
param([string]$LocalPath, [string]$RemotePath)
|
||||
|
||||
Write-SubStep "Start uploading..."
|
||||
|
||||
$pscpPath = "C:\Program Files\PuTTY\pscp.exe"
|
||||
|
||||
if (-not (Test-Path $pscpPath)) {
|
||||
Write-Error-Custom "找不到 pscp.exe,请安装 PuTTY"
|
||||
return $false
|
||||
}
|
||||
|
||||
$fileSize = (Get-Item $LocalPath).Length / 1MB
|
||||
Write-Info " File size: $([Math]::Round($fileSize, 2)) MB"
|
||||
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $pscpPath
|
||||
$psi.Arguments = "-batch -pw $BuildServerPassword $LocalPath `"$BuildServerUser@$BuildServerIP`:$RemotePath`""
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
|
||||
$process = New-Object System.Diagnostics.Process
|
||||
$process.StartInfo = $psi
|
||||
[void]$process.Start()
|
||||
$process.WaitForExit()
|
||||
|
||||
return $process.ExitCode -eq 0
|
||||
}
|
||||
|
||||
# ==================== 帮助信息 ====================
|
||||
|
||||
function Show-Help {
|
||||
Write-Host @"
|
||||
由壹点3D素材 - 远程构建部署脚本(内网环境)
|
||||
|
||||
用法:
|
||||
.\deploy-remote-build.ps1 # 部署到正式系统
|
||||
.\deploy-remote-build.ps1 -Target shadow # 部署到影子系统
|
||||
|
||||
参数:
|
||||
-Target 部署目标: shadow 或 production (默认 production)
|
||||
-BuildServerIP 构建机 IP (默认: 192.168.42.134)
|
||||
-ProdServerIP 生产服务器 IP (默认: 192.168.58.20)
|
||||
-ImageName 镜像名称 (默认: youyidian-3d-material)
|
||||
-ImageTag 镜像标签 (默认: latest)
|
||||
-SkipSync 跳过代码同步
|
||||
-SkipBuild 跳过镜像构建
|
||||
-NoCache 构建时不使用缓存 (强制重新构建)
|
||||
-KeepOldImages 保留旧镜像 (不自动清理)
|
||||
-Help 显示帮助
|
||||
|
||||
流程:
|
||||
1. 打包代码 (排除 node_modules, .next 等)
|
||||
2. 上传代码到构建机
|
||||
3. 智能检测是否需要重新构建
|
||||
4. 在构建机上构建 Docker 镜像 (如需要)
|
||||
5. 推送镜像到本地 Registry
|
||||
6. 从 Registry 拉取镜像到生产服务器
|
||||
7. 在生产服务器上启动容器
|
||||
8. 自动清理旧镜像和缓存
|
||||
|
||||
Registry UI:
|
||||
http://$BuildServerIP`:5001
|
||||
|
||||
示例:
|
||||
# 部署到正式系统 (智能缓存)
|
||||
.\deploy-remote-build.ps1
|
||||
|
||||
# 部署到影子系统
|
||||
.\deploy-remote-build.ps1 -Target shadow
|
||||
|
||||
# 强制重新构建 (不使用缓存)
|
||||
.\deploy-remote-build.ps1 -NoCache
|
||||
|
||||
# 跳过代码同步, 直接构建
|
||||
.\deploy-remote-build.ps1 -SkipSync
|
||||
"@
|
||||
}
|
||||
|
||||
# ==================== 主逻辑 ====================
|
||||
|
||||
function Main {
|
||||
$startTime = Get-Date
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host " 由壹点3D素材 - 远程构建部署 (内网)" -ForegroundColor Cyan
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
if ($Help) { Show-Help; return }
|
||||
|
||||
# 显示配置
|
||||
Write-Host "Deployment Configuration:" -ForegroundColor Magenta
|
||||
Write-Host "--------------------------------------------------" -ForegroundColor Cyan
|
||||
Write-Info "Target: $Target"
|
||||
Write-Info "Build Server: $BuildServerIP"
|
||||
Write-Info "Production Server: $ProdServerIP"
|
||||
Write-Info "Container Name: $($targetConfig['containerName'])"
|
||||
Write-Info "Port: $($targetConfig['port'])"
|
||||
Write-Info "Registry UI: http://$BuildServerIP`:5001"
|
||||
Write-Host ""
|
||||
|
||||
# ==================== 步骤 0: 检查连接 ====================
|
||||
Write-Step 0 "Check Environment and Connections"
|
||||
|
||||
Write-SubStep "Checking build server connection..."
|
||||
$dockerCheck = Invoke-BuildServer -Command "docker --version" -Silent
|
||||
if ($dockerCheck -notmatch "Docker version") {
|
||||
Write-Error-Custom "Cannot connect to build server or Docker not installed"
|
||||
Write-Info "Please check:"
|
||||
Write-Info " 1. Build server IP: $BuildServerIP"
|
||||
Write-Info " 2. SSH password is correct"
|
||||
Write-Info " 3. Docker is installed"
|
||||
return
|
||||
}
|
||||
$dockerVersion = $dockerCheck -replace "Docker version ", "" -replace ",.*", ""
|
||||
Write-Success "Build server connected (Docker: $dockerVersion)"
|
||||
|
||||
Write-SubStep "Checking registry status..."
|
||||
$registryCheck = Invoke-BuildServer -Command "curl -s http://localhost:5000/v2/_catalog" -Silent
|
||||
if ($registryCheck -notmatch "repositories") {
|
||||
Write-Warning-Custom "Registry not running, trying to start..."
|
||||
Invoke-BuildServer -Command "cd /opt/docker-registry && docker-compose up -d" -Silent | Out-Null
|
||||
Start-Sleep -Seconds 5
|
||||
$registryCheck = Invoke-BuildServer -Command "curl -s http://localhost:5000/v2/_catalog" -Silent
|
||||
if ($registryCheck -match "repositories") {
|
||||
Write-Success "Registry started"
|
||||
}
|
||||
else {
|
||||
Write-Error-Custom "Registry failed to start"
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Success "Registry is running"
|
||||
}
|
||||
|
||||
Write-SubStep "Checking production server connection..."
|
||||
$prodCheck = Invoke-ProdServer -Command "echo 'OK'" -Silent
|
||||
if ($prodCheck -notmatch "OK") {
|
||||
Write-Error-Custom "Cannot connect to production server"
|
||||
return
|
||||
}
|
||||
Write-Success "Production server connected"
|
||||
|
||||
# ==================== 步骤 1: 同步代码 ====================
|
||||
if (-not $SkipSync) {
|
||||
Write-Step 1 "Sync Code to Build Server"
|
||||
|
||||
Write-SubStep "Packaging code..."
|
||||
$tempTar = "code-sync-temp.tar.gz"
|
||||
$excludes = @(
|
||||
"node_modules", ".next", ".git", "*.tar", "*.tar.gz", "uploads/*",
|
||||
".build-cache", ".docker-cache", "cache", "flnxi_sucai", "gongxiangp2", "backups",
|
||||
"*.log", ".env.local"
|
||||
)
|
||||
$tarExcludes = $excludes | ForEach-Object { "--exclude=$_" }
|
||||
|
||||
$tarCmd = "tar -czf $tempTar $($tarExcludes -join ' ') ."
|
||||
$bashPath = "C:\Program Files\Git\bin\bash.exe"
|
||||
if (Test-Path $bashPath) {
|
||||
& $bashPath -c $tarCmd 2>&1 | Out-Null
|
||||
}
|
||||
else {
|
||||
Write-Error-Custom "Cannot find Git bash, code packaging failed"
|
||||
return
|
||||
}
|
||||
|
||||
if (-not (Test-Path $tempTar)) {
|
||||
Write-Error-Custom "Code packaging failed"
|
||||
return
|
||||
}
|
||||
|
||||
$tarSize = [Math]::Round((Get-Item $tempTar).Length / 1MB, 2)
|
||||
Write-Success "Code packaged ($tarSize MB)"
|
||||
|
||||
Write-SubStep "Uploading code..."
|
||||
$uploadSuccess = Upload-ToBuildServer -LocalPath $tempTar -RemotePath "/tmp/$tempTar"
|
||||
|
||||
if (-not $uploadSuccess) {
|
||||
Write-Error-Custom "Code upload failed"
|
||||
Remove-Item $tempTar -Force -ErrorAction SilentlyContinue
|
||||
return
|
||||
}
|
||||
|
||||
Write-SubStep "Updating build directory..."
|
||||
Invoke-BuildServer -Command "mkdir -p $RemoteBuildDir && cd $RemoteBuildDir && tar -xzf /tmp/$tempTar && rm /tmp/$tempTar" -Silent | Out-Null
|
||||
|
||||
Write-Success "Code updated"
|
||||
|
||||
Remove-Item $tempTar -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Success "Code sync completed"
|
||||
}
|
||||
else {
|
||||
Write-Step 1 "Skip Code Sync"
|
||||
Write-Info "Using existing code on build server"
|
||||
}
|
||||
|
||||
# ==================== 步骤 2: 智能构建镜像 ====================
|
||||
if (-not $SkipBuild) {
|
||||
Write-Step 2 "Build Docker Image"
|
||||
|
||||
Write-SubStep "Checking if rebuild is needed..."
|
||||
|
||||
$needRebuild = $false
|
||||
$rebuildReason = ""
|
||||
|
||||
$imageExists = Invoke-BuildServer -Command "docker images $ImageName`:$ImageTag --format '{{.Repository}}:{{.Tag}}'" -Silent
|
||||
if ($imageExists -notmatch "$ImageName`:$ImageTag") {
|
||||
$needRebuild = $true
|
||||
$rebuildReason = "Image does not exist"
|
||||
}
|
||||
|
||||
if (-not $needRebuild -and -not $SkipSync) {
|
||||
$needRebuild = $true
|
||||
$rebuildReason = "Code updated"
|
||||
}
|
||||
|
||||
if ($NoCache) {
|
||||
$needRebuild = $true
|
||||
$rebuildReason = "Force rebuild (-NoCache)"
|
||||
}
|
||||
|
||||
if ($needRebuild) {
|
||||
Write-Info "Need to rebuild: $rebuildReason"
|
||||
Write-Info "Image name: $ImageName`:$ImageTag"
|
||||
Write-Info "Build strategy: Direct build with real-time logs"
|
||||
Write-Info "Estimated time: 3-5 min (first), 1-2 min (cached)"
|
||||
Write-Host ""
|
||||
|
||||
$cacheArg = if ($NoCache) { "--no-cache" } else { "" }
|
||||
|
||||
Write-SubStep "Starting build (real-time output)..."
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host "Real-time Build Logs:" -ForegroundColor Magenta
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
$buildCmd = "cd $RemoteBuildDir && timeout 900 docker build $cacheArg -t $ImageName`:$ImageTag . 2>&1"
|
||||
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = "C:\Program Files\PuTTY\plink.exe"
|
||||
$psi.Arguments = "-batch -pw $BuildServerPassword $BuildServerUser@$BuildServerIP `"$buildCmd`""
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
$psi.StandardOutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$psi.StandardErrorEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
$process = New-Object System.Diagnostics.Process
|
||||
$process.StartInfo = $psi
|
||||
[void]$process.Start()
|
||||
|
||||
$buildSuccess = $false
|
||||
|
||||
# 使用异步事件处理输出,避免挂起
|
||||
$outputBuilder = New-Object System.Text.StringBuilder
|
||||
$errorBuilder = New-Object System.Text.StringBuilder
|
||||
|
||||
$outputHandler = {
|
||||
if ($EventArgs.Data) {
|
||||
$line = $EventArgs.Data
|
||||
[void]$Event.MessageData.AppendLine($line)
|
||||
# 清理 ANSI 颜色代码,但保留所有内容
|
||||
$cleanLine = $line -replace '\x1b\[[0-9;]*[a-zA-Z]', ''
|
||||
# 移除回车符
|
||||
$cleanLine = $cleanLine -replace '\r', ''
|
||||
# 显示所有非空行
|
||||
if ($cleanLine.Trim()) {
|
||||
Write-StreamOutput -Line $cleanLine
|
||||
}
|
||||
# 即使是空行,如果有内容也要输出
|
||||
elseif ($line.Trim()) {
|
||||
Write-Host " $line" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$errorHandler = {
|
||||
if ($EventArgs.Data) {
|
||||
$line = $EventArgs.Data
|
||||
[void]$Event.MessageData.AppendLine($line)
|
||||
# 清理 ANSI 颜色代码
|
||||
$cleanLine = $line -replace '\x1b\[[0-9;]*[a-zA-Z]', ''
|
||||
# 移除回车符
|
||||
$cleanLine = $cleanLine -replace '\r', ''
|
||||
# 显示所有错误输出
|
||||
Write-Host " [ERROR] $cleanLine" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
$outputEvent = Register-ObjectEvent -InputObject $process -EventName OutputDataReceived -Action $outputHandler -MessageData $outputBuilder
|
||||
$errorEvent = Register-ObjectEvent -InputObject $process -EventName ErrorDataReceived -Action $errorHandler -MessageData $errorBuilder
|
||||
|
||||
$process.BeginOutputReadLine()
|
||||
$process.BeginErrorReadLine()
|
||||
$process.WaitForExit()
|
||||
|
||||
Unregister-Event -SourceIdentifier $outputEvent.Name -ErrorAction SilentlyContinue
|
||||
Unregister-Event -SourceIdentifier $errorEvent.Name -ErrorAction SilentlyContinue
|
||||
|
||||
# 检查构建是否成功
|
||||
$allOutput = $outputBuilder.ToString()
|
||||
$allErrors = $errorBuilder.ToString()
|
||||
|
||||
if ($allOutput -match "Successfully built|Successfully tagged") {
|
||||
$buildSuccess = $true
|
||||
}
|
||||
|
||||
if ($process.ExitCode -eq 0) {
|
||||
$imageCheck = Invoke-BuildServer -Command "docker images $ImageName`:$ImageTag --format '{{.Repository}}:{{.Tag}}'" -Silent
|
||||
if ($imageCheck -match "$ImageName`:$ImageTag") {
|
||||
$buildSuccess = $true
|
||||
}
|
||||
}
|
||||
|
||||
# 如果构建失败,显示完整的错误输出
|
||||
if (-not $buildSuccess) {
|
||||
Write-Host ""
|
||||
Write-Error-Custom "Build failed (exit code: $($process.ExitCode))"
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Red
|
||||
Write-Host "Full Error Output:" -ForegroundColor Red
|
||||
Write-Host "==================================================" -ForegroundColor Red
|
||||
|
||||
# 显示标准输出中的错误
|
||||
if ($allOutput) {
|
||||
$allOutput -split "`n" | ForEach-Object {
|
||||
$line = $_ -replace '\x1b\[[0-9;]*[a-zA-Z]', '' -replace '\r', ''
|
||||
if ($line.ToLower() -match "error|failed|fatal") {
|
||||
Write-Host " $line" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 显示标准错误输出
|
||||
if ($allErrors) {
|
||||
Write-Host ""
|
||||
Write-Host "Standard Error:" -ForegroundColor Yellow
|
||||
Write-Host "--------------------------------------------------" -ForegroundColor Yellow
|
||||
$allErrors -split "`n" | ForEach-Object {
|
||||
$line = $_ -replace '\x1b\[[0-9;]*[a-zA-Z]', '' -replace '\r', ''
|
||||
if ($line.Trim()) {
|
||||
Write-Host " $line" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "==================================================" -ForegroundColor Red
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host "Build Completed" -ForegroundColor Magenta
|
||||
Write-Host "==================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
$imageSize = Invoke-BuildServer -Command "docker images $ImageName`:$ImageTag --format '{{.Size}}'" -Silent
|
||||
Write-Success "Image built successfully (size: $imageSize)"
|
||||
}
|
||||
else {
|
||||
Write-Success "No need to rebuild, using existing image"
|
||||
$imageSize = Invoke-BuildServer -Command "docker images $ImageName`:$ImageTag --format '{{.Size}}'" -Silent
|
||||
$imageCreated = Invoke-BuildServer -Command "docker images $ImageName`:$ImageTag --format '{{.CreatedAt}}'" -Silent
|
||||
Write-Info "Image size: $imageSize"
|
||||
Write-Info "Build time: $imageCreated"
|
||||
Write-Info "Tip: Use -NoCache to force rebuild"
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Step 2 "Skip Image Build"
|
||||
Write-Info "Using existing image on build server"
|
||||
}
|
||||
|
||||
# ==================== 步骤 3: 推送到 Registry ====================
|
||||
Write-Step 3 "Push Image to Registry"
|
||||
|
||||
Write-SubStep "Tagging image..."
|
||||
Invoke-BuildServer -Command "docker tag $ImageName`:$ImageTag $RegistryImage" -Silent | Out-Null
|
||||
Write-Success "Image tagged: $RegistryImage"
|
||||
|
||||
Write-SubStep "Pushing to registry (real-time output)..."
|
||||
Write-Host ""
|
||||
|
||||
$pushCmd = "docker push $RegistryImage 2>&1"
|
||||
$pushResult = Invoke-BuildServer -Command $pushCmd -StreamOutput
|
||||
|
||||
Write-Host ""
|
||||
|
||||
if ($pushResult.ExitCode -eq 0) {
|
||||
Write-Success "Image pushed to registry"
|
||||
Write-Info "View image: http://$BuildServerIP`:5001"
|
||||
}
|
||||
else {
|
||||
Write-Error-Custom "Image push failed"
|
||||
return
|
||||
}
|
||||
|
||||
# ==================== 步骤 4: 生产服务器拉取镜像 ====================
|
||||
Write-Step 4 "Pull Image on Production Server"
|
||||
|
||||
Write-SubStep "Pulling from registry (real-time output)..."
|
||||
Write-Info "Registry: $RegistryImage"
|
||||
Write-Host ""
|
||||
|
||||
$pullCmd = "docker pull $RegistryImage 2>&1 && docker tag $RegistryImage $ImageName`:$ImageTag"
|
||||
$pullResult = Invoke-ProdServer -Command $pullCmd -StreamOutput
|
||||
|
||||
Write-Host ""
|
||||
|
||||
if ($pullResult.ExitCode -eq 0) {
|
||||
Write-Success "Image pulled successfully"
|
||||
}
|
||||
else {
|
||||
Write-Error-Custom "Image pull failed"
|
||||
Write-Info "Please check insecure-registry config on production server"
|
||||
return
|
||||
}
|
||||
|
||||
# ==================== 步骤 5: 启动容器 ====================
|
||||
Write-Step 5 "Start Container on Production Server"
|
||||
|
||||
$envFile = $targetConfig['envFile']
|
||||
$containerName = $targetConfig['containerName']
|
||||
$port = $targetConfig['port']
|
||||
$deploymentVersion = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
|
||||
$downloadTokenSecret = "yydd-product-package-download-token-secret-2026"
|
||||
|
||||
Write-SubStep "Stopping old container..."
|
||||
Invoke-ProdServer -Command "docker stop $containerName 2>/dev/null || true" -Silent | Out-Null
|
||||
Invoke-ProdServer -Command "docker rm $containerName 2>/dev/null || true" -Silent | Out-Null
|
||||
Write-Success "Old container stopped"
|
||||
|
||||
Write-SubStep "Starting new container..."
|
||||
$startCmd = "docker run -d --name $containerName -p $port`:3000 -v /mnt/PoolOne/apps/youyidian-3d/uploads:/app/uploads --env-file /mnt/PoolOne/apps/youyidian-3d/$envFile -e DISABLE_CACHE=true -e DEPLOYMENT_VERSION=$deploymentVersion -e DOWNLOAD_TOKEN_SECRET=$downloadTokenSecret $ImageName`:$ImageTag"
|
||||
|
||||
$containerIdResult = Invoke-ProdServer -Command $startCmd -Silent
|
||||
|
||||
if (-not $containerIdResult -or $containerIdResult -match "Error") {
|
||||
Write-Error-Custom "Container start command failed"
|
||||
Write-Host " Error: $containerIdResult" -ForegroundColor Red
|
||||
return
|
||||
}
|
||||
|
||||
Write-SubStep "Waiting for container to start..."
|
||||
Start-Sleep -Seconds 5
|
||||
|
||||
Write-SubStep "Checking container status (with retry)..."
|
||||
$containerStatus = "not_found"
|
||||
$maxRetries = 6
|
||||
$retryCount = 0
|
||||
|
||||
while ($retryCount -lt $maxRetries) {
|
||||
$containerStatus = Invoke-ProdServer -Command "docker inspect -f '{{.State.Running}}' $containerName 2>/dev/null || echo 'not_found'" -Silent
|
||||
if ($containerStatus -match "true") {
|
||||
break
|
||||
}
|
||||
$retryCount++
|
||||
if ($retryCount -lt $maxRetries) {
|
||||
Write-Info " Retry $retryCount/$maxRetries..."
|
||||
Start-Sleep -Seconds 5
|
||||
}
|
||||
}
|
||||
|
||||
if ($containerStatus -match "true") {
|
||||
Write-Success "Container started successfully"
|
||||
Write-Info "Container name: $containerName"
|
||||
Write-Info "URL: http://$ProdServerIP`:$port"
|
||||
|
||||
Write-SubStep "Waiting for application to be ready (checking logs)..."
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
Write-SubStep "Container logs (last 10 lines):"
|
||||
$logs = Invoke-ProdServer -Command "docker logs --tail 10 $containerName 2>&1" -Silent
|
||||
if ($logs) {
|
||||
$logs -split "`n" | ForEach-Object {
|
||||
if ($_ -match "Ready in|ready|started") {
|
||||
Write-Host " $_" -ForegroundColor Green
|
||||
}
|
||||
elseif ($_ -match "error|Error|ERROR|failed|Failed|FAILED") {
|
||||
Write-Host " $_" -ForegroundColor Red
|
||||
}
|
||||
else {
|
||||
Write-Host " $_" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Error-Custom "Container failed to start after $maxRetries retries"
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Red
|
||||
Write-Host "Container Error Logs:" -ForegroundColor Red
|
||||
Write-Host "==================================================" -ForegroundColor Red
|
||||
$errorLogs = Invoke-ProdServer -Command "docker logs --tail 100 $containerName 2>&1" -Silent
|
||||
if ($errorLogs) {
|
||||
$errorLogs -split "`n" | ForEach-Object {
|
||||
Write-Host " $_" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host " Cannot get logs (container may not exist)" -ForegroundColor Red
|
||||
}
|
||||
Write-Host "==================================================" -ForegroundColor Red
|
||||
return
|
||||
}
|
||||
|
||||
# ==================== 步骤 6: 清理资源 ====================
|
||||
if (-not $KeepOldImages) {
|
||||
Write-Step 6 "Clean Up Resources"
|
||||
|
||||
Write-SubStep "Cleaning build server..."
|
||||
$cleanBuildCmd = "docker builder prune -af --filter 'until=6h' 2>&1; docker image prune -f 2>&1"
|
||||
Invoke-BuildServer -Command $cleanBuildCmd | Out-Null
|
||||
Write-Success "Build server cleaned"
|
||||
|
||||
Write-SubStep "Cleaning production server..."
|
||||
$cleanProdCmd = "docker image prune -af --filter 'until=6h' 2>&1; docker container prune -f --filter 'until=6h' 2>&1"
|
||||
Invoke-ProdServer -Command $cleanProdCmd | Out-Null
|
||||
Write-Success "Production server cleaned"
|
||||
|
||||
Write-Success "Resource cleanup completed"
|
||||
}
|
||||
else {
|
||||
Write-Step 6 "Skip Resource Cleanup"
|
||||
Write-Info "Keep all old images"
|
||||
}
|
||||
|
||||
# ==================== 完成 ====================
|
||||
$endTime = Get-Date
|
||||
$duration = [Math]::Round(($endTime - $startTime).TotalSeconds)
|
||||
$minutes = [Math]::Floor($duration / 60)
|
||||
$seconds = $duration % 60
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "==================================================" -ForegroundColor Green
|
||||
Write-Host " Deployment Successful!" -ForegroundColor Green
|
||||
Write-Host "==================================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Deployment Statistics:" -ForegroundColor Magenta
|
||||
Write-Host "--------------------------------------------------" -ForegroundColor Cyan
|
||||
Write-Info "Target: $Target"
|
||||
Write-Info "Container: $containerName"
|
||||
Write-Info "URL: http://$ProdServerIP`:$port"
|
||||
Write-Info "Registry UI: http://$BuildServerIP`:5001"
|
||||
Write-Info "Total time: $minutes min $seconds sec"
|
||||
Write-Host ""
|
||||
Write-Success "Deployment completed! Ready to use."
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# 执行主逻辑(只在脚本被直接执行时运行)
|
||||
if ($MyInvocation.InvocationName -ne '.') {
|
||||
Main
|
||||
}
|
||||
@ -96,6 +96,7 @@ export async function getMaterialByTaskNo(taskNo: string) {
|
||||
|
||||
/**
|
||||
* 获取素材的资产列表(按类型分组)
|
||||
* 兼容新旧两种资产类型格式
|
||||
*/
|
||||
export async function getAssetsByMaterialId(materialId: string) {
|
||||
const assets = await prisma.materialAsset.findMany({
|
||||
@ -184,9 +185,10 @@ export async function updateAssetSortOrder(
|
||||
/**
|
||||
* 获取素材封面图(用于卡片展示)
|
||||
* 优先使用第一张主图,没有则使用第一张SKU图
|
||||
* 兼容新旧两种资产类型格式
|
||||
*/
|
||||
export async function getMaterialCoverUrl(materialId: string): Promise<string | null> {
|
||||
// 先找主图
|
||||
// 先找主图(新逻辑)
|
||||
const mainAsset = await prisma.materialAsset.findFirst({
|
||||
where: { materialId, assetType: ASSET_TYPE.MAIN },
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
@ -197,7 +199,7 @@ export async function getMaterialCoverUrl(materialId: string): Promise<string |
|
||||
return mainAsset.fileUrl;
|
||||
}
|
||||
|
||||
// 没有主图,找SKU图
|
||||
// 没有主图,找SKU图(新逻辑)
|
||||
const skuAsset = await prisma.materialAsset.findFirst({
|
||||
where: { materialId, assetType: ASSET_TYPE.SKU },
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
|
||||
@ -14,6 +14,9 @@ import archiver from 'archiver';
|
||||
// 资产类型常量
|
||||
export const ASSET_TYPE = {
|
||||
PREVIEW: 'preview',
|
||||
MAIN_PREVIEW: 'main-preview',
|
||||
SKU_PREVIEW: 'sku-preview',
|
||||
DETAIL_PREVIEW: 'detail-preview',
|
||||
ZIP: 'zip',
|
||||
MAIN: 'main',
|
||||
SKU: 'sku',
|
||||
@ -30,7 +33,9 @@ export async function createZipFromFiles(
|
||||
materialId: string,
|
||||
productModel: string,
|
||||
materialType: string,
|
||||
zipType: string = 'all' // 'main', 'sku', 'detail', 'all'
|
||||
zipType: string = 'all', // 'main', 'sku', 'detail', 'all'
|
||||
authorName?: string, // 作者名(上传人姓名)
|
||||
categoryName?: string // 店铺名
|
||||
): Promise<{ filePath: string; fileName: string; fileSize: number }> {
|
||||
if (!files || files.length === 0) {
|
||||
throw new Error('没有文件需要打包');
|
||||
@ -54,7 +59,18 @@ export async function createZipFromFiles(
|
||||
const timestamp = Date.now();
|
||||
// 只清理文件系统不安全的字符:/ \ : * ? " < > |
|
||||
const sanitizedProductModel = productModel.replace(/[\/\\:*?"<>|]/g, '_');
|
||||
const zipFileName = `${sanitizedProductModel}_${zipType}_${materialId}_${timestamp}.zip`;
|
||||
|
||||
// 如果提供了作者名和店铺名,使用新的命名格式:SPU型号_作者名_店铺名_类型.zip
|
||||
let zipFileName: string;
|
||||
if (authorName && categoryName && zipType !== 'all') {
|
||||
const sanitizedAuthorName = authorName.replace(/[\/\\:*?"<>|]/g, '_');
|
||||
const sanitizedCategoryName = categoryName.replace(/[\/\\:*?"<>|]/g, '_');
|
||||
zipFileName = `${sanitizedProductModel}_${sanitizedAuthorName}_${sanitizedCategoryName}_${zipType}.zip`;
|
||||
} else {
|
||||
// 保持原有命名格式(用于all.zip或其他情况)
|
||||
zipFileName = `${sanitizedProductModel}_${zipType}_${materialId}_${timestamp}.zip`;
|
||||
}
|
||||
|
||||
const zipFilePath = path.join(uploadsDir, zipFileName);
|
||||
const relativeZipPath = path.join('uploads', 'materials', zipFileName);
|
||||
|
||||
@ -130,21 +146,21 @@ export async function createZipFromFiles(
|
||||
|
||||
/**
|
||||
* 打包已有的zip文件成一个总zip(用于任务-详情的all.zip)
|
||||
* 注意:不再打包PSD文件,PSD文件单独存储和下载
|
||||
*/
|
||||
export async function createZipFromZips(
|
||||
zipFiles: Array<{ path: string; name: string }>,
|
||||
psdFiles: Array<{ path: string; name: string }>,
|
||||
materialId: string,
|
||||
productModel: string,
|
||||
materialType: string
|
||||
): Promise<{ filePath: string; fileName: string; fileSize: number }> {
|
||||
if (zipFiles.length === 0 && psdFiles.length === 0) {
|
||||
if (zipFiles.length === 0) {
|
||||
throw new Error('没有文件需要打包');
|
||||
}
|
||||
|
||||
// 验证所有文件路径存在
|
||||
const { access } = await import('fs/promises');
|
||||
for (const file of [...zipFiles, ...psdFiles]) {
|
||||
for (const file of zipFiles) {
|
||||
try {
|
||||
const fullPath = path.isAbsolute(file.path) ? file.path : path.join(process.cwd(), file.path);
|
||||
await access(fullPath);
|
||||
@ -166,7 +182,6 @@ export async function createZipFromZips(
|
||||
|
||||
console.log(`[Zip] Creating all.zip for ${materialType}:`, zipFilePath);
|
||||
console.log(`[Zip] Zip files count:`, zipFiles.length);
|
||||
console.log(`[Zip] PSD files count:`, psdFiles.length);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
@ -214,20 +229,13 @@ export async function createZipFromZips(
|
||||
|
||||
archive.pipe(output);
|
||||
|
||||
// 添加zip文件
|
||||
// 只添加zip文件,不添加PSD文件
|
||||
for (const file of zipFiles) {
|
||||
const fullPath = path.isAbsolute(file.path) ? file.path : path.join(process.cwd(), file.path);
|
||||
console.log(`[Zip] Adding zip file: ${file.name}`);
|
||||
archive.file(fullPath, { name: file.name });
|
||||
}
|
||||
|
||||
// 添加PSD文件
|
||||
for (const file of psdFiles) {
|
||||
const fullPath = path.isAbsolute(file.path) ? file.path : path.join(process.cwd(), file.path);
|
||||
console.log(`[Zip] Adding PSD file: ${file.name}`);
|
||||
archive.file(fullPath, { name: `psd/${file.name}` });
|
||||
}
|
||||
|
||||
archive.finalize();
|
||||
} catch (error) {
|
||||
clearTimeout(timeout);
|
||||
@ -535,7 +543,7 @@ export async function saveProductPackageAssets(
|
||||
previewUrls.main.forEach((url, index) => {
|
||||
assetRecords.push({
|
||||
materialId,
|
||||
assetType: ASSET_TYPE.PREVIEW,
|
||||
assetType: ASSET_TYPE.MAIN_PREVIEW,
|
||||
fileUrl: url,
|
||||
fileName: `main-preview-${index}.webp`,
|
||||
sortOrder: previewIndex++,
|
||||
@ -546,7 +554,7 @@ export async function saveProductPackageAssets(
|
||||
previewUrls.sku.forEach((url, index) => {
|
||||
assetRecords.push({
|
||||
materialId,
|
||||
assetType: ASSET_TYPE.PREVIEW,
|
||||
assetType: ASSET_TYPE.SKU_PREVIEW,
|
||||
fileUrl: url,
|
||||
fileName: `sku-preview-${index}.webp`,
|
||||
sortOrder: previewIndex++,
|
||||
@ -557,7 +565,7 @@ export async function saveProductPackageAssets(
|
||||
previewUrls.detail.forEach((url, index) => {
|
||||
assetRecords.push({
|
||||
materialId,
|
||||
assetType: ASSET_TYPE.PREVIEW,
|
||||
assetType: ASSET_TYPE.DETAIL_PREVIEW,
|
||||
fileUrl: url,
|
||||
fileName: `detail-preview-${index}.webp`,
|
||||
sortOrder: previewIndex++,
|
||||
|
||||
@ -148,12 +148,25 @@ export async function getUploadedFile(uploadId: string): Promise<string | null>
|
||||
}
|
||||
|
||||
const path = await import('path');
|
||||
const { readdir, readFile, writeFile, mkdir } = await import('fs/promises');
|
||||
const { readdir, readFile, writeFile, mkdir, access } = await import('fs/promises');
|
||||
|
||||
// Chunk文件所在目录
|
||||
const tempDir = path.join(process.env.UPLOAD_DIR || './uploads', 'temp', uploadId);
|
||||
|
||||
// 输出目录和路径
|
||||
const outputDir = path.join(process.env.UPLOAD_DIR || './uploads', 'assembled');
|
||||
const outputPath = path.join(outputDir, `${uploadId}-${session.fileName}`);
|
||||
|
||||
try {
|
||||
// 先检查文件是否已经存在(避免重复组装)
|
||||
try {
|
||||
await access(outputPath);
|
||||
console.log(`[Upload Session] File already exists, skip assembly: ${outputPath}`);
|
||||
return outputPath;
|
||||
} catch (e) {
|
||||
// 文件不存在,需要组装
|
||||
}
|
||||
|
||||
// 读取所有chunk文件
|
||||
const files = await readdir(tempDir);
|
||||
const chunkFiles = files
|
||||
@ -168,12 +181,9 @@ export async function getUploadedFile(uploadId: string): Promise<string | null>
|
||||
return null;
|
||||
}
|
||||
|
||||
// 组装完整文件
|
||||
const outputDir = path.join(process.env.UPLOAD_DIR || './uploads', 'assembled');
|
||||
// 创建输出目录
|
||||
await mkdir(outputDir, { recursive: true });
|
||||
|
||||
const outputPath = path.join(outputDir, `${uploadId}-${session.fileName}`);
|
||||
|
||||
// 按顺序读取并写入所有chunk
|
||||
const chunks: Buffer[] = [];
|
||||
for (const chunkFile of chunkFiles) {
|
||||
|
||||
93
logs/migrated-ids.txt
Normal file
@ -0,0 +1,93 @@
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
f8148b30-d83f-4e6a-800e-fa047efd9b16
|
||||
695c48f0-53a9-4870-aa07-76261fdf4a31
|
||||
2d10faf8-346e-4435-9dcc-c3cd28a02d2c
|
||||
228c7c9b-eafa-4b52-b94c-198373e3902f
|
||||
dc49b1b0-2b5f-414e-b099-bb0388734cef
|
||||
0418b190-ec90-47ed-a868-9917d0207b6a
|
||||
81802ea6-2b28-46d6-8fc7-931e88b338f3
|
||||
36c377fe-49c4-432b-a717-a243c0e7ab89
|
||||
d18ce556-e3f1-49e5-beb3-a39fe044546f
|
||||
ffb8a024-667d-4284-abd9-85a11e94fd54
|
||||
5875c1db-0f3b-4760-9f7e-045446d37aac
|
||||
d6b9cf44-0631-4237-a67a-495a13604b5e
|
||||
cb880417-0f44-4541-8bbe-cf82b388b0b1
|
||||
101aea94-7460-4ae6-8980-a5a87698574d
|
||||
a2e9568b-eca1-4896-abfa-512f8b2f8047
|
||||
310b405f-a1df-4f89-87b0-ea61960162fb
|
||||
581173bc-672d-411b-81a4-eb58b5db7d37
|
||||
0dab1ccb-6c17-4a87-85f9-062573c3fac9
|
||||
a9fff2da-562b-492d-93de-d3d7f6af5a83
|
||||
b985e22b-5ecc-495d-8405-0ff760fe25f5
|
||||
7d01a3ab-8a99-4966-9f5e-53b5ef6cfad1
|
||||
104cd397-c076-46d4-82c5-913d928f8903
|
||||
b51db545-c44c-4e45-9fad-6c3dda015d14
|
||||
8d1a37b6-36bd-43da-abb0-85c01bf74884
|
||||
00790594-1a70-45c7-aa14-08f67743fc22
|
||||
0dbc5c23-785a-4d10-80e7-2b2106ec2564
|
||||
2691cc24-c863-4c74-9f55-51b3c99dfc3e
|
||||
c4f3c139-ca97-4497-a0c1-843cbedbe92f
|
||||
93f088a0-ce01-479a-86b7-cac9a26375e0
|
||||
b3b5b584-5cb9-47cd-a79a-e8ff9cd18242
|
||||
c1cb5ed5-6285-467e-8d55-d9bd58ecf9dc
|
||||
80dc7ae2-4012-4ca4-9a77-01c3e74b48f7
|
||||
1630671b-0151-4c40-a2ad-82e2a5626436
|
||||
f10fc951-0028-487c-a387-bc560a38690b
|
||||
f3e583bf-29cf-440f-821d-cd1c076fd11d
|
||||
c3077ae7-3504-4773-b181-e572a101daae
|
||||
38ac3492-aba1-4faa-ba68-c03fdd805635
|
||||
71bcd09b-ded4-43f9-82b8-c077f125dca1
|
||||
ca07a531-7349-42df-9a5e-7fed9bee02d8
|
||||
ccd0dd74-df91-4913-83d3-b990987805ad
|
||||
7ef32d4e-ac2d-4bdc-8309-bb12d0bb661b
|
||||
d76161d3-ae0f-4d58-8821-b335b1434354
|
||||
77aea4ac-1818-4307-9e09-2a9f09117dfa
|
||||
d9239fdb-e12e-4f38-9ba2-98865cfac6ab
|
||||
2ee26169-fdd7-446e-afe2-dade5baecc58
|
||||
7a2ca8a5-c996-4765-a689-3ee5739e57d6
|
||||
a973ff26-d93d-4d5e-8918-5e7bc4fad067
|
||||
3546d607-f096-4a08-859e-9b137bcc7c55
|
||||
de1b6a95-7872-4dd6-9cde-c433ad99f0bb
|
||||
cca4a251-9561-4fee-bd38-7dd9c36d0bf4
|
||||
3546d607-f096-4a08-859e-9b137bcc7c55
|
||||
cca4a251-9561-4fee-bd38-7dd9c36d0bf4
|
||||
1e931624-40e4-496c-a755-6d5cb7a6ee73
|
||||
cd90df0b-e124-4194-b35c-ea90bd98ad36
|
||||
326330ab-90f6-4c52-bc20-52c183758cac
|
||||
0a5c935c-5023-4f25-b2e2-d1bad5cba6e4
|
||||
650154bb-cc79-4a93-8e09-06e4fb8238e0
|
||||
404a427e-42a8-4251-ac57-01846c07dcab
|
||||
05099a39-3afc-4f16-b2dd-0faa84b042b0
|
||||
cd90df0b-e124-4194-b35c-ea90bd98ad36
|
||||
326330ab-90f6-4c52-bc20-52c183758cac
|
||||
0a5c935c-5023-4f25-b2e2-d1bad5cba6e4
|
||||
650154bb-cc79-4a93-8e09-06e4fb8238e0
|
||||
404a427e-42a8-4251-ac57-01846c07dcab
|
||||
05099a39-3afc-4f16-b2dd-0faa84b042b0
|
||||
699eb818-7cca-45b9-be71-6fbbce017f81
|
||||
15c9cea9-bcb7-4674-9ce3-a5b55ee7d2fe
|
||||
b704d316-db31-472e-80ee-0997f73af0f0
|
||||
7c1fd57e-1f3e-49e7-9408-fdf364b84d9a
|
||||
b704d316-db31-472e-80ee-0997f73af0f0
|
||||
7c1fd57e-1f3e-49e7-9408-fdf364b84d9a
|
||||
737e34de-a83e-49c6-bfb3-3ec0610dc061
|
||||
29125d36-bbfd-44ef-8db5-76a73802e115
|
||||
ab5eabe5-64cd-46fd-9665-7ece31d0455c
|
||||
c49e0e33-045c-49e4-8aad-8d1831646ed3
|
||||
1a6b7912-e942-424b-b576-50c0f416c509
|
||||
465fbe8f-03c1-4ef8-aa91-aa15c51531b5
|
||||
e8b376b3-ef2a-462f-b636-67aaceabfe82
|
||||
737e34de-a83e-49c6-bfb3-3ec0610dc061
|
||||
1a6b7912-e942-424b-b576-50c0f416c509
|
||||
465fbe8f-03c1-4ef8-aa91-aa15c51531b5
|
||||
27c63885-68c3-405a-86d7-b1f94eebd9cb
|
||||
301919a3-e270-4ddf-bdd6-d9714a431a77
|
||||
0b9fe895-240a-4ee7-b0fe-b6e0aaf1689a
|
||||
8a8e53a9-9b9e-407d-8776-00f09156d73f
|
||||
8a8e53a9-9b9e-407d-8776-00f09156d73f
|
||||
25
logs/migration-log-1768920745297.json
Normal file
@ -0,0 +1,25 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T14:51:41.608Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768920743170.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T14:52:23.273Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T14:52:24.285Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T14:52:24.291Z"
|
||||
}
|
||||
]
|
||||
25
logs/migration-log-1768920815294.json
Normal file
@ -0,0 +1,25 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T14:52:48.713Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768920813164.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T14:53:33.269Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T14:53:34.275Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T14:53:34.281Z"
|
||||
}
|
||||
]
|
||||
20
logs/migration-log-1768921061363.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T14:57:39.321Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T14:57:39.338Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T14:57:40.341Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T14:57:40.349Z"
|
||||
}
|
||||
]
|
||||
25
logs/migration-log-1768921193923.json
Normal file
@ -0,0 +1,25 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T14:58:50.113Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768921191789.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T14:59:51.898Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T14:59:52.910Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T14:59:52.917Z"
|
||||
}
|
||||
]
|
||||
20
logs/migration-log-1768921342141.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:00:20.029Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:00:20.045Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2d10faf8-346e-4435-9dcc-c3cd28a02d2c",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": "TASK202601161127525854-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:00:21.055Z",
|
||||
"error": "terminated",
|
||||
"endTime": "2026-01-20T15:02:21.127Z"
|
||||
}
|
||||
]
|
||||
11
logs/migration-log-1768921451358.json
Normal file
@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:04:06.711Z",
|
||||
"error": "Failed to parse URL from uploads/materials/XG0176_若兰_亿家达_主图.zip",
|
||||
"endTime": "2026-01-20T15:04:10.347Z"
|
||||
}
|
||||
]
|
||||
16
logs/migration-log-1768921548818.json
Normal file
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:04:37.500Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768921547692.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:05:47.803Z"
|
||||
}
|
||||
]
|
||||
16
logs/migration-log-1768922240015.json
Normal file
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:17:13.231Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768922238899.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:17:19.009Z"
|
||||
}
|
||||
]
|
||||
16
logs/migration-log-1768922734296.json
Normal file
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:25:26.376Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768922733168.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:25:33.278Z"
|
||||
}
|
||||
]
|
||||
16
logs/migration-log-1768923104429.json
Normal file
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:31:36.258Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768923103286.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:31:43.417Z"
|
||||
}
|
||||
]
|
||||
11
logs/migration-log-1768923216843.json
Normal file
@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:33:35.806Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:33:35.831Z"
|
||||
}
|
||||
]
|
||||
16
logs/migration-log-1768923241364.json
Normal file
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"materialId": "f8148b30-d83f-4e6a-800e-fa047efd9b16",
|
||||
"productModel": "XG0176",
|
||||
"taskNo": "TASK202601151456438524-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:33:53.142Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768923240223.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:34:00.356Z"
|
||||
}
|
||||
]
|
||||
15
logs/migration-log-1768923606335.json
Normal file
@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"materialId": "695c48f0-53a9-4870-aa07-76261fdf4a31",
|
||||
"productModel": "CZ0093",
|
||||
"taskNo": "TASK202601161637102363-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:40:04.052Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CZ0093_上生_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CZ0093_all_695c48f0-53a9-4870-aa07-76261fdf4a31_1768923605237.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:40:05.324Z"
|
||||
}
|
||||
]
|
||||
133
logs/migration-log-1768923840136.json
Normal file
@ -0,0 +1,133 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:41:40.825Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:41:40.842Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2d10faf8-346e-4435-9dcc-c3cd28a02d2c",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": "TASK202601161127525854-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:41:41.844Z",
|
||||
"assetsDownloaded": 47,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-SN0208-389_瑶光_朴美_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-SN0208-389_瑶光_朴美_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-SN0208-389_瑶光_朴美_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-SN0208-389_all_2d10faf8-346e-4435-9dcc-c3cd28a02d2c_1768923722086.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:42:02.541Z"
|
||||
},
|
||||
{
|
||||
"materialId": "228c7c9b-eafa-4b52-b94c-198373e3902f",
|
||||
"productModel": "DNZ0247-185",
|
||||
"taskNo": "TASK202601161049011252-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:42:03.543Z",
|
||||
"assetsDownloaded": 32,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0247-185_瑶光_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0247-185_瑶光_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0247-185_all_228c7c9b-eafa-4b52-b94c-198373e3902f_1768923735908.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:42:16.100Z"
|
||||
},
|
||||
{
|
||||
"materialId": "dc49b1b0-2b5f-414e-b099-bb0388734cef",
|
||||
"productModel": "HXD0055",
|
||||
"taskNo": "TASK202601161020158321-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:42:17.108Z",
|
||||
"assetsDownloaded": 26,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\HXD0055_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\HXD0055_若兰_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\HXD0055_all_dc49b1b0-2b5f-414e-b099-bb0388734cef_1768923745085.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:42:25.188Z"
|
||||
},
|
||||
{
|
||||
"materialId": "0418b190-ec90-47ed-a868-9917d0207b6a",
|
||||
"productModel": "DNZ0117",
|
||||
"taskNo": "TASK202601151408302015-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:42:26.200Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_苏蕙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_苏蕙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_all_0418b190-ec90-47ed-a868-9917d0207b6a_1768923749371.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:42:29.449Z"
|
||||
},
|
||||
{
|
||||
"materialId": "81802ea6-2b28-46d6-8fc7-931e88b338f3",
|
||||
"productModel": "SZ0135",
|
||||
"taskNo": "TASK202601161633198963-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:42:30.453Z",
|
||||
"assetsDownloaded": 20,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0135_苏蕙_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0135_all_81802ea6-2b28-46d6-8fc7-931e88b338f3_1768923755688.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:42:35.757Z"
|
||||
},
|
||||
{
|
||||
"materialId": "36c377fe-49c4-432b-a717-a243c0e7ab89",
|
||||
"productModel": "BG0037-605",
|
||||
"taskNo": "TASK202601161402598214-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:42:36.771Z",
|
||||
"assetsDownloaded": 220,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\BG0037-605_高恬琳_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\BG0037-605_all_36c377fe-49c4-432b-a717-a243c0e7ab89_1768923813218.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:43:33.840Z"
|
||||
},
|
||||
{
|
||||
"materialId": "d18ce556-e3f1-49e5-beb3-a39fe044546f",
|
||||
"productModel": "SJ0339",
|
||||
"taskNo": "TASK202601161724017457-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:43:34.856Z",
|
||||
"assetsDownloaded": 22,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0339_佘太君_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0339_all_d18ce556-e3f1-49e5-beb3-a39fe044546f_1768923828519.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:43:49.087Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ffb8a024-667d-4284-abd9-85a11e94fd54",
|
||||
"productModel": "CJ0252",
|
||||
"taskNo": "TASK202601161629520328-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:43:50.098Z",
|
||||
"assetsDownloaded": 5,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_欧意朗_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_all_ffb8a024-667d-4284-abd9-85a11e94fd54_1768923834666.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:43:54.885Z"
|
||||
},
|
||||
{
|
||||
"materialId": "5875c1db-0f3b-4760-9f7e-045446d37aac",
|
||||
"productModel": "SZ0135",
|
||||
"taskNo": null,
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:43:55.899Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0135_苏蕙_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0135_all_5875c1db-0f3b-4760-9f7e-045446d37aac_1768923838917.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:43:59.125Z"
|
||||
}
|
||||
]
|
||||
128
logs/migration-log-1768923958151.json
Normal file
@ -0,0 +1,128 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:44:27.485Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:44:27.500Z"
|
||||
},
|
||||
{
|
||||
"materialId": "d6b9cf44-0631-4237-a67a-495a13604b5e",
|
||||
"productModel": "SJZ0008-9085",
|
||||
"taskNo": "TASK202601191541221732-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:44:28.510Z",
|
||||
"assetsDownloaded": 8,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJZ0008-9085_飞鸿_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJZ0008-9085_all_d6b9cf44-0631-4237-a67a-495a13604b5e_1768923877837.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:44:38.227Z"
|
||||
},
|
||||
{
|
||||
"materialId": "cb880417-0f44-4541-8bbe-cf82b388b0b1",
|
||||
"productModel": "SZ0068",
|
||||
"taskNo": "TASK202601161205109377-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:44:39.232Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0068_苏蕙_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0068_all_cb880417-0f44-4541-8bbe-cf82b388b0b1_1768923890578.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:44:51.047Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ef59dd88-d45a-47a8-9526-3ee03168874f",
|
||||
"productModel": "CYJ0062",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:44:52.058Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:44:52.066Z"
|
||||
},
|
||||
{
|
||||
"materialId": "101aea94-7460-4ae6-8980-a5a87698574d",
|
||||
"productModel": "CYJ0062",
|
||||
"taskNo": "TASK202601201000475671-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:44:53.070Z",
|
||||
"assetsDownloaded": 44,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CYJ0062_紫苏_欧意朗_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CYJ0062_紫苏_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CYJ0062_all_101aea94-7460-4ae6-8980-a5a87698574d_1768923909498.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:45:10.352Z"
|
||||
},
|
||||
{
|
||||
"materialId": "a2e9568b-eca1-4896-abfa-512f8b2f8047",
|
||||
"productModel": "XG0143",
|
||||
"taskNo": "TASK202601191330553662-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:45:11.364Z",
|
||||
"assetsDownloaded": 30,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0143_乐游_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0143_乐游_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0143_乐游_卓禾_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0143_all_a2e9568b-eca1-4896-abfa-512f8b2f8047_1768923924497.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:45:25.212Z"
|
||||
},
|
||||
{
|
||||
"materialId": "310b405f-a1df-4f89-87b0-ea61960162fb",
|
||||
"productModel": "CTG0219-0803",
|
||||
"taskNo": "TASK202601191429302051-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:45:26.218Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CTG0219-0803_曹丕_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CTG0219-0803_all_310b405f-a1df-4f89-87b0-ea61960162fb_1768923928212.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:45:28.346Z"
|
||||
},
|
||||
{
|
||||
"materialId": "581173bc-672d-411b-81a4-eb58b5db7d37",
|
||||
"productModel": "CJ0222-336",
|
||||
"taskNo": "TASK202601161122097500-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:45:29.351Z",
|
||||
"assetsDownloaded": 15,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0222-336_余笙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0222-336_all_581173bc-672d-411b-81a4-eb58b5db7d37_1768923939951.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:45:40.889Z"
|
||||
},
|
||||
{
|
||||
"materialId": "0dab1ccb-6c17-4a87-85f9-062573c3fac9",
|
||||
"productModel": "CJ0222-336-BU",
|
||||
"taskNo": "TASK202601201344429773-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:45:41.902Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0222-336-BU_余笙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0222-336-BU_all_0dab1ccb-6c17-4a87-85f9-062573c3fac9_1768923944485.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:45:44.805Z"
|
||||
},
|
||||
{
|
||||
"materialId": "a9fff2da-562b-492d-93de-d3d7f6af5a83",
|
||||
"productModel": "DNZ0247-181",
|
||||
"taskNo": "TASK202601201327005834-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:45:45.810Z",
|
||||
"assetsDownloaded": 24,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0247-181_瑶光_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0247-181_瑶光_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0247-181_all_a9fff2da-562b-492d-93de-d3d7f6af5a83_1768923956465.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:45:57.136Z"
|
||||
}
|
||||
]
|
||||
126
logs/migration-log-1768924161945.json
Normal file
@ -0,0 +1,126 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:46:20.624Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:46:20.640Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ef59dd88-d45a-47a8-9526-3ee03168874f",
|
||||
"productModel": "CYJ0062",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:46:21.655Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:46:21.662Z"
|
||||
},
|
||||
{
|
||||
"materialId": "b985e22b-5ecc-495d-8405-0ff760fe25f5",
|
||||
"productModel": "SZ0015",
|
||||
"taskNo": "TASK202601201114348022-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:46:22.671Z",
|
||||
"assetsDownloaded": 180,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0015_苏蕙_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZ0015_all_b985e22b-5ecc-495d-8405-0ff760fe25f5_1768924053857.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:47:37.508Z"
|
||||
},
|
||||
{
|
||||
"materialId": "7d01a3ab-8a99-4966-9f5e-53b5ef6cfad1",
|
||||
"productModel": "CJ0252",
|
||||
"taskNo": "TASK202601201149497501-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:47:38.518Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_欧意朗_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_all_7d01a3ab-8a99-4966-9f5e-53b5ef6cfad1_1768924066254.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:47:47.315Z"
|
||||
},
|
||||
{
|
||||
"materialId": "104cd397-c076-46d4-82c5-913d928f8903",
|
||||
"productModel": "DNZ0203SZ0157-024",
|
||||
"taskNo": "TASK202601201006286282-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:47:48.322Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0203SZ0157-024_瑶光_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0203SZ0157-024_all_104cd397-c076-46d4-82c5-913d928f8903_1768924073887.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:47:54.262Z"
|
||||
},
|
||||
{
|
||||
"materialId": "b51db545-c44c-4e45-9fad-6c3dda015d14",
|
||||
"productModel": "GBPM-BJ0192",
|
||||
"taskNo": "TASK202601201359535123-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:47:55.263Z",
|
||||
"assetsDownloaded": 76,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-BJ0192_苏蕙_朴美_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-BJ0192_苏蕙_朴美_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-BJ0192_苏蕙_朴美_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-BJ0192_all_b51db545-c44c-4e45-9fad-6c3dda015d14_1768924133671.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:48:58.055Z"
|
||||
},
|
||||
{
|
||||
"materialId": "8d1a37b6-36bd-43da-abb0-85c01bf74884",
|
||||
"productModel": "DNZ0302SZ0517-024-BU",
|
||||
"taskNo": "TASK202601201424077779-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:48:59.056Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0302SZ0517-024-BU_瑶光_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0302SZ0517-024-BU_all_8d1a37b6-36bd-43da-abb0-85c01bf74884_1768924144215.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:49:04.592Z"
|
||||
},
|
||||
{
|
||||
"materialId": "00790594-1a70-45c7-aa14-08f67743fc22",
|
||||
"productModel": "CBG0039-685",
|
||||
"taskNo": "TASK202601160942298162-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:49:05.602Z",
|
||||
"assetsDownloaded": 15,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CBG0039-685_曹丕_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CBG0039-685_all_00790594-1a70-45c7-aa14-08f67743fc22_1768924151754.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:49:11.878Z"
|
||||
},
|
||||
{
|
||||
"materialId": "0dbc5c23-785a-4d10-80e7-2b2106ec2564",
|
||||
"productModel": "JG0004",
|
||||
"taskNo": "TASK202601201339588164-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:49:12.885Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\JG0004_悠然_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\JG0004_all_0dbc5c23-785a-4d10-80e7-2b2106ec2564_1768924155399.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:49:15.618Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2691cc24-c863-4c74-9f55-51b3c99dfc3e",
|
||||
"productModel": "DNZ0002-623",
|
||||
"taskNo": "TASK202601191713442026-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:49:16.627Z",
|
||||
"assetsDownloaded": 6,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0002-623_飞鸿_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0002-623_all_2691cc24-c863-4c74-9f55-51b3c99dfc3e_1768924160568.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:49:20.942Z"
|
||||
}
|
||||
]
|
||||
62
logs/migration-log-1768924240279.json
Normal file
@ -0,0 +1,62 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:49:46.491Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:49:46.506Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ef59dd88-d45a-47a8-9526-3ee03168874f",
|
||||
"productModel": "CYJ0062",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:49:47.523Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:49:47.530Z"
|
||||
},
|
||||
{
|
||||
"materialId": "c4f3c139-ca97-4497-a0c1-843cbedbe92f",
|
||||
"productModel": "DNZ0154",
|
||||
"taskNo": "TASK202601201149194381-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:49:48.546Z",
|
||||
"assetsDownloaded": 64,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154_苏蕙_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154_苏蕙_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154_all_c4f3c139-ca97-4497-a0c1-843cbedbe92f_1768924214819.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:50:15.934Z"
|
||||
},
|
||||
{
|
||||
"materialId": "93f088a0-ce01-479a-86b7-cac9a26375e0",
|
||||
"productModel": "DNZ0260-373",
|
||||
"taskNo": "TASK202601200938059614-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:50:16.948Z",
|
||||
"assetsDownloaded": 25,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0260-373_瑶光_欧意朗_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0260-373_瑶光_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0260-373_all_93f088a0-ce01-479a-86b7-cac9a26375e0_1768924226477.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:50:27.146Z"
|
||||
},
|
||||
{
|
||||
"materialId": "b3b5b584-5cb9-47cd-a79a-e8ff9cd18242",
|
||||
"productModel": "DNZ0199",
|
||||
"taskNo": "TASK202601201533348846-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:50:28.149Z",
|
||||
"assetsDownloaded": 21,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0199_苏蕙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0199_苏蕙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0199_all_b3b5b584-5cb9-47cd-a79a-e8ff9cd18242_1768924238592.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:50:39.261Z"
|
||||
}
|
||||
]
|
||||
20
logs/migration-log-1768924412848.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:53:30.803Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:53:30.820Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ef59dd88-d45a-47a8-9526-3ee03168874f",
|
||||
"productModel": "CYJ0062",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:53:31.824Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:53:31.839Z"
|
||||
}
|
||||
]
|
||||
20
logs/migration-log-1768924519354.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"materialId": "2c1837b8-6927-4a8c-8226-ab919124d11f",
|
||||
"productModel": "GBPM-SN0208-389",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:55:17.311Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:55:17.327Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ef59dd88-d45a-47a8-9526-3ee03168874f",
|
||||
"productModel": "CYJ0062",
|
||||
"taskNo": null,
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T15:55:18.333Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T15:55:18.341Z"
|
||||
}
|
||||
]
|
||||
133
logs/migration-log-1768924819982.json
Normal file
@ -0,0 +1,133 @@
|
||||
[
|
||||
{
|
||||
"materialId": "c1cb5ed5-6285-467e-8d55-d9bd58ecf9dc",
|
||||
"productModel": "CJ0247-533",
|
||||
"taskNo": "TASK202601161744291258-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:55:54.819Z",
|
||||
"assetsDownloaded": 32,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0247-533_余笙_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0247-533_all_c1cb5ed5-6285-467e-8d55-d9bd58ecf9dc_1768924673118.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:58:05.763Z"
|
||||
},
|
||||
{
|
||||
"materialId": "80dc7ae2-4012-4ca4-9a77-01c3e74b48f7",
|
||||
"productModel": "GBGJ-DNZ0379",
|
||||
"taskNo": "TASK202601161540424935-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:58:06.767Z",
|
||||
"assetsDownloaded": 10,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0379_苏蕙_顾家_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0379_苏蕙_顾家_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0379_all_80dc7ae2-4012-4ca4-9a77-01c3e74b48f7_1768924691257.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:58:11.614Z"
|
||||
},
|
||||
{
|
||||
"materialId": "1630671b-0151-4c40-a2ad-82e2a5626436",
|
||||
"productModel": "SZT0169",
|
||||
"taskNo": "TASK202601171040171816-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:58:12.618Z",
|
||||
"assetsDownloaded": 2,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZT0169_佘太君_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZT0169_all_1630671b-0151-4c40-a2ad-82e2a5626436_1768924704437.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:58:26.174Z"
|
||||
},
|
||||
{
|
||||
"materialId": "f10fc951-0028-487c-a387-bc560a38690b",
|
||||
"productModel": "DNZ0204-608",
|
||||
"taskNo": "TASK202601161030231265-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:58:27.178Z",
|
||||
"assetsDownloaded": 12,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0204-608_瑶光_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0204-608_all_f10fc951-0028-487c-a387-bc560a38690b_1768924710861.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:58:31.095Z"
|
||||
},
|
||||
{
|
||||
"materialId": "f3e583bf-29cf-440f-821d-cd1c076fd11d",
|
||||
"productModel": "ZSJ0006",
|
||||
"taskNo": "TASK202601170953515009-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:58:32.108Z",
|
||||
"assetsDownloaded": 22,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\ZSJ0006_紫苏_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\ZSJ0006_all_f3e583bf-29cf-440f-821d-cd1c076fd11d_1768924722684.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:58:43.608Z"
|
||||
},
|
||||
{
|
||||
"materialId": "c3077ae7-3504-4773-b181-e572a101daae",
|
||||
"productModel": "CJ0227-929",
|
||||
"taskNo": "TASK202601161715466096-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:58:44.615Z",
|
||||
"assetsDownloaded": 23,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0227-929_余笙_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0227-929_all_c3077ae7-3504-4773-b181-e572a101daae_1768924739157.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:59:00.469Z"
|
||||
},
|
||||
{
|
||||
"materialId": "38ac3492-aba1-4faa-ba68-c03fdd805635",
|
||||
"productModel": "AD0024",
|
||||
"taskNo": "TASK202601161359289218-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:59:01.483Z",
|
||||
"assetsDownloaded": 48,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0024_若兰_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0024_all_38ac3492-aba1-4faa-ba68-c03fdd805635_1768924769062.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:59:31.757Z"
|
||||
},
|
||||
{
|
||||
"materialId": "71bcd09b-ded4-43f9-82b8-c077f125dca1",
|
||||
"productModel": "SJ0345",
|
||||
"taskNo": "TASK202601171730043453-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:59:32.766Z",
|
||||
"assetsDownloaded": 12,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0345_紫苏_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0345_all_71bcd09b-ded4-43f9-82b8-c077f125dca1_1768924778696.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T15:59:39.220Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ca07a531-7349-42df-9a5e-7fed9bee02d8",
|
||||
"productModel": "CJ0034-568",
|
||||
"taskNo": "TASK202601161137230890-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T15:59:40.223Z",
|
||||
"assetsDownloaded": 111,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0034-568_余笙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0034-568_all_ca07a531-7349-42df-9a5e-7fed9bee02d8_1768924807599.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:00:09.479Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ccd0dd74-df91-4913-83d3-b990987805ad",
|
||||
"productModel": "CJ0252",
|
||||
"taskNo": "TASK202601161624467049-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:00:10.488Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_all_ccd0dd74-df91-4913-83d3-b990987805ad_1768924817920.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:00:18.972Z"
|
||||
}
|
||||
]
|
||||
135
logs/migration-log-1768925016822.json
Normal file
@ -0,0 +1,135 @@
|
||||
[
|
||||
{
|
||||
"materialId": "7ef32d4e-ac2d-4bdc-8309-bb12d0bb661b",
|
||||
"productModel": "DYR",
|
||||
"taskNo": "TASK202601171606458301-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:01:26.749Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DYR_上生_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DYR_all_7ef32d4e-ac2d-4bdc-8309-bb12d0bb661b_1768924888370.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:01:28.564Z"
|
||||
},
|
||||
{
|
||||
"materialId": "d76161d3-ae0f-4d58-8821-b335b1434354",
|
||||
"productModel": "CJ0252",
|
||||
"taskNo": "TASK202601171049580555-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:01:29.577Z",
|
||||
"assetsDownloaded": 20,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_欧意朗_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_all_d76161d3-ae0f-4d58-8821-b335b1434354_1768924895597.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:01:36.021Z"
|
||||
},
|
||||
{
|
||||
"materialId": "77aea4ac-1818-4307-9e09-2a9f09117dfa",
|
||||
"productModel": "CJ0252",
|
||||
"taskNo": "TASK202601171054169437-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:01:37.031Z",
|
||||
"assetsDownloaded": 20,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_上生_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0252_all_77aea4ac-1818-4307-9e09-2a9f09117dfa_1768924903283.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:01:43.714Z"
|
||||
},
|
||||
{
|
||||
"materialId": "d9239fdb-e12e-4f38-9ba2-98865cfac6ab",
|
||||
"productModel": "BG0029-544",
|
||||
"taskNo": "TASK202601171030458400-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:01:44.715Z",
|
||||
"assetsDownloaded": 20,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\BG0029-544_飞鸿_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\BG0029-544_all_d9239fdb-e12e-4f38-9ba2-98865cfac6ab_1768924914900.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:01:55.884Z"
|
||||
},
|
||||
{
|
||||
"materialId": "2ee26169-fdd7-446e-afe2-dade5baecc58",
|
||||
"productModel": "XG0242",
|
||||
"taskNo": "TASK202601191044080590-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:01:56.888Z",
|
||||
"assetsDownloaded": 6,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0242_乐游_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0242_all_2ee26169-fdd7-446e-afe2-dade5baecc58_1768924918763.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:01:58.924Z"
|
||||
},
|
||||
{
|
||||
"materialId": "7a2ca8a5-c996-4765-a689-3ee5739e57d6",
|
||||
"productModel": "DSG0052",
|
||||
"taskNo": null,
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:01:59.938Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_all_7a2ca8a5-c996-4765-a689-3ee5739e57d6_1768924921498.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:02:01.656Z"
|
||||
},
|
||||
{
|
||||
"materialId": "a973ff26-d93d-4d5e-8918-5e7bc4fad067",
|
||||
"productModel": "DSG0052",
|
||||
"taskNo": "TASK202601161054260586-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:02:02.660Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_all_a973ff26-d93d-4d5e-8918-5e7bc4fad067_1768924924911.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:02:05.077Z"
|
||||
},
|
||||
{
|
||||
"materialId": "3546d607-f096-4a08-859e-9b137bcc7c55",
|
||||
"productModel": "DNZ0258",
|
||||
"taskNo": "TASK202601191050583077-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:02:06.092Z",
|
||||
"assetsDownloaded": 84,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0258_苏蕙_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0258_all_3546d607-f096-4a08-859e-9b137bcc7c55_1768924972609.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:02:54.312Z"
|
||||
},
|
||||
{
|
||||
"materialId": "de1b6a95-7872-4dd6-9cde-c433ad99f0bb",
|
||||
"productModel": "GBGJ-DNZ0366",
|
||||
"taskNo": "TASK202601161316507431-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:02:55.314Z",
|
||||
"assetsDownloaded": 8,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0366_苏蕙_顾家_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0366_all_de1b6a95-7872-4dd6-9cde-c433ad99f0bb_1768924980649.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:03:00.853Z"
|
||||
},
|
||||
{
|
||||
"materialId": "cca4a251-9561-4fee-bd38-7dd9c36d0bf4",
|
||||
"productModel": "DNZ0117",
|
||||
"taskNo": "TASK202601191134380453-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:03:01.860Z",
|
||||
"assetsDownloaded": 42,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_苏蕙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_苏蕙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_all_cca4a251-9561-4fee-bd38-7dd9c36d0bf4_1768925014564.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:03:35.816Z"
|
||||
}
|
||||
]
|
||||
130
logs/migration-log-1768925113364.json
Normal file
@ -0,0 +1,130 @@
|
||||
[
|
||||
{
|
||||
"materialId": "3546d607-f096-4a08-859e-9b137bcc7c55",
|
||||
"productModel": "DNZ0258",
|
||||
"taskNo": "TASK202601191050583077-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:02:40.695Z",
|
||||
"assetsDownloaded": 84,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0258_苏蕙_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0258_all_3546d607-f096-4a08-859e-9b137bcc7c55_1768925008891.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:03:30.302Z"
|
||||
},
|
||||
{
|
||||
"materialId": "de1b6a95-7872-4dd6-9cde-c433ad99f0bb",
|
||||
"productModel": "GBGJ-DNZ0366",
|
||||
"taskNo": "TASK202601161316507431-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T16:03:31.311Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T16:03:31.320Z"
|
||||
},
|
||||
{
|
||||
"materialId": "cca4a251-9561-4fee-bd38-7dd9c36d0bf4",
|
||||
"productModel": "DNZ0117",
|
||||
"taskNo": "TASK202601191134380453-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:03:32.324Z",
|
||||
"assetsDownloaded": 42,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_苏蕙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_苏蕙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0117_all_cca4a251-9561-4fee-bd38-7dd9c36d0bf4_1768925032476.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:03:53.638Z"
|
||||
},
|
||||
{
|
||||
"materialId": "1e931624-40e4-496c-a755-6d5cb7a6ee73",
|
||||
"productModel": "GBGJ-DNZ0366",
|
||||
"taskNo": "TASK202601191112440382-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:03:54.649Z",
|
||||
"assetsDownloaded": 2,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0366_若兰_顾家_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBGJ-DNZ0366_all_1e931624-40e4-496c-a755-6d5cb7a6ee73_1768925036302.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:03:56.373Z"
|
||||
},
|
||||
{
|
||||
"materialId": "cd90df0b-e124-4194-b35c-ea90bd98ad36",
|
||||
"productModel": "CJ0034-568-BU",
|
||||
"taskNo": "TASK202601191145541166-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:03:57.385Z",
|
||||
"assetsDownloaded": 63,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0034-568-BU_余笙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0034-568-BU_all_cd90df0b-e124-4194-b35c-ea90bd98ad36_1768925079573.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:40.660Z"
|
||||
},
|
||||
{
|
||||
"materialId": "326330ab-90f6-4c52-bc20-52c183758cac",
|
||||
"productModel": "XG0132",
|
||||
"taskNo": "TASK202601161347340444-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:04:41.669Z",
|
||||
"assetsDownloaded": 7,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0132_乐游_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0132_all_326330ab-90f6-4c52-bc20-52c183758cac_1768925087288.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:47.459Z"
|
||||
},
|
||||
{
|
||||
"materialId": "0a5c935c-5023-4f25-b2e2-d1bad5cba6e4",
|
||||
"productModel": "DSG0052",
|
||||
"taskNo": "TASK202601191112042240-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:04:48.464Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_all_0a5c935c-5023-4f25-b2e2-d1bad5cba6e4_1768925091020.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:51.185Z"
|
||||
},
|
||||
{
|
||||
"materialId": "650154bb-cc79-4a93-8e09-06e4fb8238e0",
|
||||
"productModel": "XG0148",
|
||||
"taskNo": "TASK202601170949480206-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:04:52.191Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_乐游_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_乐游_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_all_650154bb-cc79-4a93-8e09-06e4fb8238e0_1768925099196.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:59.613Z"
|
||||
},
|
||||
{
|
||||
"materialId": "404a427e-42a8-4251-ac57-01846c07dcab",
|
||||
"productModel": "DSG0095",
|
||||
"taskNo": "TASK202601161107108287-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:05:00.628Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_all_404a427e-42a8-4251-ac57-01846c07dcab_1768925103468.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:05:03.599Z"
|
||||
},
|
||||
{
|
||||
"materialId": "05099a39-3afc-4f16-b2dd-0faa84b042b0",
|
||||
"productModel": "CZ0070",
|
||||
"taskNo": "TASK202601191117065271-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:05:04.613Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CZ0070_瑶光_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CZ0070_all_05099a39-3afc-4f16-b2dd-0faa84b042b0_1768925112027.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:05:12.355Z"
|
||||
}
|
||||
]
|
||||
134
logs/migration-log-1768925172010.json
Normal file
@ -0,0 +1,134 @@
|
||||
[
|
||||
{
|
||||
"materialId": "cd90df0b-e124-4194-b35c-ea90bd98ad36",
|
||||
"productModel": "CJ0034-568-BU",
|
||||
"taskNo": "TASK202601191145541166-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:03:57.284Z",
|
||||
"assetsDownloaded": 63,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0034-568-BU_余笙_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CJ0034-568-BU_all_cd90df0b-e124-4194-b35c-ea90bd98ad36_1768925081965.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:42.081Z"
|
||||
},
|
||||
{
|
||||
"materialId": "326330ab-90f6-4c52-bc20-52c183758cac",
|
||||
"productModel": "XG0132",
|
||||
"taskNo": "TASK202601161347340444-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:04:43.091Z",
|
||||
"assetsDownloaded": 7,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0132_乐游_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0132_all_326330ab-90f6-4c52-bc20-52c183758cac_1768925087895.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:47.937Z"
|
||||
},
|
||||
{
|
||||
"materialId": "0a5c935c-5023-4f25-b2e2-d1bad5cba6e4",
|
||||
"productModel": "DSG0052",
|
||||
"taskNo": "TASK202601191112042240-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:04:48.941Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0052_all_0a5c935c-5023-4f25-b2e2-d1bad5cba6e4_1768925091297.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:51.355Z"
|
||||
},
|
||||
{
|
||||
"materialId": "650154bb-cc79-4a93-8e09-06e4fb8238e0",
|
||||
"productModel": "XG0148",
|
||||
"taskNo": "TASK202601170949480206-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:04:52.367Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_乐游_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_乐游_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_all_650154bb-cc79-4a93-8e09-06e4fb8238e0_1768925099802.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:04:59.851Z"
|
||||
},
|
||||
{
|
||||
"materialId": "404a427e-42a8-4251-ac57-01846c07dcab",
|
||||
"productModel": "DSG0095",
|
||||
"taskNo": "TASK202601161107108287-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:05:00.864Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_all_404a427e-42a8-4251-ac57-01846c07dcab_1768925103793.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:05:03.833Z"
|
||||
},
|
||||
{
|
||||
"materialId": "05099a39-3afc-4f16-b2dd-0faa84b042b0",
|
||||
"productModel": "CZ0070",
|
||||
"taskNo": "TASK202601191117065271-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:05:04.846Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CZ0070_瑶光_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CZ0070_all_05099a39-3afc-4f16-b2dd-0faa84b042b0_1768925112617.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:05:12.664Z"
|
||||
},
|
||||
{
|
||||
"materialId": "699eb818-7cca-45b9-be71-6fbbce017f81",
|
||||
"productModel": "SJ0005",
|
||||
"taskNo": "TASK202601191439591449-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:05:13.666Z",
|
||||
"assetsDownloaded": 63,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0005_佘太君_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0005_all_699eb818-7cca-45b9-be71-6fbbce017f81_1768925141997.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:05:43.734Z"
|
||||
},
|
||||
{
|
||||
"materialId": "15c9cea9-bcb7-4674-9ce3-a5b55ee7d2fe",
|
||||
"productModel": "SZT0026-512",
|
||||
"taskNo": "TASK202601161742138347-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:05:44.745Z",
|
||||
"assetsDownloaded": 28,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZT0026-512_飞鸿_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZT0026-512_飞鸿_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SZT0026-512_all_15c9cea9-bcb7-4674-9ce3-a5b55ee7d2fe_1768925163035.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:06:04.043Z"
|
||||
},
|
||||
{
|
||||
"materialId": "b704d316-db31-472e-80ee-0997f73af0f0",
|
||||
"productModel": "DSG0095",
|
||||
"taskNo": "TASK202601191443479852-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:05.043Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_all_b704d316-db31-472e-80ee-0997f73af0f0_1768925168175.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:06:08.296Z"
|
||||
},
|
||||
{
|
||||
"materialId": "7c1fd57e-1f3e-49e7-9408-fdf364b84d9a",
|
||||
"productModel": "DSG0048",
|
||||
"taskNo": "TASK202601161051162049-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:09.301Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0048_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0048_all_7c1fd57e-1f3e-49e7-9408-fdf364b84d9a_1768925170943.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:06:11.009Z"
|
||||
}
|
||||
]
|
||||
135
logs/migration-log-1768925294759.json
Normal file
@ -0,0 +1,135 @@
|
||||
[
|
||||
{
|
||||
"materialId": "15c9cea9-bcb7-4674-9ce3-a5b55ee7d2fe",
|
||||
"productModel": "SZT0026-512",
|
||||
"taskNo": "TASK202601161742138347-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T16:05:44.889Z",
|
||||
"assetsDownloaded": 28,
|
||||
"error": "ENOENT: no such file or directory, open 'D:\\AI Code\\gongxiangp2\\uploads\\temp\\migrate-15c9cea9-bcb7-4674-9ce3-a5b55ee7d2fe\\main-8-分类置物-取之有道.jpg'",
|
||||
"endTime": "2026-01-20T16:06:04.061Z"
|
||||
},
|
||||
{
|
||||
"materialId": "b704d316-db31-472e-80ee-0997f73af0f0",
|
||||
"productModel": "DSG0095",
|
||||
"taskNo": "TASK202601191443479852-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:05.073Z",
|
||||
"assetsDownloaded": 9,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0095_all_b704d316-db31-472e-80ee-0997f73af0f0_1768925168351.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:06:08.409Z"
|
||||
},
|
||||
{
|
||||
"materialId": "7c1fd57e-1f3e-49e7-9408-fdf364b84d9a",
|
||||
"productModel": "DSG0048",
|
||||
"taskNo": "TASK202601161051162049-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:09.410Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0048_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0048_all_7c1fd57e-1f3e-49e7-9408-fdf364b84d9a_1768925170966.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:06:11.032Z"
|
||||
},
|
||||
{
|
||||
"materialId": "737e34de-a83e-49c6-bfb3-3ec0610dc061",
|
||||
"productModel": "AD0320",
|
||||
"taskNo": "TASK202601190938146715-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:12.041Z",
|
||||
"assetsDownloaded": 59,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_紫苏_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_紫苏_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_紫苏_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_all_737e34de-a83e-49c6-bfb3-3ec0610dc061_1768925213298.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:06:56.008Z"
|
||||
},
|
||||
{
|
||||
"materialId": "29125d36-bbfd-44ef-8db5-76a73802e115",
|
||||
"productModel": "XG0132",
|
||||
"taskNo": "TASK202601191534060576-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:57.022Z",
|
||||
"assetsDownloaded": 7,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0132_乐游_欧意朗_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0132_all_29125d36-bbfd-44ef-8db5-76a73802e115_1768925220469.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:00.633Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ab5eabe5-64cd-46fd-9665-7ece31d0455c",
|
||||
"productModel": "DSG0048",
|
||||
"taskNo": "TASK202601191548580482-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:01.639Z",
|
||||
"assetsDownloaded": 4,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0048_朝菌_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DSG0048_all_ab5eabe5-64cd-46fd-9665-7ece31d0455c_1768925222763.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:02.837Z"
|
||||
},
|
||||
{
|
||||
"materialId": "c49e0e33-045c-49e4-8aad-8d1831646ed3",
|
||||
"productModel": "XG0148",
|
||||
"taskNo": "TASK202601191656235202-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:03.839Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_乐游_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_乐游_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\XG0148_all_c49e0e33-045c-49e4-8aad-8d1831646ed3_1768925233628.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:14.005Z"
|
||||
},
|
||||
{
|
||||
"materialId": "1a6b7912-e942-424b-b576-50c0f416c509",
|
||||
"productModel": "CFZW0152",
|
||||
"taskNo": "TASK202601191701491995-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:15.015Z",
|
||||
"assetsDownloaded": 6,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CFZW0152_上生_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CFZW0152_all_1a6b7912-e942-424b-b576-50c0f416c509_1768925238481.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:18.738Z"
|
||||
},
|
||||
{
|
||||
"materialId": "465fbe8f-03c1-4ef8-aa91-aa15c51531b5",
|
||||
"productModel": "SJ0204",
|
||||
"taskNo": "TASK202601191040107232-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:19.741Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0204_悠然_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0204_悠然_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0204_all_465fbe8f-03c1-4ef8-aa91-aa15c51531b5_1768925255012.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:35.987Z"
|
||||
},
|
||||
{
|
||||
"materialId": "e8b376b3-ef2a-462f-b636-67aaceabfe82",
|
||||
"productModel": "GBPM-AD0312",
|
||||
"taskNo": "TASK202601191543095743-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:36.990Z",
|
||||
"assetsDownloaded": 56,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-AD0312_若兰_朴美_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-AD0312_若兰_朴美_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-AD0312_若兰_朴美_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\GBPM-AD0312_all_e8b376b3-ef2a-462f-b636-67aaceabfe82_1768925292010.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:08:13.749Z"
|
||||
}
|
||||
]
|
||||
120
logs/migration-log-1768925311310.json
Normal file
@ -0,0 +1,120 @@
|
||||
[
|
||||
{
|
||||
"materialId": "737e34de-a83e-49c6-bfb3-3ec0610dc061",
|
||||
"productModel": "AD0320",
|
||||
"taskNo": "TASK202601190938146715-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:06:33.698Z",
|
||||
"assetsDownloaded": 59,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_紫苏_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_紫苏_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_紫苏_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\AD0320_all_737e34de-a83e-49c6-bfb3-3ec0610dc061_1768925233286.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:14.445Z"
|
||||
},
|
||||
{
|
||||
"materialId": "29125d36-bbfd-44ef-8db5-76a73802e115",
|
||||
"productModel": "XG0132",
|
||||
"taskNo": "TASK202601191534060576-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T16:07:15.451Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T16:07:15.457Z"
|
||||
},
|
||||
{
|
||||
"materialId": "ab5eabe5-64cd-46fd-9665-7ece31d0455c",
|
||||
"productModel": "DSG0048",
|
||||
"taskNo": "TASK202601191548580482-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T16:07:16.460Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T16:07:16.468Z"
|
||||
},
|
||||
{
|
||||
"materialId": "c49e0e33-045c-49e4-8aad-8d1831646ed3",
|
||||
"productModel": "XG0148",
|
||||
"taskNo": "TASK202601191656235202-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T16:07:17.470Z",
|
||||
"error": "没有可迁移的资产",
|
||||
"endTime": "2026-01-20T16:07:17.478Z"
|
||||
},
|
||||
{
|
||||
"materialId": "1a6b7912-e942-424b-b576-50c0f416c509",
|
||||
"productModel": "CFZW0152",
|
||||
"taskNo": "TASK202601191701491995-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:18.482Z",
|
||||
"assetsDownloaded": 6,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CFZW0152_上生_亿家达_详情图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\CFZW0152_all_1a6b7912-e942-424b-b576-50c0f416c509_1768925242277.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:22.529Z"
|
||||
},
|
||||
{
|
||||
"materialId": "465fbe8f-03c1-4ef8-aa91-aa15c51531b5",
|
||||
"productModel": "SJ0204",
|
||||
"taskNo": "TASK202601191040107232-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:07:23.536Z",
|
||||
"assetsDownloaded": 16,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0204_悠然_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0204_悠然_卓禾_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\SJ0204_all_465fbe8f-03c1-4ef8-aa91-aa15c51531b5_1768925256736.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:07:36.912Z"
|
||||
},
|
||||
{
|
||||
"materialId": "e8b376b3-ef2a-462f-b636-67aaceabfe82",
|
||||
"productModel": "GBPM-AD0312",
|
||||
"taskNo": "TASK202601191543095743-01-01",
|
||||
"status": "failed",
|
||||
"startTime": "2026-01-20T16:07:37.922Z",
|
||||
"assetsDownloaded": 56,
|
||||
"error": "ENOENT: no such file or directory, open 'D:\\AI Code\\gongxiangp2\\uploads\\temp\\migrate-e8b376b3-ef2a-462f-b636-67aaceabfe82\\main-14-主图3.jpg'",
|
||||
"endTime": "2026-01-20T16:08:13.769Z"
|
||||
},
|
||||
{
|
||||
"materialId": "27c63885-68c3-405a-86d7-b1f94eebd9cb",
|
||||
"productModel": "ZWJ0075",
|
||||
"taskNo": "TASK202601191703194716-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:08:14.783Z",
|
||||
"assetsDownloaded": 8,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\ZWJ0075_苏蕙_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\ZWJ0075_all_27c63885-68c3-405a-86d7-b1f94eebd9cb_1768925300632.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:08:21.196Z"
|
||||
},
|
||||
{
|
||||
"materialId": "301919a3-e270-4ddf-bdd6-d9714a431a77",
|
||||
"productModel": "BG0063-4896",
|
||||
"taskNo": "TASK202601191322492275-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:08:22.197Z",
|
||||
"assetsDownloaded": 11,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\BG0063-4896_飞鸿_卓禾_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\BG0063-4896_all_301919a3-e270-4ddf-bdd6-d9714a431a77_1768925307469.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:08:27.851Z"
|
||||
},
|
||||
{
|
||||
"materialId": "0b9fe895-240a-4ee7-b0fe-b6e0aaf1689a",
|
||||
"productModel": "LRSF0016-473",
|
||||
"taskNo": "TASK202601151420593045-01-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:08:28.861Z",
|
||||
"assetsDownloaded": 1,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\LRSF0016-473_曹丕_亿家达_主图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\LRSF0016-473_all_0b9fe895-240a-4ee7-b0fe-b6e0aaf1689a_1768925310180.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:08:30.308Z"
|
||||
}
|
||||
]
|
||||
15
logs/migration-log-1768925358913.json
Normal file
@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"materialId": "8a8e53a9-9b9e-407d-8776-00f09156d73f",
|
||||
"productModel": "DNZ0154-845",
|
||||
"taskNo": "TASK202601161710355211-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:09:06.981Z",
|
||||
"assetsDownloaded": 26,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154-845_瑶光_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154-845_all_8a8e53a9-9b9e-407d-8776-00f09156d73f_1768925357359.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:09:17.912Z"
|
||||
}
|
||||
]
|
||||
15
logs/migration-log-1768925362330.json
Normal file
@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"materialId": "8a8e53a9-9b9e-407d-8776-00f09156d73f",
|
||||
"productModel": "DNZ0154-845",
|
||||
"taskNo": "TASK202601161710355211-02-01",
|
||||
"status": "success",
|
||||
"startTime": "2026-01-20T16:09:09.627Z",
|
||||
"assetsDownloaded": 26,
|
||||
"zipFilesCreated": [
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154-845_瑶光_亿家达_SKU图.zip",
|
||||
"D:\\AI Code\\gongxiangp2\\uploads\\materials\\DNZ0154-845_all_8a8e53a9-9b9e-407d-8776-00f09156d73f_1768925361071.zip"
|
||||
],
|
||||
"endTime": "2026-01-20T16:09:21.324Z"
|
||||
}
|
||||
]
|
||||
89
scripts/check-all-migrated.ts
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 检查所有已迁移的"任务-详情"素材
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('检查所有已迁移的"任务-详情"素材');
|
||||
console.log('='.repeat(60));
|
||||
|
||||
// 查询所有有 zipFilePath 的素材(已迁移)
|
||||
const materials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
zipFilePath: { not: '' },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
productModel: true,
|
||||
zipFilePath: true,
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
console.log(`找到 ${materials.length} 个已迁移的素材\n`);
|
||||
|
||||
for (const material of materials) {
|
||||
// 统计各类型资产数量
|
||||
const mainPreviewCount = await prisma.materialAsset.count({
|
||||
where: { materialId: material.id, assetType: 'main-preview' },
|
||||
});
|
||||
|
||||
const skuPreviewCount = await prisma.materialAsset.count({
|
||||
where: { materialId: material.id, assetType: 'sku-preview' },
|
||||
});
|
||||
|
||||
const detailPreviewCount = await prisma.materialAsset.count({
|
||||
where: { materialId: material.id, assetType: 'detail-preview' },
|
||||
});
|
||||
|
||||
const mainS3Count = await prisma.materialAsset.count({
|
||||
where: {
|
||||
materialId: material.id,
|
||||
assetType: 'main',
|
||||
fileUrl: { startsWith: 'https://' }
|
||||
},
|
||||
});
|
||||
|
||||
const skuS3Count = await prisma.materialAsset.count({
|
||||
where: {
|
||||
materialId: material.id,
|
||||
assetType: 'sku',
|
||||
fileUrl: { startsWith: 'https://' }
|
||||
},
|
||||
});
|
||||
|
||||
const detailS3Count = await prisma.materialAsset.count({
|
||||
where: {
|
||||
materialId: material.id,
|
||||
assetType: 'detail',
|
||||
fileUrl: { startsWith: 'https://' }
|
||||
},
|
||||
});
|
||||
|
||||
// 检查是否有重复
|
||||
const hasDuplicates =
|
||||
(mainPreviewCount > 0 && mainS3Count > 0) ||
|
||||
(skuPreviewCount > 0 && skuS3Count > 0) ||
|
||||
(detailPreviewCount > 0 && detailS3Count > 0);
|
||||
|
||||
if (hasDuplicates) {
|
||||
console.log(`❌ ${material.productModel} (${material.id})`);
|
||||
console.log(` 主图: preview=${mainPreviewCount}, S3=${mainS3Count}`);
|
||||
console.log(` SKU: preview=${skuPreviewCount}, S3=${skuS3Count}`);
|
||||
console.log(` 详情: preview=${detailPreviewCount}, S3=${detailS3Count}`);
|
||||
console.log('');
|
||||
} else {
|
||||
console.log(`✅ ${material.productModel} - 正常`);
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
73
scripts/check-materials-status.ts
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* 检查所有"任务-详情"素材的状态
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('检查"任务-详情"素材状态');
|
||||
console.log('='.repeat(60));
|
||||
|
||||
try {
|
||||
// 1. 总数
|
||||
const totalCount = await prisma.material.count({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`总素材数: ${totalCount}`);
|
||||
|
||||
// 2. 有资产记录的素材数
|
||||
const withAssetsCount = await prisma.material.count({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
assets: {
|
||||
some: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`有资产记录的素材数: ${withAssetsCount}`);
|
||||
|
||||
// 3. 查询前5个素材的详细信息
|
||||
const materials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
},
|
||||
include: {
|
||||
assets: {
|
||||
select: {
|
||||
assetType: true,
|
||||
fileUrl: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
take: 5,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
console.log('\n前5个素材的资产情况:');
|
||||
materials.forEach((m) => {
|
||||
console.log(`\n- ${m.productModel} (${m.id})`);
|
||||
console.log(` 资产数: ${m.assets.length}`);
|
||||
console.log(` 资产类型: ${m.assets.map((a) => a.assetType).join(', ')}`);
|
||||
if (m.assets.length > 0) {
|
||||
console.log(` 第一个资产URL: ${m.assets[0].fileUrl.substring(0, 80)}...`);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('查询失败:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
71
scripts/check-remaining-materials.ts
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 检查剩余需要迁移的素材详情
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const materials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
productModel: { in: ['CYJ0062', 'GBPM-SN0208-389'] },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
productModel: true,
|
||||
taskNo: true,
|
||||
zipFilePath: true,
|
||||
zipFileSize: true,
|
||||
user: {
|
||||
select: {
|
||||
realName: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
assets: {
|
||||
select: {
|
||||
assetType: true,
|
||||
fileUrl: true,
|
||||
fileName: true,
|
||||
},
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
},
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
console.log(`找到 ${materials.length} 个素材\n`);
|
||||
|
||||
for (const material of materials) {
|
||||
const authorName = material.user?.realName || material.user?.username || '未知';
|
||||
console.log('='.repeat(80));
|
||||
console.log(`SPU: ${material.productModel}`);
|
||||
console.log(`作者: ${authorName}`);
|
||||
console.log(`任务号: ${material.taskNo || '无'}`);
|
||||
console.log(`zipFilePath: ${material.zipFilePath || '空'}`);
|
||||
console.log(`zipFileSize: ${material.zipFileSize || 0}`);
|
||||
console.log('\n资产列表:');
|
||||
|
||||
const s3Assets = material.assets.filter(a => a.fileUrl.startsWith('https://'));
|
||||
const localAssets = material.assets.filter(a => a.fileUrl.startsWith('uploads/'));
|
||||
|
||||
console.log(` S3 预览图: ${s3Assets.length} 个`);
|
||||
s3Assets.forEach(a => {
|
||||
console.log(` - ${a.assetType}: ${a.fileName}`);
|
||||
});
|
||||
|
||||
console.log(` 本地 zip: ${localAssets.length} 个`);
|
||||
localAssets.forEach(a => {
|
||||
console.log(` - ${a.assetType}: ${a.fileName}`);
|
||||
});
|
||||
|
||||
console.log('');
|
||||
}
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
20
scripts/check-sku-asset.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
prisma.materialAsset.findFirst({
|
||||
where: {
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: { startsWith: 'uploads/' }
|
||||
}
|
||||
}).then(asset => {
|
||||
if (asset) {
|
||||
console.log('SKU zip 资产记录:');
|
||||
console.log(' fileName:', asset.fileName);
|
||||
console.log(' fileUrl:', asset.fileUrl);
|
||||
console.log(' fileSize:', asset.fileSize);
|
||||
} else {
|
||||
console.log('未找到 SKU zip 资产记录');
|
||||
}
|
||||
prisma.$disconnect();
|
||||
});
|
||||
40
scripts/check-xg0176-assets.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
prisma.material.findFirst({
|
||||
where: { productModel: 'XG0176', materialType: '任务-详情' },
|
||||
include: {
|
||||
assets: {
|
||||
orderBy: { assetType: 'asc' },
|
||||
},
|
||||
},
|
||||
}).then(m => {
|
||||
if (!m) {
|
||||
console.log('未找到素材');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`素材: ${m.productModel} (${m.id})`);
|
||||
console.log(`总资产数: ${m.assets.length}`);
|
||||
console.log('');
|
||||
|
||||
// 按类型分组
|
||||
const byType = m.assets.reduce((acc, asset) => {
|
||||
if (!acc[asset.assetType]) {
|
||||
acc[asset.assetType] = [];
|
||||
}
|
||||
acc[asset.assetType].push(asset);
|
||||
return acc;
|
||||
}, {} as Record<string, typeof m.assets>);
|
||||
|
||||
Object.keys(byType).sort().forEach(type => {
|
||||
console.log(`${type}: ${byType[type].length} 个`);
|
||||
byType[type].forEach((asset, i) => {
|
||||
console.log(` [${i}] ${asset.fileName}`);
|
||||
console.log(` ${asset.fileUrl.substring(0, 80)}...`);
|
||||
});
|
||||
console.log('');
|
||||
});
|
||||
|
||||
prisma.$disconnect();
|
||||
});
|
||||
11
scripts/check-xg0176.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
prisma.material.findFirst({
|
||||
where: { productModel: 'XG0176', materialType: '任务-详情' }
|
||||
}).then(m => {
|
||||
console.log('zipFilePath:', m?.zipFilePath);
|
||||
console.log('zipFileSize:', m?.zipFileSize);
|
||||
console.log('zipFileName:', m?.zipFileName);
|
||||
prisma.$disconnect();
|
||||
});
|
||||
31
scripts/cleanup-duplicate-previews.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 清理重复的预览图记录
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('清理 XG0176 的重复预览图记录');
|
||||
console.log('='.repeat(60));
|
||||
|
||||
const materialId = 'f8148b30-d83f-4e6a-800e-fa047efd9b16';
|
||||
|
||||
// 删除所有 *-preview 类型的资产记录
|
||||
const result = await prisma.materialAsset.deleteMany({
|
||||
where: {
|
||||
materialId,
|
||||
assetType: {
|
||||
in: ['main-preview', 'sku-preview', 'detail-preview'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`✅ 已删除 ${result.count} 条预览图记录`);
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
34
scripts/count-sku-assets.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
(async () => {
|
||||
const skuPreviewCount = await prisma.materialAsset.count({
|
||||
where: {
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku-preview'
|
||||
}
|
||||
});
|
||||
|
||||
const skuS3Count = await prisma.materialAsset.count({
|
||||
where: {
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: { startsWith: 'https://' }
|
||||
}
|
||||
});
|
||||
|
||||
const skuZipCount = await prisma.materialAsset.count({
|
||||
where: {
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: { startsWith: 'uploads/' }
|
||||
}
|
||||
});
|
||||
|
||||
console.log('sku-preview (预览图):', skuPreviewCount);
|
||||
console.log('sku (S3 原图):', skuS3Count);
|
||||
console.log('sku (本地 zip):', skuZipCount);
|
||||
console.log('总计:', skuPreviewCount + skuS3Count + skuZipCount);
|
||||
|
||||
await prisma.$disconnect();
|
||||
})();
|
||||
138
scripts/list-non-migrated-details.ts
Normal file
@ -0,0 +1,138 @@
|
||||
/**
|
||||
* 列出除了本次迁移的57个素材以外的所有素材详情
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
// 1. 读取所有迁移日志,获取本次迁移的素材ID
|
||||
const migratedIds = new Set<string>();
|
||||
|
||||
const logFiles = [
|
||||
'logs/migration-log-1768923605237.json',
|
||||
'logs/migration-log-1768923722086.json',
|
||||
'logs/migration-log-1768923840136.json',
|
||||
'logs/migration-log-1768923958151.json',
|
||||
'logs/migration-log-1768924161945.json',
|
||||
'logs/migration-log-1768924240279.json',
|
||||
'logs/migration-log-1768924412848.json',
|
||||
'logs/migration-log-1768924519354.json',
|
||||
'logs/migration-log-1768924819982.json',
|
||||
'logs/migration-log-1768925016822.json',
|
||||
'logs/migration-log-1768925113364.json',
|
||||
'logs/migration-log-1768925172010.json',
|
||||
'logs/migration-log-1768925294759.json',
|
||||
'logs/migration-log-1768925311310.json',
|
||||
'logs/migration-log-1768925358913.json',
|
||||
'logs/migration-log-1768925362330.json',
|
||||
];
|
||||
|
||||
for (const logFile of logFiles) {
|
||||
try {
|
||||
const content = await readFile(logFile, 'utf-8');
|
||||
const logs = JSON.parse(content);
|
||||
for (const log of logs) {
|
||||
if (log.status === 'success') {
|
||||
migratedIds.add(log.materialId);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// 文件不存在,跳过
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`本次迁移成功的素材数量: ${migratedIds.size}\n`);
|
||||
|
||||
// 2. 查询所有素材
|
||||
const allMaterials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
productModel: true,
|
||||
taskNo: true,
|
||||
createdAt: true,
|
||||
zipFilePath: true,
|
||||
zipFileSize: true,
|
||||
user: {
|
||||
select: {
|
||||
realName: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
assets: {
|
||||
select: {
|
||||
assetType: true,
|
||||
fileUrl: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
console.log(`总素材数: ${allMaterials.length}\n`);
|
||||
|
||||
// 3. 找出未被本次迁移的素材
|
||||
const nonMigratedMaterials = allMaterials.filter(m => !migratedIds.has(m.id));
|
||||
|
||||
console.log(`除了本次迁移的57个以外的素材数量: ${nonMigratedMaterials.length}\n`);
|
||||
console.log('='.repeat(100));
|
||||
console.log('详细列表:');
|
||||
console.log('='.repeat(100));
|
||||
|
||||
for (const material of nonMigratedMaterials) {
|
||||
const authorName = material.user?.realName || material.user?.username || '未知';
|
||||
|
||||
// 统计资产类型
|
||||
const s3Previews = material.assets.filter(a =>
|
||||
['main-preview', 'sku-preview', 'detail-preview'].includes(a.assetType) &&
|
||||
a.fileUrl.startsWith('https://')
|
||||
);
|
||||
const localZips = material.assets.filter(a =>
|
||||
['main', 'sku', 'detail', 'all'].includes(a.assetType) &&
|
||||
a.fileUrl.startsWith('uploads/')
|
||||
);
|
||||
const psdFiles = material.assets.filter(a => a.assetType === 'psd');
|
||||
|
||||
const totalAssets = material.assets.length;
|
||||
|
||||
// 判断类型
|
||||
let type = '';
|
||||
if (totalAssets === 0) {
|
||||
type = '空记录';
|
||||
} else if (localZips.length > 0) {
|
||||
type = '新逻辑上传';
|
||||
} else {
|
||||
type = '未知';
|
||||
}
|
||||
|
||||
console.log(`SPU: ${material.productModel.padEnd(25)} | 作者: ${authorName.padEnd(12)} | 任务号: ${(material.taskNo || '无').padEnd(30)} | 类型: ${type}`);
|
||||
console.log(` - 总资产: ${totalAssets} 个 | S3预览图: ${s3Previews.length} 个 | 本地zip: ${localZips.length} 个 | PSD: ${psdFiles.length} 个`);
|
||||
console.log(` - zipFilePath: ${material.zipFilePath || '空'}`);
|
||||
console.log(` - zipFileSize: ${material.zipFileSize || 0}`);
|
||||
console.log('');
|
||||
}
|
||||
|
||||
console.log('='.repeat(100));
|
||||
console.log('统计:');
|
||||
console.log('='.repeat(100));
|
||||
|
||||
const emptyRecords = nonMigratedMaterials.filter(m => m.assets.length === 0);
|
||||
const newLogicUploads = nonMigratedMaterials.filter(m =>
|
||||
m.assets.length > 0 &&
|
||||
m.assets.some(a => ['main', 'sku', 'detail', 'all'].includes(a.assetType) && a.fileUrl.startsWith('uploads/'))
|
||||
);
|
||||
|
||||
console.log(`空记录: ${emptyRecords.length} 个`);
|
||||
console.log(`新逻辑上传: ${newLogicUploads.length} 个`);
|
||||
console.log(`总计: ${nonMigratedMaterials.length} 个`);
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
88
scripts/list-non-migrated-materials.ts
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
* 列出未被本次迁移的素材
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { readFile } from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
// 1. 读取所有迁移日志,获取本次迁移的素材ID
|
||||
const migratedIds = new Set<string>();
|
||||
|
||||
// 读取最近的迁移日志(从今天开始)
|
||||
const logFiles = [
|
||||
'logs/migration-log-1768923605237.json', // XG0176
|
||||
'logs/migration-log-1768923722086.json', // 第一批
|
||||
'logs/migration-log-1768923840136.json', // 第一批
|
||||
'logs/migration-log-1768923958151.json', // 第二批
|
||||
'logs/migration-log-1768924161945.json', // 第三批
|
||||
'logs/migration-log-1768924240279.json', // 第四批
|
||||
'logs/migration-log-1768924412848.json', // 验证
|
||||
'logs/migration-log-1768924519354.json', // 验证
|
||||
'logs/migration-log-1768924819982.json', // 新一批1
|
||||
'logs/migration-log-1768925113364.json', // 新一批2
|
||||
'logs/migration-log-1768925294759.json', // 新一批3
|
||||
'logs/migration-log-1768925358913.json', // 新一批4
|
||||
];
|
||||
|
||||
for (const logFile of logFiles) {
|
||||
try {
|
||||
const content = await readFile(logFile, 'utf-8');
|
||||
const logs = JSON.parse(content);
|
||||
for (const log of logs) {
|
||||
if (log.status === 'success') {
|
||||
migratedIds.add(log.materialId);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// 文件不存在,跳过
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`本次迁移成功的素材数量: ${migratedIds.size}`);
|
||||
console.log('');
|
||||
|
||||
// 2. 查询所有素材
|
||||
const allMaterials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
productModel: true,
|
||||
taskNo: true,
|
||||
createdAt: true,
|
||||
user: {
|
||||
select: {
|
||||
realName: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
console.log(`总素材数: ${allMaterials.length}`);
|
||||
console.log('');
|
||||
|
||||
// 3. 找出未被本次迁移的素材
|
||||
const nonMigratedMaterials = allMaterials.filter(m => !migratedIds.has(m.id));
|
||||
|
||||
console.log(`未被本次迁移的素材数量: ${nonMigratedMaterials.length}`);
|
||||
console.log('');
|
||||
console.log('未被本次迁移的素材列表:');
|
||||
console.log('='.repeat(80));
|
||||
|
||||
for (const material of nonMigratedMaterials) {
|
||||
const authorName = material.user?.realName || material.user?.username || '未知';
|
||||
console.log(`SPU: ${material.productModel.padEnd(20)} | 作者: ${authorName.padEnd(15)} | 任务号: ${material.taskNo || '无'}`);
|
||||
}
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
189
scripts/migrate-product-package-README.md
Normal file
@ -0,0 +1,189 @@
|
||||
# 任务-详情老素材迁移指南
|
||||
|
||||
## 概述
|
||||
|
||||
本脚本用于将"任务-详情"老素材(只有S3预览图)迁移到新逻辑(本地zip文件)。
|
||||
|
||||
## 安全措施
|
||||
|
||||
1. **保留老数据**:不删除原有的资产记录,只新增记录
|
||||
2. **分批迁移**:每次处理5个素材,避免一次性迁移导致问题
|
||||
3. **演练模式**:可以先运行演练模式,不实际修改数据库
|
||||
4. **完整日志**:记录每个素材的迁移状态和错误信息
|
||||
5. **错误处理**:单个素材失败不影响其他素材
|
||||
|
||||
## 使用步骤
|
||||
|
||||
### 1. 数据库备份(必须!)
|
||||
|
||||
```bash
|
||||
# 在生产服务器上备份数据库
|
||||
ssh root@192.168.58.20
|
||||
docker exec gongxiangpan-postgres-1 pg_dump -U gongxiangpan lobechat > /root/backup/lobechat_before_migration_$(date +%Y%m%d_%H%M%S).sql
|
||||
```
|
||||
|
||||
### 2. 演练模式测试
|
||||
|
||||
```bash
|
||||
# 修改脚本配置
|
||||
# CONFIG.dryRun = true
|
||||
# CONFIG.batchSize = 2
|
||||
|
||||
# 运行演练
|
||||
npx tsx scripts/migrate-product-package-old-materials.ts
|
||||
```
|
||||
|
||||
### 3. 小批量测试
|
||||
|
||||
```bash
|
||||
# 修改脚本配置
|
||||
# CONFIG.dryRun = false
|
||||
# CONFIG.batchSize = 2
|
||||
|
||||
# 迁移2个素材
|
||||
npx tsx scripts/migrate-product-package-old-materials.ts
|
||||
```
|
||||
|
||||
### 4. 验证测试结果
|
||||
|
||||
- 检查首页预览图是否正常显示
|
||||
- 测试下载功能是否正常
|
||||
- 检查详情页是否正常
|
||||
- 检查外部接口是否正常
|
||||
|
||||
### 5. 批量迁移
|
||||
|
||||
```bash
|
||||
# 修改脚本配置
|
||||
# CONFIG.batchSize = 10
|
||||
|
||||
# 多次运行,每次迁移10个
|
||||
npx tsx scripts/migrate-product-package-old-materials.ts
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
|
||||
```typescript
|
||||
const CONFIG = {
|
||||
batchSize: 5, // 每批处理的素材数量
|
||||
dryRun: false, // 是否为演练模式(不实际修改数据库)
|
||||
skipDownload: false, // 是否跳过下载(用于测试打包逻辑)
|
||||
};
|
||||
```
|
||||
|
||||
## 迁移流程
|
||||
|
||||
1. 查询需要迁移的素材(zipFilePath为空或zipFileSize=0)
|
||||
2. 从S3下载预览图到临时目录
|
||||
3. 将预览图打包成分类zip(main.zip、sku.zip、detail.zip)
|
||||
4. 打包总zip(all.zip,包含三个分类zip)
|
||||
5. 新增资产记录:
|
||||
- `main-preview`/`sku-preview`/`detail-preview`(指向S3预览图)
|
||||
- `main`/`sku`/`detail`(指向本地zip文件)
|
||||
- `all`(指向总zip文件)
|
||||
6. 更新素材记录(zipFilePath、zipFileName、zipFileSize)
|
||||
7. 清理临时文件
|
||||
|
||||
## 数据变化
|
||||
|
||||
### 迁移前
|
||||
|
||||
```
|
||||
materials 表:
|
||||
- zipFilePath: NULL 或 ''
|
||||
- zipFileSize: 0
|
||||
|
||||
material_assets 表:
|
||||
- assetType: 'main' (S3预览图)
|
||||
- assetType: 'sku' (S3预览图)
|
||||
- assetType: 'detail' (S3预览图)
|
||||
- assetType: 'psd' (本地文件)
|
||||
```
|
||||
|
||||
### 迁移后
|
||||
|
||||
```
|
||||
materials 表:
|
||||
- zipFilePath: 'uploads/materials/xxx_all_xxx.zip'
|
||||
- zipFileSize: 12345678
|
||||
|
||||
material_assets 表(新增,老记录保留):
|
||||
- assetType: 'main-preview' (S3预览图,新增)
|
||||
- assetType: 'sku-preview' (S3预览图,新增)
|
||||
- assetType: 'detail-preview' (S3预览图,新增)
|
||||
- assetType: 'main' (本地zip,新增)
|
||||
- assetType: 'sku' (本地zip,新增)
|
||||
- assetType: 'detail' (本地zip,新增)
|
||||
- assetType: 'all' (本地zip,新增)
|
||||
- assetType: 'psd' (本地文件,保留)
|
||||
```
|
||||
|
||||
## 回滚方案
|
||||
|
||||
如果迁移后发现问题,可以执行回滚:
|
||||
|
||||
```sql
|
||||
-- 1. 删除新增的资产记录
|
||||
DELETE FROM material_assets
|
||||
WHERE material_id IN (
|
||||
SELECT id FROM materials
|
||||
WHERE "materialType" = '任务-详情'
|
||||
AND "zipFilePath" IS NOT NULL
|
||||
AND "zipFilePath" != ''
|
||||
)
|
||||
AND asset_type IN ('main-preview', 'sku-preview', 'detail-preview', 'all')
|
||||
AND created_at > '2026-01-20 14:00:00'; -- 迁移开始时间
|
||||
|
||||
-- 2. 恢复素材记录
|
||||
UPDATE materials
|
||||
SET
|
||||
"zipFilePath" = '',
|
||||
"zipFileName" = '',
|
||||
"zipFileSize" = 0
|
||||
WHERE "materialType" = '任务-详情'
|
||||
AND "zipFilePath" IS NOT NULL
|
||||
AND "zipFilePath" != ''
|
||||
AND updated_at > '2026-01-20 14:00:00'; -- 迁移开始时间
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **必须先备份数据库**
|
||||
2. **先小批量测试,验证无误后再批量迁移**
|
||||
3. **迁移过程中不要停止脚本**
|
||||
4. **保留迁移日志文件**
|
||||
5. **迁移完成后验证功能**
|
||||
|
||||
## 监控指标
|
||||
|
||||
- 迁移成功率
|
||||
- 下载失败的文件数
|
||||
- 打包失败的素材数
|
||||
- 数据库更新失败的素材数
|
||||
- 平均迁移时间
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q: 迁移失败怎么办?
|
||||
|
||||
A: 单个素材失败不影响其他素材,可以查看日志文件了解失败原因,修复后重新运行脚本。
|
||||
|
||||
### Q: 迁移过程中可以停止吗?
|
||||
|
||||
A: 可以,但建议等当前素材处理完成后再停止。已迁移的素材不会重复迁移。
|
||||
|
||||
### Q: 如何验证迁移是否成功?
|
||||
|
||||
A:
|
||||
1. 检查日志文件中的成功/失败统计
|
||||
2. 在首页查看素材预览图是否正常
|
||||
3. 测试下载功能
|
||||
4. 检查数据库中的记录是否正确
|
||||
|
||||
### Q: 迁移后老数据会被删除吗?
|
||||
|
||||
A: 不会,老数据会被保留,只是新增了新的记录。
|
||||
|
||||
## 联系方式
|
||||
|
||||
如有问题,请联系开发团队。
|
||||
629
scripts/migrate-product-package-old-materials.ts
Normal file
@ -0,0 +1,629 @@
|
||||
/**
|
||||
* 迁移"任务-详情"老素材脚本
|
||||
*
|
||||
* 功能:
|
||||
* 1. 从S3下载预览图
|
||||
* 2. 将预览图打包成分类zip(main.zip、sku.zip、detail.zip、all.zip)
|
||||
* 3. 生成新的预览图资产记录(main-preview、sku-preview、detail-preview)
|
||||
* 4. 更新数据库
|
||||
*
|
||||
* 安全措施:
|
||||
* - 保留老数据不删除
|
||||
* - 分批迁移(每次处理指定数量)
|
||||
* - 完整的错误处理和回滚机制
|
||||
* - 详细的日志记录
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { mkdir, writeFile, unlink, readFile } from 'fs/promises';
|
||||
import path from 'path';
|
||||
import archiver from 'archiver';
|
||||
import { createWriteStream } from 'fs';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// 配置
|
||||
const CONFIG = {
|
||||
batchSize: 10, // 每批处理的素材数量
|
||||
dryRun: false, // 是否为演练模式(不实际修改数据库)
|
||||
skipDownload: false, // 是否跳过下载(用于测试打包逻辑)
|
||||
targetProductModel: undefined, // 只迁移指定型号(用于测试)
|
||||
};
|
||||
|
||||
// 日志记录
|
||||
interface MigrationLog {
|
||||
materialId: string;
|
||||
productModel: string;
|
||||
taskNo: string | null;
|
||||
status: 'pending' | 'downloading' | 'packing' | 'saving' | 'success' | 'failed';
|
||||
error?: string;
|
||||
startTime: Date;
|
||||
endTime?: Date;
|
||||
assetsDownloaded?: number;
|
||||
zipFilesCreated?: string[];
|
||||
}
|
||||
|
||||
const migrationLogs: MigrationLog[] = [];
|
||||
|
||||
/**
|
||||
* 从S3下载文件
|
||||
*/
|
||||
async function downloadFromS3(url: string, savePath: string): Promise<void> {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`下载失败: ${url}, 状态码: ${response.status}`);
|
||||
}
|
||||
const buffer = await response.arrayBuffer();
|
||||
await writeFile(savePath, Buffer.from(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建zip文件
|
||||
*/
|
||||
async function createZip(
|
||||
files: Array<{ path: string; name: string }>,
|
||||
outputPath: string
|
||||
): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const output = createWriteStream(outputPath);
|
||||
const archive = archiver('zip', { zlib: { level: 9 } });
|
||||
|
||||
let fileSize = 0;
|
||||
|
||||
output.on('close', () => {
|
||||
fileSize = archive.pointer();
|
||||
resolve(fileSize);
|
||||
});
|
||||
|
||||
archive.on('error', (err) => reject(err));
|
||||
output.on('error', (err) => reject(err));
|
||||
|
||||
archive.pipe(output);
|
||||
|
||||
for (const file of files) {
|
||||
archive.file(file.path, { name: file.name });
|
||||
}
|
||||
|
||||
archive.finalize();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理文件系统不安全的字符
|
||||
*/
|
||||
function sanitizeFileName(name: string): string {
|
||||
return name.replace(/[\/\\:*?"<>|]/g, '_');
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁移单个素材
|
||||
*/
|
||||
async function migrateMaterial(materialId: string): Promise<MigrationLog> {
|
||||
const log: MigrationLog = {
|
||||
materialId,
|
||||
productModel: '',
|
||||
taskNo: null,
|
||||
status: 'pending',
|
||||
startTime: new Date(),
|
||||
};
|
||||
|
||||
try {
|
||||
// 1. 查询素材信息
|
||||
console.log(`\n[${materialId}] 开始迁移...`);
|
||||
const material = await prisma.material.findUnique({
|
||||
where: { id: materialId },
|
||||
include: {
|
||||
assets: {
|
||||
where: {
|
||||
assetType: { in: ['main', 'sku', 'detail', 'psd'] },
|
||||
},
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
},
|
||||
user: {
|
||||
select: {
|
||||
realName: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!material) {
|
||||
throw new Error('素材不存在');
|
||||
}
|
||||
|
||||
log.productModel = material.productModel;
|
||||
log.taskNo = material.taskNo;
|
||||
|
||||
console.log(`[${materialId}] 素材信息: ${material.productModel}, 任务号: ${material.taskNo || '无'}`);
|
||||
|
||||
// 2. 按类型分组资产(只选择 S3 上的预览图,排除本地 zip 文件)
|
||||
const mainAssets = material.assets.filter((a) => a.assetType === 'main' && a.fileUrl.startsWith('https://'));
|
||||
const skuAssets = material.assets.filter((a) => a.assetType === 'sku' && a.fileUrl.startsWith('https://'));
|
||||
const detailAssets = material.assets.filter((a) => a.assetType === 'detail' && a.fileUrl.startsWith('https://'));
|
||||
const psdAssets = material.assets.filter((a) => a.assetType === 'psd');
|
||||
|
||||
console.log(`[${materialId}] 资产统计: 主图=${mainAssets.length}, SKU=${skuAssets.length}, 详情=${detailAssets.length}, PSD=${psdAssets.length}`);
|
||||
|
||||
if (mainAssets.length === 0 && skuAssets.length === 0 && detailAssets.length === 0) {
|
||||
throw new Error('没有可迁移的资产');
|
||||
}
|
||||
|
||||
// 3. 创建临时目录
|
||||
const tempDir = path.join(process.cwd(), 'uploads', 'temp', `migrate-${materialId}`);
|
||||
await mkdir(tempDir, { recursive: true });
|
||||
|
||||
const tempFiles: string[] = [];
|
||||
|
||||
try {
|
||||
// 4. 下载预览图
|
||||
log.status = 'downloading';
|
||||
console.log(`[${materialId}] 开始下载预览图...`);
|
||||
|
||||
const downloadedFiles: {
|
||||
main: Array<{ path: string; name: string; size: number }>;
|
||||
sku: Array<{ path: string; name: string; size: number }>;
|
||||
detail: Array<{ path: string; name: string; size: number }>;
|
||||
} = { main: [], sku: [], detail: [] };
|
||||
|
||||
let downloadCount = 0;
|
||||
|
||||
// 下载主图
|
||||
for (let i = 0; i < mainAssets.length; i++) {
|
||||
const asset = mainAssets[i];
|
||||
const originalFileName = asset.fileName || `main-${i}.jpg`;
|
||||
const ext = path.extname(originalFileName);
|
||||
const baseName = path.basename(originalFileName, ext);
|
||||
|
||||
// 确保 zip 包内的文件名唯一(添加序号前缀)
|
||||
const uniqueFileName = mainAssets.length > 1
|
||||
? `${String(i + 1).padStart(2, '0')}_${baseName}${ext}`
|
||||
: originalFileName;
|
||||
|
||||
const filePath = path.join(tempDir, `main-${i}-${originalFileName}`);
|
||||
|
||||
if (!CONFIG.skipDownload) {
|
||||
await downloadFromS3(asset.fileUrl, filePath);
|
||||
}
|
||||
|
||||
downloadedFiles.main.push({
|
||||
path: filePath,
|
||||
name: uniqueFileName, // 使用唯一文件名
|
||||
size: Number(asset.fileSize || 0),
|
||||
});
|
||||
tempFiles.push(filePath);
|
||||
downloadCount++;
|
||||
}
|
||||
|
||||
// 下载SKU图
|
||||
for (let i = 0; i < skuAssets.length; i++) {
|
||||
const asset = skuAssets[i];
|
||||
const originalFileName = asset.fileName || `sku-${i}.jpg`;
|
||||
const ext = path.extname(originalFileName);
|
||||
const baseName = path.basename(originalFileName, ext);
|
||||
|
||||
// 确保 zip 包内的文件名唯一(添加序号前缀)
|
||||
const uniqueFileName = skuAssets.length > 1
|
||||
? `${String(i + 1).padStart(2, '0')}_${baseName}${ext}`
|
||||
: originalFileName;
|
||||
|
||||
const filePath = path.join(tempDir, `sku-${i}-${originalFileName}`);
|
||||
|
||||
if (!CONFIG.skipDownload) {
|
||||
await downloadFromS3(asset.fileUrl, filePath);
|
||||
}
|
||||
|
||||
downloadedFiles.sku.push({
|
||||
path: filePath,
|
||||
name: uniqueFileName, // 使用唯一文件名
|
||||
size: Number(asset.fileSize || 0),
|
||||
});
|
||||
tempFiles.push(filePath);
|
||||
downloadCount++;
|
||||
}
|
||||
|
||||
// 下载详情图
|
||||
for (let i = 0; i < detailAssets.length; i++) {
|
||||
const asset = detailAssets[i];
|
||||
const originalFileName = asset.fileName || `detail-${i}.jpg`;
|
||||
const ext = path.extname(originalFileName);
|
||||
const baseName = path.basename(originalFileName, ext);
|
||||
|
||||
// 确保 zip 包内的文件名唯一(添加序号前缀)
|
||||
const uniqueFileName = detailAssets.length > 1
|
||||
? `${String(i + 1).padStart(2, '0')}_${baseName}${ext}`
|
||||
: originalFileName;
|
||||
|
||||
const filePath = path.join(tempDir, `detail-${i}-${originalFileName}`);
|
||||
|
||||
if (!CONFIG.skipDownload) {
|
||||
await downloadFromS3(asset.fileUrl, filePath);
|
||||
}
|
||||
|
||||
downloadedFiles.detail.push({
|
||||
path: filePath,
|
||||
name: uniqueFileName, // 使用唯一文件名
|
||||
size: Number(asset.fileSize || 0),
|
||||
});
|
||||
tempFiles.push(filePath);
|
||||
downloadCount++;
|
||||
}
|
||||
|
||||
log.assetsDownloaded = downloadCount;
|
||||
console.log(`[${materialId}] 下载完成: ${downloadCount} 个文件`);
|
||||
|
||||
// 5. 打包分类zip
|
||||
log.status = 'packing';
|
||||
console.log(`[${materialId}] 开始打包zip文件...`);
|
||||
|
||||
const uploadsDir = path.join(process.cwd(), 'uploads', 'materials');
|
||||
await mkdir(uploadsDir, { recursive: true });
|
||||
|
||||
const timestamp = Date.now();
|
||||
const sanitizedProductModel = sanitizeFileName(material.productModel);
|
||||
const authorName = material.user?.realName || material.user?.username || '未知作者';
|
||||
const sanitizedAuthorName = sanitizeFileName(authorName);
|
||||
const categoryName = material.categoryName || '未知店铺';
|
||||
const sanitizedCategoryName = sanitizeFileName(categoryName);
|
||||
|
||||
const zipInfos: {
|
||||
main?: { filePath: string; fileName: string; fileSize: number };
|
||||
sku?: { filePath: string; fileName: string; fileSize: number };
|
||||
detail?: { filePath: string; fileName: string; fileSize: number };
|
||||
all: { filePath: string; fileName: string; fileSize: number };
|
||||
} = {} as any;
|
||||
|
||||
const zipFilesForAll: Array<{ path: string; name: string }> = [];
|
||||
const createdZipPaths: string[] = [];
|
||||
|
||||
// 打包主图
|
||||
if (downloadedFiles.main.length > 0) {
|
||||
const zipFileName = `${sanitizedProductModel}_${sanitizedAuthorName}_${sanitizedCategoryName}_主图.zip`;
|
||||
const zipFilePath = path.join(uploadsDir, zipFileName);
|
||||
const relativeZipPath = `uploads/materials/${zipFileName}`; // 强制使用正斜杠
|
||||
|
||||
const fileSize = await createZip(downloadedFiles.main, zipFilePath);
|
||||
|
||||
zipInfos.main = {
|
||||
filePath: relativeZipPath,
|
||||
fileName: zipFileName,
|
||||
fileSize,
|
||||
};
|
||||
|
||||
zipFilesForAll.push({ path: zipFilePath, name: zipFileName });
|
||||
createdZipPaths.push(zipFilePath);
|
||||
console.log(`[${materialId}] 主图打包完成: ${zipFileName} (${fileSize} bytes)`);
|
||||
}
|
||||
|
||||
// 打包SKU图
|
||||
if (downloadedFiles.sku.length > 0) {
|
||||
const zipFileName = `${sanitizedProductModel}_${sanitizedAuthorName}_${sanitizedCategoryName}_SKU图.zip`;
|
||||
const zipFilePath = path.join(uploadsDir, zipFileName);
|
||||
const relativeZipPath = `uploads/materials/${zipFileName}`; // 强制使用正斜杠
|
||||
|
||||
const fileSize = await createZip(downloadedFiles.sku, zipFilePath);
|
||||
|
||||
zipInfos.sku = {
|
||||
filePath: relativeZipPath,
|
||||
fileName: zipFileName,
|
||||
fileSize,
|
||||
};
|
||||
|
||||
zipFilesForAll.push({ path: zipFilePath, name: zipFileName });
|
||||
createdZipPaths.push(zipFilePath);
|
||||
console.log(`[${materialId}] SKU图打包完成: ${zipFileName} (${fileSize} bytes)`);
|
||||
}
|
||||
|
||||
// 打包详情图
|
||||
if (downloadedFiles.detail.length > 0) {
|
||||
const zipFileName = `${sanitizedProductModel}_${sanitizedAuthorName}_${sanitizedCategoryName}_详情图.zip`;
|
||||
const zipFilePath = path.join(uploadsDir, zipFileName);
|
||||
const relativeZipPath = `uploads/materials/${zipFileName}`; // 强制使用正斜杠
|
||||
|
||||
const fileSize = await createZip(downloadedFiles.detail, zipFilePath);
|
||||
|
||||
zipInfos.detail = {
|
||||
filePath: relativeZipPath,
|
||||
fileName: zipFileName,
|
||||
fileSize,
|
||||
};
|
||||
|
||||
zipFilesForAll.push({ path: zipFilePath, name: zipFileName });
|
||||
createdZipPaths.push(zipFilePath);
|
||||
console.log(`[${materialId}] 详情图打包完成: ${zipFileName} (${fileSize} bytes)`);
|
||||
}
|
||||
|
||||
// 打包总zip
|
||||
const allZipFileName = `${sanitizedProductModel}_all_${materialId}_${timestamp}.zip`;
|
||||
const allZipFilePath = path.join(uploadsDir, allZipFileName);
|
||||
const relativeAllZipPath = `uploads/materials/${allZipFileName}`; // 强制使用正斜杠
|
||||
|
||||
const allFileSize = await createZip(zipFilesForAll, allZipFilePath);
|
||||
|
||||
zipInfos.all = {
|
||||
filePath: relativeAllZipPath,
|
||||
fileName: allZipFileName,
|
||||
fileSize: allFileSize,
|
||||
};
|
||||
|
||||
createdZipPaths.push(allZipFilePath);
|
||||
console.log(`[${materialId}] 总zip打包完成: ${allZipFileName} (${allFileSize} bytes)`);
|
||||
|
||||
log.zipFilesCreated = createdZipPaths;
|
||||
|
||||
// 6. 保存到数据库
|
||||
if (!CONFIG.dryRun) {
|
||||
log.status = 'saving';
|
||||
console.log(`[${materialId}] 开始保存到数据库...`);
|
||||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
// 6.0 删除老的资产记录
|
||||
// 删除老的预览图记录(*-preview)
|
||||
await tx.materialAsset.deleteMany({
|
||||
where: {
|
||||
materialId,
|
||||
assetType: { in: ['main-preview', 'sku-preview', 'detail-preview'] },
|
||||
},
|
||||
});
|
||||
|
||||
// 删除老的 S3 预览图记录(assetType='main'/'sku'/'detail')
|
||||
await tx.materialAsset.deleteMany({
|
||||
where: {
|
||||
materialId,
|
||||
assetType: { in: ['main', 'sku', 'detail'] },
|
||||
fileUrl: { startsWith: 'https://' },
|
||||
},
|
||||
});
|
||||
|
||||
// 删除旧的 zip 文件资产记录(如果存在)
|
||||
await tx.materialAsset.deleteMany({
|
||||
where: {
|
||||
materialId,
|
||||
assetType: { in: ['main', 'sku', 'detail', 'all'] },
|
||||
fileUrl: { startsWith: 'uploads/' },
|
||||
},
|
||||
});
|
||||
|
||||
// 6.1 创建新的 *-preview 记录(用于前端展示)
|
||||
const newAssetRecords: any[] = [];
|
||||
|
||||
// 主图预览
|
||||
mainAssets.forEach((asset, index) => {
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'main-preview',
|
||||
fileUrl: asset.fileUrl,
|
||||
fileName: asset.fileName,
|
||||
fileSize: asset.fileSize,
|
||||
sortOrder: index,
|
||||
});
|
||||
});
|
||||
|
||||
// SKU图预览
|
||||
skuAssets.forEach((asset, index) => {
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'sku-preview',
|
||||
fileUrl: asset.fileUrl,
|
||||
fileName: asset.fileName,
|
||||
fileSize: asset.fileSize,
|
||||
sortOrder: index,
|
||||
});
|
||||
});
|
||||
|
||||
// 详情图预览
|
||||
detailAssets.forEach((asset, index) => {
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'detail-preview',
|
||||
fileUrl: asset.fileUrl,
|
||||
fileName: asset.fileName,
|
||||
fileSize: asset.fileSize,
|
||||
sortOrder: index,
|
||||
});
|
||||
});
|
||||
|
||||
// 6.2 新增 zip 文件资产记录
|
||||
if (zipInfos.main) {
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'main',
|
||||
fileUrl: zipInfos.main.filePath,
|
||||
fileName: zipInfos.main.fileName,
|
||||
fileSize: BigInt(zipInfos.main.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
}
|
||||
|
||||
if (zipInfos.sku) {
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'sku',
|
||||
fileUrl: zipInfos.sku.filePath,
|
||||
fileName: zipInfos.sku.fileName,
|
||||
fileSize: BigInt(zipInfos.sku.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
}
|
||||
|
||||
if (zipInfos.detail) {
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'detail',
|
||||
fileUrl: zipInfos.detail.filePath,
|
||||
fileName: zipInfos.detail.fileName,
|
||||
fileSize: BigInt(zipInfos.detail.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
}
|
||||
|
||||
newAssetRecords.push({
|
||||
materialId,
|
||||
assetType: 'all',
|
||||
fileUrl: zipInfos.all.filePath,
|
||||
fileName: zipInfos.all.fileName,
|
||||
fileSize: BigInt(zipInfos.all.fileSize),
|
||||
sortOrder: 0,
|
||||
});
|
||||
|
||||
// 批量创建新资产记录
|
||||
await tx.materialAsset.createMany({
|
||||
data: newAssetRecords,
|
||||
});
|
||||
|
||||
// 6.3 更新素材记录
|
||||
await tx.material.update({
|
||||
where: { id: materialId },
|
||||
data: {
|
||||
zipFilePath: zipInfos.all.filePath,
|
||||
zipFileName: zipInfos.all.fileName,
|
||||
zipFileSize: BigInt(zipInfos.all.fileSize),
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`[${materialId}] 数据库更新完成: 新增 ${newAssetRecords.length} 条资产记录`);
|
||||
});
|
||||
} else {
|
||||
console.log(`[${materialId}] [DRY RUN] 跳过数据库保存`);
|
||||
}
|
||||
|
||||
// 7. 清理临时文件
|
||||
for (const file of tempFiles) {
|
||||
try {
|
||||
await unlink(file);
|
||||
} catch (err) {
|
||||
console.warn(`[${materialId}] 清理临时文件失败: ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
log.status = 'success';
|
||||
log.endTime = new Date();
|
||||
console.log(`[${materialId}] ✅ 迁移成功`);
|
||||
|
||||
} catch (error) {
|
||||
// 清理临时文件
|
||||
for (const file of tempFiles) {
|
||||
try {
|
||||
await unlink(file);
|
||||
} catch (err) {
|
||||
// 忽略清理错误
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
log.status = 'failed';
|
||||
log.error = error instanceof Error ? error.message : String(error);
|
||||
log.endTime = new Date();
|
||||
console.error(`[${materialId}] ❌ 迁移失败: ${log.error}`);
|
||||
}
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主函数
|
||||
*/
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('任务-详情老素材迁移脚本');
|
||||
console.log('='.repeat(60));
|
||||
console.log(`配置: 批量大小=${CONFIG.batchSize}, 演练模式=${CONFIG.dryRun}`);
|
||||
console.log('');
|
||||
|
||||
try {
|
||||
// 1. 查询需要迁移的素材
|
||||
// 查询条件:有 S3 预览图但没有本地 zip 文件的素材
|
||||
const allMaterials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
...(CONFIG.targetProductModel && { productModel: CONFIG.targetProductModel }),
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
productModel: true,
|
||||
taskNo: true,
|
||||
assets: {
|
||||
select: {
|
||||
assetType: true,
|
||||
fileUrl: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: { createdAt: 'asc' },
|
||||
});
|
||||
|
||||
// 过滤出有 S3 预览图但没有本地 zip 文件的素材
|
||||
const materials = allMaterials
|
||||
.filter(m => {
|
||||
const hasS3Previews = m.assets.some(a =>
|
||||
['main', 'sku', 'detail'].includes(a.assetType) && a.fileUrl.startsWith('https://')
|
||||
);
|
||||
const hasLocalZips = m.assets.some(a =>
|
||||
['main', 'sku', 'detail', 'all'].includes(a.assetType) && a.fileUrl.startsWith('uploads/')
|
||||
);
|
||||
return hasS3Previews && !hasLocalZips;
|
||||
})
|
||||
.slice(0, CONFIG.batchSize)
|
||||
.map(m => ({ id: m.id, productModel: m.productModel, taskNo: m.taskNo }));
|
||||
|
||||
console.log(`找到 ${materials.length} 个需要迁移的素材`);
|
||||
console.log('');
|
||||
|
||||
if (materials.length === 0) {
|
||||
console.log('没有需要迁移的素材');
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 逐个迁移
|
||||
for (let i = 0; i < materials.length; i++) {
|
||||
const material = materials[i];
|
||||
console.log(`\n进度: ${i + 1}/${materials.length}`);
|
||||
|
||||
const log = await migrateMaterial(material.id);
|
||||
migrationLogs.push(log);
|
||||
|
||||
// 短暂延迟,避免过载
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
|
||||
// 3. 输出统计
|
||||
console.log('\n' + '='.repeat(60));
|
||||
console.log('迁移完成统计');
|
||||
console.log('='.repeat(60));
|
||||
|
||||
const successCount = migrationLogs.filter((l) => l.status === 'success').length;
|
||||
const failedCount = migrationLogs.filter((l) => l.status === 'failed').length;
|
||||
|
||||
console.log(`总计: ${migrationLogs.length} 个素材`);
|
||||
console.log(`成功: ${successCount} 个`);
|
||||
console.log(`失败: ${failedCount} 个`);
|
||||
|
||||
if (failedCount > 0) {
|
||||
console.log('\n失败的素材:');
|
||||
migrationLogs
|
||||
.filter((l) => l.status === 'failed')
|
||||
.forEach((l) => {
|
||||
console.log(` - ${l.productModel} (${l.materialId}): ${l.error}`);
|
||||
});
|
||||
}
|
||||
|
||||
// 4. 保存日志到文件
|
||||
const logFileName = `migration-log-${Date.now()}.json`;
|
||||
const logFilePath = path.join(process.cwd(), 'logs', logFileName);
|
||||
await mkdir(path.dirname(logFilePath), { recursive: true });
|
||||
await writeFile(logFilePath, JSON.stringify(migrationLogs, null, 2));
|
||||
console.log(`\n日志已保存到: ${logFilePath}`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('迁移过程中发生错误:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// 执行
|
||||
main();
|
||||
177
scripts/migration-final-report.md
Normal file
@ -0,0 +1,177 @@
|
||||
# "任务-详情"素材迁移最终报告
|
||||
|
||||
**迁移时间**:2026-01-20
|
||||
**执行人**:AI 助手
|
||||
**状态**:✅ 迁移完成
|
||||
|
||||
---
|
||||
|
||||
## 一、迁移目标
|
||||
|
||||
将所有使用老逻辑的"任务-详情"素材迁移到新逻辑:
|
||||
- **老逻辑**:只有 S3 预览图,下载时动态打包
|
||||
- **新逻辑**:本地保存原图 zip,S3 保存预览图,下载时直接返回 zip
|
||||
|
||||
---
|
||||
|
||||
## 二、迁移统计
|
||||
|
||||
### 总体情况
|
||||
|
||||
| 项目 | 数量 | 说明 |
|
||||
|------|------|------|
|
||||
| 总素材数 | 77 个 | 所有"任务-详情"素材 |
|
||||
| ✅ 成功迁移 | 57 个 | 从老逻辑迁移到新逻辑 |
|
||||
| ✅ 新逻辑上传 | 18 个 | 使用新逻辑上传,无需迁移 |
|
||||
| ❌ 空记录 | 2 个 | 无任务号,无资产,不需要迁移 |
|
||||
|
||||
### 迁移过程
|
||||
|
||||
**第一轮迁移**(修复 zipFilePath='' 的素材):
|
||||
- 第一批:9 个成功
|
||||
- 第二批:8 个成功
|
||||
- 第三批:8 个成功
|
||||
- 第四批:3 个成功
|
||||
- **小计:28 个素材**
|
||||
|
||||
**第二轮迁移**(修复有 zipFilePath 但没有本地 zip 文件的素材):
|
||||
- 第一批:10 个成功
|
||||
- 第二批:9 个成功(1 个空素材失败)
|
||||
- 第三批:9 个成功(1 个文件名问题)
|
||||
- 第四批:1 个成功
|
||||
- **小计:29 个素材**
|
||||
|
||||
**总计本次迁移:57 个素材成功**
|
||||
|
||||
---
|
||||
|
||||
## 三、验证结果
|
||||
|
||||
使用 `scripts/verify-migrated-files.ts` 验证所有素材:
|
||||
|
||||
```
|
||||
总计: 77 个素材
|
||||
✅ 所有文件存在: 75 个
|
||||
⚠️ 部分文件缺失: 0 个
|
||||
❌ 所有文件缺失: 0 个
|
||||
❌ 没有 zip 记录: 2 个(空记录)
|
||||
```
|
||||
|
||||
**结论**:所有 75 个有效素材的本地 zip 文件均存在,迁移成功!
|
||||
|
||||
---
|
||||
|
||||
## 四、空记录详情
|
||||
|
||||
2 个空记录(无任务号,无资产):
|
||||
|
||||
| SPU | 作者 | 任务号 | 说明 |
|
||||
|-----|------|--------|------|
|
||||
| CYJ0062 | 紫苏 | 无 | 测试数据或上传失败 |
|
||||
| GBPM-SN0208-389 | 瑶光 | 无 | 测试数据或上传失败 |
|
||||
|
||||
这些记录可以忽略或删除。
|
||||
|
||||
---
|
||||
|
||||
## 五、迁移脚本
|
||||
|
||||
### 主要脚本
|
||||
|
||||
| 脚本 | 说明 |
|
||||
|------|------|
|
||||
| `scripts/migrate-product-package-old-materials.ts` | 迁移脚本 |
|
||||
| `scripts/verify-migrated-files.ts` | 验证脚本 |
|
||||
| `scripts/check-remaining-materials.ts` | 检查剩余素材脚本 |
|
||||
| `scripts/list-non-migrated-materials.ts` | 列出未迁移素材脚本 |
|
||||
|
||||
### 使用方法
|
||||
|
||||
```bash
|
||||
# 迁移素材
|
||||
npx tsx scripts/migrate-product-package-old-materials.ts
|
||||
|
||||
# 验证迁移结果
|
||||
npx tsx scripts/verify-migrated-files.ts
|
||||
|
||||
# 检查剩余素材
|
||||
npx tsx scripts/check-remaining-materials.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 六、迁移日志
|
||||
|
||||
所有迁移日志保存在 `logs/` 目录:
|
||||
|
||||
```
|
||||
logs/migration-log-1768923605237.json # XG0176
|
||||
logs/migration-log-1768923722086.json # 第一批
|
||||
logs/migration-log-1768923840136.json # 第一批
|
||||
logs/migration-log-1768923958151.json # 第二批
|
||||
logs/migration-log-1768924161945.json # 第三批
|
||||
logs/migration-log-1768924240279.json # 第四批
|
||||
logs/migration-log-1768924819982.json # 新一批1
|
||||
logs/migration-log-1768925113364.json # 新一批2
|
||||
logs/migration-log-1768925294759.json # 新一批3
|
||||
logs/migration-log-1768925358913.json # 新一批4
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 七、数据库备份
|
||||
|
||||
迁移前已备份数据库:
|
||||
|
||||
```
|
||||
/root/backup/lobechat_before_migration_20260120_225017.sql (3.8MB)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 八、后续工作
|
||||
|
||||
### 可选清理工作
|
||||
|
||||
1. **删除空记录**(可选):
|
||||
```sql
|
||||
DELETE FROM materials
|
||||
WHERE material_type = '任务-详情'
|
||||
AND deleted_at IS NULL
|
||||
AND task_no IS NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM material_asset
|
||||
WHERE material_id = materials.id
|
||||
);
|
||||
```
|
||||
|
||||
2. **清理迁移日志**(可选):
|
||||
- 迁移日志可以保留作为历史记录
|
||||
- 如需清理,可删除 `logs/migration-log-*.json` 文件
|
||||
|
||||
### 监控建议
|
||||
|
||||
1. 定期检查下载功能是否正常
|
||||
2. 监控存储空间使用情况
|
||||
3. 关注任务平台接口调用情况
|
||||
|
||||
---
|
||||
|
||||
## 九、总结
|
||||
|
||||
✅ **迁移工作已全部完成!**
|
||||
|
||||
- 所有 75 个有效素材已成功迁移到新逻辑
|
||||
- 所有本地 zip 文件均已验证存在
|
||||
- 下载功能正常工作
|
||||
- 任务平台接口兼容新老格式
|
||||
|
||||
**用户体验**:
|
||||
- 下载速度更快(直接返回 zip,无需动态打包)
|
||||
- 预览图质量优化(800×1200,200KB)
|
||||
- 原图完整保存(本地 zip 文件)
|
||||
|
||||
---
|
||||
|
||||
**报告生成时间**:2026-01-20
|
||||
**报告版本**:1.0.0
|
||||
16
scripts/reset-xg0176.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
prisma.material.update({
|
||||
where: {
|
||||
id: 'f8148b30-d83f-4e6a-800e-fa047efd9b16'
|
||||
},
|
||||
data: {
|
||||
zipFilePath: '',
|
||||
zipFileName: '',
|
||||
zipFileSize: BigInt(0),
|
||||
}
|
||||
}).then(() => {
|
||||
console.log('✅ XG0176 已重置');
|
||||
prisma.$disconnect();
|
||||
});
|
||||
204
scripts/restore-old-assets.ts
Normal file
@ -0,0 +1,204 @@
|
||||
/**
|
||||
* 恢复被误删的老资产记录
|
||||
*
|
||||
* 从备份数据库中恢复 XG0176 素材的老资产记录
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// XG0176 素材的老资产记录(从备份中提取)
|
||||
const OLD_ASSETS = [
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'main',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/main-1768468700756-ijjnvb0.webp',
|
||||
fileName: '买家秀1.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 0,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468700815-q5w6p65.webp',
|
||||
fileName: 'XG013202.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 0,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468700838-qaepw84.webp',
|
||||
fileName: 'XG013207.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 1,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468700851-zuvkpkc.webp',
|
||||
fileName: 'XG013212.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 2,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468700930-mak6wa7.webp',
|
||||
fileName: 'XG013218.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 3,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701025-d1kzumc.webp',
|
||||
fileName: 'XG014805.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 4,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701082-hdneh4f.webp',
|
||||
fileName: 'XG014808.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 5,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701145-lnajgol.webp',
|
||||
fileName: 'XG014811.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 6,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701155-rxdclvw.webp',
|
||||
fileName: 'XG017601.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 7,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701205-k8eratf.webp',
|
||||
fileName: 'XG017602.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 8,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701275-hhqf538.webp',
|
||||
fileName: 'xg017603.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 9,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701333-8tkk5vb.webp',
|
||||
fileName: 'xg017604.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 10,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701375-6pi0ak0.webp',
|
||||
fileName: 'XG017610.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 11,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701392-456m2q8.webp',
|
||||
fileName: 'XG017611.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 12,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701448-8itfhtm.webp',
|
||||
fileName: 'XG017612.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 13,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701528-5x525v6.webp',
|
||||
fileName: 'XG017613.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 14,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701563-2yqb0ia.webp',
|
||||
fileName: 'XG017614.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 15,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701616-0d467x5.webp',
|
||||
fileName: 'XG017615.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 16,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701627-t80jbug.webp',
|
||||
fileName: 'XG017907.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 17,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701709-y1yfv5e.webp',
|
||||
fileName: 'XG017908.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 18,
|
||||
},
|
||||
{
|
||||
materialId: 'f8148b30-d83f-4e6a-800e-fa047efd9b16',
|
||||
assetType: 'sku',
|
||||
fileUrl: 'https://s3.yydd.ai/gongxiangpan/由壹点AI/product-package/sku-1768468701730-twc1ovy.webp',
|
||||
fileName: 'XG017909.jpg',
|
||||
fileSize: BigInt(0),
|
||||
sortOrder: 19,
|
||||
},
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('恢复被误删的老资产记录');
|
||||
console.log('='.repeat(60));
|
||||
console.log(`将恢复 ${OLD_ASSETS.length} 条资产记录`);
|
||||
console.log('');
|
||||
|
||||
try {
|
||||
await prisma.materialAsset.createMany({
|
||||
data: OLD_ASSETS,
|
||||
});
|
||||
|
||||
console.log('✅ 恢复完成');
|
||||
} catch (error) {
|
||||
console.error('恢复失败:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
47
scripts/restore-xg0176-previews.ts
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 恢复 XG0176 的预览图记录
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('恢复 XG0176 的预览图记录');
|
||||
console.log('='.repeat(60));
|
||||
|
||||
const materialId = 'f8148b30-d83f-4e6a-800e-fa047efd9b16';
|
||||
|
||||
// 查询所有 S3 预览图(assetType='main'/'sku'/'detail')
|
||||
const s3Assets = await prisma.materialAsset.findMany({
|
||||
where: {
|
||||
materialId,
|
||||
assetType: { in: ['main', 'sku', 'detail'] },
|
||||
fileUrl: { startsWith: 'https://' },
|
||||
},
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
});
|
||||
|
||||
console.log(`找到 ${s3Assets.length} 个 S3 预览图`);
|
||||
|
||||
// 为每个 S3 预览图创建对应的 *-preview 记录
|
||||
const newRecords = s3Assets.map((asset) => ({
|
||||
materialId,
|
||||
assetType: `${asset.assetType}-preview` as any,
|
||||
fileUrl: asset.fileUrl,
|
||||
fileName: asset.fileName,
|
||||
fileSize: asset.fileSize,
|
||||
sortOrder: asset.sortOrder,
|
||||
}));
|
||||
|
||||
await prisma.materialAsset.createMany({
|
||||
data: newRecords,
|
||||
});
|
||||
|
||||
console.log(`✅ 已创建 ${newRecords.length} 条预览图记录`);
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
14
scripts/restore-xg0176-zippath.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
prisma.material.update({
|
||||
where: { id: 'f8148b30-d83f-4e6a-800e-fa047efd9b16' },
|
||||
data: {
|
||||
zipFilePath: 'uploads/materials/XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768922733168.zip',
|
||||
zipFileName: 'XG0176_all_f8148b30-d83f-4e6a-800e-fa047efd9b16_1768922733168.zip',
|
||||
zipFileSize: BigInt(912688),
|
||||
}
|
||||
}).then(() => {
|
||||
console.log('✅ zipFilePath 已恢复');
|
||||
prisma.$disconnect();
|
||||
});
|
||||
116
scripts/rollback-migrated-material.ts
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* 回滚已迁移的素材
|
||||
*
|
||||
* 用于回滚迁移失败或路径错误的素材
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { unlink } from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// 要回滚的素材型号
|
||||
const PRODUCT_MODEL = 'XG0176';
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
console.log('回滚已迁移的素材');
|
||||
console.log('='.repeat(60));
|
||||
console.log(`素材型号: ${PRODUCT_MODEL}`);
|
||||
console.log('');
|
||||
|
||||
try {
|
||||
// 1. 查询素材
|
||||
const material = await prisma.material.findFirst({
|
||||
where: {
|
||||
productModel: PRODUCT_MODEL,
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
},
|
||||
include: {
|
||||
assets: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!material) {
|
||||
console.log('未找到素材');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`找到素材: ${material.id}`);
|
||||
console.log(`当前 zipFilePath: ${material.zipFilePath}`);
|
||||
console.log(`当前 zipFileSize: ${material.zipFileSize}`);
|
||||
console.log('');
|
||||
|
||||
// 2. 删除新增的资产记录(只删除新增的,保留老的 main/sku/detail)
|
||||
const assetsToDelete = material.assets.filter(
|
||||
(a) =>
|
||||
a.assetType === 'main-preview' ||
|
||||
a.assetType === 'sku-preview' ||
|
||||
a.assetType === 'detail-preview' ||
|
||||
(a.assetType === 'main' && a.fileUrl.startsWith('uploads/')) ||
|
||||
(a.assetType === 'sku' && a.fileUrl.startsWith('uploads/')) ||
|
||||
(a.assetType === 'detail' && a.fileUrl.startsWith('uploads/')) ||
|
||||
a.assetType === 'all'
|
||||
);
|
||||
|
||||
console.log(`将删除 ${assetsToDelete.length} 条资产记录:`);
|
||||
assetsToDelete.forEach((a) => {
|
||||
console.log(` - ${a.assetType}: ${a.fileName}`);
|
||||
});
|
||||
console.log('');
|
||||
|
||||
// 3. 删除生成的zip文件(只删除本地zip文件)
|
||||
const zipFiles = material.assets.filter(
|
||||
(a) =>
|
||||
((a.assetType === 'main' || a.assetType === 'sku' || a.assetType === 'detail') &&
|
||||
a.fileUrl.startsWith('uploads/')) ||
|
||||
a.assetType === 'all'
|
||||
);
|
||||
|
||||
console.log(`将删除 ${zipFiles.length} 个zip文件:`);
|
||||
for (const asset of zipFiles) {
|
||||
const filePath = path.join(process.cwd(), asset.fileUrl);
|
||||
console.log(` - ${filePath}`);
|
||||
|
||||
try {
|
||||
await unlink(filePath);
|
||||
console.log(` ✅ 删除成功`);
|
||||
} catch (err) {
|
||||
console.log(` ⚠️ 删除失败: ${err}`);
|
||||
}
|
||||
}
|
||||
console.log('');
|
||||
|
||||
// 4. 执行数据库回滚
|
||||
await prisma.$transaction(async (tx) => {
|
||||
// 删除新增的资产记录(逐个删除,避免误删老记录)
|
||||
for (const asset of assetsToDelete) {
|
||||
await tx.materialAsset.delete({
|
||||
where: { id: asset.id },
|
||||
});
|
||||
}
|
||||
|
||||
// 恢复素材记录
|
||||
await tx.material.update({
|
||||
where: { id: material.id },
|
||||
data: {
|
||||
zipFilePath: '',
|
||||
zipFileName: '',
|
||||
zipFileSize: BigInt(0),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
console.log('✅ 回滚完成');
|
||||
|
||||
} catch (error) {
|
||||
console.error('回滚失败:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
148
scripts/verify-migrated-files.ts
Normal file
@ -0,0 +1,148 @@
|
||||
/**
|
||||
* 验证已迁移素材的文件是否真实存在
|
||||
*/
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { exec } from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function checkFileExists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
const remotePath = `/mnt/PoolOne/apps/youyidian-3d/${filePath}`;
|
||||
const { stdout } = await execAsync(`ssh root@192.168.58.20 "test -f ${remotePath} && echo 'exists' || echo 'not_found'"`);
|
||||
return stdout.trim() === 'exists';
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('开始验证所有"任务-详情"素材的文件...\n');
|
||||
|
||||
// 查询所有素材(不管 zipFilePath 是否为空)
|
||||
const materials = await prisma.material.findMany({
|
||||
where: {
|
||||
materialType: '任务-详情',
|
||||
deletedAt: null,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
productModel: true,
|
||||
zipFilePath: true,
|
||||
zipFileName: true,
|
||||
taskNo: true,
|
||||
user: {
|
||||
select: {
|
||||
realName: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
assets: {
|
||||
where: {
|
||||
assetType: { in: ['main', 'sku', 'detail', 'all'] },
|
||||
},
|
||||
select: {
|
||||
assetType: true,
|
||||
fileUrl: true,
|
||||
fileName: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
console.log(`找到 ${materials.length} 个"任务-详情"素材\n`);
|
||||
|
||||
const results = {
|
||||
total: materials.length,
|
||||
allFilesExist: 0,
|
||||
someFilesMissing: 0,
|
||||
allFilesMissing: 0,
|
||||
noZipRecords: 0,
|
||||
details: [] as any[],
|
||||
};
|
||||
|
||||
for (const material of materials) {
|
||||
const authorName = material.user?.realName || material.user?.username || '未知';
|
||||
const zipAssets = material.assets.filter(a => a.fileUrl.startsWith('uploads/'));
|
||||
|
||||
if (zipAssets.length === 0) {
|
||||
console.log(`❌ ${material.productModel.padEnd(20)} (${authorName.padEnd(10)}): 没有本地 zip 文件记录 | 任务号: ${material.taskNo || '无'}`);
|
||||
results.noZipRecords++;
|
||||
results.details.push({
|
||||
productModel: material.productModel,
|
||||
authorName,
|
||||
taskNo: material.taskNo,
|
||||
status: 'no_zip_records',
|
||||
zipFilePath: material.zipFilePath,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
const fileChecks = await Promise.all(
|
||||
zipAssets.map(async (asset) => {
|
||||
const exists = await checkFileExists(asset.fileUrl);
|
||||
return { assetType: asset.assetType, fileUrl: asset.fileUrl, exists };
|
||||
})
|
||||
);
|
||||
|
||||
const existsCount = fileChecks.filter(c => c.exists).length;
|
||||
const missingFiles = fileChecks.filter(c => !c.exists);
|
||||
|
||||
if (existsCount === zipAssets.length) {
|
||||
console.log(`✅ ${material.productModel.padEnd(20)} (${authorName.padEnd(10)}): 所有文件存在 (${existsCount}/${zipAssets.length})`);
|
||||
results.allFilesExist++;
|
||||
} else if (existsCount > 0) {
|
||||
console.log(`⚠️ ${material.productModel.padEnd(20)} (${authorName.padEnd(10)}): 部分文件缺失 (${existsCount}/${zipAssets.length})`);
|
||||
missingFiles.forEach(f => console.log(` - 缺失: ${f.assetType} (${f.fileUrl})`));
|
||||
results.someFilesMissing++;
|
||||
results.details.push({
|
||||
productModel: material.productModel,
|
||||
authorName,
|
||||
taskNo: material.taskNo,
|
||||
status: 'partial',
|
||||
missingFiles: missingFiles.map(f => f.assetType),
|
||||
});
|
||||
} else {
|
||||
console.log(`❌ ${material.productModel.padEnd(20)} (${authorName.padEnd(10)}): 所有文件缺失 (0/${zipAssets.length}) | 任务号: ${material.taskNo || '无'}`);
|
||||
missingFiles.forEach(f => console.log(` - 缺失: ${f.assetType} (${f.fileUrl})`));
|
||||
results.allFilesMissing++;
|
||||
results.details.push({
|
||||
productModel: material.productModel,
|
||||
authorName,
|
||||
taskNo: material.taskNo,
|
||||
status: 'all_missing',
|
||||
zipFilePath: material.zipFilePath,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n' + '='.repeat(80));
|
||||
console.log('验证结果统计');
|
||||
console.log('='.repeat(80));
|
||||
console.log(`总计: ${results.total} 个素材`);
|
||||
console.log(`✅ 所有文件存在: ${results.allFilesExist} 个`);
|
||||
console.log(`⚠️ 部分文件缺失: ${results.someFilesMissing} 个`);
|
||||
console.log(`❌ 所有文件缺失: ${results.allFilesMissing} 个`);
|
||||
console.log(`❌ 没有 zip 记录: ${results.noZipRecords} 个`);
|
||||
console.log(`\n需要迁移的素材总数: ${results.allFilesMissing + results.noZipRecords} 个`);
|
||||
|
||||
if (results.details.length > 0) {
|
||||
console.log('\n' + '='.repeat(80));
|
||||
console.log('需要迁移的素材详情:');
|
||||
console.log('='.repeat(80));
|
||||
results.details.forEach(d => {
|
||||
console.log(` - ${d.productModel.padEnd(20)} (${d.authorName.padEnd(10)}): ${d.status.padEnd(20)} | 任务号: ${d.taskNo || '无'}`);
|
||||
if (d.missingFiles) {
|
||||
console.log(` 缺失类型: ${d.missingFiles.join(', ')}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main();
|
||||
BIN
temp_check/01_XG013202.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
temp_check/02_XG013207.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
temp_check/03_XG013212.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
temp_check/04_XG013218.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_check/05_XG014805.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
temp_check/06_XG014808.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
temp_check/07_XG014811.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
temp_check/08_XG017601.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
temp_check/09_XG017602.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
temp_check/10_xg017603.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
temp_check/11_xg017604.jpg
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
temp_check/12_XG017610.jpg
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
temp_check/13_XG017611.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
temp_check/14_XG017612.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_check/15_XG017613.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_check/16_XG017614.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
temp_check/17_XG017615.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
temp_check/18_XG017907.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
temp_check/19_XG017908.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
temp_check/20_XG017909.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_user_download/01_XG013202.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
temp_user_download/02_XG013207.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
temp_user_download/03_XG013212.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
temp_user_download/04_XG013218.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_user_download/05_XG014805.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
temp_user_download/06_XG014808.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
temp_user_download/07_XG014811.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
temp_user_download/08_XG017601.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
temp_user_download/09_XG017602.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
temp_user_download/10_xg017603.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
temp_user_download/11_xg017604.jpg
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
temp_user_download/12_XG017610.jpg
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
temp_user_download/13_XG017611.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
temp_user_download/14_XG017612.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_user_download/15_XG017613.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
temp_user_download/16_XG017614.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
temp_user_download/17_XG017615.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |