|
@@ -242,7 +242,9 @@ export class PatentService extends BaseService<modelType> {
|
|
|
const typeList: any = await this.adminAxios.get(
|
|
|
'dictData?type=patent_type'
|
|
|
);
|
|
|
- const path = `${this.root_path}${sep}${this.file_type}`;
|
|
|
+ const path = `${this.root_path}${sep}${this.file_type}${sep}${
|
|
|
+ this.patentInfo_dir
|
|
|
+ }${new Date().getTime()}`;
|
|
|
if (!path) {
|
|
|
throw new ServiceError(
|
|
|
'服务端没有设置存储路径',
|
|
@@ -321,22 +323,29 @@ export class PatentService extends BaseService<modelType> {
|
|
|
}
|
|
|
sheet.addRow(arr);
|
|
|
}
|
|
|
- skip = skip + parseInt(query.end_num);
|
|
|
+ skip = skip + parseInt(query.end_num || total);
|
|
|
+ meta.forEach((r, i) => {
|
|
|
+ sheet.getRow(i + 2).height = 60;
|
|
|
+ // 控制列的宽度,以及对齐方式
|
|
|
+ sheet.getColumn(i + 1).width = 13;
|
|
|
+ sheet.getColumn(i + 1).alignment = {
|
|
|
+ vertical: 'middle',
|
|
|
+ horizontal: 'center',
|
|
|
+ };
|
|
|
+ });
|
|
|
// 生成excel
|
|
|
const filename = `专利信息导出结果(${i + 1}-${
|
|
|
- i + parseInt(query.end_num)
|
|
|
+ i + parseInt(query.end_num || total)
|
|
|
}).xlsx`;
|
|
|
const filePath = `${path}${sep}${filename}`;
|
|
|
console.log(filePath);
|
|
|
await workbook.xlsx.writeFile(filePath);
|
|
|
-
|
|
|
try {
|
|
|
let progress = _.ceil((skip / total) * 100);
|
|
|
if (progress > 95) progress = 95;
|
|
|
const data = {
|
|
|
progress,
|
|
|
status: '1',
|
|
|
- // id: missionid,
|
|
|
remark: '组织数据生成excel中...',
|
|
|
};
|
|
|
await this.sendToMQ(data);
|
|
@@ -347,7 +356,6 @@ export class PatentService extends BaseService<modelType> {
|
|
|
const data = {
|
|
|
progress: 0,
|
|
|
status: '-1',
|
|
|
- // id: missionid,
|
|
|
remark: '组织数据进入excel失败',
|
|
|
};
|
|
|
this.sendToMQ(data);
|
|
@@ -358,7 +366,6 @@ export class PatentService extends BaseService<modelType> {
|
|
|
const data = {
|
|
|
progress: 98,
|
|
|
status: '1',
|
|
|
- // id: missionid,
|
|
|
remark: '正在打包',
|
|
|
};
|
|
|
this.sendToMQ(data);
|
|
@@ -380,7 +387,6 @@ export class PatentService extends BaseService<modelType> {
|
|
|
progress: 100,
|
|
|
status: '2',
|
|
|
uri: downloadPath,
|
|
|
- // id: missionid,
|
|
|
remark: '打包成功',
|
|
|
};
|
|
|
this.sendToMQ(data);
|
|
@@ -388,7 +394,6 @@ export class PatentService extends BaseService<modelType> {
|
|
|
const data = {
|
|
|
progress: 0,
|
|
|
status: '-2',
|
|
|
- // id: missionid,
|
|
|
remark: '打包失败',
|
|
|
};
|
|
|
this.sendToMQ(data);
|