|
@@ -242,6 +242,10 @@ export class PatentService extends BaseService<modelType> {
|
|
|
}
|
|
|
// 导出
|
|
|
async export(query) {
|
|
|
+ let mission: any = await this.downloadModel.create({
|
|
|
+ title: '专利信息文件',
|
|
|
+ });
|
|
|
+ if (mission) mission = JSON.parse(JSON.stringify(mission));
|
|
|
const termList: any = await this.adminAxios.get(
|
|
|
'dictData?type=patent_term'
|
|
|
);
|
|
@@ -344,10 +348,13 @@ export class PatentService extends BaseService<modelType> {
|
|
|
try {
|
|
|
let progress = _.ceil((skip / total) * 100);
|
|
|
if (progress > 95) progress = 95;
|
|
|
- const data = {
|
|
|
+ const data: any = {
|
|
|
progress,
|
|
|
status: '1',
|
|
|
remark: '组织数据生成excel中...',
|
|
|
+ id: mission._id,
|
|
|
+ user: this.ctx.user?._id || '',
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
};
|
|
|
await this.sendToMQ(data);
|
|
|
} catch (error) {
|
|
@@ -356,6 +363,7 @@ export class PatentService extends BaseService<modelType> {
|
|
|
} catch (error) {
|
|
|
const data = {
|
|
|
progress: 0,
|
|
|
+ id: mission._id,
|
|
|
status: '-1',
|
|
|
remark: '组织数据进入excel失败',
|
|
|
};
|
|
@@ -366,6 +374,7 @@ export class PatentService extends BaseService<modelType> {
|
|
|
try {
|
|
|
const data = {
|
|
|
progress: 98,
|
|
|
+ id: mission._id,
|
|
|
status: '1',
|
|
|
remark: '正在打包',
|
|
|
};
|
|
@@ -388,6 +397,7 @@ export class PatentService extends BaseService<modelType> {
|
|
|
progress: 100,
|
|
|
status: '2',
|
|
|
uri: downloadPath,
|
|
|
+ id: mission._id,
|
|
|
remark: '打包成功',
|
|
|
};
|
|
|
this.sendToMQ(data);
|
|
@@ -395,6 +405,7 @@ export class PatentService extends BaseService<modelType> {
|
|
|
const data = {
|
|
|
progress: 0,
|
|
|
status: '-2',
|
|
|
+ id: mission._id,
|
|
|
remark: '打包失败',
|
|
|
};
|
|
|
this.sendToMQ(data);
|
|
@@ -467,10 +478,9 @@ export class PatentService extends BaseService<modelType> {
|
|
|
) {
|
|
|
data.progress = 100;
|
|
|
}
|
|
|
- data.title = '专利信息文件';
|
|
|
- data.user = this.ctx.user?._id || '';
|
|
|
- data.create_time = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
- await this.downloadModel.create(data);
|
|
|
+ const id = data.id;
|
|
|
+ delete data.id;
|
|
|
+ await this.downloadModel.updateOne({ _id: id }, data);
|
|
|
await this.rabbitmqService.connect();
|
|
|
await this.rabbitmqService.sendToQueue('tasks', data);
|
|
|
await this.rabbitmqService.close();
|