|
@@ -160,36 +160,36 @@ class Patent_transService extends CrudService {
|
|
if (!(file && file.data)) {
|
|
if (!(file && file.data)) {
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定文件');
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定文件');
|
|
}
|
|
}
|
|
- const workbook = new Excel.Workbook();
|
|
|
|
- await workbook.xlsx.load(file.data);
|
|
|
|
- const sheet = workbook.getWorksheet(1);
|
|
|
|
- const arr = [];
|
|
|
|
- const allNotice = [];
|
|
|
|
- sheet.eachRow(async (row, rindex) => {
|
|
|
|
- if (rindex !== 1) {
|
|
|
|
- // 组织数据
|
|
|
|
- const create_number = row.getCell(3).value || undefined,
|
|
|
|
- patent_name = row.getCell(2).value || undefined,
|
|
|
|
- on_obligee = row.getCell(4).value || undefined,
|
|
|
|
- transfer_date = moment(row.getCell(5).value).format('YYYY-MM-DD') || undefined,
|
|
|
|
- on_afterobligee = row.getCell(6).value || undefined,
|
|
|
|
- status = row.getCell(7).value || undefined,
|
|
|
|
- const has_data = await this.model.count({ create_number });
|
|
|
|
- if (!has_data) {
|
|
|
|
- const obj = {patent_name,create_number,on_obligee,transfer_date,on_afterobligee,status };
|
|
|
|
- // 此处添加判断条件,不限制则不需要加,直接放过即可
|
|
|
|
- const { result, notice } = this.tocheckData(obj);
|
|
|
|
- if (result) {
|
|
|
|
- arr.push(obj);
|
|
|
|
- } else {
|
|
|
|
- allNotice.push(notice);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- if (allNotice.length > 0) return allNotice;
|
|
|
|
- const res = await this.model.insertMany(arr);
|
|
|
|
- return res;
|
|
|
|
|
|
+ // const workbook = new Excel.Workbook();
|
|
|
|
+ // await workbook.xlsx.load(file.data);
|
|
|
|
+ // const sheet = workbook.getWorksheet(1);
|
|
|
|
+ // const arr = [];
|
|
|
|
+ // const allNotice = [];
|
|
|
|
+ // sheet.eachRow(async (row, rindex) => {
|
|
|
|
+ // if (rindex !== 1) {
|
|
|
|
+ // // 组织数据
|
|
|
|
+ // const create_number = row.getCell(3).value || undefined,
|
|
|
|
+ // patent_name = row.getCell(2).value || undefined,
|
|
|
|
+ // on_obligee = row.getCell(4).value || undefined,
|
|
|
|
+ // transfer_date = moment(row.getCell(5).value).format('YYYY-MM-DD') || undefined,
|
|
|
|
+ // on_afterobligee = row.getCell(6).value || undefined,
|
|
|
|
+ // status = row.getCell(7).value || undefined,
|
|
|
|
+ // const has_data = await this.model.count({ create_number });
|
|
|
|
+ // if (!has_data) {
|
|
|
|
+ // const obj = {patent_name,create_number,on_obligee,transfer_date,on_afterobligee,status };
|
|
|
|
+ // // 此处添加判断条件,不限制则不需要加,直接放过即可
|
|
|
|
+ // const { result, notice } = this.tocheckData(obj);
|
|
|
|
+ // if (result) {
|
|
|
|
+ // arr.push(obj);
|
|
|
|
+ // } else {
|
|
|
|
+ // allNotice.push(notice);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // if (allNotice.length > 0) return allNotice;
|
|
|
|
+ // const res = await this.model.insertMany(arr);
|
|
|
|
+ // return res;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|